Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@statsig/client-core

Package Overview
Dependencies
Maintainers
11
Versions
193
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
3.32.4
to
3.32.5
+1
-1
package.json
{
"name": "@statsig/client-core",
"version": "3.32.4",
"version": "3.32.5",
"license": "ISC",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/statsig-io/js-client-monorepo",

@@ -14,3 +14,3 @@ import { StatsigClientEmitEventFunc } from './StatsigClientBase';

logDroppedEvents(count: number, reason: string, metadata?: Record<string, unknown>): void;
logEventRequestFailure(count: number, reason: string, flushType: string, statusCode: number, retries: number, failurePath?: string): void;
logEventRequestFailure(count: number, reason: string, flushType: string, statusCode: number, retries: number, failurePath?: string, failureErrorMessage?: string): void;
getLastSeenErrorAndReset(): Error | null;

@@ -17,0 +17,0 @@ attachErrorIfNoneExists(error: unknown): void;

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

}
logEventRequestFailure(count, reason, flushType, statusCode, retries, failurePath) {
logEventRequestFailure(count, reason, flushType, statusCode, retries, failurePath, failureErrorMessage) {
const extra = {

@@ -71,2 +71,6 @@ eventCount: String(count),

}
if (typeof failureErrorMessage === 'string' &&
failureErrorMessage.length > 0) {
extra['failureErrorMessage'] = failureErrorMessage;
}
this._onError(`statsig::log_event_failed`, new Error(reason), true, extra);

@@ -73,0 +77,0 @@ }

@@ -10,2 +10,3 @@ import { EventBatch } from './EventBatch';

failurePath?: string;
failureErrorMessage?: string;
};

@@ -12,0 +13,0 @@ export declare class EventSender {

@@ -58,15 +58,11 @@ "use strict";

}
return {
success: false,
statusCode: response.statusCode,
failurePath: response.failurePath,
};
return Object.assign({ success: false, statusCode: response.statusCode, failurePath: response.failurePath }, (response.failureErrorMessage
? { failureErrorMessage: response.failureErrorMessage }
: {}));
}
catch (error) {
Log_1.Log.warn('Failed to send batch:', error);
return {
success: false,
statusCode: -1,
failurePath: (_c = transportFailure.path) !== null && _c !== void 0 ? _c : failurePath,
};
return Object.assign({ success: false, statusCode: -1, failurePath: (_c = transportFailure.path) !== null && _c !== void 0 ? _c : failurePath }, (transportFailure.errorMessage
? { failureErrorMessage: transportFailure.errorMessage }
: {}));
}

@@ -81,9 +77,7 @@ });

if (code === -1) {
return {
success: false,
statusCode: -1,
failurePath: (_b = failureInfo.path) !== null && _b !== void 0 ? _b : (result === undefined
return Object.assign({ success: false, statusCode: -1, failurePath: (_b = failureInfo.path) !== null && _b !== void 0 ? _b : (result === undefined
? 'event_sender_post_returned_undefined'
: 'event_sender_post_returned_null'),
};
: 'event_sender_post_returned_null') }, (failureInfo.errorMessage
? { failureErrorMessage: failureInfo.errorMessage }
: {}));
}

@@ -96,9 +90,7 @@ return { success: code >= 200 && code < 300, statusCode: code };

const success = this._network.beacon(this._getRequestData(batch), failureInfo);
return {
success,
statusCode: success ? 200 : -1,
failurePath: success
return Object.assign({ success, statusCode: success ? 200 : -1, failurePath: success
? undefined
: (_a = failureInfo.path) !== null && _a !== void 0 ? _a : 'beacon_send_false',
};
: (_a = failureInfo.path) !== null && _a !== void 0 ? _a : 'beacon_send_false' }, (!success && failureInfo.errorMessage
? { failureErrorMessage: failureInfo.errorMessage }
: {}));
}

