tas-client
Advanced tools
Comparing version 0.0.23 to 0.0.363
{ | ||
"name": "tas-client", | ||
"version": "0.0.23", | ||
"version": "0.0.363", | ||
"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", |
@@ -11,3 +11,5 @@ import { IExperimentationFilterProvider } from '../../contracts/IExperimentationFilterProvider'; | ||
constructor(telemetry: IExperimentationTelemetry, filterProviders: IExperimentationFilterProvider[]); | ||
private cachedTelemetryEvents; | ||
protected getFilters(): Map<string, any>; | ||
protected PostEventToTelemetry(headers: any): void; | ||
} |
@@ -12,2 +12,3 @@ "use strict"; | ||
this.filterProviders = filterProviders; | ||
this.cachedTelemetryEvents = []; | ||
} | ||
@@ -28,4 +29,18 @@ getFilters() { | ||
} | ||
PostEventToTelemetry(headers) { | ||
/** | ||
* If these headers have already been posted, we skip from posting them again.. | ||
*/ | ||
if (this.cachedTelemetryEvents.includes(headers)) { | ||
return; | ||
} | ||
const jsonHeaders = JSON.stringify(headers); | ||
this.telemetry.postEvent('report-headers', new Map([['ABExp.headers', jsonHeaders]])); | ||
/** | ||
* We cache the flight so we don't post it again. | ||
*/ | ||
this.cachedTelemetryEvents.push(headers); | ||
} | ||
} | ||
exports.FilteredFeatureProvider = FilteredFeatureProvider; | ||
//# sourceMappingURL=FilteredFeatureProvider.js.map |
@@ -29,2 +29,6 @@ "use strict"; | ||
let response = await this.httpClient.get({ headers: headers }); | ||
// If we have at least one filter, we post it to telemetry event. | ||
if (filters.keys.length > 0) { | ||
this.PostEventToTelemetry(headers); | ||
} | ||
// Read the response data from the server. | ||
@@ -31,0 +35,0 @@ let responseData = response.data; |
@@ -27,3 +27,6 @@ "use strict"; | ||
await this.onTick(); | ||
}, this.fetchInterval).unref(); // unref is used to avoid keeping node.js alive only because of these timeouts. | ||
}, this.fetchInterval); | ||
if (this.intervalHandle.unref) { // unref is only available in Node, not the web | ||
this.intervalHandle.unref(); // unref is used to avoid keeping node.js alive only because of these timeouts. | ||
} | ||
} | ||
@@ -30,0 +33,0 @@ } |
@@ -9,2 +9,3 @@ "use strict"; | ||
const ExperimentationTelemetryMock_1 = require("./mocks/ExperimentationTelemetryMock"); | ||
const MockFilteredFeatureProvider_1 = require("./mocks/MockFilteredFeatureProvider"); | ||
let mockKeyValueStorage = new KeyValueStorageMock_1.KeyValueStorageMock(); | ||
@@ -40,3 +41,13 @@ let mockFilterProvider = new ExperimentationFilterProviderMock_1.ExperimentationFilterProviderMock(); | ||
}); | ||
it('Feature provider should post headers to telemetry.', async () => { | ||
const telemetryMock = new ExperimentationTelemetryMock_1.ExperimentationTelemetryMock(); | ||
const filteredFeatureProvider = new MockFilteredFeatureProvider_1.MockFilteredFeatureProvider(telemetryMock, [new ExperimentationFilterProviderMock_1.ExperimentationFilterProviderTwoFilterMock()]); | ||
// In the fetch method we're posting the headers. | ||
await filteredFeatureProvider.fetch(); | ||
chai_1.expect(telemetryMock.postedEvents.length).to.be.greaterThan(0); | ||
const postedEvent = telemetryMock.postedEvents[0]; | ||
const postedEventArgs = postedEvent.args.get('ABExp.headers'); | ||
chai_1.expect(postedEventArgs).to.be.equal('{"lucario":true,"wario":false}'); | ||
}); | ||
}); | ||
//# sourceMappingURL=FeatureProvider.test.js.map |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
88305
82
1300
1