@hanzo/event 0.3.33 → 0.3.34

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