@shellapps/experience 1.14.1 → 1.14.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/dist/index.d.mts CHANGED
@@ -10,6 +10,8 @@ interface ExperienceConfig {
10
10
  batchIntervalMs?: number;
11
11
  maxBatchSize?: number;
12
12
  debug?: boolean;
13
+ /** Force JSON transport instead of protobuf. Recommended until protobuf is stable. */
14
+ transport?: 'protobuf' | 'json';
13
15
  }
14
16
  interface TrackEvent {
15
17
  eventType: string;
@@ -112,6 +114,7 @@ interface TransportConfig {
112
114
  endpoint: string;
113
115
  apiKey: string;
114
116
  debug: boolean;
117
+ useJSON?: boolean;
115
118
  }
116
119
  type EventHandler = (event: Event) => void;
117
120
  type UnsubscribeFn = () => void;
@@ -127,6 +130,7 @@ interface ResolvedExperienceConfig {
127
130
  batchIntervalMs: number;
128
131
  maxBatchSize: number;
129
132
  debug: boolean;
133
+ transport: 'protobuf' | 'json';
130
134
  }
131
135
 
132
136
  declare class Experience {
package/dist/index.d.ts CHANGED
@@ -10,6 +10,8 @@ interface ExperienceConfig {
10
10
  batchIntervalMs?: number;
11
11
  maxBatchSize?: number;
12
12
  debug?: boolean;
13
+ /** Force JSON transport instead of protobuf. Recommended until protobuf is stable. */
14
+ transport?: 'protobuf' | 'json';
13
15
  }
14
16
  interface TrackEvent {
15
17
  eventType: string;
@@ -112,6 +114,7 @@ interface TransportConfig {
112
114
  endpoint: string;
113
115
  apiKey: string;
114
116
  debug: boolean;
117
+ useJSON?: boolean;
115
118
  }
116
119
  type EventHandler = (event: Event) => void;
117
120
  type UnsubscribeFn = () => void;
@@ -127,6 +130,7 @@ interface ResolvedExperienceConfig {
127
130
  batchIntervalMs: number;
128
131
  maxBatchSize: number;
129
132
  debug: boolean;
133
+ transport: 'protobuf' | 'json';
130
134
  }
131
135
 
132
136
  declare class Experience {
package/dist/index.js CHANGED
@@ -579,11 +579,12 @@ var Transport = class {
579
579
  }
580
580
  }
581
581
  async sendEventBatch(batch) {
582
+ if (this.config.useJSON || this.config.debug) {
583
+ return this.sendJSON("/api/v1/events/ingest/json", batch);
584
+ }
582
585
  try {
583
- if (!this.config.debug) {
584
- const protobufData = this.encoder.encodeEventBatch(batch);
585
- return await this.sendProtobuf("/api/v1/events/ingest", protobufData);
586
- }
586
+ const protobufData = this.encoder.encodeEventBatch(batch);
587
+ return await this.sendProtobuf("/api/v1/events/ingest", protobufData);
587
588
  } catch (error) {
588
589
  if (this.config.debug) {
589
590
  console.warn("[ExperienceSDK] Protobuf failed, falling back to JSON:", error);
@@ -592,6 +593,9 @@ var Transport = class {
592
593
  return this.sendJSON("/api/v1/events/ingest/json", batch);
593
594
  }
594
595
  async sendErrorBatch(batch) {
596
+ if (this.config.useJSON || this.config.debug) {
597
+ return this.sendJSON("/api/v1/errors/ingest/json", batch);
598
+ }
595
599
  try {
596
600
  if (!this.config.debug) {
597
601
  const protobufData = this.encoder.encodeErrorBatch(batch);
@@ -2365,7 +2369,8 @@ var _Experience = class _Experience {
2365
2369
  this.transport = new Transport({
2366
2370
  endpoint: this.config.endpoint,
2367
2371
  apiKey: this.config.apiKey,
2368
- debug: this.config.debug
2372
+ debug: this.config.debug,
2373
+ useJSON: this.config.transport === "json"
2369
2374
  });
2370
2375
  this.batcher = new EventBatcher(
2371
2376
  this.transport,
@@ -2395,7 +2400,8 @@ var _Experience = class _Experience {
2395
2400
  sampleRate: Math.max(0, Math.min(1, config.sampleRate ?? 1)),
2396
2401
  batchIntervalMs: config.batchIntervalMs ?? 2e3,
2397
2402
  maxBatchSize: config.maxBatchSize ?? 50,
2398
- debug: config.debug ?? false
2403
+ debug: config.debug ?? false,
2404
+ transport: config.transport ?? "json"
2399
2405
  };
2400
2406
  }
2401
2407
  setupFailureHandling() {