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