@@ -67,78 +67,72 @@ var constructor = function () {
6767 api_host : forwarderSettings . baseUrl ,
6868 } ;
6969
70- if ( forwarderSettings . recordSessionsPercent != null ) {
71- var sessionPercent = parseInt (
72- forwarderSettings . recordSessionsPercent ,
73- 10
74- ) ;
75-
76- if ( ! isNaN ( sessionPercent ) ) {
77- initOptions . record_sessions_percent = sessionPercent ;
78- }
79- }
80-
81- if ( forwarderSettings . recordHeatmapData != null ) {
82- initOptions . record_heatmap_data =
83- forwarderSettings . recordHeatmapData === 'True' ;
84- }
85-
86- if ( forwarderSettings . autocapture != null ) {
87- initOptions . autocapture =
88- forwarderSettings . autocapture === 'True' ;
89- }
90-
91- // Privacy and masking settings
92- if ( forwarderSettings . recordMaskTextSelector ) {
93- initOptions . record_mask_text_selector =
94- forwarderSettings . recordMaskTextSelector ;
95- }
96-
97- if ( forwarderSettings . recordBlockSelector ) {
98- initOptions . record_block_selector =
99- forwarderSettings . recordBlockSelector ;
100- }
101-
102- if ( forwarderSettings . recordBlockClass ) {
103- initOptions . record_block_class =
104- forwarderSettings . recordBlockClass ;
105- }
106-
107- if ( forwarderSettings . recordMaskTextClass ) {
108- initOptions . record_mask_text_class =
109- forwarderSettings . recordMaskTextClass ;
110- }
111-
112- // Canvas recording (experimental)
113- if ( forwarderSettings . recordCanvas != null ) {
114- initOptions . record_canvas =
115- forwarderSettings . recordCanvas === 'True' ;
116- }
117-
118- // Timing settings
119- if ( forwarderSettings . recordIdleTimeoutMs != null ) {
120- var idleTimeoutMs = parseInt (
121- forwarderSettings . recordIdleTimeoutMs ,
122- 10
123- ) ;
124- if ( ! isNaN ( idleTimeoutMs ) ) {
125- initOptions . record_idle_timeout_ms = idleTimeoutMs ;
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 = [
79+ {
80+ key : 'recordSessionsPercent' ,
81+ mappedKey : 'record_sessions_percent' ,
82+ } ,
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' ;
126113 }
127- }
128-
129- if ( forwarderSettings . recordMaxMs != null ) {
130- var maxMs = parseInt ( forwarderSettings . recordMaxMs , 10 ) ;
131- if ( ! isNaN ( maxMs ) ) {
132- initOptions . record_max_ms = maxMs ;
114+ } ) ;
115+
116+ // Process numeric settings
117+ numericSettings . forEach ( function ( setting ) {
118+ if ( forwarderSettings [ setting . key ] != null ) {
119+ var numericValue = parseInt (
120+ forwarderSettings [ setting . key ] ,
121+ 10
122+ ) ;
123+ if ( ! isNaN ( numericValue ) ) {
124+ initOptions [ setting . mappedKey ] = numericValue ;
125+ }
133126 }
134- }
127+ } ) ;
135128
136- if ( forwarderSettings . recordMinMs != null ) {
137- var minMs = parseInt ( forwarderSettings . recordMinMs , 10 ) ;
138- if ( ! isNaN ( minMs ) ) {
139- initOptions . record_min_ms = minMs ;
129+ // Process string settings
130+ stringSettings . forEach ( function ( setting ) {
131+ if ( forwarderSettings [ setting . key ] ) {
132+ initOptions [ setting . mappedKey ] =
133+ forwarderSettings [ setting . key ] ;
140134 }
141- }
135+ } ) ;
142136
143137 mixpanel . init ( settings . token , initOptions , 'mparticle' ) ;
144138
@@ -265,7 +259,7 @@ var constructor = function () {
265259 // When mParticle identifies a user, because the user might
266260 // actually be anonymous, we only want to send an
267261 // identify request to Mixpanel if the user is
268- // actually known. If a user has any user identities, they are
262+ // actually known. If a user has any user identities, they are
269263 // considered to be "known" users.
270264 var userIdentities = getUserIdentities ( user ) ;
271265
0 commit comments