Skip to content

Commit

Permalink
Revert "Merge remote-tracking branch 'origin/EXCH-10877-add-support-f…
Browse files Browse the repository at this point in the history
…or-native-imps' into EXCH-10877-add-support-for-native-imps"

This reverts commit c881386, reversing
changes made to 55a23a5.
  • Loading branch information
gmiedlar-ox committed Jan 2, 2025
1 parent c881386 commit 77648f0
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 210 deletions.
125 changes: 51 additions & 74 deletions modules/mobianRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,15 @@ import { setKeyValue } from '../libraries/gptUtils/gptUtils.js';

export const MOBIAN_URL = 'https://prebid.outcomes.net/api/prebid/v1/assessment/async';

export const AP_VALUES = 'apValues';
export const CATEGORIES = 'categories';
export const EMOTIONS = 'emotions';
export const GENRES = 'genres';
export const RISK = 'risk';
export const SENTIMENT = 'sentiment';
export const THEMES = 'themes';
export const TONES = 'tones';

export const CONTEXT_KEYS = [
AP_VALUES,
CATEGORIES,
EMOTIONS,
GENRES,
RISK,
SENTIMENT,
THEMES,
TONES
'apValues',
'categories',
'emotions',
'genres',
'risk',
'sentiment',
'themes',
'tones'
];

