Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

tas-client

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tas-client - npm Package Compare versions

Comparing version 0.0.10 to 0.0.19

2

package.json
{
"name": "tas-client",
"version": "0.0.10",
"version": "0.0.19",
"description": "This package is intended to be used as an endpoint client to query, refetch, and cache data from the Experimentation service (or any given endpoint). The endpoint result must follow the required structure for experimentation data.",

@@ -5,0 +5,0 @@ "main": "./out/src/index",

@@ -21,3 +21,5 @@ import { IExperimentationService } from '../contracts/IExperimentationService';

private cachedTelemetryEvents;
private features;
private _features;
private get features();
private set features(value);
constructor(telemetry: IExperimentationTelemetry, telemetryPropertyName: string, telemetryEventName: string, storageKey?: string | undefined, storage?: IKeyValueStorage | undefined);

@@ -24,0 +26,0 @@ /**

@@ -19,3 +19,3 @@ "use strict";

this.cachedTelemetryEvents = [];
this.features = [];
this._features = [];
if (!this.storageKey) {

@@ -28,2 +28,14 @@ this.storageKey = 'ABExp.Features';

}
get features() {
return this._features;
}
set features(value) {
this._features = value;
/**
* If an implementation of telemetry exists, we set the shared property.
*/
if (this.telemetry) {
this.telemetry.setSharedProperty(this.telemetryPropertyName, this.features.join(';'));
}
}
/**

@@ -93,8 +105,2 @@ * Gets all the features from the provider sources (not cache).

/**
* If an implementation of telemetry exists, we set the shared property.
*/
if (this.telemetry) {
this.telemetry.setSharedProperty(this.telemetryPropertyName, this.features.join(';'));
}
/**
* If we have storage, we cache the latest results into the storage.

@@ -133,3 +139,2 @@ */

async isCachedFlightEnabled(flight) {
this.PostEventToTelemetry(flight);
// If features haven't been loaded, we load the features in the cache, and save them into memory.

@@ -142,2 +147,3 @@ if (this.isState(ExperimentationServiceState.None)) {

}
this.PostEventToTelemetry(flight);
// Use memory features to check if a flight is enabled.

@@ -152,4 +158,4 @@ return this.features.includes(flight);

async isFlightEnabledAsync(flight) {
const features = await this.getFeaturesAsync();
this.PostEventToTelemetry(flight);
let features = await this.getFeaturesAsync();
return features.includes(flight);

@@ -164,3 +170,3 @@ }

}
this.telemetry.postEvent(this.telemetryEventName, new Map([['ABExp.feature', flight]]));
this.telemetry.postEvent(this.telemetryEventName, new Map([['ABExp.queriedFeature', flight]]));
/**

@@ -167,0 +173,0 @@ * We cache the flight so we don't post it again.

@@ -8,2 +8,4 @@ "use strict";

const ExperimentationFilterProviderMock_1 = require("./mocks/ExperimentationFilterProviderMock");
const ExperimentationTelemetryMock_1 = require("./mocks/ExperimentationTelemetryMock");
const KeyValueStorageMock_1 = require("./mocks/KeyValueStorageMock");
let defaultEndpoint = 'https://visualstudio-devdiv-c2s.msedge.net/ab';

@@ -131,2 +133,13 @@ /**

});
describe('Telemetry tests', () => {
it('Shared properties should be set on isCachedFlightEnabled', async () => {
const experimentationTelemetryMock = new ExperimentationTelemetryMock_1.ExperimentationTelemetryMock();
const keyValueStorageMock = new KeyValueStorageMock_1.KeyValueStorageMock();
keyValueStorageMock.setValue('StorageKey', ['testFlight']);
const service = new ExperimentationServiceMock_1.ExperimentationServiceMock([], 10000, experimentationTelemetryMock, keyValueStorageMock);
await service.isCachedFlightEnabled('testFlight');
chai_1.expect('testFlight').to.equal(experimentationTelemetryMock.sharedProperties.get('TelemetryName'));
chai_1.expect('testFlight').to.equal(experimentationTelemetryMock.postedEvents[0].sharedProperties.get('TelemetryName'));
});
});
/** Other possible tests to do: */

@@ -133,0 +146,0 @@ //- Test wether the promise for fetch is re-used.

import { FetchResolver } from './FetchResolver';
import { ExperimentationServiceAutoPolling } from '../../tas-client/ExperimentationServiceAutoPolling';
import { IExperimentationTelemetry } from 'src/contracts/IExperimentationTelemetry';
import { IKeyValueStorage } from 'src/contracts/IKeyValueStorage';
export declare class ExperimentationServiceMock extends ExperimentationServiceAutoPolling {
private testSpecs;
private pollingInterval;
constructor(testSpecs: FeatureProviderTestSpec[], pollingInterval?: number);
constructor(testSpecs: FeatureProviderTestSpec[], pollingInterval?: number, experimentationTelemetry?: IExperimentationTelemetry, keyValueStorage?: IKeyValueStorage);
protected init(): void;

@@ -8,0 +10,0 @@ }

@@ -9,4 +9,4 @@ "use strict";

class ExperimentationServiceMock extends ExperimentationServiceAutoPolling_1.ExperimentationServiceAutoPolling {
constructor(testSpecs, pollingInterval = 1000) {
super(new ExperimentationTelemetryMock_1.ExperimentationTelemetryMock(), [new ExperimentationFilterProviderMock_1.ExperimentationFilterProviderMock()], pollingInterval, 'TelemetryName', 'TelemetryEventName', 'StorageKey', new KeyValueStorageMock_1.KeyValueStorageMock());
constructor(testSpecs, pollingInterval = 1000, experimentationTelemetry, keyValueStorage) {
super(experimentationTelemetry || new ExperimentationTelemetryMock_1.ExperimentationTelemetryMock(), [new ExperimentationFilterProviderMock_1.ExperimentationFilterProviderMock()], pollingInterval, 'TelemetryName', 'TelemetryEventName', 'StorageKey', keyValueStorage || new KeyValueStorageMock_1.KeyValueStorageMock());
this.testSpecs = testSpecs;

@@ -13,0 +13,0 @@ this.pollingInterval = pollingInterval;

import { IExperimentationTelemetry } from '../../contracts/IExperimentationTelemetry';
export declare class ExperimentationTelemetryMock implements IExperimentationTelemetry {
postedEvents: {
eventName: string;
args: any;
sharedProperties: Map<string, string>;
}[];
postEvent(eventName: string, args: any): void;

@@ -4,0 +9,0 @@ sharedProperties: Map<string, string>;

@@ -5,2 +5,3 @@ "use strict";

constructor() {
this.postedEvents = [];
this.sharedProperties = new Map();

@@ -11,2 +12,3 @@ }

console.log(args);
this.postedEvents.push({ eventName, args, sharedProperties: new Map(this.sharedProperties) });
}

@@ -13,0 +15,0 @@ setSharedProperty(name, value) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc