@devcycle/js-client-sdk
Advanced tools
Comparing version 1.21.1 to 1.21.2
@@ -14,20 +14,2 @@ 'use strict'; | ||
function _interopNamespace(e) { | ||
if (e && e.__esModule) return e; | ||
var n = Object.create(null); | ||
if (e) { | ||
Object.keys(e).forEach(function (k) { | ||
if (k !== 'default') { | ||
var d = Object.getOwnPropertyDescriptor(e, k); | ||
Object.defineProperty(n, k, d.get ? d : { | ||
enumerable: true, | ||
get: function () { return e[k]; } | ||
}); | ||
} | ||
}); | ||
} | ||
n["default"] = e; | ||
return Object.freeze(n); | ||
} | ||
var fetchWithRetry__default = /*#__PURE__*/_interopDefaultLegacy(fetchWithRetry); | ||
@@ -78,12 +60,23 @@ var chunk__default = /*#__PURE__*/_interopDefaultLegacy(chunk); | ||
async function getWithTimeout(url, requestConfig, timeout) { | ||
var _a; | ||
const controller = new AbortController(); | ||
const id = setTimeout(() => { | ||
controller.abort(); | ||
}, timeout); | ||
const response = await get(url, { | ||
...requestConfig, | ||
signal: controller.signal, | ||
}); | ||
clearTimeout(id); | ||
return response; | ||
try { | ||
const id = setTimeout(() => { | ||
controller.abort(); | ||
}, timeout); | ||
const response = await get(url, { | ||
...requestConfig, | ||
signal: controller.signal, | ||
}); | ||
clearTimeout(id); | ||
return response; | ||
} | ||
catch (e) { | ||
if ((_a = controller === null || controller === void 0 ? void 0 : controller.signal) === null || _a === void 0 ? void 0 : _a.aborted) { | ||
throw new Error('Network connection timed out.'); | ||
} | ||
else { | ||
throw e; | ||
} | ||
} | ||
} | ||
@@ -128,10 +121,3 @@ async function post(url, requestConfig, sdkKey) { | ||
} | ||
async function getFetch() { | ||
if (typeof fetch !== 'undefined') { | ||
return fetch; | ||
} | ||
return (await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('cross-fetch')); })).default; | ||
} | ||
async function getFetchWithRetry() { | ||
const fetch = await getFetch(); | ||
function getFetchWithRetry() { | ||
return fetchWithRetry__default["default"](fetch); | ||
@@ -145,5 +131,5 @@ } | ||
newConfig.retryDelay = exponentialBackoff; | ||
return [await getFetchWithRetry(), newConfig]; | ||
return [getFetchWithRetry(), newConfig]; | ||
} | ||
return [await getFetch(), requestConfig]; | ||
return [fetch, requestConfig]; | ||
} | ||
@@ -179,2 +165,5 @@ | ||
} | ||
if (options === null || options === void 0 ? void 0 : options.enableObfuscation) { | ||
queryParams.append('obfuscated', '1'); | ||
} | ||
const url = `${(options === null || options === void 0 ? void 0 : options.apiProxyURL) || CLIENT_SDK_URL}${CONFIG_PATH}?` + | ||
@@ -198,3 +187,7 @@ queryParams.toString(); | ||
logger.info(`Submit Events Payload: ${JSON.stringify(payload)}`); | ||
const res = await post(`${(options === null || options === void 0 ? void 0 : options.apiProxyURL) || EVENT_URL}${EVENTS_PATH}`, { | ||
let url = `${(options === null || options === void 0 ? void 0 : options.apiProxyURL) || EVENT_URL}${EVENTS_PATH}`; | ||
if (options === null || options === void 0 ? void 0 : options.enableObfuscation) { | ||
url += '?obfuscated=1'; | ||
} | ||
const res = await post(url, { | ||
...requestConfig, | ||
@@ -299,3 +292,3 @@ body: JSON.stringify(payload), | ||
try { | ||
const res = await publishEvents(this.sdkKey, this.client.config || null, user, eventRequest, this.client.logger); | ||
const res = await publishEvents(this.sdkKey, this.client.config || null, user, eventRequest, this.client.logger, this.options); | ||
if (res.status === 201) { | ||
@@ -593,3 +586,3 @@ this.client.logger.info(`DevCycle Flushed ${eventRequest.length} Events.`); | ||
var name = "@devcycle/js-client-sdk"; | ||
var version = "1.21.1"; | ||
var version = "1.21.2"; | ||
var description = "The Javascript Client SDK for DevCycle"; | ||
@@ -606,5 +599,7 @@ var author = ""; | ||
var types = "./index.cjs.d.ts"; | ||
var devDependencies = { | ||
"cross-fetch": "^4.0.0" | ||
}; | ||
var dependencies = { | ||
"@devcycle/types": "^1.9.1", | ||
"cross-fetch": "^4.0.0", | ||
"@devcycle/types": "^1.9.2", | ||
"fetch-retry": "^5.0.6", | ||
@@ -623,2 +618,3 @@ lodash: "^4.17.21", | ||
types: types, | ||
devDependencies: devDependencies, | ||
dependencies: dependencies | ||
@@ -625,0 +621,0 @@ }; |
@@ -48,12 +48,23 @@ import fetchWithRetry from 'fetch-retry'; | ||
async function getWithTimeout(url, requestConfig, timeout) { | ||
var _a; | ||
const controller = new AbortController(); | ||
const id = setTimeout(() => { | ||
controller.abort(); | ||
}, timeout); | ||
const response = await get(url, { | ||
...requestConfig, | ||
signal: controller.signal, | ||
}); | ||
clearTimeout(id); | ||
return response; | ||
try { | ||
const id = setTimeout(() => { | ||
controller.abort(); | ||
}, timeout); | ||
const response = await get(url, { | ||
...requestConfig, | ||
signal: controller.signal, | ||
}); | ||
clearTimeout(id); | ||
return response; | ||
} | ||
catch (e) { | ||
if ((_a = controller === null || controller === void 0 ? void 0 : controller.signal) === null || _a === void 0 ? void 0 : _a.aborted) { | ||
throw new Error('Network connection timed out.'); | ||
} | ||
else { | ||
throw e; | ||
} | ||
} | ||
} | ||
@@ -98,10 +109,3 @@ async function post(url, requestConfig, sdkKey) { | ||
} | ||
async function getFetch() { | ||
if (typeof fetch !== 'undefined') { | ||
return fetch; | ||
} | ||
return (await import('cross-fetch')).default; | ||
} | ||
async function getFetchWithRetry() { | ||
const fetch = await getFetch(); | ||
function getFetchWithRetry() { | ||
return fetchWithRetry(fetch); | ||
@@ -115,5 +119,5 @@ } | ||
newConfig.retryDelay = exponentialBackoff; | ||
return [await getFetchWithRetry(), newConfig]; | ||
return [getFetchWithRetry(), newConfig]; | ||
} | ||
return [await getFetch(), requestConfig]; | ||
return [fetch, requestConfig]; | ||
} | ||
@@ -149,2 +153,5 @@ | ||
} | ||
if (options === null || options === void 0 ? void 0 : options.enableObfuscation) { | ||
queryParams.append('obfuscated', '1'); | ||
} | ||
const url = `${(options === null || options === void 0 ? void 0 : options.apiProxyURL) || CLIENT_SDK_URL}${CONFIG_PATH}?` + | ||
@@ -168,3 +175,7 @@ queryParams.toString(); | ||
logger.info(`Submit Events Payload: ${JSON.stringify(payload)}`); | ||
const res = await post(`${(options === null || options === void 0 ? void 0 : options.apiProxyURL) || EVENT_URL}${EVENTS_PATH}`, { | ||
let url = `${(options === null || options === void 0 ? void 0 : options.apiProxyURL) || EVENT_URL}${EVENTS_PATH}`; | ||
if (options === null || options === void 0 ? void 0 : options.enableObfuscation) { | ||
url += '?obfuscated=1'; | ||
} | ||
const res = await post(url, { | ||
...requestConfig, | ||
@@ -269,3 +280,3 @@ body: JSON.stringify(payload), | ||
try { | ||
const res = await publishEvents(this.sdkKey, this.client.config || null, user, eventRequest, this.client.logger); | ||
const res = await publishEvents(this.sdkKey, this.client.config || null, user, eventRequest, this.client.logger, this.options); | ||
if (res.status === 201) { | ||
@@ -563,3 +574,3 @@ this.client.logger.info(`DevCycle Flushed ${eventRequest.length} Events.`); | ||
var name = "@devcycle/js-client-sdk"; | ||
var version = "1.21.1"; | ||
var version = "1.21.2"; | ||
var description = "The Javascript Client SDK for DevCycle"; | ||
@@ -576,5 +587,7 @@ var author = ""; | ||
var types = "./index.cjs.d.ts"; | ||
var devDependencies = { | ||
"cross-fetch": "^4.0.0" | ||
}; | ||
var dependencies = { | ||
"@devcycle/types": "^1.9.1", | ||
"cross-fetch": "^4.0.0", | ||
"@devcycle/types": "^1.9.2", | ||
"fetch-retry": "^5.0.6", | ||
@@ -593,2 +606,3 @@ lodash: "^4.17.21", | ||
types: types, | ||
devDependencies: devDependencies, | ||
dependencies: dependencies | ||
@@ -595,0 +609,0 @@ }; |
{ | ||
"name": "@devcycle/js-client-sdk", | ||
"version": "1.21.1", | ||
"version": "1.21.2", | ||
"description": "The Javascript Client SDK for DevCycle", | ||
@@ -15,5 +15,7 @@ "author": "", | ||
"types": "./index.cjs.d.ts", | ||
"devDependencies": { | ||
"cross-fetch": "^4.0.0" | ||
}, | ||
"dependencies": { | ||
"@devcycle/types": "^1.9.1", | ||
"cross-fetch": "^4.0.0", | ||
"@devcycle/types": "^1.9.2", | ||
"fetch-retry": "^5.0.6", | ||
@@ -20,0 +22,0 @@ "lodash": "^4.17.21", |
@@ -101,2 +101,7 @@ import type { DVCLogger, DVCDefaultLogLevel, VariableTypeAlias, VariableValue, DVCJSON, DVCCustomDataJSON, BucketedUserConfig } from '@devcycle/types'; | ||
}; | ||
/** | ||
* Enable obfuscation of the variable keys in the SDK. This setting should be used with a generated DevCycle client | ||
* using the CLI. | ||
*/ | ||
enableObfuscation?: boolean; | ||
} | ||
@@ -103,0 +108,0 @@ export interface DevCycleUser { |
@@ -101,2 +101,7 @@ import { DVCLogger, DVCDefaultLogLevel, VariableTypeAlias, VariableValue, DVCJSON, DVCCustomDataJSON, BucketedUserConfig } from '@devcycle/types'; | ||
}; | ||
/** | ||
* Enable obfuscation of the variable keys in the SDK. This setting should be used with a generated DevCycle client | ||
* using the CLI. | ||
*/ | ||
enableObfuscation?: boolean; | ||
} | ||
@@ -103,0 +108,0 @@ export interface DevCycleUser { |
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
171626
5
4306
4
1
- Removedcross-fetch@^4.0.0
- Removedcross-fetch@4.0.0(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removedtr46@0.0.3(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)
Updated@devcycle/types@^1.9.2