@hanzo/event 0.3.20 → 0.3.21
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/LICENSE.md +21 -0
- package/dist/index.cjs +17 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -7
- package/dist/index.d.ts +10 -7
- package/dist/index.mjs +17 -24
- package/dist/index.mjs.map +1 -1
- package/dist/react.cjs +17 -24
- package/dist/react.cjs.map +1 -1
- package/dist/react.mjs +17 -24
- package/dist/react.mjs.map +1 -1
- package/hz.js +7 -8
- package/package.json +10 -10
- package/src/core.test.ts +3 -37
- package/src/core.ts +18 -24
- package/src/dsn.test.ts +28 -18
- package/src/dsn.ts +14 -34
- package/src/hz.test.ts +4 -10
- package/src/version.ts +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -6,7 +6,7 @@ declare function getFirstTouch(): Attribution | undefined;
|
|
|
6
6
|
/** Read persisted cohort dimensions. */
|
|
7
7
|
declare function getCohort(): Cohort | undefined;
|
|
8
8
|
|
|
9
|
-
declare const VERSION = "0.3.
|
|
9
|
+
declare const VERSION = "0.3.21";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* parseDsn parses "https://<version>:<hmac>@<host>/v1/sentry/<projectId>" into its
|
|
@@ -110,12 +110,15 @@ declare function uuidv7Time(id: string): number;
|
|
|
110
110
|
* project — an explicit map, because the projects predate this and do not derive
|
|
111
111
|
* cleanly from the product name. */
|
|
112
112
|
declare const PRODUCT_PROJECT: Readonly<Record<string, string>>;
|
|
113
|
-
/** dsnForProduct builds the product's Sentry DSN
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
|
|
113
|
+
/** dsnForProduct builds the product's Sentry DSN from the caller's resolved
|
|
114
|
+
* publishable `key` and the product's project — the SAME key the event stream
|
|
115
|
+
* carries, at the product's envelope endpoint. Returns undefined when there is no
|
|
116
|
+
* key or no project for the product, leaving the error plane inert rather than
|
|
117
|
+
* posting into the wrong one. The key is NOT baked here: it is the value the
|
|
118
|
+
* surface resolved (an explicit `ingestKey`, or the KMS-sourced
|
|
119
|
+
* NEXT_PUBLIC_PUBLISHABLE_KEY the build inlines) — the ONE live source, never a
|
|
120
|
+
* literal committed beside the code. */
|
|
121
|
+
declare function dsnForProduct(product: string | undefined, key: string | undefined): string | undefined;
|
|
119
122
|
|
|
120
123
|
/** redactSecrets removes known secret shapes. Always applied. */
|
|
121
124
|
declare function redactSecrets(s: string): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ declare function getFirstTouch(): Attribution | undefined;
|
|
|
6
6
|
/** Read persisted cohort dimensions. */
|
|
7
7
|
declare function getCohort(): Cohort | undefined;
|
|
8
8
|
|
|
9
|
-
declare const VERSION = "0.3.
|
|
9
|
+
declare const VERSION = "0.3.21";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* parseDsn parses "https://<version>:<hmac>@<host>/v1/sentry/<projectId>" into its
|
|
@@ -110,12 +110,15 @@ declare function uuidv7Time(id: string): number;
|
|
|
110
110
|
* project — an explicit map, because the projects predate this and do not derive
|
|
111
111
|
* cleanly from the product name. */
|
|
112
112
|
declare const PRODUCT_PROJECT: Readonly<Record<string, string>>;
|
|
113
|
-
/** dsnForProduct builds the product's Sentry DSN
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
|
|
113
|
+
/** dsnForProduct builds the product's Sentry DSN from the caller's resolved
|
|
114
|
+
* publishable `key` and the product's project — the SAME key the event stream
|
|
115
|
+
* carries, at the product's envelope endpoint. Returns undefined when there is no
|
|
116
|
+
* key or no project for the product, leaving the error plane inert rather than
|
|
117
|
+
* posting into the wrong one. The key is NOT baked here: it is the value the
|
|
118
|
+
* surface resolved (an explicit `ingestKey`, or the KMS-sourced
|
|
119
|
+
* NEXT_PUBLIC_PUBLISHABLE_KEY the build inlines) — the ONE live source, never a
|
|
120
|
+
* literal committed beside the code. */
|
|
121
|
+
declare function dsnForProduct(product: string | undefined, key: string | undefined): string | undefined;
|
|
119
122
|
|
|
120
123
|
/** redactSecrets removes known secret shapes. Always applied. */
|
|
121
124
|
declare function redactSecrets(s: string): string;
|
package/dist/index.mjs
CHANGED
|
@@ -80,15 +80,11 @@ var PRODUCT_PROJECT = Object.freeze({
|
|
|
80
80
|
site: "019f9b1e-5785-7359-ad0b-f75db8e58c99"
|
|
81
81
|
// hanzo.ai (marketing; product `site`)
|
|
82
82
|
});
|
|
83
|
-
function dsnForProduct(product) {
|
|
84
|
-
if (!product) return void 0;
|
|
83
|
+
function dsnForProduct(product, key) {
|
|
84
|
+
if (!product || !key) return void 0;
|
|
85
85
|
const projectId = PRODUCT_PROJECT[product];
|
|
86
86
|
if (!projectId) return void 0;
|
|
87
|
-
return `https://${
|
|
88
|
-
}
|
|
89
|
-
var HANZO_PUBLISHABLE_KEY = "pk-live-c88649f1085fb6ad441d8a0072933a9b";
|
|
90
|
-
function defaultPublishableKey(host) {
|
|
91
|
-
return host === void 0 || host === "https://api.hanzo.ai" ? HANZO_PUBLISHABLE_KEY : void 0;
|
|
87
|
+
return `https://${key}@api.hanzo.ai/v1/sentry/${projectId}`;
|
|
92
88
|
}
|
|
93
89
|
|
|
94
90
|
// src/events.ts
|
|
@@ -372,7 +368,7 @@ function uuidv7Time(id) {
|
|
|
372
368
|
}
|
|
373
369
|
|
|
374
370
|
// src/version.ts
|
|
375
|
-
var VERSION = "0.3.
|
|
371
|
+
var VERSION = "0.3.21";
|
|
376
372
|
|
|
377
373
|
// src/sentry.ts
|
|
378
374
|
var MAX_FRAMES = 50;
|
|
@@ -823,27 +819,24 @@ var Analytics = class {
|
|
|
823
819
|
enabled: true,
|
|
824
820
|
captureErrors: true,
|
|
825
821
|
...config,
|
|
826
|
-
// The publishable key resolves
|
|
827
|
-
//
|
|
828
|
-
// enough. Most specific first:
|
|
822
|
+
// The publishable key resolves from ONE live source, never a literal baked
|
|
823
|
+
// beside the code. Most specific first:
|
|
829
824
|
// 1. an explicit `ingestKey` in config;
|
|
830
825
|
// 2. NEXT_PUBLIC_PUBLISHABLE_KEY, the inlined build-time env the fleet
|
|
831
|
-
// carries end to end
|
|
832
|
-
// build-arg -> the NEXT_PUBLIC_ prefix Next inlines
|
|
833
|
-
// 3. the hanzo org key baked in `dsn.ts`, on the hanzo cloud only.
|
|
826
|
+
// carries end to end — KMS `deploy/PUBLISHABLE_KEY` -> the PUBLISHABLE_KEY
|
|
827
|
+
// build-arg -> the NEXT_PUBLIC_ prefix Next inlines.
|
|
834
828
|
//
|
|
835
|
-
//
|
|
836
|
-
//
|
|
837
|
-
//
|
|
838
|
-
//
|
|
839
|
-
//
|
|
840
|
-
|
|
841
|
-
// its own cloud (a non-default host) gets no default, so the org this
|
|
842
|
-
// attributes to is never the wrong one.
|
|
843
|
-
ingestKey: config.ingestKey ?? readEnv("NEXT_PUBLIC_PUBLISHABLE_KEY") ?? defaultPublishableKey(config.host ?? DEFAULT_HOST)
|
|
829
|
+
// A surface that provides neither has no key, and its anonymous traffic
|
|
830
|
+
// files under `$public` (which drops track/identify/group and answers 200);
|
|
831
|
+
// the fix is to give it the KMS-sourced env, not to hardcode the org key
|
|
832
|
+
// here. The key is a credential-class value: its home is KMS, and the ONE
|
|
833
|
+
// build reads it from there.
|
|
834
|
+
ingestKey: config.ingestKey ?? readEnv("NEXT_PUBLIC_PUBLISHABLE_KEY")
|
|
844
835
|
};
|
|
845
836
|
this.transport = config.transport ?? new DefaultTransport();
|
|
846
|
-
this.dsn = parseDsn(
|
|
837
|
+
this.dsn = parseDsn(
|
|
838
|
+
config.dsn ?? readEnvDsn() ?? dsnForProduct(this.cfg.product, this.cfg.ingestKey)
|
|
839
|
+
);
|
|
847
840
|
}
|
|
848
841
|
/** errorPlaneEnabled reports whether captured exceptions can actually reach the
|
|
849
842
|
* error host. False means a DSN was never configured — the documented
|