@@ -223,9 +223,9 @@ export class ExperimentService extends Disposable implements IExperimentService
223
223
224
224
public markAsCompleted ( experimentId : string ) : void {
225
225
const storageKey = 'experiments.' + experimentId ;
226
- const experimentState : IExperimentStorageState = safeParse ( this . storageService . get ( storageKey , StorageScope . GLOBAL ) , { } ) ;
226
+ const experimentState : IExperimentStorageState = safeParse ( this . storageService . get ( storageKey , StorageScope . APPLICATION ) , { } ) ;
227
227
experimentState . state = ExperimentState . Complete ;
228
- this . storageService . store ( storageKey , JSON . stringify ( experimentState ) , StorageScope . GLOBAL , StorageTarget . MACHINE ) ;
228
+ this . storageService . store ( storageKey , JSON . stringify ( experimentState ) , StorageScope . APPLICATION , StorageTarget . MACHINE ) ;
229
229
}
230
230
231
231
protected async getExperiments ( ) : Promise < IRawExperiment [ ] | null > {
@@ -255,11 +255,11 @@ export class ExperimentService extends Disposable implements IExperimentService
255
255
return this . getExperiments ( ) . then ( rawExperiments => {
256
256
// Offline mode
257
257
if ( ! rawExperiments ) {
258
- const allExperimentIdsFromStorage = safeParse ( this . storageService . get ( 'allExperiments' , StorageScope . GLOBAL ) , [ ] ) ;
258
+ const allExperimentIdsFromStorage = safeParse ( this . storageService . get ( 'allExperiments' , StorageScope . APPLICATION ) , [ ] ) ;
259
259
if ( Array . isArray ( allExperimentIdsFromStorage ) ) {
260
260
allExperimentIdsFromStorage . forEach ( experimentId => {
261
261
const storageKey = 'experiments.' + experimentId ;
262
- const experimentState : IExperimentStorageState = safeParse ( this . storageService . get ( storageKey , StorageScope . GLOBAL ) , null ) ;
262
+ const experimentState : IExperimentStorageState = safeParse ( this . storageService . get ( storageKey , StorageScope . APPLICATION ) , null ) ;
263
263
if ( experimentState ) {
264
264
this . _experiments . push ( {
265
265
id : experimentId ,
@@ -278,19 +278,19 @@ export class ExperimentService extends Disposable implements IExperimentService
278
278
rawExperiments = rawExperiments . filter ( e => ( e . schemaVersion || 0 ) <= currentSchemaVersion ) ;
279
279
280
280
// Clear disbaled/deleted experiments from storage
281
- const allExperimentIdsFromStorage = safeParse ( this . storageService . get ( 'allExperiments' , StorageScope . GLOBAL ) , [ ] ) ;
281
+ const allExperimentIdsFromStorage = safeParse ( this . storageService . get ( 'allExperiments' , StorageScope . APPLICATION ) , [ ] ) ;
282
282
const enabledExperiments = rawExperiments . filter ( experiment => ! ! experiment . enabled ) . map ( experiment => experiment . id . toLowerCase ( ) ) ;
283
283
if ( Array . isArray ( allExperimentIdsFromStorage ) ) {
284
284
allExperimentIdsFromStorage . forEach ( experiment => {
285
285
if ( enabledExperiments . indexOf ( experiment ) === - 1 ) {
286
- this . storageService . remove ( `experiments.${ experiment } ` , StorageScope . GLOBAL ) ;
286
+ this . storageService . remove ( `experiments.${ experiment } ` , StorageScope . APPLICATION ) ;
287
287
}
288
288
} ) ;
289
289
}
290
290
if ( enabledExperiments . length ) {
291
- this . storageService . store ( 'allExperiments' , JSON . stringify ( enabledExperiments ) , StorageScope . GLOBAL , StorageTarget . MACHINE ) ;
291
+ this . storageService . store ( 'allExperiments' , JSON . stringify ( enabledExperiments ) , StorageScope . APPLICATION , StorageTarget . MACHINE ) ;
292
292
} else {
293
- this . storageService . remove ( 'allExperiments' , StorageScope . GLOBAL ) ;
293
+ this . storageService . remove ( 'allExperiments' , StorageScope . APPLICATION ) ;
294
294
}
295
295
296
296
const activationEvents = new Set ( rawExperiments . map ( exp => exp . condition ?. activationEvent ?. event )
@@ -348,7 +348,7 @@ export class ExperimentService extends Disposable implements IExperimentService
348
348
}
349
349
350
350
const storageKey = 'experiments.' + experiment . id ;
351
- const experimentState : IExperimentStorageState = safeParse ( this . storageService . get ( storageKey , StorageScope . GLOBAL ) , { } ) ;
351
+ const experimentState : IExperimentStorageState = safeParse ( this . storageService . get ( storageKey , StorageScope . APPLICATION ) , { } ) ;
352
352
if ( ! experimentState . hasOwnProperty ( 'enabled' ) ) {
353
353
experimentState . enabled = processedExperiment . enabled ;
354
354
}
@@ -360,7 +360,7 @@ export class ExperimentService extends Disposable implements IExperimentService
360
360
361
361
return this . shouldRunExperiment ( experiment , processedExperiment ) . then ( ( state : ExperimentState ) => {
362
362
experimentState . state = processedExperiment . state = state ;
363
- this . storageService . store ( storageKey , JSON . stringify ( experimentState ) , StorageScope . GLOBAL , StorageTarget . MACHINE ) ;
363
+ this . storageService . store ( storageKey , JSON . stringify ( experimentState ) , StorageScope . APPLICATION , StorageTarget . MACHINE ) ;
364
364
365
365
if ( state === ExperimentState . Run ) {
366
366
this . fireRunExperiment ( processedExperiment ) ;
@@ -372,22 +372,22 @@ export class ExperimentService extends Disposable implements IExperimentService
372
372
373
373
private fireRunExperiment ( experiment : IExperiment ) {
374
374
this . _onExperimentEnabled . fire ( experiment ) ;
375
- const runExperimentIdsFromStorage : string [ ] = safeParse ( this . storageService . get ( 'currentOrPreviouslyRunExperiments' , StorageScope . GLOBAL ) , [ ] ) ;
375
+ const runExperimentIdsFromStorage : string [ ] = safeParse ( this . storageService . get ( 'currentOrPreviouslyRunExperiments' , StorageScope . APPLICATION ) , [ ] ) ;
376
376
if ( runExperimentIdsFromStorage . indexOf ( experiment . id ) === - 1 ) {
377
377
runExperimentIdsFromStorage . push ( experiment . id ) ;
378
378
}
379
379
380
380
// Ensure we dont store duplicates
381
381
const distinctExperiments = distinct ( runExperimentIdsFromStorage ) ;
382
382
if ( runExperimentIdsFromStorage . length !== distinctExperiments . length ) {
383
- this . storageService . store ( 'currentOrPreviouslyRunExperiments' , JSON . stringify ( distinctExperiments ) , StorageScope . GLOBAL , StorageTarget . MACHINE ) ;
383
+ this . storageService . store ( 'currentOrPreviouslyRunExperiments' , JSON . stringify ( distinctExperiments ) , StorageScope . APPLICATION , StorageTarget . MACHINE ) ;
384
384
}
385
385
}
386
386
387
387
private checkExperimentDependencies ( experiment : IRawExperiment ) : boolean {
388
388
const experimentsPreviouslyRun = experiment . condition ?. experimentsPreviouslyRun ;
389
389
if ( experimentsPreviouslyRun ) {
390
- const runExperimentIdsFromStorage : string [ ] = safeParse ( this . storageService . get ( 'currentOrPreviouslyRunExperiments' , StorageScope . GLOBAL ) , [ ] ) ;
390
+ const runExperimentIdsFromStorage : string [ ] = safeParse ( this . storageService . get ( 'currentOrPreviouslyRunExperiments' , StorageScope . APPLICATION ) , [ ] ) ;
391
391
let includeCheck = true ;
392
392
let excludeCheck = true ;
393
393
const includes = experimentsPreviouslyRun . includes ;
@@ -407,9 +407,9 @@ export class ExperimentService extends Disposable implements IExperimentService
407
407
408
408
private recordActivatedEvent ( event : string ) {
409
409
const key = experimentEventStorageKey ( event ) ;
410
- const record = getCurrentActivationRecord ( safeParse ( this . storageService . get ( key , StorageScope . GLOBAL ) , undefined ) ) ;
410
+ const record = getCurrentActivationRecord ( safeParse ( this . storageService . get ( key , StorageScope . APPLICATION ) , undefined ) ) ;
411
411
record . count [ 0 ] ++ ;
412
- this . storageService . store ( key , JSON . stringify ( record ) , StorageScope . GLOBAL , StorageTarget . MACHINE ) ;
412
+ this . storageService . store ( key , JSON . stringify ( record ) , StorageScope . APPLICATION , StorageTarget . MACHINE ) ;
413
413
414
414
this . _experiments
415
415
. filter ( e => {
@@ -434,7 +434,7 @@ export class ExperimentService extends Disposable implements IExperimentService
434
434
435
435
const events = typeof setting . event === 'string' ? [ setting . event ] : setting . event ;
436
436
for ( const event of events ) {
437
- const { count } = getCurrentActivationRecord ( safeParse ( this . storageService . get ( experimentEventStorageKey ( event ) , StorageScope . GLOBAL ) , undefined ) ) ;
437
+ const { count } = getCurrentActivationRecord ( safeParse ( this . storageService . get ( experimentEventStorageKey ( event ) , StorageScope . APPLICATION ) , undefined ) ) ;
438
438
439
439
for ( const entry of count ) {
440
440
if ( entry > 0 ) {
@@ -532,7 +532,7 @@ export class ExperimentService extends Disposable implements IExperimentService
532
532
}
533
533
534
534
const storageKey = 'experiments.' + experiment . id ;
535
- const experimentState : IExperimentStorageState = safeParse ( this . storageService . get ( storageKey , StorageScope . GLOBAL ) , { } ) ;
535
+ const experimentState : IExperimentStorageState = safeParse ( this . storageService . get ( storageKey , StorageScope . APPLICATION ) , { } ) ;
536
536
537
537
return extensionsCheckPromise . then ( success => {
538
538
const fileEdits = condition . fileEdits ;
@@ -549,7 +549,7 @@ export class ExperimentService extends Disposable implements IExperimentService
549
549
// Process model-save event every 250ms to reduce load
550
550
const onModelsSavedWorker = this . _register ( new RunOnceWorker < ITextFileEditorModel > ( models => {
551
551
const date = new Date ( ) . toDateString ( ) ;
552
- const latestExperimentState : IExperimentStorageState = safeParse ( this . storageService . get ( storageKey , StorageScope . GLOBAL ) , { } ) ;
552
+ const latestExperimentState : IExperimentStorageState = safeParse ( this . storageService . get ( storageKey , StorageScope . APPLICATION ) , { } ) ;
553
553
if ( latestExperimentState . state !== ExperimentState . Evaluating ) {
554
554
onSaveHandler . dispose ( ) ;
555
555
onModelsSavedWorker . dispose ( ) ;
@@ -579,12 +579,12 @@ export class ExperimentService extends Disposable implements IExperimentService
579
579
if ( filePathCheck && workspaceCheck ) {
580
580
latestExperimentState . editCount = ( latestExperimentState . editCount || 0 ) + 1 ;
581
581
latestExperimentState . lastEditedDate = date ;
582
- this . storageService . store ( storageKey , JSON . stringify ( latestExperimentState ) , StorageScope . GLOBAL , StorageTarget . MACHINE ) ;
582
+ this . storageService . store ( storageKey , JSON . stringify ( latestExperimentState ) , StorageScope . APPLICATION , StorageTarget . MACHINE ) ;
583
583
}
584
584
} ) ;
585
585
if ( typeof latestExperimentState . editCount === 'number' && latestExperimentState . editCount >= fileEdits . minEditCount ) {
586
586
processedExperiment . state = latestExperimentState . state = ( typeof condition . userProbability === 'number' && Math . random ( ) < condition . userProbability && this . checkExperimentDependencies ( experiment ) ) ? ExperimentState . Run : ExperimentState . NoRun ;
587
- this . storageService . store ( storageKey , JSON . stringify ( latestExperimentState ) , StorageScope . GLOBAL , StorageTarget . MACHINE ) ;
587
+ this . storageService . store ( storageKey , JSON . stringify ( latestExperimentState ) , StorageScope . APPLICATION , StorageTarget . MACHINE ) ;
588
588
if ( latestExperimentState . state === ExperimentState . Run && processedExperiment . action && ExperimentActionType [ processedExperiment . action . type ] === ExperimentActionType . Prompt ) {
589
589
this . fireRunExperiment ( processedExperiment ) ;
590
590
}
0 commit comments