@hanzo/event 0.3.16 → 0.3.18
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/TAXONOMY.md +1 -1
- package/dist/{core-BZraSvcr.d.cts → core-D4PaPlOB.d.cts} +3 -3
- package/dist/{core-BZraSvcr.d.ts → core-D4PaPlOB.d.ts} +3 -3
- package/dist/index.cjs +22 -16
- 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 +22 -16
- package/dist/index.mjs.map +1 -1
- package/dist/react.cjs +22 -16
- 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 +22 -16
- package/dist/react.mjs.map +1 -1
- package/hz.js +9 -3
- package/package.json +1 -1
- package/src/core.test.ts +45 -9
- package/src/core.ts +21 -16
- package/src/dsn.ts +26 -0
- package/src/hz.test.ts +13 -4
- package/src/types.ts +3 -3
- package/src/version.ts +1 -1
package/TAXONOMY.md
CHANGED
|
@@ -239,7 +239,7 @@ Verified against the trees at the time of writing. ✅ = emitting, ❌ = not emi
|
|
|
239
239
|
no org today; chat funnels are person-scoped only.
|
|
240
240
|
5. **Logged-out reach depends on a publishable key.** Anonymous events need
|
|
241
241
|
`ingestKey` (`pk_…`, write-only) or they fail closed at the door.
|
|
242
|
-
`NEXT_PUBLIC_HANZO_INGEST_KEY` (hanzo.ai), `
|
|
242
|
+
`NEXT_PUBLIC_HANZO_INGEST_KEY` (hanzo.ai), `NEXT_PUBLIC_PUBLISHABLE_KEY`
|
|
243
243
|
(hanzo.app), `VITE_HANZO_INGEST_KEY` (hanzo.chat) are read but must be
|
|
244
244
|
provisioned per org via `POST /v1/ingest/keys`. Config, not code.
|
|
245
245
|
|
|
@@ -108,11 +108,11 @@ interface AnalyticsConfig {
|
|
|
108
108
|
* a reading principal — so it is safe to ship in a bundle. Mint one per org with
|
|
109
109
|
* POST /v1/keys {"type":"publishable"}.
|
|
110
110
|
*
|
|
111
|
-
* Omit it and the client reads
|
|
111
|
+
* Omit it and the client reads NEXT_PUBLIC_PUBLISHABLE_KEY from the inlined
|
|
112
112
|
* build env, the same way `dsn` falls back — so a surface declares BOTH planes
|
|
113
113
|
* in its build and neither needs code to switch on. That is the ONE spelling
|
|
114
|
-
* the fleet already carries: KMS holds deploy/
|
|
115
|
-
* Dockerfile takes
|
|
114
|
+
* the fleet already carries: KMS holds deploy/PUBLISHABLE_KEY, and each
|
|
115
|
+
* Dockerfile takes PUBLISHABLE_KEY as a build-arg and re-exports it with the
|
|
116
116
|
* NEXT_PUBLIC_ prefix that makes Next inline it.
|
|
117
117
|
*
|
|
118
118
|
* A surface with no key at all still reports for whoever is SIGNED IN (the
|
|
@@ -108,11 +108,11 @@ interface AnalyticsConfig {
|
|
|
108
108
|
* a reading principal — so it is safe to ship in a bundle. Mint one per org with
|
|
109
109
|
* POST /v1/keys {"type":"publishable"}.
|
|
110
110
|
*
|
|
111
|
-
* Omit it and the client reads
|
|
111
|
+
* Omit it and the client reads NEXT_PUBLIC_PUBLISHABLE_KEY from the inlined
|
|
112
112
|
* build env, the same way `dsn` falls back — so a surface declares BOTH planes
|
|
113
113
|
* in its build and neither needs code to switch on. That is the ONE spelling
|
|
114
|
-
* the fleet already carries: KMS holds deploy/
|
|
115
|
-
* Dockerfile takes
|
|
114
|
+
* the fleet already carries: KMS holds deploy/PUBLISHABLE_KEY, and each
|
|
115
|
+
* Dockerfile takes PUBLISHABLE_KEY as a build-arg and re-exports it with the
|
|
116
116
|
* NEXT_PUBLIC_ prefix that makes Next inline it.
|
|
117
117
|
*
|
|
118
118
|
* A surface with no key at all still reports for whoever is SIGNED IN (the
|
package/dist/index.cjs
CHANGED
|
@@ -86,6 +86,10 @@ function dsnForProduct(product) {
|
|
|
86
86
|
if (!product) return void 0;
|
|
87
87
|
return PRODUCT_DSN[product];
|
|
88
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;
|
|
92
|
+
}
|
|
89
93
|
|
|
90
94
|
// src/events.ts
|
|
91
95
|
var EVENTS = {
|
|
@@ -367,7 +371,7 @@ function uuidv7Time(id) {
|
|
|
367
371
|
}
|
|
368
372
|
|
|
369
373
|
// src/version.ts
|
|
370
|
-
var VERSION = "0.3.
|
|
374
|
+
var VERSION = "0.3.18";
|
|
371
375
|
|
|
372
376
|
// src/sentry.ts
|
|
373
377
|
var MAX_FRAMES = 50;
|
|
@@ -730,22 +734,24 @@ var Analytics = class {
|
|
|
730
734
|
enabled: true,
|
|
731
735
|
captureErrors: true,
|
|
732
736
|
...config,
|
|
733
|
-
// The publishable key resolves the SAME way the DSN below does
|
|
734
|
-
//
|
|
735
|
-
//
|
|
736
|
-
//
|
|
737
|
-
//
|
|
738
|
-
//
|
|
739
|
-
//
|
|
740
|
-
//
|
|
737
|
+
// The publishable key resolves the SAME way the DSN below does, and now
|
|
738
|
+
// ends the SAME way too — in a baked default, so declaring nothing is
|
|
739
|
+
// enough. Most specific first:
|
|
740
|
+
// 1. an explicit `ingestKey` in config;
|
|
741
|
+
// 2. NEXT_PUBLIC_PUBLISHABLE_KEY, the inlined build-time env the fleet
|
|
742
|
+
// carries end to end (KMS `deploy/PUBLISHABLE_KEY` -> the PUBLISHABLE_KEY
|
|
743
|
+
// build-arg -> the NEXT_PUBLIC_ prefix Next inlines);
|
|
744
|
+
// 3. the hanzo org key baked in `dsn.ts`, on the hanzo cloud only.
|
|
741
745
|
//
|
|
742
|
-
//
|
|
743
|
-
//
|
|
744
|
-
//
|
|
745
|
-
//
|
|
746
|
-
// in the page and invisible until you read the
|
|
747
|
-
// missing entirely.
|
|
748
|
-
|
|
746
|
+
// (3) is why this is `publishable_key for all`: a hanzo surface that passes
|
|
747
|
+
// no key in code and inlines no env still emits attributed, exactly as
|
|
748
|
+
// declaring `product` is enough for the DSN. Without it that surface sent
|
|
749
|
+
// its beacons to `$public` — which drops every track/identify/group and
|
|
750
|
+
// still answers 200 — silent in the page and invisible until you read the
|
|
751
|
+
// warehouse and find the host missing entirely. A white-label surface on
|
|
752
|
+
// its own cloud (a non-default host) gets no default, so the org this
|
|
753
|
+
// attributes to is never the wrong one.
|
|
754
|
+
ingestKey: config.ingestKey ?? readEnv("NEXT_PUBLIC_PUBLISHABLE_KEY") ?? defaultPublishableKey(config.host ?? DEFAULT_HOST)
|
|
749
755
|
};
|
|
750
756
|
this.transport = config.transport ?? new DefaultTransport();
|
|
751
757
|
this.dsn = parseDsn(config.dsn ?? readEnvDsn() ?? dsnForProduct(this.cfg.product));
|