Skip to content

Commit 829ad84

Browse files
author
Josh Larson
committed
Attempt to store queue in-prototype
1 parent 774a1b6 commit 829ad84

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

modules/concertAnalyticsAdapter.js

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,17 @@ const {
2020
}
2121
} = CONSTANTS;
2222

23-
let queue = [];
24-
2523
let concertAnalytics = Object.assign(adapter({url, analyticsType}), {
2624
track({ eventType, args }) {
27-
// eslint-disable-next-line no-console
28-
console.log('got event', eventType, args);
2925
switch (eventType) {
3026
case BID_RESPONSE:
3127
if (args.bidder !== 'concert') break;
32-
queue.push(mapBidEvent(eventType, args));
28+
this.queue.push(mapBidEvent(eventType, args));
3329
break;
3430

3531
case BID_WON:
3632
if (args.bidder !== 'concert') break;
37-
queue.push(mapBidEvent(eventType, args));
33+
this.queue.push(mapBidEvent(eventType, args));
3834
break;
3935

4036
case AUCTION_END:
@@ -45,7 +41,10 @@ let concertAnalytics = Object.assign(adapter({url, analyticsType}), {
4541
default:
4642
break;
4743
}
48-
}
44+
},
45+
46+
queue: [],
47+
eventsStorage: []
4948
});
5049

5150
function mapBidEvent(eventType, args) {
@@ -85,24 +84,18 @@ function sampleAnalytics() {
8584
}
8685

8786
function sendEvents() {
88-
concertAnalytics.eventsStorage = queue;
89-
// eslint-disable-next-line no-console
90-
console.log('set concert events storage', concertAnalytics.eventsStorage);
87+
concertAnalytics.eventsStorage = concertAnalytics.queue.slice();
9188

92-
if (!queue.length) return;
89+
if (!concertAnalytics.queue.length) return;
9390

9491
if (!pageIncludedInSample) {
9592
utils.logMessage('Page not included in sample for Concert Analytics');
9693
return;
9794
}
9895

9996
try {
100-
const body = JSON.stringify(queue);
101-
ajax(url, () => {
102-
// eslint-disable-next-line no-console
103-
console.log('flushing bid queue');
104-
queue = []
105-
}, body, {
97+
const body = JSON.stringify(concertAnalytics.queue);
98+
ajax(url, () => concertAnalytics.queue = [], body, {
10699
contentType: 'application/json',
107100
method: 'POST'
108101
});

0 commit comments

Comments
 (0)