@@ -20,21 +20,17 @@ const {
20
20
}
21
21
} = CONSTANTS ;
22
22
23
- let queue = [ ] ;
24
-
25
23
let concertAnalytics = Object . assign ( adapter ( { url, analyticsType} ) , {
26
24
track ( { eventType, args } ) {
27
- // eslint-disable-next-line no-console
28
- console . log ( 'got event' , eventType , args ) ;
29
25
switch ( eventType ) {
30
26
case BID_RESPONSE :
31
27
if ( args . bidder !== 'concert' ) break ;
32
- queue . push ( mapBidEvent ( eventType , args ) ) ;
28
+ this . queue . push ( mapBidEvent ( eventType , args ) ) ;
33
29
break ;
34
30
35
31
case BID_WON :
36
32
if ( args . bidder !== 'concert' ) break ;
37
- queue . push ( mapBidEvent ( eventType , args ) ) ;
33
+ this . queue . push ( mapBidEvent ( eventType , args ) ) ;
38
34
break ;
39
35
40
36
case AUCTION_END :
@@ -45,7 +41,10 @@ let concertAnalytics = Object.assign(adapter({url, analyticsType}), {
45
41
default :
46
42
break ;
47
43
}
48
- }
44
+ } ,
45
+
46
+ queue : [ ] ,
47
+ eventsStorage : [ ]
49
48
} ) ;
50
49
51
50
function mapBidEvent ( eventType , args ) {
@@ -85,24 +84,18 @@ function sampleAnalytics() {
85
84
}
86
85
87
86
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 ( ) ;
91
88
92
- if ( ! queue . length ) return ;
89
+ if ( ! concertAnalytics . queue . length ) return ;
93
90
94
91
if ( ! pageIncludedInSample ) {
95
92
utils . logMessage ( 'Page not included in sample for Concert Analytics' ) ;
96
93
return ;
97
94
}
98
95
99
96
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 , {
106
99
contentType : 'application/json' ,
107
100
method : 'POST'
108
101
} ) ;
0 commit comments