@hanzo/event 0.3.17 → 0.3.19

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/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.17";
9
+ declare const VERSION = "0.3.19";
10
10
 
11
11
  /**
12
12
  * parseDsn parses "https://<version>:<hmac>@<host>/v1/sentry/<projectId>" into its
@@ -102,12 +102,19 @@ declare function uuidv7Time(id: string): number;
102
102
  * (POST /v1/sentry/projects with X-Org-Id), then add its `dsn` here keyed by the
103
103
  * product name the app passes to `createAnalytics`.
104
104
  */
105
- /** PRODUCT_DSN maps a `product` to the DSN its errors are submitted to. */
106
- declare const PRODUCT_DSN: Readonly<Record<string, string>>;
107
- /** dsnForProduct resolves the registered DSN for a product, or undefined when the
108
- * product has no project yet which leaves the error plane inert rather than
109
- * guessing a destination and silently posting a surface's errors into the wrong
110
- * project. */
105
+ /** PRODUCT_PROJECT maps a `product` to its Sentry project id. The DSN's KEY is no
106
+ * longer a per-project secret — it is the ONE org publishable key (below), so a
107
+ * surface's errors ride the SAME key its events do. The id only names WHICH
108
+ * project the errors group under, and cloud auto-provisions that project on first
109
+ * keyed ingest, so a new id needs nothing minted. `site` lives in the `hanzo-ai`
110
+ * project — an explicit map, because the projects predate this and do not derive
111
+ * cleanly from the product name. */
112
+ declare const PRODUCT_PROJECT: Readonly<Record<string, string>>;
113
+ /** dsnForProduct builds the product's Sentry DSN — the ONE org publishable key at
114
+ * its project's envelope endpoint — or undefined when the product has no project
115
+ * yet, which leaves the error plane inert rather than posting into the wrong one.
116
+ * Same key as the event stream: cloud resolves it to the org and attributes the
117
+ * errors there. */
111
118
  declare function dsnForProduct(product: string | undefined): string | undefined;
112
119
 
113
120
  /** redactSecrets removes known secret shapes. Always applied. */
@@ -290,4 +297,4 @@ declare function hasAttribution(a: Attribution): boolean;
290
297
  /** isoWeek returns the ISO-8601 week label, e.g. "2026-W28". */
291
298
  declare function isoWeek(d: Date): string;
292
299
 
293
- export { Attribution, COHORTS, CaptureErrorOptions, Cohort, type CohortDef, Dsn, EVENTS, type ErrorIdentity, type EventName, FUNNELS, type FunnelDef, type FunnelId, type FunnelStep, GOALS, type GoalDef, PAGEVIEW, PRODUCTS, PRODUCT_DSN, type ProductId, SentryEvent, SentryFrame, VERSION, buildEnvelope, buildSentryEvent, deriveChannel, dsnForProduct, eventsOf, framesFromStack, getCohort, getFirstTouch, hasAttribution, hostOf, isoWeek, parseAttribution, parseDsn, redactSecrets, scrubPII, scrubText, hzUuidv7 as uuidv7, uuidv7Time };
300
+ export { Attribution, COHORTS, CaptureErrorOptions, Cohort, type CohortDef, Dsn, EVENTS, type ErrorIdentity, type EventName, FUNNELS, type FunnelDef, type FunnelId, type FunnelStep, GOALS, type GoalDef, PAGEVIEW, PRODUCTS, PRODUCT_PROJECT, type ProductId, SentryEvent, SentryFrame, VERSION, buildEnvelope, buildSentryEvent, deriveChannel, dsnForProduct, eventsOf, framesFromStack, getCohort, getFirstTouch, hasAttribution, hostOf, isoWeek, parseAttribution, parseDsn, redactSecrets, scrubPII, scrubText, hzUuidv7 as uuidv7, uuidv7Time };
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.17";
9
+ declare const VERSION = "0.3.19";
10
10
 
11
11
  /**
12
12
  * parseDsn parses "https://<version>:<hmac>@<host>/v1/sentry/<projectId>" into its
@@ -102,12 +102,19 @@ declare function uuidv7Time(id: string): number;
102
102
  * (POST /v1/sentry/projects with X-Org-Id), then add its `dsn` here keyed by the
103
103
  * product name the app passes to `createAnalytics`.
104
104
  */
