@hanzo/event 0.3.23 → 0.3.25
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/{core-CHLpJy51.d.cts → core-DO8tBUy7.d.cts} +4 -2
- package/dist/{core-CHLpJy51.d.ts → core-DO8tBUy7.d.ts} +4 -2
- package/dist/index.cjs +11 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +11 -5
- package/dist/index.mjs.map +1 -1
- package/dist/react.cjs +11 -5
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.mjs +11 -5
- package/dist/react.mjs.map +1 -1
- package/hz.js +24 -5
- package/package.json +10 -10
- package/src/core.ts +25 -5
- package/src/hz.test.ts +88 -7
- package/src/stack.ts +144 -0
- package/src/transport.test.ts +139 -0
- package/src/types.ts +4 -2
- package/src/version.ts +1 -1
- package/LICENSE.md +0 -21
|
@@ -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`
|
|
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`
|
|
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.
|
|
322
|
+
var VERSION = "0.3.25";
|
|
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(
|
|
730
|
-
|
|
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 = {
|
|
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, {
|