@hanzo/event 0.3.22 → 0.3.24

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/react.mjs CHANGED
@@ -307,7 +307,7 @@ function hzAnonId() {
307
307
  }
308
308
 
309
309
  // src/version.ts
310
- var VERSION = "0.3.21";
310
+ var VERSION = "0.3.24";
311
311
 
312
312
  // src/sentry.ts
313
313
  var MAX_FRAMES = 50;
@@ -666,6 +666,7 @@ function mergeCohort(patch) {
666
666
  var EVENT_PATH = "/v1/event";
667
667
  var DEFAULT_HOST = "https://api.hanzo.ai";
668
668
  var ENVELOPE_CONTENT_TYPE = "application/x-sentry-envelope";
669
+ var BEACON_CONTENT_TYPE = "text/plain";
669
670
  function readEnvDsn() {
670
671
  try {
671
672
  if (typeof process !== "undefined" && process.env) {
@@ -710,17 +711,22 @@ function serializeBatch(batch) {
710
711
  }
711
712
  var DefaultTransport = class {
712
713
  send(url, body, opts) {
713
- const contentType = opts.contentType ?? "application/json";
714
714
  if (opts.beacon && isBrowser() && typeof navigator.sendBeacon === "function") {
715
715
  const beaconUrl = opts.ingestKey ? appendQuery(url, "ingest_key", opts.ingestKey) : url;
716
716
  try {
717
- navigator.sendBeacon(beaconUrl, new Blob([body], { type: contentType }));
718
- return;
717
+ const queued = navigator.sendBeacon(
718
+ beaconUrl,
719
+ new Blob([body], { type: BEACON_CONTENT_TYPE })
720
+ );
721
+ if (queued) return;
722
+ if (opts.debug) console.warn("[event] beacon refused, falling back to fetch");
719
723
  } catch {
720
724
  }
721
725
  }
722
726
  if (typeof fetch !== "function") return;
723
- const headers = { "Content-Type": contentType };
727
+ const headers = {
728
+ "Content-Type": opts.contentType ?? "application/json"
729
+ };
724
730
  const bearer = opts.ingestKey ?? opts.token;
725
731
  if (bearer) headers.Authorization = `Bearer ${bearer}`;
726
732
  void fetch(url, {