@@ -62,13 +62,74 @@ var constructor = function () {
6262 if ( ! testMode ) {
6363 renderSnippet ( ) ;
6464 }
65- mixpanel . init (
66- settings . token ,
65+ // Build init options object
66+ var initOptions = {
67+ api_host : forwarderSettings . baseUrl ,
68+ } ;
69+
70+ // Session Replay boolean settings
71+ var boolSettings = [
72+ { key : 'recordHeatmapData' , mappedKey : 'record_heatmap_data' } ,
73+ { key : 'autocapture' , mappedKey : 'autocapture' } ,
74+ { key : 'recordCanvas' , mappedKey : 'record_canvas' } ,
75+ ] ;
76+
77+ // Session Replay numeric settings
78+ var numericSettings = [
6779 {
68- api_host : forwarderSettings . baseUrl ,
80+ key : 'recordSessionsPercent' ,
81+ mappedKey : 'record_sessions_percent' ,
6982 } ,
70- 'mparticle'
71- ) ;
83+ {
84+ key : 'recordIdleTimeoutMs' ,
85+ mappedKey : 'record_idle_timeout_ms' ,
86+ } ,
87+ { key : 'recordMaxMs' , mappedKey : 'record_max_ms' } ,
88+ { key : 'recordMinMs' , mappedKey : 'record_min_ms' } ,
89+ ] ;
90+
91+ // Session Replay string settings
92+ var stringSettings = [
93+ {
94+ key : 'recordMaskTextSelector' ,
95+ mappedKey : 'record_mask_text_selector' ,
96+ } ,
97+ {
98+ key : 'recordBlockSelector' ,
99+ mappedKey : 'record_block_selector' ,
100+ } ,
101+ { key : 'recordBlockClass' , mappedKey : 'record_block_class' } ,
102+ {
103+ key : 'recordMaskTextClass' ,
104+ mappedKey : 'record_mask_text_class' ,
105+ } ,
106+ ] ;
107+
108+ // Process boolean settings
109+ boolSettings . forEach ( function ( setting ) {
110+ if ( forwarderSettings [ setting . key ] != null ) {
111+ initOptions [ setting . mappedKey ] =
112+ forwarderSettings [ setting . key ] === 'True' ;
113+ }
114+ } ) ;
115+
116+ // Process numeric settings
117+ numericSettings . forEach ( function ( setting ) {
118+ var numericValue = parseIntSafe ( forwarderSettings [ setting . key ] ) ;
119+ if ( numericValue !== undefined ) {
120+ initOptions [ setting . mappedKey ] = numericValue ;
121+ }
122+ } ) ;
123+
124+ // Process string settings
125+ stringSettings . forEach ( function ( setting ) {
126+ if ( forwarderSettings [ setting . key ] ) {
127+ initOptions [ setting . mappedKey ] =
128+ forwarderSettings [ setting . key ] ;
129+ }
130+ } ) ;
131+
132+ mixpanel . init ( settings . token , initOptions , 'mparticle' ) ;
72133
73134 isInitialized = true ;
74135
@@ -193,7 +254,7 @@ var constructor = function () {
193254 // When mParticle identifies a user, because the user might
194255 // actually be anonymous, we only want to send an
195256 // identify request to Mixpanel if the user is
196- // actually known. If a user has any user identities, they are
257+ // actually known. If a user has any user identities, they are
197258 // considered to be "known" users.
198259 var userIdentities = getUserIdentities ( user ) ;
199260
@@ -394,6 +455,11 @@ function isObject(val) {
394455 ) ;
395456}
396457
458+ function parseIntSafe ( value ) {
459+ var n = parseInt ( value , 10 ) ;
460+ return isNaN ( n ) ? undefined : n ;
461+ }
462+
397463if ( typeof window !== 'undefined' ) {
398464 if ( window && window . mParticle && window . mParticle . addForwarder ) {
399465 window . mParticle . addForwarder ( {
0 commit comments