@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 +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -546,11 +546,12 @@ var Transport = class {
|
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
548
|
async sendEventBatch(batch) {
|
|
549
|
+
if (this.config.useJSON || this.config.debug) {
|
|
550
|
+
return this.sendJSON("/api/v1/events/ingest/json", batch);
|
|
551
|
+
}
|
|
549
552
|
try {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
return await this.sendProtobuf("/api/v1/events/ingest", protobufData);
|
|
553
|
-
}
|
|
553
|
+
const protobufData = this.encoder.encodeEventBatch(batch);
|
|
554
|
+
return await this.sendProtobuf("/api/v1/events/ingest", protobufData);
|
|
554
555
|
} catch (error) {
|
|
555
556
|
if (this.config.debug) {
|
|
556
557
|
console.warn("[ExperienceSDK] Protobuf failed, falling back to JSON:", error);
|
|
@@ -559,6 +560,9 @@ var Transport = class {
|
|
|
559
560
|
return this.sendJSON("/api/v1/events/ingest/json", batch);
|
|
560
561
|
}
|
|
561
562
|
async sendErrorBatch(batch) {
|
|
563
|
+
if (this.config.useJSON || this.config.debug) {
|
|
564
|
+
return this.sendJSON("/api/v1/errors/ingest/json", batch);
|
|
565
|
+
}
|
|
562
566
|
try {
|
|
563
567
|
if (!this.config.debug) {
|
|
564
568
|
const protobufData = this.encoder.encodeErrorBatch(batch);
|
|
@@ -2332,7 +2336,8 @@ var _Experience = class _Experience {
|
|
|
2332
2336
|
this.transport = new Transport({
|
|
2333
2337
|
endpoint: this.config.endpoint,
|
|
2334
2338
|
apiKey: this.config.apiKey,
|
|
2335
|
-
debug: this.config.debug
|
|
2339
|
+
debug: this.config.debug,
|
|
2340
|
+
useJSON: this.config.transport === "json"
|
|
2336
2341
|
});
|
|
2337
2342
|
this.batcher = new EventBatcher(
|
|
2338
2343
|
this.transport,
|
|
@@ -2362,7 +2367,8 @@ var _Experience = class _Experience {
|
|
|
2362
2367
|
sampleRate: Math.max(0, Math.min(1, config.sampleRate ?? 1)),
|
|
2363
2368
|
batchIntervalMs: config.batchIntervalMs ?? 2e3,
|
|
2364
2369
|
maxBatchSize: config.maxBatchSize ?? 50,
|
|
2365
|
-
debug: config.debug ?? false
|
|
2370
|
+
debug: config.debug ?? false,
|
|
2371
|
+
transport: config.transport ?? "json"
|
|
2366
2372
|
};
|
|
2367
2373
|
}
|
|
2368
2374
|
setupFailureHandling() {
|