Registry / http-networking / tas-client-umd

tas-client-umd

JSON →
library0.2.0jsnpmunverified

tas-client-umd is a Unified Module Definition (UMD) repackaging of the core `tas-client` module, designed to provide a client for interacting with an experimentation service, typically a Treatment Assignment Service (TAS). Its primary function is to query, refetch, and cache experimentation data, often referred to as "flights" or "treatment variables," from a specified endpoint. This package, currently at version 0.2.0, targets early-stage development with an implied unstable release cadence typical of pre-1.0 software. A key aspect of its design is the requirement for consumers to implement specific interfaces: `IExperimentationFilterProvider` for supplying contextual filters, `IExperimentationTelemetry` for logging events and shared properties, and `IKeyValueStorage` for persistent data storage. This dependency injection approach allows for flexible integration into various environments and telemetry systems. Its UMD format differentiates it by ensuring compatibility across CommonJS, AMD, and browser global environments, making it versatile for diverse JavaScript ecosystems, particularly where `tas-client` is used.

npm install tas-client-umd
INSTALL
IMPORT
SIG · TAS-CLIENT-UMD
T
tas-client-umd
http-networkingjavascriptv0.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TASClient
import { TASClient } from 'tas-client-umd';
const TASClient = require('tas-client-umd');
For CommonJS, use destructuring: `const { TASClient } = require('tas-client-umd');`. Direct `require()` without destructuring will yield an object containing the exports.
IExperimentationService
import { IExperimentationService } from 'tas-client-umd';
import IExperimentationService from 'tas-client-umd';
All interfaces are named exports. This package ships TypeScript types.
IKeyValueStorage
import type { IKeyValueStorage } from 'tas-client-umd';
Type-only import for interfaces when not used as a value, for bundler tree-shaking and type safety.

This quickstart demonstrates how to instantiate `TASClient` with mock interface implementations and retrieve a treatment variable after initialization.

import { TASClient } from 'tas-client-umd'; // Mock implementations for required interfaces const mockFilterProvider = { getFilters: () => new Map([['region', 'us'], ['platform', 'web']]) }; const mockTelemetry = { setSharedProperty: (name, value) => console.log(`Telemetry shared property: ${name}=${value}`), postEvent: (eventName, props) => console.log(`Telemetry event: ${eventName}, props: ${JSON.stringify(Object.fromEntries(props))}`) }; const mockKeyValueStorage = { _storage: new Map(), getValue: async (key, defaultValue) => { const value = mockKeyValueStorage._storage.get(key); return value !== undefined ? value : defaultValue; }, setValue: (key, value) => { mockKeyValueStorage._storage.set(key, value); } }; const tasClient = new TASClient({ filterProviders: [mockFilterProvider], telemetry: mockTelemetry, storageKey: 'my-tas-experiments', keyValueStorage: mockKeyValueStorage, assignmentContextTelemetryPropertyName: 'myExpContext', telemetryEventName: 'MyExperimentationQuery', endpoint: process.env.TAS_ENDPOINT ?? 'https://example.com/tas-api', // Replace with your actual endpoint refetchInterval: 30000 // Refetch every 30 seconds }); // Initialize the client and fetch a treatment variable tasClient.initializePromise.then(async () => { console.log('TASClient initialized successfully.'); // Example: Getting a treatment variable const treatmentValue = await tasClient.getTreatmentVariable('my-feature-config', 'my-variable-name'); console.log(`Treatment variable 'my-variable-name': ${treatmentValue}`); }).catch(error => { console.error('Failed to initialize TASClient:', error); });
Debug
Known issues
deprecatedThe `isFlightEnabled` method on `IExperimentationService` is deprecated. Consumers should transition to using `getTreatmentVariable` instead for retrieving experiment values.
fix
Replace calls to `tasClient.isFlightEnabled(flightName)` with `tasClient.getTreatmentVariable(configId, variableName)`.
affects: >=0.2.0
gotchaThe `TASClient` requires multiple interfaces (`IExperimentationFilterProvider`, `IExperimentationTelemetry`, `IKeyValueStorage`) to be implemented by the consumer and provided during construction. Failing to do so or providing incomplete implementations will lead to runtime errors.
fix
Ensure all required interfaces are fully implemented with the necessary methods before instantiating `TASClient`. Refer to the interface definitions for details.
affects: >=0.2.0
gotchaCalling `tasClient.getTreatmentVariable()` before the experimentation service has fully initialized (i.e., before `tasClient.initializePromise` resolves) will result in a runtime error. If you cannot await initialization, use `getTreatmentVariableAsync()`.
fix
Always await `tasClient.initializePromise` before making synchronous calls to `getTreatmentVariable()`. If an asynchronous API is required before full initialization, use the `getTreatmentVariableAsync()` method.
affects: >=0.2.0
Errors
Common errors & fixes
TypeError: TASClient is not a constructor
Attempting to use `const TASClient = require('tas-client-umd'); new TASClient()` in CommonJS, instead of destructuring the import.
fix
In CommonJS, use `const { TASClient } = require('tas-client-umd');` or access via the default export if bundling: `const TASClient = require('tas-client-umd').TASClient;`
ReferenceError: TASClient is not defined
In a browser environment using the UMD build, the global variable might not be accessible, or the script tag for `tas-client-umd` was not loaded before its usage.
fix
Ensure the `tas-client-umd` script is loaded in your HTML before any code attempts to use `TASClient`. Verify the global variable name exposed by the UMD bundle.
Property 'isFlightEnabled' is deprecated.
Using the `isFlightEnabled` method which has been marked for removal.
fix
Update your code to use `getTreatmentVariable(configId, name)` instead of `isFlightEnabled(flightName)`.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
tas-client-umd — npm install tas-client-umd · libregistry