@amplitude/experiment-js-client
Advanced tools
Comparing version 1.9.9 to 1.10.0
@@ -255,2 +255,3 @@ import { AnalyticsConnector } from '@amplitude/analytics-connector'; | ||
| **initialVariants** | `null` | | ||
| **initialFlags** | `undefined` | | ||
| **source** | `Source.LocalStorage` | | ||
@@ -278,2 +279,3 @@ | **serverUrl** | `"https://api.lab.amplitude.com"` | | ||
initialVariants: {}, | ||
initialFlags: undefined, | ||
source: Source.LocalStorage, | ||
@@ -295,3 +297,3 @@ serverUrl: 'https://api.lab.amplitude.com', | ||
var version = "1.9.9"; | ||
var version = "1.10.0"; | ||
@@ -782,2 +784,3 @@ class ConnectorUserProvider { | ||
} | ||
this.mergeInitialFlagsWithStorage(); | ||
} | ||
@@ -1009,2 +1012,12 @@ /** | ||
} | ||
mergeInitialFlagsWithStorage() { | ||
if (this.config.initialFlags) { | ||
const initialFlags = JSON.parse(this.config.initialFlags); | ||
initialFlags.forEach((flag) => { | ||
if (!this.flags.get(flag.key)) { | ||
this.flags.put(flag.key, flag); | ||
} | ||
}); | ||
} | ||
} | ||
evaluate(flagKeys) { | ||
@@ -1035,3 +1048,2 @@ const user = this.addContext(this.user); | ||
} | ||
// TODO variant and source for both local and remote needs to be cleaned up. | ||
/** | ||
@@ -1272,2 +1284,3 @@ * This function assumes the flag exists and is local evaluation mode. For | ||
} | ||
this.mergeInitialFlagsWithStorage(); | ||
}); | ||
@@ -1274,0 +1287,0 @@ } |
@@ -34,2 +34,7 @@ import { ExperimentAnalyticsProvider } from './types/analytics'; | ||
/** | ||
* Initial values for flags. This is useful for bootstrapping the | ||
* client with fallbacks for flag configs. | ||
*/ | ||
initialFlags?: string; | ||
/** | ||
* Determines the primary source of variants and variants before falling back. | ||
@@ -128,2 +133,3 @@ * @see Source | ||
| **initialVariants** | `null` | | ||
| **initialFlags** | `undefined` | | ||
| **source** | `Source.LocalStorage` | | ||
@@ -130,0 +136,0 @@ | **serverUrl** | `"https://api.lab.amplitude.com"` | |
@@ -163,2 +163,3 @@ /** | ||
setUserProvider(userProvider: ExperimentUserProvider): Client; | ||
private mergeInitialFlagsWithStorage; | ||
private evaluate; | ||
@@ -165,0 +166,0 @@ private variantAndSource; |
{ | ||
"name": "@amplitude/experiment-js-client", | ||
"version": "1.9.9", | ||
"version": "1.10.0", | ||
"description": "Amplitude Experiment Javascript Client SDK", | ||
@@ -50,3 +50,3 @@ "keywords": [ | ||
], | ||
"gitHead": "320e92738fae8a60aab5a30b6fbc3ec20b4aa333" | ||
"gitHead": "37e70076de14e48ed8a5e33f79f2bcdd7d4c9800" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
347117
8510