@@ -105,0 +97,0 @@ _getRequestData(batch) {

@@ -47,2 +47,3 @@ import { BatchQueue } from './BatchedEventsQueue';

convertPendingEventsToBatches(): number;
private _isRetryableBatch;
private _handleFailure;

@@ -49,0 +50,0 @@ loadAndRetryShutdownFailedEvents(): Promise<void>;

@@ -24,2 +24,9 @@ "use strict";

const StorageProvider_1 = require("./StorageProvider");
const RETRYABLE_NO_RESPONSE_FAILURE_PATHS = new Set([
'network_request_timed_out_no_response',
'network_request_exception_no_response',
'event_sender_post_returned_null',
'event_sender_post_returned_undefined',
'event_sender_post_exception',
]);
class FlushCoordinator {

@@ -258,3 +265,3 @@ constructor(batchQueue, pendingEvents, onPrepareFlush,

this._flushInterval.adjustForFailure();
this._handleFailure(batch, flushType, result.statusCode, result.failurePath);
this._handleFailure(batch, flushType, result.statusCode, result.failurePath, result.failureErrorMessage);
return false;

@@ -288,3 +295,14 @@ });

}
_handleFailure(batch, flushType, statusCode, failurePath) {
_isRetryableBatch(statusCode, failurePath) {
if (NetworkCore_1.RETRYABLE_CODES.has(statusCode)) {
return true;
}
if (statusCode === -1 &&
failurePath &&
RETRYABLE_NO_RESPONSE_FAILURE_PATHS.has(failurePath)) {
return true;
}
return false;
}
_handleFailure(batch, flushType, statusCode, failurePath, failureErrorMessage) {
if (flushType === FlushTypes_1.FlushType.Shutdown) {

@@ -296,6 +314,6 @@ Log_1.Log.warn(`${flushType} flush failed during shutdown. ` +

}
if (!NetworkCore_1.RETRYABLE_CODES.has(statusCode)) {
if (!this._isRetryableBatch(statusCode, failurePath)) {
Log_1.Log.warn(`${flushType} flush failed after ${batch.attempts} attempt(s). ` +
`${batch.events.length} event(s) will be dropped. Non-retryable error: ${statusCode}`);
this._errorBoundary.logEventRequestFailure(batch.events.length, `non-retryable error`, flushType, statusCode, batch.attempts, failurePath);
this._errorBoundary.logEventRequestFailure(batch.events.length, `non-retryable error`, flushType, statusCode, batch.attempts, failurePath, failureErrorMessage);
return;

@@ -306,3 +324,3 @@ }

`${batch.events.length} event(s) will be dropped.`);
this._errorBoundary.logEventRequestFailure(batch.events.length, `max retry attempts exceeded`, flushType, statusCode, batch.attempts, failurePath);
this._errorBoundary.logEventRequestFailure(batch.events.length, `max retry attempts exceeded`, flushType, statusCode, batch.attempts, failurePath, failureErrorMessage);
return;

@@ -309,0 +327,0 @@ }

@@ -29,2 +29,3 @@ import './$_StatsigGlobal';

path?: string;
errorMessage?: string;
};

@@ -31,0 +32,0 @@ type BeaconRequestArgs = Pick<RequestArgsWithData, 'data' | 'sdkKey' | 'urlConfig' | 'params' | 'isCompressable' | 'attempt'>;

@@ -213,2 +213,5 @@ "use strict";

: 'network_request_exception_no_response';
if (errorMessage) {
failureInfo.errorMessage = errorMessage;
}
}

@@ -215,0 +218,0 @@ }

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

export declare const SDK_VERSION = "3.32.4";
export declare const SDK_VERSION = "3.32.5";
export type StatsigMetadata = {

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StatsigMetadataProvider = exports.SDK_VERSION = void 0;
exports.SDK_VERSION = '3.32.4';
exports.SDK_VERSION = '3.32.5';
let metadata = {

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