@amplitude/experiment-js-client
Advanced tools
Comparing version 1.8.1 to 1.9.0-beta.1
@@ -39,6 +39,16 @@ import { ExperimentAnalyticsProvider } from './types/analytics'; | ||
/** | ||
* The server endpoint from which to request variants. | ||
* The domain from which to request variants using remote evaluation. | ||
*/ | ||
serverUrl?: string; | ||
/** | ||
* The domain to request flag configurations used in local evaluation from. | ||
*/ | ||
flagsServerUrl?: string; | ||
/** | ||
* The amplitude data center to fetch flags and variants from. If set, | ||
* automatically sets the {@link serverUrl} and {@link flagsServerUrl} | ||
* configurations. | ||
*/ | ||
serverZone?: string; | ||
/** | ||
* The request timeout, in milliseconds, when fetching variants. | ||
@@ -59,2 +69,6 @@ */ | ||
/** | ||
* Enable or disable local evaluation flag configuration polling on `start()`. | ||
*/ | ||
pollOnStart?: boolean; | ||
/** | ||
* This config only matters if you are using the amplitude analytics SDK | ||
@@ -109,5 +123,8 @@ * integration initialized by calling | ||
| **serverUrl** | `"https://api.lab.amplitude.com"` | | ||
| **flagsServerUrl** | `"https://flag.lab.amplitude.com"` | | ||
| **serverZone** | `"US"` | | ||
| **assignmentTimeoutMillis** | `10000` | | ||
| **retryFailedAssignment** | `true` | | ||
| **automaticExposureTracking** | `true` | | ||
| **pollOnStart** | `true` | | ||
| **automaticFetchOnAmplitudeIdentityChange** | `false` | | ||
@@ -114,0 +131,0 @@ | **userProvider** | `null` | |
@@ -19,12 +19,14 @@ /** | ||
private readonly config; | ||
private readonly httpClient; | ||
private readonly storage; | ||
private readonly variants; | ||
private readonly flags; | ||
private readonly flagApi; | ||
private readonly evaluationApi; | ||
private readonly engine; | ||
private user; | ||
private userProvider; | ||
private exposureTrackingProvider; | ||
private retriesBackoff; | ||
/** | ||
* @deprecated | ||
*/ | ||
private userProvider; | ||
private poller; | ||
private isRunning; | ||
private analyticsProvider; | ||
private exposureTrackingProvider; | ||
/** | ||
@@ -41,2 +43,30 @@ * Creates a new ExperimentClient instance. | ||
/** | ||
* Start the SDK by getting flag configurations from the server. The promise | ||
* returned by this function resolves when the SDK has received updated flag | ||
* configurations and is ready to locally evaluate flags when the | ||
* {@link variant} function is called. This function also starts polling | ||
* for flag configuration updates at an interval. | ||
* | ||
* <p /> | ||
* | ||
* If you also have remote evaluation flags, use {@link fetch} to evaluate | ||
* those flags remotely and await both the promises. | ||
* | ||
* <p /> | ||
* | ||
* For example, to await both local and remote evaluation readiness: | ||
* | ||
* <pre> | ||
* await Promise.all([client.start(), client.fetch()]); | ||
* </pre> | ||
* <p /> | ||
* @param user | ||
* @see {@link variant}, {@link fetch} | ||
*/ | ||
start(user?: ExperimentUser): Promise<Client>; | ||
/** | ||
* Stop the local flag configuration poller. | ||
*/ | ||
stop(): void; | ||
/** | ||
* Assign the given user to the SDK and asynchronously fetch all variants | ||
@@ -59,2 +89,3 @@ * from the server. Subsequent calls may omit the user from the argument to | ||
* @param user The user to fetch variants for. | ||
* @param options Options for this specific fetch call. | ||
* @returns Promise that resolves when the request for variants completes. | ||
@@ -138,6 +169,7 @@ * @see ExperimentUser | ||
setUserProvider(userProvider: ExperimentUserProvider): Client; | ||
private evaluate; | ||
private variantAndSource; | ||
private fetchInternal; | ||
private doFetch; | ||
private parseResponse; | ||
private doFlags; | ||
private storeVariants; | ||
@@ -149,6 +181,9 @@ private startRetries; | ||
private convertVariant; | ||
private translateFromEvaluationVariant; | ||
private translateToEvaluationVariant; | ||
private sourceVariants; | ||
private secondaryVariants; | ||
private exposureInternal; | ||
private legacyExposureInternal; | ||
private debug; | ||
} |
@@ -12,3 +12,3 @@ /** | ||
export { ExperimentClient } from './experimentClient'; | ||
export { Client } from './types/client'; | ||
export { Client, FetchOptions } from './types/client'; | ||
export { ExperimentAnalyticsProvider, ExperimentAnalyticsEvent, } from './types/analytics'; | ||
@@ -15,0 +15,0 @@ export { ExperimentUserProvider } from './types/provider'; |
@@ -10,2 +10,4 @@ import { Client } from './types/client'; | ||
getUser(): ExperimentUser; | ||
start(user?: ExperimentUser): Promise<Client>; | ||
stop(): void; | ||
setUser(user: ExperimentUser): void; | ||
@@ -12,0 +14,0 @@ fetch(user: ExperimentUser): Promise<StubExperimentClient>; |
@@ -5,3 +5,13 @@ /** | ||
*/ | ||
import { HttpClient as CoreHttpClient, HttpRequest, HttpResponse } from '@amplitude/experiment-core'; | ||
import { HttpClient } from '../types/transport'; | ||
/** | ||
* Wrap the exposed HttpClient in a CoreClient implementation to work with | ||
* FlagsApi and EvaluationApi. | ||
*/ | ||
export declare class WrapperClient implements CoreHttpClient { | ||
private readonly client; | ||
constructor(client: HttpClient); | ||
request(request: HttpRequest): Promise<HttpResponse>; | ||
} | ||
export declare const FetchHttpClient: HttpClient; |
@@ -12,2 +12,4 @@ import { ExperimentUserProvider } from './provider'; | ||
export interface Client { | ||
start(user?: ExperimentUser): Promise<Client>; | ||
stop(): void; | ||
fetch(user?: ExperimentUser, options?: FetchOptions): Promise<Client>; | ||
@@ -14,0 +16,0 @@ variant(key: string, fallback?: string | Variant): Variant; |
@@ -43,2 +43,7 @@ /** | ||
experiment_key?: string; | ||
/** | ||
* (Optional) Flag, segment, and variant metadata produced as a result of | ||
* evaluation for the user. Used for system purposes. | ||
*/ | ||
metadata?: Record<string, unknown>; | ||
}; | ||
@@ -45,0 +50,0 @@ /** |
@@ -33,3 +33,4 @@ /** | ||
FallbackInline = "fallback-inline", | ||
FallbackConfig = "fallback-config" | ||
FallbackConfig = "fallback-config", | ||
LocalEvaluation = "local-evaluation" | ||
} | ||
@@ -36,0 +37,0 @@ /** |
@@ -1,10 +0,5 @@ | ||
import { Variant, Variants } from './variant'; | ||
export interface Storage { | ||
put(key: string, value: Variant): void; | ||
get(key: string): Variant; | ||
clear(): void; | ||
remove(key: string): void; | ||
getAll(): Variants; | ||
save(): void; | ||
load(): void; | ||
get(key: string): Promise<string>; | ||
put(key: string, value: string): Promise<void>; | ||
delete(key: string): Promise<void>; | ||
} |
@@ -6,2 +6,6 @@ /** | ||
/** | ||
* The key of the variant. | ||
*/ | ||
key?: string; | ||
/** | ||
* The value of the variant. | ||
@@ -18,2 +22,7 @@ */ | ||
expKey?: string; | ||
/** | ||
* Flag, segment, and variant metadata produced as a result of | ||
* evaluation for the user. Used for system purposes. | ||
*/ | ||
metadata?: Record<string, unknown>; | ||
}; | ||
@@ -20,0 +29,0 @@ /** |
{ | ||
"name": "@amplitude/experiment-js-client", | ||
"version": "1.8.1", | ||
"version": "1.9.0-beta.1", | ||
"description": "Amplitude Experiment Javascript Client SDK", | ||
@@ -37,2 +37,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@amplitude/experiment-core": "^0.1.0", | ||
"@amplitude/analytics-connector": "^1.4.8", | ||
@@ -49,4 +50,3 @@ "@amplitude/ua-parser-js": "^0.7.31", | ||
"dist" | ||
], | ||
"gitHead": "f99ab95593e50d2e51168491d9c55835c727ce3a" | ||
] | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
322727
7877
5
30
1
+ Added@amplitude/experiment-core@0.1.0(transitive)