@@ -8,6 +8,21 @@ var refThis = this;
8
8
var storedObject ;
9
9
var frequencyDepth ;
10
10
const PREFIX = 'PROFILE_AUCTION_INFO_' ;
11
+
12
+ const TRACKER_METHODS = {
13
+ img : 1 ,
14
+ js : 2 ,
15
+ 1 : 'img' ,
16
+ 2 : 'js'
17
+ }
18
+
19
+ const TRACKER_EVENTS = {
20
+ impression : 1 ,
21
+ 'viewable-mrc50' : 2 ,
22
+ 'viewable-mrc100' : 3 ,
23
+ 'viewable-video50' : 4 ,
24
+ }
25
+
11
26
function createBidEntry ( divID ) { // TDD, i/o : done
12
27
/* istanbul ignore else */
13
28
if ( ! util . isOwnProperty ( window . PWT . bidMap , divID ) ) {
@@ -374,8 +389,8 @@ exports.displayCreative = function(theDocument, bidID){ // TDD, i/o : done
374
389
if ( frequencyDepth !== null && frequencyDepth . slotLevelFrquencyDepth ) {
375
390
frequencyDepth . slotLevelFrquencyDepth [ frequencyDepth . codeAdUnitMap [ divID ] ] . impressionServed = frequencyDepth . slotLevelFrquencyDepth [ frequencyDepth . codeAdUnitMap [ divID ] ] . impressionServed + 1 ;
376
391
frequencyDepth . impressionServed = frequencyDepth . impressionServed + 1 ;
392
+ localStorage . setItem ( PREFIX + window . location . hostname , JSON . stringify ( frequencyDepth ) ) ;
377
393
}
378
- localStorage . setItem ( PREFIX + window . location . hostname , JSON . stringify ( frequencyDepth ) ) ;
379
394
}
380
395
} ;
381
396
// endRemoveIf(removeLegacyAnalyticsRelatedCode)
@@ -409,13 +424,7 @@ exports.executeAnalyticsPixel = function(){ // TDD, i/o : done
409
424
outputObj [ CONSTANTS . CONFIG . PROFILE_VERSION_ID ] = CONFIG . getProfileDisplayVersionID ( ) ;
410
425
outputObj [ 'ih' ] = CONFIG . isUserIdModuleEnabled ( ) ? 1 : 0 ;
411
426
outputObj [ "bm" ] = refThis . getBrowser ( ) ;
412
- outputObj [ "tgid" ] = ( function ( ) {
413
- var testGroupId = parseInt ( PWT . testGroupId || 0 ) ;
414
- if ( testGroupId <= 15 && testGroupId >= 0 ) {
415
- return testGroupId ;
416
- }
417
- return 0 ;
418
- } ) ( ) ;
427
+ outputObj [ "tgid" ] = util . getTgid ( ) ;
419
428
420
429
if ( Object . keys ( frequencyDepth ) . length ) {
421
430
outputObj [ "tpv" ] = frequencyDepth . pageView ;
@@ -521,24 +530,6 @@ exports.getAdUnitAdFormats = getAdUnitAdFormats;
521
530
/* end-test-block */
522
531
// endRemoveIf(removeLegacyAnalyticsRelatedCode)
523
532
524
- // removeIf(removeLegacyAnalyticsRelatedCode)
525
- function getAdDomain ( bidResponse ) {
526
- if ( bidResponse . meta && bidResponse . meta . advertiserDomains && bidResponse . meta . advertiserDomains . length > 0 ) {
527
- var adomain = bidResponse . meta . advertiserDomains [ 0 ] ;
528
-
529
- if ( adomain ) {
530
- try {
531
- var hostname = new URL ( adomain ) ;
532
- return hostname . hostname . replace ( 'www.' , '' ) ;
533
- } catch ( e ) {
534
- util . log ( "Adomain URL (Not a proper URL):" + adomain ) ;
535
- return adomain . split ( '/' ) [ 0 ] . replace ( 'www.' , '' ) ;
536
- }
537
- }
538
- }
539
- }
540
- // endRemoveIf(removeLegacyAnalyticsRelatedCode)
541
-
542
533
// Returns property from localstorages slotlevel object
543
534
exports . getSlotLevelFrequencyDepth = function ( frequencyDepth , prop , adUnit ) {
544
535
var freqencyValue ;
@@ -692,7 +683,7 @@ function analyticalPixelCallback(slotID, bmEntry, impressionIDMap) { // TDD, i/o
692
683
"dc" : theBid . getDealChannel ( ) ,
693
684
"l1" : theBid . getServerSideStatus ( ) ? theBid . getServerSideResponseTime ( ) : ( endTime - startTime ) ,
694
685
"l2" : 0 ,
695
- "adv" : pbbid ? getAdDomain ( pbbid ) || undefined : undefined ,
686
+ "adv" : pbbid ? util . getAdDomain ( pbbid ) || undefined : undefined ,
696
687
"ss" : theBid . getServerSideStatus ( ) ,
697
688
"t" : theBid . getPostTimeoutStatus ( ) === false ? 0 : 1 ,
698
689
"wb" : theBid . getWinningBidStatus ( ) === true ? 1 : 0 ,
@@ -821,25 +812,37 @@ exports.fireTracker = function(bidDetails, action) {
821
812
var trackers ;
822
813
823
814
if ( action === "click" ) {
824
- trackers = bidDetails [ "native" ] && bidDetails [ "native" ] . clickTrackers ;
815
+ trackers = bidDetails [ "native" ] && bidDetails [ "native" ] . ortb &&
816
+ bidDetails [ "native" ] . ortb . link && bidDetails [ "native" ] . ortb . link . clickTrackers ;
825
817
} else if ( action === "imptrackers" ) {
826
- trackers = bidDetails [ "native" ] && bidDetails [ "native" ] . impressionTrackers ;
827
- if ( bidDetails [ 'native' ] && bidDetails [ 'native' ] . javascriptTrackers ) {
828
- var iframe = util . createInvisibleIframe ( ) ;
829
- /* istanbul ignore else */
830
- if ( ! iframe ) {
831
- throw { message : 'Failed to create invisible frame for native javascript trackers' } ;
832
- }
833
- /* istanbul ignore else */
834
- if ( ! iframe . contentWindow ) {
835
- throw { message : 'Unable to access frame window for native javascript trackers' } ;
818
+ const nativeResponse = bidDetails . native . ortb || bidDetails . native ;
819
+
820
+ const impTrackers = ( nativeResponse . eventtrackers || [ ] )
821
+ . filter ( function ( tracker ) {
822
+ tracker . event === TRACKER_EVENTS . impression
823
+ } ) ;
824
+
825
+ const tally = { img : [ ] , js : [ ] } ;
826
+ impTrackers . forEach ( function ( tracker ) {
827
+ if ( TRACKER_METHODS . hasOwnProperty ( tracker . method ) ) {
828
+ tally [ TRACKER_METHODS [ tracker . method ] ] . push ( tracker . url ) ;
836
829
}
837
- window . document . body . appendChild ( iframe ) ;
838
- iframe . contentWindow . document . open ( ) ;
839
- iframe . contentWindow . document . write ( bidDetails [ 'native' ] . javascriptTrackers ) ;
840
- iframe . contentWindow . document . close ( ) ;
830
+ } ) ;
831
+
832
+ if ( tally . img . length == 0 && nativeResponse . imptrackers ) {
833
+ tally . img = tally . img . concat ( nativeResponse . imptrackers ) ;
834
+ }
835
+ trackers = tally . img ;
836
+
837
+ if ( tally . js . length == 0 && nativeResponse . jstracker ) {
838
+ // jstracker is already HTML markup
839
+ tally . js = tally . js . concat ( [ nativeResponse . jstracker ] ) ;
840
+ }
841
+ if ( tally . js . length ) {
842
+ util . insertHtmlIntoIframe ( tally . js . join ( '\n' ) ) ;
841
843
}
842
844
}
845
+
843
846
( trackers || [ ] ) . forEach ( function ( url ) { refThis . setImageSrcToPixelURL ( url , false ) ; } ) ;
844
847
} ;
845
848
// endRemoveIf(removeNativeRelatedCode)
0 commit comments