@devcycle/js-client-sdk
Advanced tools
Comparing version 1.28.4 to 1.28.5
@@ -0,1 +1,3 @@ | ||
import { UserError, getVariableTypeFromValue } from '@devcycle/types'; | ||
export { UserError } from '@devcycle/types'; | ||
import fetchWithRetry from 'fetch-retry'; | ||
@@ -5,5 +7,11 @@ import chunk from 'lodash/chunk'; | ||
import UAParser from 'ua-parser-js'; | ||
import { getVariableTypeFromValue } from '@devcycle/types'; | ||
import isNumber from 'lodash/isNumber'; | ||
const StoreKey = { | ||
User: 'dvc:user', | ||
AnonUserId: 'dvc:anonymous_user_id', | ||
AnonymousConfig: 'dvc:anonymous_config', | ||
IdentifiedConfig: 'dvc:identified_config', | ||
}; | ||
// NOTE: This file is duplicated from "lib/shared/server-request" because nx:rollup cant build non-external dependencies | ||
@@ -166,2 +174,8 @@ class ResponseError extends Error { | ||
`response message: ${e}`); | ||
if (e instanceof ResponseError) { | ||
if (e.status === 401 || e.status === 403) { | ||
throw new UserError(`Invalid SDK Key. Error details: ${e.message}`); | ||
} | ||
throw new Error(`Failed to download DevCycle config. Error details: ${e.message}`); | ||
} | ||
throw new Error(`Failed to download DevCycle config. Error details: ${e}`); | ||
@@ -452,9 +466,2 @@ } | ||
const StoreKey = { | ||
User: 'dvc:user', | ||
AnonUserId: 'dvc:anonymous_user_id', | ||
AnonymousConfig: 'dvc:anonymous_config', | ||
IdentifiedConfig: 'dvc:identified_config', | ||
}; | ||
class CacheStore { | ||
@@ -659,3 +666,3 @@ constructor(storage, logger) { | ||
var name = "@devcycle/js-client-sdk"; | ||
var version = "1.28.4"; | ||
var version = "1.28.5"; | ||
var description = "The Javascript Client SDK for DevCycle"; | ||
@@ -1059,3 +1066,4 @@ var author = "DevCycle <support@devcycle.com>"; | ||
} | ||
this.resolveOnInitialized(this); | ||
this._isInitialized = true; | ||
this.settleOnInitialized(this); | ||
this.logger.info('Client initialized'); | ||
@@ -1088,3 +1096,3 @@ } | ||
void this.setUser(user); | ||
this.resolveOnInitialized(this); | ||
this.settleOnInitialized(this, err instanceof UserError ? err : null); | ||
}; | ||
@@ -1107,5 +1115,11 @@ if (!options.sdkPlatform) { | ||
this.onInitialized = new Promise((resolve, reject) => { | ||
this.resolveOnInitialized = (value) => { | ||
this._isInitialized = true; | ||
resolve(value); | ||
this.settleOnInitialized = (value, error) => { | ||
if (error) { | ||
this._isInitialized = false; | ||
reject(error); | ||
} | ||
else { | ||
this._isInitialized = true; | ||
resolve(value); | ||
} | ||
}; | ||
@@ -1564,4 +1578,9 @@ }); | ||
if (!sdkKey) { | ||
throw new Error('Missing SDK key! Call initialize with a valid SDK key'); | ||
throw new UserError('Missing SDK key! Call initialize with a valid SDK key'); | ||
} | ||
if (!sdkKey.startsWith('client') && | ||
!sdkKey.startsWith('dvc_client') && | ||
!(optionsArg === null || optionsArg === void 0 ? void 0 : optionsArg.next)) { | ||
throw new UserError('Invalid SDK key provided. Please call initialize with a valid client SDK key'); | ||
} | ||
const userAndOptions = determineUserAndOptions(userOrOptions, optionsArg); | ||
@@ -1568,0 +1587,0 @@ const { options } = userAndOptions; |
{ | ||
"name": "@devcycle/js-client-sdk", | ||
"version": "1.28.4", | ||
"version": "1.28.5", | ||
"description": "The Javascript Client SDK for DevCycle", | ||
@@ -5,0 +5,0 @@ "author": "DevCycle <support@devcycle.com>", |
@@ -28,3 +28,3 @@ import { DVCFeatureSet, DevCycleOptions, DVCVariableSet, DVCVariableValue, DevCycleEvent, DevCycleUser, ErrorCallback, DVCFeature, VariableDefinitions } from './types'; | ||
private onInitialized; | ||
private resolveOnInitialized; | ||
private settleOnInitialized; | ||
private userSaved; | ||
@@ -31,0 +31,0 @@ private _closing; |
import type { DVCLogger, DVCDefaultLogLevel, VariableTypeAlias, VariableValue, DVCJSON, DVCCustomDataJSON, BucketedUserConfig } from '@devcycle/types'; | ||
export { UserError } from '@devcycle/types'; | ||
export type DVCVariableValue = VariableValue; | ||
@@ -3,0 +4,0 @@ export type { DVCJSON, DVCCustomDataJSON }; |
@@ -28,3 +28,3 @@ import { DVCFeatureSet, DevCycleOptions, DVCVariableSet, DVCVariableValue, DevCycleEvent, DevCycleUser, ErrorCallback, DVCFeature, VariableDefinitions } from './types'; | ||
private onInitialized; | ||
private resolveOnInitialized; | ||
private settleOnInitialized; | ||
private userSaved; | ||
@@ -31,0 +31,0 @@ private _closing; |
import { DVCLogger, DVCDefaultLogLevel, VariableTypeAlias, VariableValue, DVCJSON, DVCCustomDataJSON, BucketedUserConfig } from '@devcycle/types'; | ||
export { UserError } from '@devcycle/types'; | ||
export type DVCVariableValue = VariableValue; | ||
@@ -3,0 +4,0 @@ export { DVCJSON, DVCCustomDataJSON }; |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
186214
4635