@statsig/client-core 3.32.0 → 3.32.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statsig/client-core",
3
- "version": "3.32.0",
3
+ "version": "3.32.2",
4
4
  "license": "ISC",
5
5
  "homepage": "https://github.com/statsig-io/js-client-monorepo",
6
6
  "repository": {
@@ -1,5 +1,18 @@
1
+ import type { SessionReplayPrivacySettings } from './InitializeResponse';
1
2
  import { ParamStoreConfig } from './ParamStoreTypes';
2
3
  import { StatsigUser } from './StatsigUser';
4
+ export type SessionReplayTriggerSpec = {
5
+ values?: string[];
6
+ sampling_rate?: number;
7
+ };
8
+ export type SessionReplayInfoSpec = {
9
+ recording_blocked?: boolean;
10
+ sampling_rate?: number;
11
+ targeting_gate?: string;
12
+ session_recording_event_triggers?: Record<string, SessionReplayTriggerSpec>;
13
+ session_recording_exposure_triggers?: Record<string, SessionReplayTriggerSpec>;
14
+ session_recording_privacy_settings?: SessionReplayPrivacySettings;
15
+ };
3
16
  export type SpecCondition = {
4
17
  type: string;
5
18
  targetValue: unknown;
@@ -58,4 +71,5 @@ export type DownloadConfigSpecsResponse = {
58
71
  experiments: string[];
59
72
  }>;
60
73
  app_id?: string;
74
+ session_replay_info?: SessionReplayInfoSpec;
61
75
  };
@@ -47,6 +47,7 @@ class ErrorBoundary {
47
47
  logDroppedEvents(count, reason, metadata) {
48
48
  const extra = {
49
49
  eventCount: String(count),
50
+ reason,
50
51
  };
51
52
  if (metadata) {
52
53
  Object.keys(metadata).forEach((key) => {
@@ -1,7 +1,7 @@
1
1
  import { EventBatch } from './EventBatch';
2
2
  import { NetworkCore } from './NetworkCore';
3
3
  import { StatsigClientEmitEventFunc } from './StatsigClientBase';
4
- import { LogEventCompressionMode, LoggingEnabledOption, NetworkConfigCommon, StatsigOptionsCommon } from './StatsigOptionsCommon';
4
+ import { LogEventCompressionMode, NetworkConfigCommon, StatsigOptionsCommon } from './StatsigOptionsCommon';
5
5
  import { UrlConfiguration } from './UrlConfiguration';
6
6
  export declare class EventSender {
7
7
  private _network;
@@ -9,10 +9,8 @@ export declare class EventSender {
9
9
  private _options;
10
10
  private _logEventUrlConfig;
11
11
  private _emitter;
12
- private _loggingEnabled;
13
- constructor(sdkKey: string, network: NetworkCore, emitter: StatsigClientEmitEventFunc, logEventUrlConfig: UrlConfiguration, options: StatsigOptionsCommon<NetworkConfigCommon> | null, loggingEnabled: LoggingEnabledOption);
12
+ constructor(sdkKey: string, network: NetworkCore, emitter: StatsigClientEmitEventFunc, logEventUrlConfig: UrlConfiguration, options: StatsigOptionsCommon<NetworkConfigCommon> | null);
14
13
  setLogEventCompressionMode(mode: LogEventCompressionMode): void;
15
- setLoggingEnabled(enabled: LoggingEnabledOption): void;
16
14
  sendBatch(batch: EventBatch): Promise<{
17
15
  success: boolean;
18
16
  statusCode: number;
@@ -14,20 +14,16 @@ const Log_1 = require("./Log");
14
14
  const NetworkConfig_1 = require("./NetworkConfig");
15
15
  const VisibilityObserving_1 = require("./VisibilityObserving");
16
16
  class EventSender {
17
- constructor(sdkKey, network, emitter, logEventUrlConfig, options, loggingEnabled) {
17
+ constructor(sdkKey, network, emitter, logEventUrlConfig, options) {
18
18
  this._sdkKey = sdkKey;
19
19
  this._network = network;
20
20
  this._emitter = emitter;
21
21
  this._options = options;
22
22
  this._logEventUrlConfig = logEventUrlConfig;
23
- this._loggingEnabled = loggingEnabled;
24
23
  }
25
24
  setLogEventCompressionMode(mode) {
26
25
  this._network.setLogEventCompressionMode(mode);
27
26
  }
28
- setLoggingEnabled(enabled) {
29
- this._loggingEnabled = enabled;
30
- }
31
27
  sendBatch(batch) {
32
28
  return __awaiter(this, void 0, void 0, function* () {
33
29
  var _a, _b;
@@ -81,6 +77,7 @@ class EventSender {
81
77
  },
82
78
  urlConfig: this._logEventUrlConfig,
83
79
  retries: 3,
80
+ preserveFailedStatusCode: true,
84
81
  isCompressable: true,
85
82
  params: {
86
83
  [NetworkConfig_1.NetworkParam.EventCount]: String(batch.events.length),
@@ -20,6 +20,7 @@ export declare class FlushCoordinator {
20
20
  private _currentFlushPromise;
21
21
  private _creationTime;
22
22
  private _isShuttingDown;
23
+ private _loggingEnabled;
23
24
  private _sdkKey;
24
25
  private _storageKey;
25
26
  constructor(batchQueue: BatchQueue, pendingEvents: PendingEvents, onPrepareFlush: PrepareFlushCallBack, sdkKey: string, network: NetworkCore, emitter: StatsigClientEmitEventFunc, logEventUrlConfig: UrlConfiguration, options: StatsigOptionsCommon<NetworkConfigCommon> | null, loggingEnabled: LoggingEnabledOption, errorBoundary: ErrorBoundary);
@@ -17,7 +17,9 @@ const FlushTypes_1 = require("./FlushTypes");
17
17
  const Hashing_1 = require("./Hashing");
18
18
  const Log_1 = require("./Log");
19
19
  const NetworkCore_1 = require("./NetworkCore");
20
+ const SafeJs_1 = require("./SafeJs");
20
21
  const SessionID_1 = require("./SessionID");
22
+ const StatsigOptionsCommon_1 = require("./StatsigOptionsCommon");
21
23
  const StorageProvider_1 = require("./StorageProvider");
22
24
  class FlushCoordinator {
23
25
  constructor(batchQueue, pendingEvents, onPrepareFlush,
@@ -36,10 +38,11 @@ class FlushCoordinator {
36
38
  this._onPrepareFlush = onPrepareFlush;
37
39
  this._errorBoundary = errorBoundary;
38
40
  this._sdkKey = sdkKey;
39
- this._eventSender = new EventSender_1.EventSender(sdkKey, network, emitter, logEventUrlConfig, options, loggingEnabled);
41
+ this._loggingEnabled = loggingEnabled;
42
+ this._eventSender = new EventSender_1.EventSender(sdkKey, network, emitter, logEventUrlConfig, options);
40
43
  }
41
44
  setLoggingEnabled(loggingEnabled) {
42
- this._eventSender.setLoggingEnabled(loggingEnabled);
45
+ this._loggingEnabled = loggingEnabled;
43
46
  }
44
47
  setLogEventCompressionMode(mode) {
45
48
  this._eventSender.setLogEventCompressionMode(mode);
@@ -240,6 +243,11 @@ class FlushCoordinator {
240
243
  }
241
244
  _processOneBatch(batch, flushType) {
242
245
  return __awaiter(this, void 0, void 0, function* () {
246
+ if (this._loggingEnabled !== StatsigOptionsCommon_1.LoggingEnabledOption.always &&
247
+ (0, SafeJs_1._isServerEnv)()) {
248
+ this._flushInterval.adjustForSuccess();
249
+ return true;
250
+ }
243
251
  const result = yield this._eventSender.sendBatch(batch);
244
252
  if (result.success) {
245
253
  this._flushInterval.adjustForSuccess();
@@ -255,7 +263,7 @@ class FlushCoordinator {
255
263
  const droppedCount = this.convertPendingEventsToBatches();
256
264
  if (droppedCount > 0) {
257
265
  Log_1.Log.warn(`Dropped ${droppedCount} events`);
258
- this._errorBoundary.logDroppedEvents(droppedCount, `Batch queue limit reached`, {
266
+ this._errorBoundary.logDroppedEvents(droppedCount, `Batch queue limit reached during batching`, {
259
267
  loggingInterval: this._flushInterval.getCurrentIntervalMs(),
260
268
  batchSize: this._batchQueue.batchSize(),
261
269
  maxPendingBatches: EventRetryConstants_1.EventRetryConstants.MAX_PENDING_BATCHES,
@@ -298,7 +306,7 @@ class FlushCoordinator {
298
306
  const droppedCount = this._batchQueue.requeueBatch(batch);
299
307
  if (droppedCount > 0) {
300
308
  Log_1.Log.warn(`Failed to requeue batch : dropped ${droppedCount} events due to full queue`);
301
- this._errorBoundary.logDroppedEvents(droppedCount, `Batch queue limit reached`, {
309
+ this._errorBoundary.logDroppedEvents(droppedCount, `Batch queue limit reached during requeue`, {
302
310
  loggingInterval: this._flushInterval.getCurrentIntervalMs(),
303
311
  batchSize: this._batchQueue.batchSize(),
304
312
  maxPendingBatches: EventRetryConstants_1.EventRetryConstants.MAX_PENDING_BATCHES,
@@ -12,6 +12,7 @@ type RequestArgs = {
12
12
  priority?: NetworkPriority;
13
13
  retries?: number;
14
14
  attempt?: number;
15
+ preserveFailedStatusCode?: boolean;
15
16
  params?: Record<string, string>;
16
17
  headers?: Record<string, string>;
17
18
  credentials?: RequestCredentials;
@@ -173,6 +173,12 @@ class NetworkCore {
173
173
  const formattedErrorMsg = `A networking error occurred during ${method} request to ${populatedUrl}.`;
174
174
  Log_1.Log.error(formattedErrorMsg, errorMessage, error);
175
175
  (_d = this._errorBoundary) === null || _d === void 0 ? void 0 : _d.attachErrorIfNoneExists(formattedErrorMsg);
176
+ if (args.preserveFailedStatusCode && response != null) {
177
+ return {
178
+ body: null,
179
+ code: response.status,
180
+ };
181
+ }
176
182
  return null;
177
183
  }
178
184
  yield _exponentialBackoff(currentAttempt);
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "3.32.0";
1
+ export declare const SDK_VERSION = "3.32.2";
2
2
  export type StatsigMetadata = {
3
3
  readonly [key: string]: string | undefined | null;
4
4
  readonly appVersion?: string;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StatsigMetadataProvider = exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = '3.32.0';
4
+ exports.SDK_VERSION = '3.32.2';
5
5
  let metadata = {
6
6
  sdkVersion: exports.SDK_VERSION,
7
7
  sdkType: 'js-mono', // js-mono is overwritten by Precomp and OnDevice clients