105
- /** PRODUCT_DSN maps a `product` to the DSN its errors are submitted to. */
106
- declare const PRODUCT_DSN: Readonly<Record<string, string>>;
107
- /** dsnForProduct resolves the registered DSN for a product, or undefined when the
108
- * product has no project yet which leaves the error plane inert rather than
109
- * guessing a destination and silently posting a surface's errors into the wrong
110
- * project. */
105
+ /** PRODUCT_PROJECT maps a `product` to its Sentry project id. The DSN's KEY is no
106
+ * longer a per-project secret — it is the ONE org publishable key (below), so a
107
+ * surface's errors ride the SAME key its events do. The id only names WHICH
108
+ * project the errors group under, and cloud auto-provisions that project on first
109
+ * keyed ingest, so a new id needs nothing minted. `site` lives in the `hanzo-ai`
110
+ * project — an explicit map, because the projects predate this and do not derive
111
+ * cleanly from the product name. */
112
+ declare const PRODUCT_PROJECT: Readonly<Record<string, string>>;
113
+ /** dsnForProduct builds the product's Sentry DSN — the ONE org publishable key at
114
+ * its project's envelope endpoint — or undefined when the product has no project
115
+ * yet, which leaves the error plane inert rather than posting into the wrong one.
116
+ * Same key as the event stream: cloud resolves it to the org and attributes the
117
+ * errors there. */
111
118
  declare function dsnForProduct(product: string | undefined): string | undefined;
112
119
 
113
120
  /** redactSecrets removes known secret shapes. Always applied. */
@@ -290,4 +297,4 @@ declare function hasAttribution(a: Attribution): boolean;
290
297
  /** isoWeek returns the ISO-8601 week label, e.g. "2026-W28". */
291
298
  declare function isoWeek(d: Date): string;
292
299
 
293
- export { Attribution, COHORTS, CaptureErrorOptions, Cohort, type CohortDef, Dsn, EVENTS, type ErrorIdentity, type EventName, FUNNELS, type FunnelDef, type FunnelId, type FunnelStep, GOALS, type GoalDef, PAGEVIEW, PRODUCTS, PRODUCT_DSN, type ProductId, SentryEvent, SentryFrame, VERSION, buildEnvelope, buildSentryEvent, deriveChannel, dsnForProduct, eventsOf, framesFromStack, getCohort, getFirstTouch, hasAttribution, hostOf, isoWeek, parseAttribution, parseDsn, redactSecrets, scrubPII, scrubText, hzUuidv7 as uuidv7, uuidv7Time };
300
+ export { Attribution, COHORTS, CaptureErrorOptions, Cohort, type CohortDef, Dsn, EVENTS, type ErrorIdentity, type EventName, FUNNELS, type FunnelDef, type FunnelId, type FunnelStep, GOALS, type GoalDef, PAGEVIEW, PRODUCTS, PRODUCT_PROJECT, type ProductId, SentryEvent, SentryFrame, VERSION, buildEnvelope, buildSentryEvent, deriveChannel, dsnForProduct, eventsOf, framesFromStack, getCohort, getFirstTouch, hasAttribution, hostOf, isoWeek, parseAttribution, parseDsn, redactSecrets, scrubPII, scrubText, hzUuidv7 as uuidv7, uuidv7Time };
package/dist/index.mjs CHANGED
@@ -72,17 +72,23 @@ function isoWeek(d) {
72
72
  }
73
73
 
74
74
  // src/dsn.ts
