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

@statsig/client-core

Package Overview
Dependencies
Maintainers
4
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@statsig/client-core - npm Package Compare versions

Comparing version 0.0.1-beta.39 to 0.0.1-beta.40

2

package.json
{
"name": "@statsig/client-core",
"version": "0.0.1-beta.39",
"version": "0.0.1-beta.40",
"dependencies": {},

@@ -5,0 +5,0 @@ "type": "commonjs",

@@ -62,3 +62,3 @@ "use strict";

const impl = () => __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e, _f, _g;
const unwrapped = (error !== null && error !== void 0 ? error : Error('[Statsig] Error was empty'));

@@ -79,3 +79,4 @@ const isError = unwrapped instanceof Error;

const body = JSON.stringify(Object.assign({ tag, exception: name, info }, Object.assign(Object.assign({}, statsigMetadata), { sdkType })));
yield fetch(exports.EXCEPTION_ENDPOINT, {
const func = (_f = (_e = (_d = this._options) === null || _d === void 0 ? void 0 : _d.networkConfig) === null || _e === void 0 ? void 0 : _e.networkOverrideFunc) !== null && _f !== void 0 ? _f : fetch;
yield func(exports.EXCEPTION_ENDPOINT, {
method: 'POST',

@@ -90,3 +91,3 @@ headers: {

});
(_d = this._emitter) === null || _d === void 0 ? void 0 : _d.call(this, { name: 'error', error });
(_g = this._emitter) === null || _g === void 0 ? void 0 : _g.call(this, { name: 'error', error });
});

@@ -93,0 +94,0 @@ impl()

@@ -149,2 +149,3 @@ "use strict";

_sendEvents(events) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {

@@ -156,4 +157,7 @@ if (this._isLoggingDisabled) {

try {
const isInForeground = (0, VisibilityObserving_1._isCurrentlyVisible)();
const response = !isInForeground && this._network.isBeaconSupported()
const isInBackground = !(0, VisibilityObserving_1._isCurrentlyVisible)();
const shouldUseBeacon = isInBackground &&
this._network.isBeaconSupported() &&
((_b = (_a = this._options) === null || _a === void 0 ? void 0 : _a.networkConfig) === null || _b === void 0 ? void 0 : _b.networkOverrideFunc) == null;
const response = shouldUseBeacon
? yield this._sendEventsViaBeacon(events)

@@ -171,3 +175,3 @@ : yield this._sendEventsViaPost(events);

}
catch (_a) {
catch (_c) {
Log_1.Log.warn('Failed to flush events.');

@@ -174,0 +178,0 @@ }

@@ -7,2 +7,5 @@ export declare const NetworkDefault: {

export type NetworkPriority = 'high' | 'low' | 'auto';
export type NetworkArgs = RequestInit & {
priority?: NetworkPriority;
};
export declare enum NetworkParam {

@@ -9,0 +12,0 @@ EventCount = "ec",

@@ -55,3 +55,3 @@ "use strict";

_sendRequest(args) {
var _a, _b, _c;
var _a, _b, _c, _d, _e, _f;
return __awaiter(this, void 0, void 0, function* () {

@@ -76,4 +76,6 @@ if (!_ensureValidSdkKey(args)) {

priority: args.priority,
keepalive: true,
};
response = yield fetch(url, config);
const func = (_e = (_d = (_c = this._options) === null || _c === void 0 ? void 0 : _c.networkConfig) === null || _d === void 0 ? void 0 : _d.networkOverrideFunc) !== null && _e !== void 0 ? _e : fetch;
response = yield func(url, config);
clearTimeout(handle);

@@ -97,3 +99,3 @@ if (!response.ok) {

if (!retries || retries <= 0) {
(_c = this._emitter) === null || _c === void 0 ? void 0 : _c.call(this, { name: 'error', error });
(_f = this._emitter) === null || _f === void 0 ? void 0 : _f.call(this, { name: 'error', error });
Log_1.Log.error(`A networking error occured during ${method} request to ${url}.`, errorMessage, error);

@@ -167,3 +169,3 @@ return null;

}
return null;
return 'Unknown Error';
}

@@ -1,2 +0,2 @@

export declare const SDK_VERSION = "0.0.1-beta.39";
export declare const SDK_VERSION = "0.0.1-beta.40";
export type StatsigMetadata = {

@@ -3,0 +3,0 @@ readonly [key: string]: string | undefined;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StatsigMetadataProvider = exports.SDK_VERSION = void 0;
exports.SDK_VERSION = '0.0.1-beta.39';
exports.SDK_VERSION = '0.0.1-beta.40';
let metadata = {

@@ -6,0 +6,0 @@ sdkVersion: exports.SDK_VERSION,

import { LogLevel } from './Log';
import { NetworkArgs } from './NetworkConfig';
import { OverrideAdapter } from './OverrideAdapter';

@@ -45,2 +46,14 @@ /** Options that can be set at init and updated during runtime. */

preventAllNetworkTraffic?: boolean;
/**
* Overrides the default networking layer used by the Statsig client.
* By default, the client use `fetch`, but overriding this
* you could use `axios` or raw `XMLHttpRequest`
*
* default: `Fetch API`
*
* @param {string} url Where the request is going.
* @param {NetworkArgs} args Configuration for the network request.
* @returns {Response}
*/
networkOverrideFunc?: (url: string, args: NetworkArgs) => Promise<Response>;
};

@@ -47,0 +60,0 @@ /** Options for configuring a Statsig client. */

@@ -1,2 +0,2 @@

type StorageProvider = {
export type StorageProvider = {
_getProviderName: () => string;

@@ -3,0 +3,0 @@ _getItem: (key: string) => Promise<string | null>;

@@ -69,9 +69,21 @@ "use strict";

let _current = _main;
function _inMemoryBreaker(get) {
try {
return get();
}
catch (error) {
if (error instanceof Error && error.name === 'SecurityError') {
exports.Storage._setProvider(_inMemoryProvider);
return null;
}
throw error;
}
}
exports.Storage = {
_getProviderName: () => _current._getProviderName(),
_getItem: (key) => _current._getItem(key),
_getItem: (key) => __awaiter(void 0, void 0, void 0, function* () { return _inMemoryBreaker(() => _current._getItem(key)); }),
_getItemSync: (key) => _inMemoryBreaker(() => { var _a, _b; return (_b = (_a = _current._getItemSync) === null || _a === void 0 ? void 0 : _a.call(_current, key)) !== null && _b !== void 0 ? _b : null; }),
_setItem: (key, value) => _current._setItem(key, value),
_removeItem: (key) => _current._removeItem(key),
_getAllKeys: () => _current._getAllKeys(),
_getItemSync: (key) => { var _a, _b; return (_b = (_a = _current._getItemSync) === null || _a === void 0 ? void 0 : _a.call(_current, key)) !== null && _b !== void 0 ? _b : null; },
// StorageProviderManagment

@@ -93,3 +105,3 @@ _setProvider: (newProvider) => {

return __awaiter(this, void 0, void 0, function* () {
const value = yield _current._getItem(key);
const value = yield exports.Storage._getItem(key);
return JSON.parse(value !== null && value !== void 0 ? value : 'null');

@@ -101,5 +113,5 @@ });

return __awaiter(this, void 0, void 0, function* () {
yield _current._setItem(key, JSON.stringify(obj));
yield exports.Storage._setItem(key, JSON.stringify(obj));
});
}
exports._setObjectInStorage = _setObjectInStorage;
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