-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AAX Blockmeter RTD Module : Initial Release #9135
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
be6f4d6
AAX Blockmeter RTD Module Release
shubham-si c425d7a
added url in rtd configuration params as params.url
product-aax 1004f85
Prebid 7.21.0 release
prebidjs-release 6dc16cd
Increment version to 7.22.0-pre
prebidjs-release 4e098d2
Prebid core: do not enforce valid size in bid responses (#9138)
dgirardi 462669e
Prebid 7.22.0 release
prebidjs-release f5d37cf
Increment version to 7.23.0-pre
prebidjs-release 8a2db85
added url in rtd configuration params as params.url
product-aax 8bb95e6
Merge branch 'master' into blockmeter-aax
product-aax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import {isEmptyStr, isStr, logError, isFn, logWarn} from '../src/utils.js'; | ||
import {submodule} from '../src/hook.js'; | ||
import { loadExternalScript } from '../src/adloader.js'; | ||
|
||
export const _config = { | ||
MODULE: 'aaxBlockmeter', | ||
ADSERVER_TARGETING_KEY: 'atk', | ||
BLOCKMETER_URL: 'c.aaxads.com/aax.js', | ||
VERSION: '1.2' | ||
}; | ||
|
||
window.aax = window.aax || {}; | ||
|
||
function loadBlockmeter(_rtdConfig) { | ||
if (!(_rtdConfig.params && _rtdConfig.params.pub) || !isStr(_rtdConfig.params && _rtdConfig.params.pub) || isEmptyStr(_rtdConfig.params && _rtdConfig.params.pub)) { | ||
logError(`${_config.MODULE}: params.pub should be a string`); | ||
return false; | ||
} | ||
|
||
const params = []; | ||
params.push(`pub=${_rtdConfig.params.pub}`); | ||
params.push(`dn=${window.location.hostname}`); | ||
|
||
let url = _rtdConfig.params.url; | ||
if (!url || isEmptyStr(url)) { | ||
logWarn(`${_config.MODULE}: params.url is missing, using default url.`); | ||
url = `${_config.BLOCKMETER_URL}?ver=${_config.VERSION}`; | ||
} | ||
|
||
const scriptUrl = `https://${url}&${params.join('&')}`; | ||
loadExternalScript(scriptUrl, _config.MODULE); | ||
return true; | ||
} | ||
|
||
function markAdBlockInventory(codes, _rtdConfig, _userConsent) { | ||
return codes.reduce((targets, code) => { | ||
targets[code] = targets[code] || {}; | ||
const getAaxTargets = () => isFn(window.aax.getTargetingData) | ||
? window.aax.getTargetingData(code, _rtdConfig, _userConsent) | ||
: {}; | ||
targets[code] = { | ||
[_config.ADSERVER_TARGETING_KEY]: code, | ||
...getAaxTargets() | ||
}; | ||
return targets; | ||
}, {}); | ||
} | ||
|
||
export const aaxBlockmeterRtdModule = { | ||
name: _config.MODULE, | ||
init: loadBlockmeter, | ||
getTargetingData: markAdBlockInventory, | ||
}; | ||
|
||
function registerSubModule() { | ||
submodule('realTimeData', aaxBlockmeterRtdModule); | ||
} | ||
|
||
registerSubModule(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
## Overview | ||
|
||
Module Name: AAX Blockmeter Realtime Data Module | ||
Module Type: Rtd Provider | ||
Maintainer: product@aax.media | ||
|
||
## Description | ||
|
||
The module enables publishers to measure traffic coming from visitors using adblockers. | ||
|
||
AAX can also help publishers monetize this traffic by allowing them to serve [acceptable ads](https://acceptableads.com/about/) to these adblock visitors and recover their lost revenue. [Reach out to us](https://www.aax.media/try-blockmeter/) to know more. | ||
|
||
## Integration | ||
|
||
Build the AAX Blockmeter Realtime Data Module into the Prebid.js package with: | ||
|
||
``` | ||
gulp build --modules=aaxBlockmeterRtdProvider,rtdModule | ||
``` | ||
|
||
## Configuration | ||
|
||
This module is configured as part of the `realTimeData.dataProviders` object. | ||
|
||
| Name | Scope | Description | Example | Type | | ||
|:----------:|:--------:|:-----------------------------|:---------------:|:------:| | ||
| `name` | required | Real time data module name | `'aaxBlockmeter'` | `string` | | ||
| `params` | required | | | `Object` | | ||
| `params.pub` | required | AAX to share pub ID, [Reach out to us](https://www.aax.media/try-blockmeter/) to know more! | `'AAX00000'` | `string` | | ||
| `params.url` | optional | AAX Blockmeter Script Url. Defaults to `'c.aaxads.com/aax.js?ver=1.2'` | `'c.aaxads.com/aax.js?ver=1.2'` | `string` | | ||
|
||
### Example | ||
|
||
```javascript | ||
pbjs.setConfig({ | ||
"realTimeData": { | ||
"dataProviders": [ | ||
{ | ||
"name": "aaxBlockmeter", | ||
"params": { | ||
"pub": "AAX00000", | ||
"url": "c.aaxads.com/aax.js?ver=1.2", | ||
} | ||
} | ||
] | ||
} | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import {aaxBlockmeterRtdModule} from '../../../modules/aaxBlockmeterRtdProvider.js'; | ||
import * as sinon from 'sinon'; | ||
import {assert} from 'chai'; | ||
|
||
let sandbox; | ||
let getTargetingDataSpy; | ||
|
||
const config = { | ||
dataProviders: [{ | ||
'name': 'aaxBlockmeter', | ||
'params': { | ||
'pub': 'publisher_id', | ||
} | ||
}] | ||
}; | ||
|
||
describe('aaxBlockmeter realtime module', function () { | ||
beforeEach(function () { | ||
sandbox = sinon.sandbox.create(); | ||
window.aax = window.aax || {}; | ||
window.aax.getTargetingData = getTargetingDataSpy = sandbox.spy(); | ||
}); | ||
|
||
afterEach(function () { | ||
sandbox.restore(); | ||
window.aax = {}; | ||
}); | ||
|
||
it('init should return false when config is empty', function () { | ||
assert.equal(aaxBlockmeterRtdModule.init({}), false); | ||
}); | ||
|
||
it('init should return false when config.params id is empty', function () { | ||
assert.equal(aaxBlockmeterRtdModule.init({params: {}}), false); | ||
}); | ||
|
||
it('init should return true when config.params.pub is not string', function () { | ||
assert.equal(aaxBlockmeterRtdModule.init({params: {pub: 12345}}), false); | ||
}); | ||
|
||
it('init should return true when config.params.pub id is passed and is string typed', function () { | ||
assert.equal(aaxBlockmeterRtdModule.init(config.dataProviders[0]), true); | ||
}); | ||
|
||
describe('getTargetingData should work correctly', function () { | ||
it('should return ad unit codes when ad units are present', function () { | ||
const codes = ['code1', 'code2']; | ||
assert.deepEqual(aaxBlockmeterRtdModule.getTargetingData(codes), { | ||
code1: {'atk': 'code1'}, | ||
code2: {'atk': 'code2'}, | ||
}); | ||
}); | ||
|
||
it('should call aax.getTargetingData if loaded', function () { | ||
aaxBlockmeterRtdModule.getTargetingData([], config.dataProviders[0], null); | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this requires an account with AAX yes? Might be better to state that here, as it doesn't look like the module itself does much more than load the AAX script.