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