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 Analytics Adapter: remove legacy internal push events #54

Open
wants to merge 1 commit into
base: adagio-feature/adagioanalyticsadapter-remove-legacy
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 0 additions & 16 deletions modules/adagioAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import { getGlobal } from '../src/prebidGlobal.js';

const emptyUrl = '';
const analyticsType = 'endpoint';
const events = Object.keys(EVENTS).map(key => EVENTS[key]);
const ADAGIO_GVLID = 617;
const VERSION = '3.0.0';
const PREBID_VERSION = '$prebid.version$';
const ENDPOINT = 'https://c.4dex.io/pba.gif';
const CURRENCY_USD = 'USD';
Expand Down Expand Up @@ -405,26 +403,12 @@ let adagioAdapter = Object.assign(adapter({ emptyUrl, analyticsType }), {
} catch (error) {
logError('Error on Adagio Analytics Adapter', error);
}

try {
if (typeof args !== 'undefined' && events.indexOf(eventType) !== -1) {
_internal.getAdagioNs().queue.push({
action: 'pb-analytics-event',
data: { eventName: eventType, args },
ts: Date.now()
});
}
} catch (error) {
logError('Error on Adagio Analytics Adapter - adagio.js', error);
}
}
});

adagioAdapter.originEnableAnalytics = adagioAdapter.enableAnalytics;

adagioAdapter.enableAnalytics = config => {
_internal.getAdagioNs().versions.adagioAnalyticsAdapter = VERSION;

let modules = getGlobal().installedModules;
if (modules && (!modules.length || modules.indexOf('adagioRtdProvider') === -1 || modules.indexOf('rtdModule') === -1)) {
logError('Adagio Analytics Adapter requires rtdModule & adagioRtdProvider modules which are not installed. No beacon will be sent');
Expand Down
106 changes: 0 additions & 106 deletions test/spec/modules/adagioAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,112 +8,6 @@ import { server } from 'test/mocks/xhr.js';
let adapterManager = require('src/adapterManager').default;
let events = require('src/events');

describe('adagio analytics adapter - adagio.js', () => {
let sandbox;
let adagioQueuePushSpy;

beforeEach(() => {
sandbox = sinon.createSandbox();
sandbox.stub(events, 'getEvents').returns([]);

sandbox.stub(prebidGlobal, 'getGlobal').returns({
installedModules: ['adagioRtdProvider', 'rtdModule']
});

adapterManager.registerAnalyticsAdapter({
code: 'adagio',
adapter: adagioAnalyticsAdapter
});

_internal.getAdagioNs().pageviewId = 'a68e6d70-213b-496c-be0a-c468ff387106';

adagioQueuePushSpy = sandbox.spy(_internal.getAdagioNs().queue, 'push');
});

afterEach(() => {
_internal.getAdagioNs().queue = [];
sandbox.restore();
});

describe('track', () => {
beforeEach(() => {
adapterManager.enableAnalytics({
provider: 'adagio',
options: {
organizationId: '1001',
site: 'test-com',
}
});
});

afterEach(() => {
adagioAnalyticsAdapter.disableAnalytics();
});

it('builds and sends auction data', () => {
const w = utils.getWindowTop();

let bidRequest = {
bids: [{
adUnitCode: 'div-1',
params: {
features: {
siteId: '2',
placement: 'pave_top',
pagetype: 'article',
category: 'IAB12,IAB12-2',
device: '2',
}
}
}, {
adUnitCode: 'div-2',
params: {
features: {
siteId: '2',
placement: 'ban_top',
pagetype: 'article',
category: 'IAB12,IAB12-2',
device: '2',
}
},
}],
};
let bidResponse = {
bidderCode: 'adagio',
width: 300,
height: 250,
statusMessage: 'Bid available',
cpm: 6.2189757658226075,
currency: '',
netRevenue: false,
adUnitCode: 'div-1',
timeToRespond: 132,
};

const testEvents = {
[EVENTS.BID_REQUESTED]: bidRequest,
[EVENTS.BID_RESPONSE]: bidResponse,
[EVENTS.AUCTION_END]: {}
};

// Step 1-3: Send events
Object.entries(testEvents).forEach(([ev, payload]) => events.emit(ev, payload));
function eventItem(eventName, args) {
return sinon.match({
action: 'pb-analytics-event',
ts: sinon.match((val) => val !== undefined),
data: {
eventName,
args
}
})
}

Object.entries(testEvents).forEach(([ev, payload]) => sinon.assert.calledWith(adagioQueuePushSpy, eventItem(ev, payload)));
});
});
});

const AUCTION_ID = '25c6d7f5-699a-4bfc-87c9-996f915341fa';
const RTD_AUCTION_ID = '753b3784-12a1-44c2-9d08-d0e4ee910e69';
const RTD_AUCTION_ID_CACHE = '04d991be-8f7d-4491-930b-2b7eefb3c447';
Expand Down