Skip to content
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

Adagio: update with external js #4217

Merged
merged 36 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
663317c
Add external loader in AdagioBidAdapter
Dec 19, 2018
0966181
Change adagioAnalyticsAdapter to "endpoint" type
osazos Jan 10, 2019
1b263f5
Change _setPredictions for a generic method
osazos Jan 10, 2019
2a210df
Improve AdagioBidAdapter test coverage
osazos Jan 30, 2019
cba4211
Add features detection in Adagio adapter
osazos Feb 11, 2019
39153e2
Fix adagioBidAdapter tests
osazos Feb 12, 2019
b35c3e6
Add featuresVersion field to bidRequest
osazos Feb 12, 2019
08fa73d
Refacto adagio.queue
osazos Feb 13, 2019
66c5bac
Expose versions in ADAGIO namespace
osazos Feb 14, 2019
c70ba0b
Generate a ADAGIO.pageviewId if missing
nfo Feb 27, 2019
a8ce67b
Update documentation
nfo May 21, 2019
051cd28
Move ad-server events tracking to adagioBidAdapter
osazos May 10, 2019
bc9163b
Store adUnitCodes in ADAGIO namespace
osazos May 15, 2019
0958623
Add internal array to prevent empty pbjs.adUnits
osazos Jun 13, 2019
ef25ff9
Be sure to access to window.top - does not work in safe-frame env
osazos Jun 11, 2019
78a6cfe
Be sure to compute features on window.top
osazos Jun 18, 2019
26cc559
Bump versions
osazos Jun 20, 2019
a0f0d22
Add Post-Bid support
osazos Jul 22, 2019
bc5b936
Set pagetype param as optional
osazos Jul 23, 2019
31c9e72
Add AdThink ad-server support
osazos Jul 26, 2019
59d08d1
adagioBidAdapter: add and improve tests
osazos Aug 29, 2019
a255d89
adagioAnalyticsAdapter: add and improve tests
osazos Aug 28, 2019
d602feb
Improve internal `pbjsAdUnits.sizes` detection
osazos Aug 13, 2019
a41a57d
adagioBidAdapter: Bump version 1.5
osazos Sep 11, 2019
b06d783
Adagio: fix import path
osazos Sep 18, 2019
54a4ad2
Add PrintNumber feature
osazos May 28, 2019
14a2aa1
PostBid: insure window.top is accessible for specifics functions
osazos Sep 19, 2019
6b8c61e
Consistency: use Prebid.js utils and fix deprecated
osazos Sep 19, 2019
30eddfe
PostBid: do not build a request if in safeframe
osazos Sep 19, 2019
484e9ea
Bump version 2.0.0
osazos Sep 19, 2019
da990a1
Try to fix tests without UA stubing
osazos Sep 20, 2019
85ed93f
Try to fix adagioAnalytics failling tests on CI
osazos Sep 20, 2019
d9c2720
Consistency: use Prebid loadExternalScript()
osazos Sep 24, 2019
c0f2520
Add "adagio" to Prebid.js adloader vendor whitelist
osazos Sep 24, 2019
3c8585e
Remove proprietary ad-server listeners
osazos Oct 23, 2019
989b0bc
Add RSA validation to adagio external script
osazos Oct 24, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 44 additions & 8 deletions modules/adagioAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,53 @@

import adapter from '../src/AnalyticsAdapter';
import adapterManager from '../src/adapterManager';
import CONSTANTS from '../src/constants.json';
import * as utils from '../src/utils';

// This config makes Prebid.js call this function on each event:
// `window['AdagioPrebidAnalytics']('on', eventType, args)`
// If it is missing, then Prebid.js will immediately log an error,
// instead of queueing the events until the function appears.
var adagioAdapter = adapter({
global: 'AdagioPrebidAnalytics',
handler: 'on',
analyticsType: 'bundle'
const emptyUrl = '';
const analyticsType = 'endpoint';
const events = Object.keys(CONSTANTS.EVENTS).map(key => CONSTANTS.EVENTS[key]);
const VERSION = '2.0.0';

const adagioEnqueue = function adagioEnqueue(action, data) {
utils.getWindowTop().ADAGIO.queue.push({ action, data, ts: Date.now() });
}

function canAccessTopWindow() {
try {
if (utils.getWindowTop().location.href) {
return true;
}
} catch (error) {
return false;
}
}

let adagioAdapter = Object.assign(adapter({ emptyUrl, analyticsType }), {
track: function({ eventType, args }) {
if (typeof args !== 'undefined' && events.indexOf(eventType) !== -1) {
adagioEnqueue('pb-analytics-event', { eventName: eventType, args });
}
}
});

adagioAdapter.originEnableAnalytics = adagioAdapter.enableAnalytics;

adagioAdapter.enableAnalytics = config => {
if (!canAccessTopWindow()) {
return;
}

const w = utils.getWindowTop();

w.ADAGIO = w.ADAGIO || {};
w.ADAGIO.queue = w.ADAGIO.queue || [];
w.ADAGIO.versions = w.ADAGIO.versions || {};
w.ADAGIO.versions.adagioAnalyticsAdapter = VERSION;

adagioAdapter.originEnableAnalytics(config);
}

adapterManager.registerAnalyticsAdapter({
adapter: adagioAdapter,
code: 'adagio'
Expand Down
2 changes: 1 addition & 1 deletion modules/adagioAnalyticsAdapter.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Overview

Module Name: Adagio Analytics Adapter
Module Type: Adagio Adapter
Module Type: Analytics Adapter
Maintainer: dev@adagio.io

# Description
Expand Down
Loading