Skip to content

Commit

Permalink
PubxaiAnalyticsAdapter Update: Added an extra field in the auction pa…
Browse files Browse the repository at this point in the history
…yload. (prebid#12181)

* send BidRejected Events to capture floored bids

* fix tests

* send pubx_id as query param

* added extraData in analytics adapter to be sent in beacon data

* added extraData in analytics adapter to be sent in beacon data

* moved data read to session storage

* bumped version

* moving all data to localStorage again

* updated test cases for pubxaiAA.js

---------

Co-authored-by: tej656 <tej@pubx.ai>
Co-authored-by: Tej <139129627+tej656@users.noreply.github.com>
Co-authored-by: NikhilX <nikhil@pubx.ai>
  • Loading branch information
4 people authored Aug 29, 2024
1 parent d690c86 commit b7efc5a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion modules/pubxaiAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let initOptions;
const emptyUrl = '';
const analyticsType = 'endpoint';
const adapterCode = 'pubxai';
const pubxaiAnalyticsVersion = 'v2.0.0';
const pubxaiAnalyticsVersion = 'v2.1.0';
const defaultHost = 'api.pbxai.com';
const auctionPath = '/analytics/auction';
const winningBidPath = '/analytics/bidwon';
Expand Down Expand Up @@ -77,6 +77,7 @@ export const auctionCache = new Proxy(
consentTypes: Object.keys(getGlobal().getConsentMetadata?.() || {}),
},
pmacDetail: JSON.parse(storage.getDataFromLocalStorage('pubx:pmac')) || {}, // {auction_1: {floor:0.23,maxBid:0.34,bidCount:3},auction_2:{floor:0.13,maxBid:0.14,bidCount:2}
extraData: JSON.parse(storage.getDataFromLocalStorage('pubx:extraData')) || {},
initOptions: {
...initOptions,
auctionId: name, // back-compat
Expand Down Expand Up @@ -248,6 +249,7 @@ const prepareSend = (auctionId) => {
'userDetail',
'consentDetail',
'pmacDetail',
'extraData',
'initOptions',
],
eventType: 'win',
Expand All @@ -263,6 +265,7 @@ const prepareSend = (auctionId) => {
'userDetail',
'consentDetail',
'pmacDetail',
'extraData',
'initOptions',
],
eventType: 'auction',
Expand Down
10 changes: 6 additions & 4 deletions test/spec/modules/pubxaiAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ describe('pubxai analytics adapter', () => {
consentTypes: Object.keys(getGlobal().getConsentMetadata?.() || {}),
},
pmacDetail: {},
extraData: {},
initOptions: {
...initOptions,
auctionId: 'bc3806e4-873e-453c-8ae5-204f35e923b4',
Expand Down Expand Up @@ -693,6 +694,7 @@ describe('pubxai analytics adapter', () => {
consentTypes: Object.keys(getGlobal().getConsentMetadata?.() || {}),
},
pmacDetail: {},
extraData: {},
initOptions: {
...initOptions,
auctionId: 'bc3806e4-873e-453c-8ae5-204f35e923b4',
Expand Down Expand Up @@ -763,7 +765,7 @@ describe('pubxai analytics adapter', () => {
);
expect(Object.fromEntries(parsedUrl.searchParams)).to.deep.equal({
auctionTimestamp: '1616654312804',
pubxaiAnalyticsVersion: 'v2.0.0',
pubxaiAnalyticsVersion: 'v2.1.0',
prebidVersion: '$prebid.version$',
pubxId: pubxId,
});
Expand Down Expand Up @@ -807,7 +809,7 @@ describe('pubxai analytics adapter', () => {
// 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',
pubxaiAnalyticsVersion: 'v2.1.0',
prebidVersion: '$prebid.version$',
pubxId: pubxId,
});
Expand Down Expand Up @@ -933,7 +935,7 @@ describe('pubxai analytics adapter', () => {
);
expect(Object.fromEntries(parsedUrl.searchParams)).to.deep.equal({
auctionTimestamp: '1616654312804',
pubxaiAnalyticsVersion: 'v2.0.0',
pubxaiAnalyticsVersion: 'v2.1.0',
prebidVersion: '$prebid.version$',
pubxId: pubxId,
});
Expand Down Expand Up @@ -1050,7 +1052,7 @@ describe('pubxai analytics adapter', () => {
);
expect(Object.fromEntries(parsedUrl.searchParams)).to.deep.equal({
auctionTimestamp: '1616654312804',
pubxaiAnalyticsVersion: 'v2.0.0',
pubxaiAnalyticsVersion: 'v2.1.0',
prebidVersion: '$prebid.version$',
pubxId: pubxId,
});
Expand Down

0 comments on commit b7efc5a

Please sign in to comment.