New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@amplitude/experiment-js-client

Package Overview
Dependencies
Maintainers
17
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@amplitude/experiment-js-client - npm Package Compare versions

Comparing version 1.4.0-alpha.8 to 1.4.0-alpha.9

217

dist/experiment.umd.js

@@ -10,5 +10,3 @@ (function (global, factory) {

/**
* DEPRECATED: This implementation is now deprecated.
*
* Update your version of the amplitude analytics SDK to X.X.X+ and for seamless
* @deprecated Update your version of the amplitude analytics SDK to X.X.X+ and for seamless
* integration with the amplitude analytics SDK.

@@ -48,5 +46,3 @@ */

/**
* DEPRECATED: This implementation is now deprecated.
*
* Update your version of the amplitude analytics SDK to X.X.X+ and for seamless
* @deprecated Update your version of the amplitude analytics SDK to X.X.X+ and for seamless
* integration with the amplitude analytics SDK.

@@ -165,3 +161,5 @@ */

function IdentityStoreImpl() {
this.identity = {};
this.identity = {
userProperties: {}
};
this.listeners = new Set();

@@ -180,3 +178,3 @@ }

var editor = {
return {
setUserId: function (userId) {

@@ -292,3 +290,2 @@ actingIdentity.userId = userId;

};
return editor;
};

@@ -408,2 +405,80 @@

/**
* Determines the primary source of variants before falling back.
*
* @category Source
*/
(function (Source) {
/**
* The default way to source variants within your application. Before the
* assignments are fetched, `getVariant(s)` will fallback to local storage
* first, then `initialVariants` if local storage is empty. This option
* effectively falls back to an assignment fetched previously.
*/
Source["LocalStorage"] = "localStorage";
/**
* This bootstrap option is used primarily for servers-side rendering using an
* Experiment server SDK. This bootstrap option always prefers the config
* `initialVariants` over data in local storage, even if variants are fetched
* successfully and stored locally.
*/
Source["InitialVariants"] = "initialVariants";
})(exports.Source || (exports.Source = {}));
/**
* Indicates from which source the variant() function determines the variant
*
* @category Source
*/
var VariantSource;
(function (VariantSource) {
VariantSource["LocalStorage"] = "storage";
VariantSource["InitialVariants"] = "initial";
VariantSource["SecondaryLocalStoraage"] = "secondary-storage";
VariantSource["SecondaryInitialVariants"] = "secondary-initial";
VariantSource["FallbackInline"] = "fallback-inline";
VariantSource["FallbackConfig"] = "fallback-config";
})(VariantSource || (VariantSource = {}));
/**
* Returns true if the VariantSource is one of the fallbacks (inline or config)
*
* @param source a {@link VariantSource}
* @returns true if source is {@link VariantSource.FallbackInline} or {@link VariantSource.FallbackConfig}
*/
var isFallback = function (source) {
return (source === VariantSource.FallbackInline ||
source === VariantSource.FallbackConfig);
};
/**
Defaults for Experiment Config options
| **Option** | **Default** |
|------------------|-----------------------------------|
| **debug** | `false` |
| **instanceName** | `$default_instance` |
| **fallbackVariant** | `null` |
| **initialVariants** | `null` |
| **source** | `Source.LocalStorage` |
| **serverUrl** | `"https://api.lab.amplitude.com"` |
| **assignmentTimeoutMillis** | `10000` |
| **retryFailedAssignment** | `true` |
| **userProvider** | `null` |
| **analyticsProvider** | `null` |
*
* @category Configuration
*/
var Defaults = {
debug: false,
instanceName: '$default_instance',
fallbackVariant: {},
initialVariants: {},
source: exports.Source.LocalStorage,
serverUrl: 'https://api.lab.amplitude.com',
fetchTimeoutMillis: 10000,
retryFetchOnFailure: true,
userProvider: null,
analyticsProvider: null,
};
/*! *****************************************************************************

@@ -583,80 +658,4 @@ Copyright (c) Microsoft Corporation.

var version = "1.4.0-alpha.7";
var version = "1.4.0-alpha.9";
/**
* Determines the primary source of variants before falling back.
*
* @category Source
*/
(function (Source) {
/**
* The default way to source variants within your application. Before the
* assignments are fetched, `getVariant(s)` will fallback to local storage
* first, then `initialVariants` if local storage is empty. This option
* effectively falls back to an assignment fetched previously.
*/
Source["LocalStorage"] = "localStorage";
/**
* This bootstrap option is used primarily for servers-side rendering using an
* Experiment server SDK. This bootstrap option always prefers the config
* `initialVariants` over data in local storage, even if variants are fetched
* successfully and stored locally.
*/
Source["InitialVariants"] = "initialVariants";
})(exports.Source || (exports.Source = {}));
/**
* Indicates from which source the variant() function determines the variant
*
* @category Source
*/
var VariantSource;
(function (VariantSource) {
VariantSource["LocalStorage"] = "storage";
VariantSource["InitialVariants"] = "initial";
VariantSource["SecondaryLocalStoraage"] = "secondary-storage";
VariantSource["SecondaryInitialVariants"] = "secondary-initial";
VariantSource["FallbackInline"] = "fallback-inline";
VariantSource["FallbackConfig"] = "fallback-config";
})(VariantSource || (VariantSource = {}));
/**
* Returns true if the VariantSource is one of the fallbacks (inline or config)
*
* @param source a {@link VariantSource}
* @returns true if source is {@link VariantSource.FallbackInline} or {@link VariantSource.FallbackConfig}
*/
var isFallback = function (source) {
return (source === VariantSource.FallbackInline ||
source === VariantSource.FallbackConfig);
};
/**
Defaults for Experiment Config options
| **Option** | **Default** |
|------------------|-----------------------------------|
| **debug** | `false` |
| **fallbackVariant** | `null` |
| **initialVariants** | `null` |
| **source** | `Source.LocalStorage` |
| **serverUrl** | `"https://api.lab.amplitude.com"` |
| **assignmentTimeoutMillis** | `10000` |
| **retryFailedAssignment** | `true` |
| **userProvider** | `null` |
| **analyticsProvider** | `null` |
*
* @category Configuration
*/
var Defaults = {
debug: false,
fallbackVariant: {},
initialVariants: {},
source: exports.Source.LocalStorage,
serverUrl: 'https://api.lab.amplitude.com',
fetchTimeoutMillis: 10000,
retryFetchOnFailure: true,
userProvider: null,
analyticsProvider: null,
};
var CoreUserProvider = /** @class */ (function () {

@@ -1091,4 +1090,2 @@ function CoreUserProvider(identityStore) {

var fetchBackoffScalar = 1.5;
// TODO this is defined twice, figure something better out.
var defaultInstance = '$default_instance';
/**

@@ -1122,3 +1119,3 @@ * The default {@link Client} used to fetch variations from Experiment's

this.httpClient = FetchHttpClient;
this.storage = new LocalStorage(defaultInstance, apiKey);
this.storage = new LocalStorage(this.config.instanceName, apiKey);
this.storage.load();

@@ -1539,6 +1536,5 @@ }

var instances = {};
// TODO this is defined twice, figure something better out.
var defaultInstance$1 = '$default_instance';
/**
* Initializes a singleton {@link ExperimentClient} identified by the api-key.
* Initializes a singleton {@link ExperimentClient} identified by the configured
* instance name.
*

@@ -1549,10 +1545,27 @@ * @param apiKey The environment API Key

var initialize = function (apiKey, config) {
if (!instances[defaultInstance$1]) {
instances[defaultInstance$1] = new ExperimentClient(apiKey, config);
// Store instances by appending the instance name and api key. Allows for
// initializing multiple default instances for different api keys.
var instanceName = (config === null || config === void 0 ? void 0 : config.instanceName) || Defaults.instanceName;
var instanceKey = instanceName + "." + apiKey;
if (!instances[instanceKey]) {
instances[instanceKey] = new ExperimentClient(apiKey, config);
}
return instances[defaultInstance$1];
return instances[instanceKey];
};
var initializeWithAmplitude = function (apiKey, config) {
var core = core_umd.AmplitudeCore.getInstance(defaultInstance$1);
if (!instances[defaultInstance$1]) {
/**
* Initialize a singleton {@link ExperimentClient} which automatically
* integrates with the installed and initialized instance of the amplitude
* analytics SDK.
*
* Amplitude analytics
* @param apiKey
* @param config
*/
var initializeWithAmplitudeAnalytics = function (apiKey, config) {
// Store instances by appending the instance name and api key. Allows for
// initializing multiple default instances for different api keys.
var instanceName = (config === null || config === void 0 ? void 0 : config.instanceName) || Defaults.instanceName;
var instanceKey = instanceName + "." + apiKey;
var core = core_umd.AmplitudeCore.getInstance(instanceName);
if (!instances[instanceKey]) {
config = config || {};

@@ -1565,8 +1578,8 @@ if (!config.userProvider) {

}
instances[defaultInstance$1] = new ExperimentClient(apiKey, config);
instances[instanceKey] = new ExperimentClient(apiKey, config);
core.identityStore.addIdentityListener(function () {
instances[defaultInstance$1].fetch();
instances[instanceKey].fetch();
});
}
return instances[defaultInstance$1];
return instances[instanceKey];
};

@@ -1579,3 +1592,3 @@ /**

initialize: initialize,
initializeWithAmplitude: initializeWithAmplitude,
initializeWithAmplitudeAnalytics: initializeWithAmplitudeAnalytics,
};

@@ -1582,0 +1595,0 @@

@@ -14,2 +14,8 @@ import { ExperimentAnalyticsProvider, ExperimentUserProvider } from './types/provider';

/**
* The name of the instance being initialized. Used for initializing separate
* instances of experiment or linking the experiment SDK to a specific
* instance of the amplitude analytics SDK.
*/
instanceName?: string;
/**
* The default fallback variant for all {@link ExperimentClient.variant}

@@ -63,2 +69,3 @@ * calls.

| **debug** | `false` |
| **instanceName** | `$default_instance` |
| **fallbackVariant** | `null` |

@@ -65,0 +72,0 @@ | **initialVariants** | `null` |

@@ -9,3 +9,3 @@ import { ExperimentConfig } from './config';

initialize: (apiKey: string, config?: ExperimentConfig) => ExperimentClient;
initializeWithAmplitude: (apiKey: string, config?: ExperimentConfig) => ExperimentClient;
initializeWithAmplitudeAnalytics: (apiKey: string, config?: ExperimentConfig) => ExperimentClient;
};

@@ -32,5 +32,3 @@ import { ExperimentAnalyticsEvent } from '../types/analytics';

/**
* DEPRECATED: This implementation is now deprecated.
*
* Update your version of the amplitude analytics SDK to X.X.X+ and for seamless
* @deprecated Update your version of the amplitude analytics SDK to X.X.X+ and for seamless
* integration with the amplitude analytics SDK.

@@ -46,5 +44,3 @@ */

/**
* DEPRECATED: This implementation is now deprecated.
*
* Update your version of the amplitude analytics SDK to X.X.X+ and for seamless
* @deprecated Update your version of the amplitude analytics SDK to X.X.X+ and for seamless
* integration with the amplitude analytics SDK.

@@ -51,0 +47,0 @@ */

{
"name": "@amplitude/experiment-js-client",
"version": "1.4.0-alpha.8",
"version": "1.4.0-alpha.9",
"description": "Javascript Client SDK for Amplitude Experiment",

@@ -5,0 +5,0 @@ "main": "dist/experiment.umd.js",

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