@hanzo/event 0.3.33 → 0.3.35
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/README.md +19 -7
- package/dist/index.cjs +80 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -2
- package/dist/index.d.ts +76 -2
- package/dist/index.mjs +76 -11
- package/dist/index.mjs.map +1 -1
- package/dist/react.cjs +75 -10
- package/dist/react.cjs.map +1 -1
- package/dist/react.mjs +75 -10
- package/dist/react.mjs.map +1 -1
- package/package.json +10 -10
- package/src/anon.d.ts +1 -1
- package/src/anon.js +29 -9
- package/src/anon.test.ts +1 -1
- package/src/core.ts +16 -6
- package/src/index.ts +7 -0
- package/src/org.test.ts +113 -0
- package/src/org.ts +129 -0
- package/src/storage.test.ts +1 -1
- package/src/version.ts +1 -1
- package/LICENSE.md +0 -21
package/dist/react.cjs
CHANGED
|
@@ -86,6 +86,56 @@ function dsnForProduct(product, key) {
|
|
|
86
86
|
return `https://${key}@api.hanzo.ai/v1/event/${projectId}`;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
// src/org.ts
|
|
90
|
+
var ORG_DOMAIN = Object.freeze({
|
|
91
|
+
hanzo: Object.freeze(["hanzo.ai", "hanzo.app", "hanzo.chat", "hanzo.id", "hanzo.bot", "hanzo.sh"]),
|
|
92
|
+
lux: Object.freeze([
|
|
93
|
+
"lux.network",
|
|
94
|
+
"lux.exchange",
|
|
95
|
+
"lux.market",
|
|
96
|
+
"lux.finance",
|
|
97
|
+
"lux.financial",
|
|
98
|
+
"lux.credit",
|
|
99
|
+
"lux.fund",
|
|
100
|
+
"lux.id"
|
|
101
|
+
]),
|
|
102
|
+
zoo: Object.freeze(["zoo.ngo", "zoo.network", "zoolabs.id"])
|
|
103
|
+
});
|
|
104
|
+
var ORG_KEY = Object.freeze({
|
|
105
|
+
hanzo: "pk-rM_CdaF2MQckGCrla113SrR1oH4zvqN8xh2I95Z9tY8",
|
|
106
|
+
lux: "pk-gUZp6ZVfhJzSwK-rb4oLbVkpCnMBx5uSCpxf_5yEhQk",
|
|
107
|
+
zoo: "pk-3TKpKnERV9AQSsBUERWkZejC1O1mUxc1jRzsP3MPbs4"
|
|
108
|
+
});
|
|
109
|
+
var PUBLISHABLE = "pk-";
|
|
110
|
+
var normalize = (host) => host.trim().toLowerCase().replace(/\.$/, "").split(":")[0] ?? "";
|
|
111
|
+
function orgOf(host) {
|
|
112
|
+
const h = normalize(host);
|
|
113
|
+
if (!h) return void 0;
|
|
114
|
+
let best;
|
|
115
|
+
let bestLen = 0;
|
|
116
|
+
for (const [org, domains] of Object.entries(ORG_DOMAIN)) {
|
|
117
|
+
for (const d of domains) {
|
|
118
|
+
if ((h === d || h.endsWith(`.${d}`)) && d.length > bestLen) {
|
|
119
|
+
best = org;
|
|
120
|
+
bestLen = d.length;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return best;
|
|
125
|
+
}
|
|
126
|
+
function keyFor(host, keyring = ORG_KEY) {
|
|
127
|
+
const org = orgOf(host);
|
|
128
|
+
if (!org) return void 0;
|
|
129
|
+
const key = keyring[org];
|
|
130
|
+
if (typeof key !== "string") return void 0;
|
|
131
|
+
const trimmed = key.trim();
|
|
132
|
+
return trimmed.startsWith(PUBLISHABLE) ? trimmed : void 0;
|
|
133
|
+
}
|
|
134
|
+
function keyForPage(keyring = ORG_KEY) {
|
|
135
|
+
if (typeof location === "undefined") return void 0;
|
|
136
|
+
return keyFor(location.hostname, keyring);
|
|
137
|
+
}
|
|
138
|
+
|
|
89
139
|
// src/scrub.ts
|
|
90
140
|
var REDACTED = "[redacted]";
|
|
91
141
|
var EMAIL_MARK = "[email]";
|
|
@@ -207,8 +257,8 @@ function scrubText(s, capturePII = false) {
|
|
|
207
257
|
}
|
|
208
258
|
|
|
209
259
|
// src/anon.js
|
|
210
|
-
var HZ_ANON_KEY = "
|
|
211
|
-
var
|
|
260
|
+
var HZ_ANON_KEY = "iam-anon-id";
|
|
261
|
+
var HZ_ANON_ADOPT = ["hz_anon_id", "hz_id"];
|
|
212
262
|
var HZ_ANON_DOMAIN = "hanzo.ai";
|
|
213
263
|
var HZ_ANON_MAX_AGE = 2 * 365 * 24 * 60 * 60;
|
|
214
264
|
var hzAnonMemo;
|
|
@@ -295,10 +345,17 @@ function hzAnonWrite(name, value) {
|
|
|
295
345
|
} catch (e) {
|
|
296
346
|
}
|
|
297
347
|
}
|
|
348
|
+
function hzAnonAdopted(s) {
|
|
349
|
+
for (var i = 0; i < HZ_ANON_ADOPT.length; i++) {
|
|
350
|
+
var id = hzAnonCookie(HZ_ANON_ADOPT[i]) || hzAnonItem(s, HZ_ANON_ADOPT[i]);
|
|
351
|
+
if (id) return id;
|
|
352
|
+
}
|
|
353
|
+
return "";
|
|
354
|
+
}
|
|
298
355
|
function hzAnonId() {
|
|
299
356
|
if (typeof window === "undefined") return "";
|
|
300
357
|
var s = hzAnonStore();
|
|
301
|
-
var id = hzAnonCookie(HZ_ANON_KEY) || hzAnonItem(s, HZ_ANON_KEY) ||
|
|
358
|
+
var id = hzAnonCookie(HZ_ANON_KEY) || hzAnonItem(s, HZ_ANON_KEY) || hzAnonAdopted(s) || hzAnonMemo || hzUuidv7();
|
|
302
359
|
hzAnonMemo = id;
|
|
303
360
|
hzAnonWrite(HZ_ANON_KEY, id);
|
|
304
361
|
try {
|
|
@@ -309,7 +366,7 @@ function hzAnonId() {
|
|
|
309
366
|
}
|
|
310
367
|
|
|
311
368
|
// src/version.ts
|
|
312
|
-
var VERSION = "0.3.
|
|
369
|
+
var VERSION = "0.3.35";
|
|
313
370
|
|
|
314
371
|
// src/sentry.ts
|
|
315
372
|
var MAX_FRAMES = 50;
|
|
@@ -771,12 +828,20 @@ var Analytics = class {
|
|
|
771
828
|
// carries end to end — KMS `deploy/PUBLISHABLE_KEY` -> the PUBLISHABLE_KEY
|
|
772
829
|
// build-arg -> the NEXT_PUBLIC_ prefix Next inlines.
|
|
773
830
|
//
|
|
774
|
-
//
|
|
775
|
-
//
|
|
776
|
-
//
|
|
777
|
-
//
|
|
778
|
-
//
|
|
779
|
-
|
|
831
|
+
// 3. the org that owns the HOST this page is served from (`org.ts`).
|
|
832
|
+
//
|
|
833
|
+
// Step 3 fires only when a surface configured NOTHING, so it never overrides
|
|
834
|
+
// the KMS chain above — it replaces going dark with reporting to the right
|
|
835
|
+
// brand. That is what a static export needs: `output: export` inlines no env,
|
|
836
|
+
// so before this the only way to report was to commit a key literal, and the
|
|
837
|
+
// fleet grew one copy per site of a value with a single source.
|
|
838
|
+
//
|
|
839
|
+
// A surface no brand claims still has no key, and the door REFUSES an
|
|
840
|
+
// unattributed event (401 `ingest_key_required`) — the reserved `$public`
|
|
841
|
+
// tenant that once caught keyless beacons is retired, and anonymous ingest is
|
|
842
|
+
// refused at every door on every brand host. So there is no quiet fallback to
|
|
843
|
+
// rely on: an event lands in the org a credential names, or it does not land.
|
|
844
|
+
ingestKey: config.ingestKey ?? readEnv("NEXT_PUBLIC_PUBLISHABLE_KEY") ?? keyForPage()
|
|
780
845
|
};
|
|
781
846
|
this.transport = config.transport ?? new DefaultTransport();
|
|
782
847
|
this.dsn = parseDsn(
|