@@ -2652,6 +2652,7 @@ describe('setVersionName', function() {
2652
2652
2653
2653
it ( 'should only send utm data once per session' , function ( ) {
2654
2654
reset ( ) ;
2655
+ const sessionTimeout = 100 ;
2655
2656
cookie . set ( '__utmz' , '133232535.1424926227.1.1.utmcct=top&utmccn=new' ) ;
2656
2657
amplitude . init ( apiKey , undefined , { includeUtm : true } ) ;
2657
2658
@@ -2661,8 +2662,8 @@ describe('setVersionName', function() {
2661
2662
assert . lengthOf ( amplitude . _unsentIdentifys , 0 ) ;
2662
2663
2663
2664
// advance clock to force new session
2664
- clock . tick ( 30 * 60 * 1000 + 1 ) ;
2665
- amplitude . init ( apiKey , undefined , { includeUtm : true , batchEvents : true , eventUploadThreshold : 2 } ) ;
2665
+ clock . tick ( sessionTimeout + 1 ) ;
2666
+ amplitude . init ( apiKey , undefined , { includeUtm : true , sessionTimeout , batchEvents : true , eventUploadThreshold : 2 } ) ;
2666
2667
amplitude . logEvent ( 'UTM Test Event' , { } ) ;
2667
2668
2668
2669
assert . lengthOf ( server . requests , 1 ) ;
@@ -2706,12 +2707,13 @@ describe('setVersionName', function() {
2706
2707
2707
2708
it ( 'should allow utm parameters to unset upon instantiating a new session' , function ( done ) {
2708
2709
reset ( ) ;
2710
+ const sessionTimeout = 100 ;
2709
2711
// send first $identify call with UTM params
2710
2712
sinon . stub ( amplitude , '_getUrlParams' ) . returns ( '?utm_source=google&utm_campaign=(organic)&utm_medium=organic&utm_term=(none)&utm_content=link' ) ;
2711
- amplitude . init ( apiKey , undefined , { includeUtm : true , saveParamsReferrerOncePerSession : false , unsetParamsReferrerOnNewSession : true } ) ;
2713
+ amplitude . init ( apiKey , undefined , { includeUtm : true , sessionTimeout , saveParamsReferrerOncePerSession : false , unsetParamsReferrerOnNewSession : true } ) ;
2712
2714
2713
2715
// advance clock to force new session
2714
- clock . tick ( 30 * 60 * 1000 + 1 ) ;
2716
+ clock . tick ( sessionTimeout + 1 ) ;
2715
2717
amplitude . _getUrlParams . restore ( ) ;
2716
2718
2717
2719
// send new session events
@@ -2762,12 +2764,13 @@ describe('setVersionName', function() {
2762
2764
2763
2765
it ( 'should reset utm parameters if it has changed during a new session' , function ( done ) {
2764
2766
reset ( ) ;
2767
+ const sessionTimeout = 100 ;
2765
2768
// send first $identify call with UTM params
2766
2769
sinon . stub ( amplitude , '_getUrlParams' ) . returns ( '?utm_source=google&utm_campaign=(organic)&utm_medium=organic&utm_term=(none)&utm_content=link' ) ;
2767
- amplitude . init ( apiKey , undefined , { includeUtm : true , saveParamsReferrerOncePerSession : false , unsetParamsReferrerOnNewSession : true } ) ;
2770
+ amplitude . init ( apiKey , undefined , { includeUtm : true , sessionTimeout , saveParamsReferrerOncePerSession : false , unsetParamsReferrerOnNewSession : true } ) ;
2768
2771
2769
2772
// advance clock to force new session, enter through a different campaign
2770
- clock . tick ( 30 * 60 * 1000 + 1 ) ;
2773
+ clock . tick ( sessionTimeout + 1 ) ;
2771
2774
amplitude . _getUrlParams . restore ( ) ;
2772
2775
sinon . stub ( amplitude , '_getUrlParams' ) . returns ( '?utm_source=google&utm_campaign=(mail_promotion)&utm_medium=email&utm_term=(none)&utm_content=click' ) ;
2773
2776
amplitude . init ( apiKey , undefined , { includeUtm : true , saveParamsReferrerOncePerSession : false , unsetParamsReferrerOnNewSession : true } ) ;
0 commit comments