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.23 to 0.0.363

tests/mocks/MockFilteredFeatureProvider.d.ts

2

package.json
{
"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

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