featurely-site-manager 1.1.8 → 1.1.9

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.js CHANGED
@@ -383,30 +383,30 @@ var _SiteManager = class _SiteManager {
383
383
  if (this.analyticsQueue.length === 0) {
384
384
  return;
385
385
  }
386
+ const url = `${this.config.apiUrl}/api/projects/${this.config.projectId}/analytics/events`;
386
387
  const eventsToSend = [...this.analyticsQueue];
387
388
  this.analyticsQueue = [];
388
389
  for (const event of eventsToSend) {
389
- try {
390
- await fetch(
391
- `${this.config.apiUrl}/api/projects/${this.config.projectId}/analytics/events`,
392
- {
390
+ const payload = JSON.stringify({
391
+ eventName: event.eventName,
392
+ properties: event.properties,
393
+ userId: this.config.userId,
394
+ sessionId: this.sessionId,
395
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
396
+ platform: typeof navigator !== "undefined" ? navigator.platform : void 0,
397
+ appVersion: this.config.appVersion
398
+ });
399
+ const sentViaBeacon = typeof navigator !== "undefined" && typeof navigator.sendBeacon === "function" && navigator.sendBeacon(url, payload);
400
+ if (!sentViaBeacon) {
401
+ try {
402
+ await fetch(url, {
393
403
  method: "POST",
394
- headers: {
395
- "Content-Type": "application/json"
396
- },
397
- body: JSON.stringify({
398
- eventName: event.eventName,
399
- properties: event.properties,
400
- userId: this.config.userId,
401
- sessionId: this.sessionId,
402
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
403
- platform: typeof navigator !== "undefined" ? navigator.platform : void 0,
404
- appVersion: this.config.appVersion
405
- })
406
- }
407
- );
408
- } catch (error) {
409
- console.error("Failed to send analytics event:", error);
404
+ headers: { "Content-Type": "application/json" },
405
+ body: payload
406
+ });
407
+ } catch (error) {
408
+ console.error("Failed to send analytics event:", error);
409
+ }
410
410
  }
411
411
  }
412
412
  }
package/dist/index.mjs CHANGED
@@ -348,30 +348,30 @@ var _SiteManager = class _SiteManager {
348
348
  if (this.analyticsQueue.length === 0) {
349
349
  return;
350
350
  }
351
+ const url = `${this.config.apiUrl}/api/projects/${this.config.projectId}/analytics/events`;
351
352
  const eventsToSend = [...this.analyticsQueue];
352
353
  this.analyticsQueue = [];
353
354
  for (const event of eventsToSend) {
354
- try {
355
- await fetch(
356
- `${this.config.apiUrl}/api/projects/${this.config.projectId}/analytics/events`,
357
- {
355
+ const payload = JSON.stringify({
356
+ eventName: event.eventName,
357
+ properties: event.properties,
358
+ userId: this.config.userId,
359
+ sessionId: this.sessionId,
360
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
361
+ platform: typeof navigator !== "undefined" ? navigator.platform : void 0,
362
+ appVersion: this.config.appVersion
363
+ });
364
+ const sentViaBeacon = typeof navigator !== "undefined" && typeof navigator.sendBeacon === "function" && navigator.sendBeacon(url, payload);
365
+ if (!sentViaBeacon) {
366
+ try {
367
+ await fetch(url, {
358
368
  method: "POST",
359
- headers: {
360
- "Content-Type": "application/json"
361
- },
362
- body: JSON.stringify({
363
- eventName: event.eventName,
364
- properties: event.properties,
365
- userId: this.config.userId,
366
- sessionId: this.sessionId,
367
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
368
- platform: typeof navigator !== "undefined" ? navigator.platform : void 0,
369
- appVersion: this.config.appVersion
370
- })
371
- }
372
- );
373
- } catch (error) {
374
- console.error("Failed to send analytics event:", error);
369
+ headers: { "Content-Type": "application/json" },
370
+ body: payload
371
+ });
372
+ } catch (error) {
373
+ console.error("Failed to send analytics event:", error);
374
+ }
375
375
  }
376
376
  }
377
377
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "featurely-site-manager",
3
- "version": "1.1.8",
3
+ "version": "1.1.9",
4
4
  "description": "Complete site management SDK for maintenance mode, status messages, feature flags, version checking, and analytics",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",