Skip to content

Commit

Permalink
AdagioAnalyticsAdapter: do not send PBA if enableTIDs is not true
Browse files Browse the repository at this point in the history
  • Loading branch information
Abyfall committed Jul 8, 2024
1 parent 3fb4533 commit c5e18ac
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 3 deletions.
10 changes: 8 additions & 2 deletions modules/adagioAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ajax } from '../src/ajax.js';
import { BANNER } from '../src/mediaTypes.js';
import { getWindowTop, getWindowSelf, deepAccess, logInfo, logError } from '../src/utils.js';
import { getGlobal } from '../src/prebidGlobal.js';
import { config } from '../src/config.js';

const emptyUrl = '';
const analyticsType = 'endpoint';
Expand Down Expand Up @@ -404,7 +405,12 @@ let adagioAdapter = Object.assign(adapter({ emptyUrl, analyticsType }), {

adagioAdapter.originEnableAnalytics = adagioAdapter.enableAnalytics;

adagioAdapter.enableAnalytics = config => {
adagioAdapter.enableAnalytics = adapterConfig => {
if (config.getConfig('enableTIDs') !== true) {
logError('Adagio Analytics Adapter requires prebid settings enableTIDs to be true. No beacon will be sent');
return;
}

const w = (canAccessTopWindow()) ? getWindowTop() : getWindowSelf();
currentWindow = w;

Expand All @@ -413,7 +419,7 @@ adagioAdapter.enableAnalytics = config => {
w.ADAGIO.versions = w.ADAGIO.versions || {};
w.ADAGIO.versions.adagioAnalyticsAdapter = VERSION;

adagioAdapter.originEnableAnalytics(config);
adagioAdapter.originEnableAnalytics(adapterConfig);
}

adapterManager.registerAnalyticsAdapter({
Expand Down
52 changes: 51 additions & 1 deletion test/spec/modules/adagioAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import adagioAnalyticsAdapter from 'modules/adagioAnalyticsAdapter.js';
import { expect } from 'chai';
import * as utils from 'src/utils.js';
import { config } from 'src/config.js';
import { server } from 'test/mocks/xhr.js';
import * as prebidGlobal from 'src/prebidGlobal.js';
import { EVENTS } from 'src/constants.js';
Expand All @@ -16,6 +17,7 @@ describe('adagio analytics adapter - adagio.js', () => {
sandbox = sinon.createSandbox();

sandbox.stub(events, 'getEvents').returns([]);
config.setConfig({enableTIDs: true});

const w = utils.getWindowTop();

Expand Down Expand Up @@ -93,7 +95,6 @@ describe('adagio analytics adapter - adagio.js', () => {

// 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',
Expand Down Expand Up @@ -616,6 +617,7 @@ const MOCK = {
describe('adagio analytics adapter', () => {
let sandbox;

config.setConfig({enableTIDs: true});
beforeEach(() => {
sandbox = sinon.sandbox.create();

Expand Down Expand Up @@ -851,3 +853,51 @@ describe('adagio analytics adapter', () => {
});
});
});

describe('adagio analytics adapter with enableTIDs = false', () => {
let sandbox;

beforeEach(() => {
sandbox = sinon.sandbox.create();

sandbox.stub(events, 'getEvents').returns([]);
config.setConfig({enableTIDs: false});

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

afterEach(() => {
sandbox.restore();
});

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

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

it('builds and sends auction data', () => {
events.emit(EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT.another);
events.emit(EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE.adagio);
events.emit(EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE.another);
events.emit(EVENTS.AUCTION_END, MOCK.AUCTION_END.another);
events.emit(EVENTS.BID_WON, MOCK.BID_WON.another);
events.emit(EVENTS.AD_RENDER_SUCCEEDED, MOCK.AD_RENDER_SUCCEEDED.another);

expect(server.requests.length).to.equal(0, 'requests count');
});
});
});

0 comments on commit c5e18ac

Please sign in to comment.