@@ -2652,6 +2652,7 @@ describe('setVersionName', function() {
26522652
26532653 it ( 'should only send utm data once per session' , function ( ) {
26542654 reset ( ) ;
2655+ const sessionTimeout = 100 ;
26552656 cookie . set ( '__utmz' , '133232535.1424926227.1.1.utmcct=top&utmccn=new' ) ;
26562657 amplitude . init ( apiKey , undefined , { includeUtm : true } ) ;
26572658
@@ -2661,8 +2662,8 @@ describe('setVersionName', function() {
26612662 assert . lengthOf ( amplitude . _unsentIdentifys , 0 ) ;
26622663
26632664 // 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 } ) ;
26662667 amplitude . logEvent ( 'UTM Test Event' , { } ) ;
26672668
26682669 assert . lengthOf ( server . requests , 1 ) ;
@@ -2706,12 +2707,13 @@ describe('setVersionName', function() {
27062707
27072708 it ( 'should allow utm parameters to unset upon instantiating a new session' , function ( done ) {
27082709 reset ( ) ;
2710+ const sessionTimeout = 100 ;
27092711 // send first $identify call with UTM params
27102712 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 } ) ;
27122714
27132715 // advance clock to force new session
2714- clock . tick ( 30 * 60 * 1000 + 1 ) ;
2716+ clock . tick ( sessionTimeout + 1 ) ;
27152717 amplitude . _getUrlParams . restore ( ) ;
27162718
27172719 // send new session events
@@ -2762,12 +2764,13 @@ describe('setVersionName', function() {
27622764
27632765 it ( 'should reset utm parameters if it has changed during a new session' , function ( done ) {
27642766 reset ( ) ;
2767+ const sessionTimeout = 100 ;
27652768 // send first $identify call with UTM params
27662769 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 } ) ;
27682771
27692772 // advance clock to force new session, enter through a different campaign
2770- clock . tick ( 30 * 60 * 1000 + 1 ) ;
2773+ clock . tick ( sessionTimeout + 1 ) ;
27712774 amplitude . _getUrlParams . restore ( ) ;
27722775 sinon . stub ( amplitude , '_getUrlParams' ) . returns ( '?utm_source=google&utm_campaign=(mail_promotion)&utm_medium=email&utm_term=(none)&utm_content=click' ) ;
27732776 amplitude . init ( apiKey , undefined , { includeUtm : true , saveParamsReferrerOncePerSession : false , unsetParamsReferrerOnNewSession : true } ) ;
0 commit comments