const AP_KEYS = ['a0', 'a1', 'p0', 'p1'];
Expand Down Expand Up @@ -82,24 +73,6 @@ function makeMemoizedFetch() {

export const getContextData = makeMemoizedFetch();

const entriesToObjectReducer = (acc, [key, value]) => ({ ...acc, [key]: value });

export function makeContextDataToKeyValuesReducer(config) {
const { prefix } = config;
return function contextDataToKeyValuesReducer(keyValues, [key, value]) {
if (key === AP_VALUES) {
AP_KEYS.forEach((apKey) => {
if (!value?.[apKey]?.length) return;
keyValues.push([`${prefix}_ap_${apKey}`, value[apKey].map((v) => String(v))]);
});
}
if (value?.length) {
keyValues.push([`${prefix}_${key}`, value]);
}
return keyValues;
}
}

export async function fetchContextData() {
const pageUrl = encodeURIComponent(window.location.href);
const requestUrl = `${MOBIAN_URL}?url=${pageUrl}`;
Expand Down Expand Up @@ -128,80 +101,84 @@ export function getConfig(config) {
}

/**
* @param {MobianConfig} config
* @param {MobianConfigParams} parsedConfig
* @param {MobianContextData} contextData
* @returns {function}
*/
export function setTargeting(config, contextData) {
export function setTargeting(parsedConfig, contextData) {
const { publisherTargeting, prefix } = parsedConfig;
logMessage('context', contextData);
const keyValues = Object.entries(contextData)
.filter(([key]) => config.publisherTargeting.includes(key))
.reduce(makeContextDataToKeyValuesReducer(config), [])

keyValues.forEach(([key, value]) => setKeyValue(key, value));
CONTEXT_KEYS.forEach((key) => {
if (!publisherTargeting.includes(key)) return;

if (key === 'apValues') {
AP_KEYS.forEach((apKey) => {
if (!contextData[key]?.[apKey]?.length) return;
logMessage(`${prefix}_ap_${apKey}`, contextData[key][apKey]);
setKeyValue(`${prefix}_ap_${apKey}`, contextData[key][apKey]);
});
return;
}

if (contextData[key]?.length) {
logMessage(`${prefix}_${key}`, contextData[key]);
setKeyValue(`${prefix}_${key}`, contextData[key]);
}
});
}

/**
* @param {Object|string} contextData
* @returns {MobianContextData}
*/
export function makeDataFromResponse(contextData) {
const data = typeof contextData === 'string' ? safeJSONParse(contextData) : contextData;
const results = data.results;
if (!results) {
return {};
}
return {
[AP_VALUES]: results.ap || {},
[CATEGORIES]: results.mobianContentCategories,
[EMOTIONS]: results.mobianEmotions,
[GENRES]: results.mobianGenres,
[RISK]: results.mobianRisk || 'unknown',
[SENTIMENT]: results.mobianSentiment || 'unknown',
[THEMES]: results.mobianThemes,
[TONES]: results.mobianTones,
apValues: results.ap || {},
categories: results.mobianContentCategories,
emotions: results.mobianEmotions,
genres: results.mobianGenres,
risk: results.mobianRisk || 'unknown',
sentiment: results.mobianSentiment || 'unknown',
themes: results.mobianThemes,
tones: results.mobianTones,
};
}

/**
* @param {Object} bidReqConfig
* @param {MobianContextData} contextData
* @param {MobianConfig} config
*/
export function extendBidRequestConfig(bidReqConfig, contextData, config) {
export function extendBidRequestConfig(bidReqConfig, contextData) {
logMessage('extendBidRequestConfig', bidReqConfig, contextData);
const { site: ortb2Site } = bidReqConfig.ortb2Fragments.global;
const keyValues = Object.entries(contextData)
.filter(([key]) => config.advertiserTargeting.includes(key))
.reduce(makeContextDataToKeyValuesReducer(config), [])
.reduce(entriesToObjectReducer, {});

ortb2Site.ext = ortb2Site.ext || {};
ortb2Site.ext.data = {
...(ortb2Site.ext.data || {}),
...keyValues
...contextData
};

return bidReqConfig;
}

/**
* @param {MobianConfig} rawConfig
* @param {MobianConfig} config
* @returns {boolean}
*/
function init(rawConfig) {
logMessage('init', rawConfig);
const config = getConfig(rawConfig);
if (config.publisherTargeting.length) {
getContextData().then((contextData) => setTargeting(config, contextData));
function init(config) {
logMessage('init', config);

const parsedConfig = getConfig(config);

if (parsedConfig.publisherTargeting.length) {
getContextData().then((contextData) => setTargeting(parsedConfig, contextData));
}

return true;
}

function getBidRequestData(bidReqConfig, callback, rawConfig) {
function getBidRequestData(bidReqConfig, callback, config) {
logMessage('getBidRequestData', bidReqConfig);

const config = getConfig(rawConfig);
const { advertiserTargeting } = config;
const { advertiserTargeting } = getConfig(config);

if (!advertiserTargeting.length) {
callback();
Expand All @@ -210,7 +187,7 @@ function getBidRequestData(bidReqConfig, callback, rawConfig) {

getContextData()
.then((contextData) => {
extendBidRequestConfig(bidReqConfig, contextData, config);
extendBidRequestConfig(bidReqConfig, contextData);
})
.catch(() => {})
.finally(() => callback());
Expand Down
116 changes: 48 additions & 68 deletions modules/mobianRtdProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,139 +14,91 @@ The Mobian Real-Time Data (RTD) Module is a plug-and-play Prebid.js adapter that

Navigate to https://docs.prebid.org/download.html and check the box labeled Mobian Prebid Contextual Evaluation. If you have installed Prebid.js on your site previously, please be sure to select any other modules and adaptors to suit your needs. When clicking the "Get Prebid.js" button at the bottom of the page, the site will build a version of Prebid.js with all of your selections.

Direct link to the Mobian module in the Prebid.js repository: https://github.com/prebid/Prebid.js/blob/master/modules/mobianRtdProvider.js
Direct link to the Mobian module in the Prebid.js repository: https://github.com/prebid/Prebid.js/blob/a9de3c15ac9a108b43a1e2df04abd6dfb5297530/modules/mobianRtdProvider.js

The client will need to provide Mobian with all the domains that would be using the prebid module so that Mobian can whitelist those domains. Failure to whitelist the domains will yield a 404 when making a request to the Mobian Contextual API at https://prebid.outcomes.net/.

## Configuration Highlight

Below is Mobian's suggested default for configuration:

```js
pbjs.setConfig({
realTimeData: {
dataProviders: [{
name: 'mobianBrandSafety',
params: {
// Prefix for the targeting keys (default: 'mobian')
prefix: 'mobian',

// Enable targeting keys for advertiser data
advertiserTargeting: true,
// Or set it as an array to pick specific targeting keys:
// advertiserTargeting: ['genres', 'emotions', 'themes'],
// Available values: 'apValues', 'categories', 'emotions', 'genres', 'risk', 'sentiment', 'themes', 'tones'

// Enable targeting keys for publisher data
publisherTargeting: true,
// Or set it as an array to pick specific targeting keys:
// publisherTargeting: ['tones', 'risk'],
// Available values: 'apValues', 'categories', 'emotions', 'genres', 'risk', 'sentiment', 'themes', 'tones'
}
}]
}
});
```

## Functionality

At a high level, the Mobian RTD Module is designed to call the Mobian Contextal API on page load, requesting the Mobian classifications and results for the URL. The classifications and results are designed to be picked up by any SSP or DSP in the Prebid.js ecosystem. The module also supports placing the Mobian classifications on each ad slot on the page, thus allowing for targeting within GAM.

## Available Classifications

NOTE: The examples below for targetable keys for GAM or otherwise in the ortb2 object assume that your prefix is the default of "mobian". The prefix in the targetable key will change based on your settings.

Risk:

Prebid.outcomes.net endpoint key: mobianRisk

Targetable Key: mobian_risk
Key: mobianRisk

Possible values: "none", "low", "medium" or "high"

Description: This category assesses whether content contains any potential risks or concerns to advertisers and returns a determination of Low Risk, Medium Risk, or High Risk based on the inclusion of sensitive or high-risk topics. Content that might be categorized as unsafe may include violence, hate speech, misinformation, or sensitive topics that most advertisers would like to avoid. Content that is explicit or overly graphic in nature will be more likely to fall into the High Risk tier compared to content that describes similar subjects in a more informative or educational manner.
Description: Risk will contain Mobian’s brand safety assessment of the page. Brand Safety is determined via the Mobian AI models taking into account a semantic analysis of the content while understanding the context. A more detailed description of the reasoning for a given URL can be observed by going to mbs.themobian.com and entering the URL.

------------------

Content Categories:

Prebid.outcomes.net endpoint key: mobianContentCategories

Targetable Key: mobian_categories
Key: mobianContentCategories

Possible values: "adult_content", "arms", "crime", "death_injury", "debated_issue", "hate_speech", "drugs_alcohol", "obscenity", "piracy", "spam", "terrorism"

Description: Brand Safety Categories contain categorical results for brand safety when relevant (e.g. Low Risk Adult Content). Note there can be Medium and High Risk content that is not associated to a specific brand safety category.
Description: Content Categories contain results based on the legacy GARM framework. GARM no longer is a standard and does not factor into our risk assessment but is included for posterity.

------------------

Sentiment:

Prebid.outcomes.net endpoint key: mobianSentiment

Targetable Key: mobian_sentiment
Key: mobianSentiment

Possible values: "negative", "neutral" or "positive"

Description: This category analyzes the overall positivity, negativity, or neutrality of a piece of content. This is a broad categorization of the content’s tone; every piece of content receives one of three possible sentiment ratings: Positive, Negative, or Neutral.
Description: Sentiment can only be one of the three values listed, and is determined via the Mobian AI analyzing the content and making one of these three determinations.

------------------

Emotion:

Prebid.outcomes.net endpoint key: mobianEmotions
Key: mobianEmotions

Targetable Key: mobian_emotions
Possible values: "love", "joy", "surprise", "anger", "sadness", "fear"

Possible values: Various but some examples include "love", "joy", "surprise", "anger", "sadness", "fear"

Description: This category represents the specific feelings expressed or evoked through the content. Emotions are the reactions tied to the content’s presentation. Multiple emotions may be evoked by a single piece of content as this category reflects the way humans engage with the content.
Description: The Mobian AI assesses the emotions exuded from the content, taking into account the context. A given piece of content can have multiple emotions. The current list of emotions is all possible emotions available but this will be updated to be more freeform and varied in a future release.

------------------

Tone:

Prebid.outcomes.net endpoint key: mobianTones

Targetable Key: mobian_tones
Key: mobianTones

Possible values: Various, but some examples include "comedic", "serious" or "emotional"

Description: This category represents the content’s stylistic attitude or perspective that is being conveyed. If the Genre classification above represents the more objective structure, the Tone classification represents the subjective form. This categorization influences the way audiences may receive the piece of content and how they could be impacted by it.
Description: While the Mobian emotion classification looks at the emotions exuded from the content, tone examines the overall presentation of the content and determines the overall mood of the work. A given piece of content can have multiple tones.

------------------

Theme:

Prebid.outcomes.net endpoint key: mobianThemes

Targetable Key: mobian_themes
Key: mobianThemes

Possible values: Various, but some examples include "skincare", "food" and "nightlife"

Description: This category includes broad conceptual ideas or underlying topics that form the foundation of the content. Themes represent the central message or idea conveyed throughout, rather than the specific details of the subject. Themes are intended to be broad and high-level, describing the overall purpose and intent of the content, and can connect multiple pieces of content, even if they are not from the same property.
Description: Themes are a wide classification of content categorization, taking into account the content and context to label the content with a theme. A given piece of content can have multiple themes.

------------------

Genre:

Prebid.outcomes.net endpoint key: mobianGenres

Targetable Key: mobian_genres
Key: mobianGenre

Possible values: Various, but some examples include "journalism", "gaming" or "how-to"

Description: This category represents the type or style of the content, focusing on the purpose, format, or presentation of the content. Genres group pieces of content into recognizable categories based on style and provide a framework for understanding the structure of the content.
Description: Genres are a more narrow classification of content categorization, aiming to label the content towards its overall purpose and audience. A given piece of content can have multiple genres.

------------------

AP Values

Prebid.outcomes.net endpoint key: ap (an array, containing values of a0, a1, p0, p1)
Keys: ap_a0, ap_a1, ap_p0, ap_p1

Targetable Keys: mobian_ap_a0, mobian_ap_a1, mobian_ap_p0, mobian_ap_p1

Possible values: Various, numerically id-based and customizable based on Mobian Context Settings.
Possible values: Various, numerically id-based and customizable based on Mobian Persona Settings.

Description: Mobian AI Personas are custom created based on prompts to find a specific audience. Please contact your Mobian contact directly for more information on this tool. The difference between the keys is below:

Expand All @@ -171,6 +123,34 @@ window.googletag.cmd.push(() => {
"key" and "value" will be replaced with the various classifications as described in the previous section. Notably, this function runs before ad calls are made to GAM, which enables the keys and value to be used for targeting or blocking in GAM.
For more details on how to set up key-value pairs in GAM, please see this documentation from Google: https://support.google.com/admanager/answer/9796369
For more details on how to set up key-value pairs in GAM, please see this documentation from Google: https://support.google.com/admanager/answer/9796369?sjid=12535178383871274096-NA
For example, if you wanted to target articles where mobianRisk is "low", the key to set in GAM would be "mobianRisk" and the value would be "low". Once these keys and values are set within the Inventory section in GAM as listed by their documentation, you can then reference the key value pair in Custom Targeting for any line item you create.
## Configuration Highlight
```js
pbjs.setConfig({
realTimeData: {
dataProviders: [{
name: 'mobianBrandSafety',
params: {
// Prefix for the targeting keys (default: 'mobian')
prefix: 'mobian',

// Enable targeting keys for advertiser data
advertiserTargeting: true,
// Or set it as an array to pick specific targeting keys:
// advertiserTargeting: ['genres', 'emotions', 'themes'],
// Available values: 'apValues', 'categories', 'emotions', 'genres', 'risk', 'sentiment', 'themes', 'tones'

For example, if you wanted to target articles where mobianRisk is "low", the key to set in GAM would be "mobian_risk" and the value would be "low". Once these keys and values are set within the Inventory section in GAM as listed by their documentation, you can then reference the key value pair in Custom Targeting for any line item you create.
// Enable targeting keys for publisher data
publisherTargeting: true,
// Or set it as an array to pick specific targeting keys:
// publisherTargeting: ['tones', 'risk'],
// Available values: 'apValues', 'categories', 'emotions', 'genres', 'risk', 'sentiment', 'themes', 'tones'
}
}]
}
});
```
Loading

0 comments on commit 77648f0

Please sign in to comment.