75
- var PRODUCT_DSN = Object.freeze({
76
- // hanzo-console — console.hanzo.ai (also served embedded by the cloud binary)
77
- console: "https://1:0c8054dbde157f4f420c56b58660052b2ad782293c4de1d606ef8fbc46a0bf34@api.hanzo.ai/v1/sentry/019fa40b-94ae-7f1d-8f7b-e92f123fad42",
78
- // hanzo-app — hanzo.app
79
- app: "https://1:b3e1173125568c80f91ef4b1fabbbd2d7e22341de02b33ce7e22ef4fc16a196e@api.hanzo.ai/v1/sentry/019f9b1e-57eb-7171-9d92-72c0b85e4b4b",
80
- // hanzo-ai — hanzo.ai (the marketing site; `site` is the product name it declares)
81
- site: "https://1:d9cbfb844958bd7ef2a455600f00fbf237fbd71b75c1504f137773096d6aa53f@api.hanzo.ai/v1/sentry/019f9b1e-5785-7359-ad0b-f75db8e58c99"
75
+ var PRODUCT_PROJECT = Object.freeze({
76
+ console: "019fa40b-94ae-7f1d-8f7b-e92f123fad42",
77
+ // console.hanzo.ai
78
+ app: "019f9b1e-57eb-7171-9d92-72c0b85e4b4b",
79
+ // hanzo.app
80
+ site: "019f9b1e-5785-7359-ad0b-f75db8e58c99"
81
+ // hanzo.ai (marketing; product `site`)
82
82
  });
83
83
  function dsnForProduct(product) {
84
84
  if (!product) return void 0;
85
- return PRODUCT_DSN[product];
85
+ const projectId = PRODUCT_PROJECT[product];
86
+ if (!projectId) return void 0;
87
+ return `https://${HANZO_PUBLISHABLE_KEY}@api.hanzo.ai/v1/sentry/${projectId}`;
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;
86
92
  }
87
93
 
88
94
  // src/events.ts
@@ -365,7 +371,7 @@ function uuidv7Time(id) {
365
371
  }
366
372
 
367
373
  // src/version.ts
368
- var VERSION = "0.3.17";
374
+ var VERSION = "0.3.19";
369
375
 
370
376
  // src/sentry.ts
371
377
  var MAX_FRAMES = 50;
@@ -728,22 +734,24 @@ var Analytics = class {
728
734
  enabled: true,
729
735
  captureErrors: true,
730
736
  ...config,
731
- // The publishable key resolves the SAME way the DSN below does: an explicit
732
- // config wins, else the inlined build-time env.
733
- //
734
- // NEXT_PUBLIC_PUBLISHABLE_KEY is that env, and it is the name the fleet
735
- // ALREADY carries end to end KMS holds deploy/PUBLISHABLE_KEY, each
736
- // Dockerfile takes it as the PUBLISHABLE_KEY build-arg and re-exports it
737
- // with the NEXT_PUBLIC_ prefix Next needs to inline it. Reading anything
738
- // else here would add a fourth spelling of one value.
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.
739
745
  //
740
- // Without this the key was the one piece of wiring a surface could not
741
- // declare the way it declares every other piece, so a surface that shipped
742
- // without passing it in code sent its beacons unattributed and an
743
- // unattributed write is refused (401 ingest_key_required), which is silent
744
- // in the page and invisible until you read the warehouse and find the host
745
- // missing entirely.
746
- ingestKey: config.ingestKey ?? readEnv("NEXT_PUBLIC_PUBLISHABLE_KEY")
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)
747
755
  };
748
756
  this.transport = config.transport ?? new DefaultTransport();
749
757
  this.dsn = parseDsn(config.dsn ?? readEnvDsn() ?? dsnForProduct(this.cfg.product));
@@ -1140,6 +1148,6 @@ var COHORTS = {
1140
1148
  * reformat of one copy is a diff against the other.
1141
1149
  */
1142
1150
 
1143
- export { Analytics, COHORTS, EVENTS, FUNNELS, GOALS, PAGEVIEW, PRODUCTS, PRODUCT_DSN, VERSION, buildEnvelope, buildSentryEvent, createAnalytics, deriveChannel, dsnForProduct, eventsOf, framesFromStack, getCohort, getFirstTouch, hasAttribution, hostOf, isoWeek, parseAttribution, parseDsn, redactSecrets, scrubPII, scrubText, hzUuidv7 as uuidv7, uuidv7Time };
1151
+ export { Analytics, COHORTS, EVENTS, FUNNELS, GOALS, PAGEVIEW, PRODUCTS, PRODUCT_PROJECT, VERSION, buildEnvelope, buildSentryEvent, createAnalytics, deriveChannel, dsnForProduct, eventsOf, framesFromStack, getCohort, getFirstTouch, hasAttribution, hostOf, isoWeek, parseAttribution, parseDsn, redactSecrets, scrubPII, scrubText, hzUuidv7 as uuidv7, uuidv7Time };
1144
1152
  //# sourceMappingURL=index.mjs.map
1145
1153
  //# sourceMappingURL=index.mjs.map