@hanzo/event 0.3.18 → 0.3.20
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-D4PaPlOB.d.cts → core-CHLpJy51.d.cts} +56 -1
- package/dist/{core-D4PaPlOB.d.ts → core-CHLpJy51.d.ts} +56 -1
- package/dist/index.cjs +119 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +70 -10
- package/dist/index.d.ts +70 -10
- package/dist/index.mjs +114 -12
- package/dist/index.mjs.map +1 -1
- package/dist/react.cjs +113 -11
- 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 +113 -11
- package/dist/react.mjs.map +1 -1
- package/hz.js +1 -1
- package/package.json +10 -10
- package/src/core.test.ts +45 -12
- package/src/core.ts +30 -3
- package/src/dsn.test.ts +14 -11
- package/src/dsn.ts +19 -14
- package/src/events.ts +5 -0
- package/src/exception.test.ts +188 -0
- package/src/exception.ts +200 -0
- package/src/index.ts +6 -2
- package/src/types.ts +53 -0
- package/src/version.ts +1 -1
- package/LICENSE.md +0 -21
package/dist/react.cjs
CHANGED
|
@@ -70,17 +70,19 @@ function hasAttribution(a) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
// src/dsn.ts
|
|
73
|
-
var
|
|
74
|
-
|
|
75
|
-
console
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
var PRODUCT_PROJECT = Object.freeze({
|
|
74
|
+
console: "019fa40b-94ae-7f1d-8f7b-e92f123fad42",
|
|
75
|
+
// console.hanzo.ai
|
|
76
|
+
app: "019f9b1e-57eb-7171-9d92-72c0b85e4b4b",
|
|
77
|
+
// hanzo.app
|
|
78
|
+
site: "019f9b1e-5785-7359-ad0b-f75db8e58c99"
|
|
79
|
+
// hanzo.ai (marketing; product `site`)
|
|
80
80
|
});
|
|
81
81
|
function dsnForProduct(product) {
|
|
82
82
|
if (!product) return void 0;
|
|
83
|
-
|
|
83
|
+
const projectId = PRODUCT_PROJECT[product];
|
|
84
|
+
if (!projectId) return void 0;
|
|
85
|
+
return `https://${HANZO_PUBLISHABLE_KEY}@api.hanzo.ai/v1/sentry/${projectId}`;
|
|
84
86
|
}
|
|
85
87
|
var HANZO_PUBLISHABLE_KEY = "pk-live-c88649f1085fb6ad441d8a0072933a9b";
|
|
86
88
|
function defaultPublishableKey(host) {
|
|
@@ -89,6 +91,7 @@ function defaultPublishableKey(host) {
|
|
|
89
91
|
|
|
90
92
|
// src/events.ts
|
|
91
93
|
var PAGEVIEW = "$pageview";
|
|
94
|
+
var EXCEPTION = "$exception";
|
|
92
95
|
|
|
93
96
|
// src/scrub.ts
|
|
94
97
|
var REDACTED = "[redacted]";
|
|
@@ -313,7 +316,7 @@ function hzAnonId() {
|
|
|
313
316
|
}
|
|
314
317
|
|
|
315
318
|
// src/version.ts
|
|
316
|
-
var VERSION = "0.3.
|
|
319
|
+
var VERSION = "0.3.20";
|
|
317
320
|
|
|
318
321
|
// src/sentry.ts
|
|
319
322
|
var MAX_FRAMES = 50;
|
|
@@ -505,6 +508,94 @@ ${itemHeader}
|
|
|
505
508
|
${payload}
|
|
506
509
|
`;
|
|
507
510
|
}
|
|
511
|
+
var MAX_VALUE = 4096;
|
|
512
|
+
function digest(s) {
|
|
513
|
+
let out = "";
|
|
514
|
+
for (const seed of [2166136261, 16777619, 2654435769, 2246822507]) {
|
|
515
|
+
let h = seed >>> 0;
|
|
516
|
+
for (let i = 0; i < s.length; i++) {
|
|
517
|
+
h ^= s.charCodeAt(i);
|
|
518
|
+
h = h + (h << 1) + (h << 4) + (h << 7) + (h << 8) + (h << 24) >>> 0;
|
|
519
|
+
}
|
|
520
|
+
out += h.toString(16).padStart(8, "0");
|
|
521
|
+
}
|
|
522
|
+
return out;
|
|
523
|
+
}
|
|
524
|
+
function frameOf(f) {
|
|
525
|
+
const source = f.filename ?? "";
|
|
526
|
+
const name = f.function ?? "<anonymous>";
|
|
527
|
+
const line = f.lineno ?? 0;
|
|
528
|
+
const column = f.colno ?? 0;
|
|
529
|
+
return {
|
|
530
|
+
// Stable per code location, so the same frame groups and re-renders under one
|
|
531
|
+
// key. The '/part' suffix is the product's format for one raw frame expanding
|
|
532
|
+
// into several resolved ones; a browser frame is always part 0.
|
|
533
|
+
raw_id: `${digest(`${source}|${name}|${line}|${column}`)}/0`,
|
|
534
|
+
mangled_name: name,
|
|
535
|
+
source,
|
|
536
|
+
line,
|
|
537
|
+
column,
|
|
538
|
+
in_app: f.in_app ?? false,
|
|
539
|
+
lang: "javascript",
|
|
540
|
+
resolved: false,
|
|
541
|
+
resolve_failure: "no symbol set uploaded for this release",
|
|
542
|
+
resolved_name: null,
|
|
543
|
+
module: null
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
function truncate2(s, max) {
|
|
547
|
+
if (s.length <= max) return s;
|
|
548
|
+
let end = max;
|
|
549
|
+
const c = s.charCodeAt(end - 1);
|
|
550
|
+
if (c >= 55296 && c <= 56319) end--;
|
|
551
|
+
return s.slice(0, end);
|
|
552
|
+
}
|
|
553
|
+
function exceptionEntry(err, opts) {
|
|
554
|
+
const n = normalizeError(err);
|
|
555
|
+
const frames = framesFromStack(n.stack).slice(-50);
|
|
556
|
+
const entry = {
|
|
557
|
+
id: opts.id,
|
|
558
|
+
type: n.name,
|
|
559
|
+
value: truncate2(n.message, MAX_VALUE),
|
|
560
|
+
mechanism: {
|
|
561
|
+
type: "generic",
|
|
562
|
+
handled: opts.handled,
|
|
563
|
+
// An exception the app reported by hand was constructed, not thrown by the
|
|
564
|
+
// runtime at a real call site.
|
|
565
|
+
synthetic: !(err instanceof Error)
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
if (frames.length > 0) {
|
|
569
|
+
entry.stacktrace = { type: "resolved", frames: frames.map(frameOf) };
|
|
570
|
+
}
|
|
571
|
+
return entry;
|
|
572
|
+
}
|
|
573
|
+
function fingerprint(entry) {
|
|
574
|
+
const frames = entry.stacktrace?.frames ?? [];
|
|
575
|
+
const pieces = frames.filter((f) => f.in_app).map((f) => `${f.mangled_name}@${f.source}`);
|
|
576
|
+
return digest([entry.type, ...pieces].join("\n"));
|
|
577
|
+
}
|
|
578
|
+
function exceptionProperties(err, opts) {
|
|
579
|
+
const entry = exceptionEntry(err, opts);
|
|
580
|
+
const frames = entry.stacktrace?.frames ?? [];
|
|
581
|
+
const fp = fingerprint(entry);
|
|
582
|
+
return {
|
|
583
|
+
$exception_list: [entry],
|
|
584
|
+
$exception_fingerprint: fp,
|
|
585
|
+
// Records WHY this fingerprint holds. 'manual' is the honest value: the client
|
|
586
|
+
// supplied the key rather than a server grouper deriving one.
|
|
587
|
+
$exception_fingerprint_record: [{ type: "manual" }],
|
|
588
|
+
$exception_type: entry.type,
|
|
589
|
+
$exception_message: entry.value,
|
|
590
|
+
$exception_level: opts.level ?? "error",
|
|
591
|
+
$exception_handled: opts.handled,
|
|
592
|
+
$exception_synthetic: entry.mechanism?.synthetic ?? false,
|
|
593
|
+
$exception_types: [entry.type],
|
|
594
|
+
$exception_values: [entry.value],
|
|
595
|
+
$exception_sources: frames.map((f) => f.source).filter((s) => !!s),
|
|
596
|
+
$exception_functions: frames.map((f) => f.resolved_name ?? f.mangled_name).filter((s) => !!s)
|
|
597
|
+
};
|
|
598
|
+
}
|
|
508
599
|
|
|
509
600
|
// src/storage.ts
|
|
510
601
|
var KEY = {
|
|
@@ -781,9 +872,20 @@ var Analytics = class {
|
|
|
781
872
|
} catch {
|
|
782
873
|
}
|
|
783
874
|
try {
|
|
875
|
+
const handled = context?.handled ?? true;
|
|
784
876
|
const ex = normalizeError2(err);
|
|
785
|
-
ex.handled =
|
|
786
|
-
this.enqueue("
|
|
877
|
+
ex.handled = handled;
|
|
878
|
+
this.enqueue("event", EXCEPTION, {
|
|
879
|
+
error: ex,
|
|
880
|
+
properties: {
|
|
881
|
+
...context?.properties,
|
|
882
|
+
...exceptionProperties(err, {
|
|
883
|
+
handled,
|
|
884
|
+
id: hzUuidv7(),
|
|
885
|
+
level: context?.level
|
|
886
|
+
})
|
|
887
|
+
}
|
|
888
|
+
});
|
|
787
889
|
this.flush();
|
|
788
890
|
} catch {
|
|
789
891
|
}
|