@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.
@@ -134,8 +134,10 @@ interface WireEvent {
134
134
  * ?ingest_key query. */
135
135
  interface Transport {
136
136
  /** Durable POST usable during page unload (fetch keepalive / sendBeacon).
137
- * `contentType` defaults to application/json; the error plane overrides it with
138
- * application/x-sentry-envelope. */
137
+ * `contentType` names the FETCH request's Content-Type it defaults to
138
+ * application/json, and the error plane sets application/x-sentry-envelope. A
139
+ * beacon body carries a CORS-safelisted type so the POST stays a simple request;
140
+ * that is a property of the transport, not a caller's choice. */
139
141
  send(url: string, body: string, opts: {
140
142
  beacon: boolean;
141
143
  token?: string;
@@ -134,8 +134,10 @@ interface WireEvent {
134
134
  * ?ingest_key query. */
135
135
  interface Transport {
136
136
  /** Durable POST usable during page unload (fetch keepalive / sendBeacon).
137
- * `contentType` defaults to application/json; the error plane overrides it with
138
- * application/x-sentry-envelope. */
137
+ * `contentType` names the FETCH request's Content-Type it defaults to
138
+ * application/json, and the error plane sets application/x-sentry-envelope. A
139
+ * beacon body carries a CORS-safelisted type so the POST stays a simple request;
140
+ * that is a property of the transport, not a caller's choice. */
139
141
  send(url: string, body: string, opts: {
140
142
  beacon: boolean;
141
143
  token?: string;
package/dist/index.cjs CHANGED
@@ -319,7 +319,7 @@ function uuidv7Time(id) {
319
319
  }
320
320
 
321
321
  // src/version.ts
322
- var VERSION = "0.3.23";
322
+ var VERSION = "0.3.24";
323
323
 
324
324
  // src/sentry.ts
325
325
  var MAX_FRAMES = 50;
@@ -678,6 +678,7 @@ function mergeCohort(patch) {
678
678
  var EVENT_PATH = "/v1/event";
679
679
  var DEFAULT_HOST = "https://api.hanzo.ai";
680
680
  var ENVELOPE_CONTENT_TYPE = "application/x-sentry-envelope";
681
+ var BEACON_CONTENT_TYPE = "text/plain";
681
682
  function readEnvDsn() {
682
683
  try {
683
684
  if (typeof process !== "undefined" && process.env) {
@@ -722,17 +723,22 @@ function serializeBatch(batch) {
722
723
  }
723
724
  var DefaultTransport = class {
724
725
  send(url, body, opts) {
725
- const contentType = opts.contentType ?? "application/json";
726
726
  if (opts.beacon && isBrowser() && typeof navigator.sendBeacon === "function") {
727
727
  const beaconUrl = opts.ingestKey ? appendQuery(url, "ingest_key", opts.ingestKey) : url;
728
728
  try {
729
- navigator.sendBeacon(beaconUrl, new Blob([body], { type: contentType }));
730
- return;
729
+ const queued = navigator.sendBeacon(
730
+ beaconUrl,
731
+ new Blob([body], { type: BEACON_CONTENT_TYPE })
732
+ );
733
+ if (queued) return;
734
+ if (opts.debug) console.warn("[event] beacon refused, falling back to fetch");
731
735
  } catch {
732
736
  }
733
737
  }
734
738
  if (typeof fetch !== "function") return;
735
- const headers = { "Content-Type": contentType };
739
+ const headers = {
740
+ "Content-Type": opts.contentType ?? "application/json"
741
+ };
736
742
  const bearer = opts.ingestKey ?? opts.token;
737
743
  if (bearer) headers.Authorization = `Bearer ${bearer}`;
738
744
  void fetch(url, {