From 5bfc26029baf8aeff4a989e32613f2d386462bc7 Mon Sep 17 00:00:00 2001 From: tej656 Date: Wed, 31 Jul 2024 12:17:48 +0530 Subject: [PATCH] send pubx_id as query param --- modules/pubxaiAnalyticsAdapter.js | 8 +++++--- test/spec/modules/pubxaiAnalyticsAdapter_spec.js | 14 +++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/modules/pubxaiAnalyticsAdapter.js b/modules/pubxaiAnalyticsAdapter.js index e831526be5e..f8ec72cde75 100644 --- a/modules/pubxaiAnalyticsAdapter.js +++ b/modules/pubxaiAnalyticsAdapter.js @@ -20,6 +20,8 @@ const analyticsType = 'endpoint'; const adapterCode = 'pubxai'; const pubxaiAnalyticsVersion = 'v2.0.0'; const defaultHost = 'api.pbxai.com'; +const auctionPath = '/analytics/auction'; +const winningBidPath = '/analytics/bidwon'; const storage = getStorageManager({ moduleType: MODULE_TYPE_ANALYTICS, moduleName: adapterCode }) /** @@ -234,10 +236,9 @@ const prepareSend = (auctionId) => { if (!shouldFireEventRequest(auctionId, initOptions.samplingRate)) { return; } - const pubxID = initOptions.pubxId; [ { - path: `/analytics/${pubxID}/bidwon`, + path: winningBidPath, requiredKeys: [ 'winningBid', 'pageDetail', @@ -252,7 +253,7 @@ const prepareSend = (auctionId) => { eventType: 'win', }, { - path: `/analytics/${pubxID}/auction`, + path: auctionPath, requiredKeys: [ 'bids', 'pageDetail', @@ -286,6 +287,7 @@ const prepareSend = (auctionId) => { auctionTimestamp: auctionData.auctionDetail.timestamp, pubxaiAnalyticsVersion: pubxaiAnalyticsVersion, prebidVersion: '$prebid.version$', + pubxId: initOptions.pubxId, }, }); sendCache[pubxaiAnalyticsRequestUrl].push(data); diff --git a/test/spec/modules/pubxaiAnalyticsAdapter_spec.js b/test/spec/modules/pubxaiAnalyticsAdapter_spec.js index a27400af46f..abc52b00439 100644 --- a/test/spec/modules/pubxaiAnalyticsAdapter_spec.js +++ b/test/spec/modules/pubxaiAnalyticsAdapter_spec.js @@ -31,7 +31,7 @@ describe('pubxai analytics adapter', () => { }); describe('track', () => { - const pubxId = '6c415fc0-8b0e-4cf5-be73-01526a4db625' + const pubxId = '6c415fc0-8b0e-4cf5-be73-01526a4db625'; let initOptions = { samplingRate: '1', pubxId: pubxId, @@ -759,12 +759,13 @@ describe('pubxai analytics adapter', () => { const [expectedUrl, expectedData] = arg; const parsedUrl = new URL(expectedUrl); expect(parsedUrl.pathname).to.equal( - [`/analytics/${pubxId}/bidwon`, `/analytics/${pubxId}/auction`][index] + ['/analytics/bidwon', '/analytics/auction'][index] ); expect(Object.fromEntries(parsedUrl.searchParams)).to.deep.equal({ auctionTimestamp: '1616654312804', pubxaiAnalyticsVersion: 'v2.0.0', prebidVersion: '$prebid.version$', + pubxId: pubxId, }); expect(expectedData.type).to.equal('text/json'); expect(JSON.parse(await readBlobSafariCompat(expectedData))).to.deep.equal([ @@ -801,13 +802,14 @@ describe('pubxai analytics adapter', () => { // Step 7: check the pathname of the calls is correct (sent only to the auction endpoint) const [expectedUrl, expectedData] = navigator.sendBeacon.args[0]; const parsedUrl = new URL(expectedUrl); - expect(parsedUrl.pathname).to.equal(`/analytics/${pubxId}/auction`); + expect(parsedUrl.pathname).to.equal('/analytics/auction'); // Step 8: check that the meta information in the call is correct expect(Object.fromEntries(parsedUrl.searchParams)).to.deep.equal({ auctionTimestamp: '1616654312804', pubxaiAnalyticsVersion: 'v2.0.0', prebidVersion: '$prebid.version$', + pubxId: pubxId, }); // Step 9: check that the data sent in the request is correct @@ -927,12 +929,13 @@ describe('pubxai analytics adapter', () => { const parsedUrl = new URL(expectedUrl); const auctionIdMapFn = index < 2 ? (i, _) => i : replaceProperty; expect(parsedUrl.pathname).to.equal( - [`/analytics/${pubxId}/bidwon`, `/analytics/${pubxId}/auction`][index % 2] + ['/analytics/bidwon', '/analytics/auction'][index % 2] ); expect(Object.fromEntries(parsedUrl.searchParams)).to.deep.equal({ auctionTimestamp: '1616654312804', pubxaiAnalyticsVersion: 'v2.0.0', prebidVersion: '$prebid.version$', + pubxId: pubxId, }); expect(expectedData.type).to.equal('text/json'); expect(JSON.parse(await readBlobSafariCompat(expectedData))).to.deep.equal([ @@ -1043,12 +1046,13 @@ describe('pubxai analytics adapter', () => { const [expectedUrl, expectedData] = arg; const parsedUrl = new URL(expectedUrl); expect(parsedUrl.pathname).to.equal( - [`/analytics/${pubxId}/bidwon`, `/analytics/${pubxId}/auction`][index] + ['/analytics/bidwon', '/analytics/auction'][index] ); expect(Object.fromEntries(parsedUrl.searchParams)).to.deep.equal({ auctionTimestamp: '1616654312804', pubxaiAnalyticsVersion: 'v2.0.0', prebidVersion: '$prebid.version$', + pubxId: pubxId, }); expect(expectedData.type).to.equal('text/json'); expect(JSON.parse(await readBlobSafariCompat(expectedData))).to.deep.equal([