@cstar.help/js 0.10.1 → 0.10.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.
@@ -288,7 +288,7 @@ var TriggerEngine = class {
288
288
  }
289
289
  /**
290
290
  * Send analytics beacon (fire-and-forget).
291
- * Uses text/plain Content-Type to avoid CORS preflight for cross-origin beacons.
291
+ * Must use application/json — SvelteKit CSRF rejects text/plain cross-origin.
292
292
  * Falls back to fetch() if sendBeacon is unavailable or fails.
293
293
  */
294
294
  sendEvent(eventType, signalType, metadata) {
@@ -300,14 +300,14 @@ var TriggerEngine = class {
300
300
  metadata: metadata || {}
301
301
  });
302
302
  try {
303
- const queued = navigator.sendBeacon?.(url, new Blob([payload], { type: "text/plain" }));
303
+ const queued = navigator.sendBeacon?.(url, new Blob([payload], { type: "application/json" }));
304
304
  if (!queued) throw void 0;
305
305
  } catch {
306
306
  try {
307
307
  fetch(url, {
308
308
  method: "POST",
309
309
  body: payload,
310
- headers: { "Content-Type": "text/plain" },
310
+ headers: { "Content-Type": "application/json" },
311
311
  keepalive: true,
312
312
  mode: "cors"
313
313
  }).catch(() => {
@@ -264,7 +264,7 @@ var TriggerEngine = class {
264
264
  }
265
265
  /**
266
266
  * Send analytics beacon (fire-and-forget).
267
- * Uses text/plain Content-Type to avoid CORS preflight for cross-origin beacons.
267
+ * Must use application/json — SvelteKit CSRF rejects text/plain cross-origin.
268
268
  * Falls back to fetch() if sendBeacon is unavailable or fails.
269
269
  */
270
270
  sendEvent(eventType, signalType, metadata) {
@@ -276,14 +276,14 @@ var TriggerEngine = class {
276
276
  metadata: metadata || {}
277
277
  });
278
278
  try {
279
- const queued = navigator.sendBeacon?.(url, new Blob([payload], { type: "text/plain" }));
279
+ const queued = navigator.sendBeacon?.(url, new Blob([payload], { type: "application/json" }));
280
280
  if (!queued) throw void 0;
281
281
  } catch {
282
282
  try {
283
283
  fetch(url, {
284
284
  method: "POST",
285
285
  body: payload,
286
- headers: { "Content-Type": "text/plain" },
286
+ headers: { "Content-Type": "application/json" },
287
287
  keepalive: true,
288
288
  mode: "cors"
289
289
  }).catch(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cstar.help/js",
3
- "version": "0.10.1",
3
+ "version": "0.10.2",
4
4
  "description": "Official TypeScript SDK for the cStar customer support platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",