@@ -41,7 +41,7 @@ interface SecondaryConfig {
41
41
42
42
// These values will be used if the remote config object is successfully
43
43
// retrieved, but the template does not have these fields.
44
- const SECONDARY_CONFIGS : SecondaryConfig = {
44
+ const DEFAULT_CONFIGS : SecondaryConfig = {
45
45
loggingEnabled : true ,
46
46
shouldSendToFl : true
47
47
} ;
@@ -184,28 +184,28 @@ function processConfig(
184
184
// known.
185
185
settingsServiceInstance . loggingEnabled =
186
186
String ( entries . fpr_enabled ) === 'true' ;
187
- } else if ( SECONDARY_CONFIGS . loggingEnabled !== undefined ) {
187
+ } else if ( DEFAULT_CONFIGS . loggingEnabled !== undefined ) {
188
188
// Config retrieved successfully, but there is no fpr_enabled in template.
189
189
// Use secondary configs value.
190
- settingsServiceInstance . loggingEnabled = SECONDARY_CONFIGS . loggingEnabled ;
190
+ settingsServiceInstance . loggingEnabled = DEFAULT_CONFIGS . loggingEnabled ;
191
191
}
192
192
if ( entries . fpr_log_source ) {
193
193
settingsServiceInstance . logSource = Number ( entries . fpr_log_source ) ;
194
- } else if ( SECONDARY_CONFIGS . logSource ) {
195
- settingsServiceInstance . logSource = SECONDARY_CONFIGS . logSource ;
194
+ } else if ( DEFAULT_CONFIGS . logSource ) {
195
+ settingsServiceInstance . logSource = DEFAULT_CONFIGS . logSource ;
196
196
}
197
197
198
198
if ( entries . fpr_log_endpoint_url ) {
199
199
settingsServiceInstance . logEndPointUrl = entries . fpr_log_endpoint_url ;
200
- } else if ( SECONDARY_CONFIGS . logEndPointUrl ) {
201
- settingsServiceInstance . logEndPointUrl = SECONDARY_CONFIGS . logEndPointUrl ;
200
+ } else if ( DEFAULT_CONFIGS . logEndPointUrl ) {
201
+ settingsServiceInstance . logEndPointUrl = DEFAULT_CONFIGS . logEndPointUrl ;
202
202
}
203
203
204
204
// Key from Remote Config has to be non-empty string, otherwsie use local value.
205
205
if ( entries . fpr_log_transport_key ) {
206
206
settingsServiceInstance . transportKey = entries . fpr_log_transport_key ;
207
- } else if ( SECONDARY_CONFIGS . transportKey ) {
208
- settingsServiceInstance . transportKey = SECONDARY_CONFIGS . transportKey ;
207
+ } else if ( DEFAULT_CONFIGS . transportKey ) {
208
+ settingsServiceInstance . transportKey = DEFAULT_CONFIGS . transportKey ;
209
209
}
210
210
211
211
// If config object state indicates that no template has been set, that means it is new user of
@@ -219,7 +219,7 @@ function processConfig(
219
219
settingsServiceInstance . shouldSendToFl =
220
220
NO_TEMPLATE_CONFIGS . shouldSendToFl ;
221
221
}
222
- } else if ( entries . fpr_log_transport_web_percent !== undefined ) {
222
+ } else if ( entries . fpr_log_transport_web_percent ) {
223
223
// If config object state doesn't indicate no template, it can only be UPDATE for now.
224
224
// - Performance Monitoring doesn't set etag in request, therefore state cannot be NO_CHANGE.
225
225
// - Sampling rate flags and master flag are required, therefore state cannot be EMPTY_CONFIG.
@@ -228,27 +228,27 @@ function processConfig(
228
228
iid ,
229
229
Number ( entries . fpr_log_transport_web_percent )
230
230
) ;
231
- } else if ( SECONDARY_CONFIGS . shouldSendToFl !== undefined ) {
231
+ } else if ( DEFAULT_CONFIGS . shouldSendToFl !== undefined ) {
232
232
// If config object state is UPDATE and rollout flag is not present, that means rollout is
233
233
// complete and rollout flag is deprecated, therefore dispatch events to new transport endpoint.
234
- settingsServiceInstance . shouldSendToFl = SECONDARY_CONFIGS . shouldSendToFl ;
234
+ settingsServiceInstance . shouldSendToFl = DEFAULT_CONFIGS . shouldSendToFl ;
235
235
}
236
236
237
237
if ( entries . fpr_vc_network_request_sampling_rate !== undefined ) {
238
238
settingsServiceInstance . networkRequestsSamplingRate = Number (
239
239
entries . fpr_vc_network_request_sampling_rate
240
240
) ;
241
- } else if ( SECONDARY_CONFIGS . networkRequestsSamplingRate !== undefined ) {
241
+ } else if ( DEFAULT_CONFIGS . networkRequestsSamplingRate !== undefined ) {
242
242
settingsServiceInstance . networkRequestsSamplingRate =
243
- SECONDARY_CONFIGS . networkRequestsSamplingRate ;
243
+ DEFAULT_CONFIGS . networkRequestsSamplingRate ;
244
244
}
245
245
if ( entries . fpr_vc_trace_sampling_rate !== undefined ) {
246
246
settingsServiceInstance . tracesSamplingRate = Number (
247
247
entries . fpr_vc_trace_sampling_rate
248
248
) ;
249
- } else if ( SECONDARY_CONFIGS . tracesSamplingRate !== undefined ) {
249
+ } else if ( DEFAULT_CONFIGS . tracesSamplingRate !== undefined ) {
250
250
settingsServiceInstance . tracesSamplingRate =
251
- SECONDARY_CONFIGS . tracesSamplingRate ;
251
+ DEFAULT_CONFIGS . tracesSamplingRate ;
252
252
}
253
253
// Set the per session trace and network logging flags.
254
254
settingsServiceInstance . logTraceAfterSampling = shouldLogAfterSampling (
@@ -269,7 +269,7 @@ function shouldLogAfterSampling(samplingRate: number): boolean {
269
269
}
270
270
271
271
/**
272
- * True if event should be sent to Fl transport endpoint rather than log endpoint.
272
+ * True if event should be sent to Fl transport endpoint rather than CC transport endpoint.
273
273
* rolloutPercent is in range [0.0, 100.0].
274
274
* @param {string } iid Installation ID which identifies a web app installed on client.
275
275
* @param {number } rolloutPercent the possibility of this app sending events to Fl endpoint.
@@ -282,7 +282,7 @@ export function isDestFl(iid: string, rolloutPercent: number): boolean {
282
282
return getHashPercent ( iid ) < rolloutPercent ;
283
283
}
284
284
/**
285
- * Generate integer value range in [0, 99].
285
+ * Generate integer value range in [0, 99]. Implementation from String.hashCode() in Java.
286
286
* @param {string } seed Same seed will generate consistent hash value using this algorithm.
287
287
* @return {number } Hash value in range [0, 99], generated from seed and hash algorithm.
288
288
*/
0 commit comments