Skip to content

Commit 33f60e3

Browse files
committed
Address comments.
1 parent acc545f commit 33f60e3

File tree

2 files changed

+34
-27
lines changed

2 files changed

+34
-27
lines changed

packages/performance/src/services/remote_config_service.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,5 +236,39 @@ describe('Performance Monitoring > remote_config_service', () => {
236236

237237
expect(SettingsService.getInstance().loggingEnabled).to.be.true;
238238
});
239+
240+
it('gets the config from RC even with deprecated transport flag', async () => {
241+
// Expired local config.
242+
const EXPIRY_LOCAL_STORAGE_VALUE = '1556524895320';
243+
const STRINGIFIED_CUSTOM_CONFIG = `{"entries":{\
244+
"fpr_vc_network_request_sampling_rate":"0.250000",\
245+
"fpr_log_transport_web_percent":"100.0",\
246+
"fpr_vc_session_sampling_rate":"0.250000","fpr_vc_trace_sampling_rate":"0.500000"},\
247+
"state":"UPDATE"}`;
248+
249+
const { storageGetItemStub: getItemStub } = setup(
250+
{
251+
expiry: EXPIRY_LOCAL_STORAGE_VALUE,
252+
config: STRINGIFIED_CUSTOM_CONFIG
253+
},
254+
{ reject: false, value: new Response(STRINGIFIED_CONFIG) }
255+
);
256+
257+
await getConfig(IID);
258+
259+
expect(getItemStub).to.be.calledOnce;
260+
expect(SettingsService.getInstance().loggingEnabled).to.be.true;
261+
expect(SettingsService.getInstance().logEndPointUrl).to.equal(LOG_URL);
262+
expect(SettingsService.getInstance().transportKey).to.equal(
263+
TRANSPORT_KEY
264+
);
265+
expect(SettingsService.getInstance().logSource).to.equal(LOG_SOURCE);
266+
expect(
267+
SettingsService.getInstance().networkRequestsSamplingRate
268+
).to.equal(NETWORK_SAMPLIG_RATE);
269+
expect(SettingsService.getInstance().tracesSamplingRate).to.equal(
270+
TRACE_SAMPLING_RATE
271+
);
272+
});
239273
});
240274
});

packages/performance/src/services/remote_config_service.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -231,30 +231,3 @@ function configValid(expiry: string): boolean {
231231
function shouldLogAfterSampling(samplingRate: number): boolean {
232232
return Math.random() <= samplingRate;
233233
}
234-
235-
/**
236-
* True if event should be sent to Fl transport endpoint rather than CC transport endpoint.
237-
* rolloutPercent is in range [0.0, 100.0].
238-
* @param iid Installation ID which identifies a web app installed on client.
239-
* @param rolloutPercent the possibility of this app sending events to Fl endpoint.
240-
* @return true if this installation should send events to Fl endpoint.
241-
*/
242-
export function isDestFl(iid: string, rolloutPercent: number): boolean {
243-
if (iid.length === 0) {
244-
return false;
245-
}
246-
return getHashPercent(iid) < rolloutPercent;
247-
}
248-
/**
249-
* Generate integer value range in [0, 99]. Implementation from String.hashCode() in Java.
250-
* @param seed Same seed will generate consistent hash value using this algorithm.
251-
* @return Hash value in range [0, 99], generated from seed and hash algorithm.
252-
*/
253-
function getHashPercent(seed: string): number {
254-
let hash = 0;
255-
for (let i = 0; i < seed.length; i++) {
256-
hash = (hash << 3) + hash - seed.charCodeAt(i);
257-
}
258-
hash = Math.abs(hash % 100);
259-
return hash;
260-
}

0 commit comments

Comments
 (0)