@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/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.20";
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 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. */
118
- declare function dsnForProduct(product: string | undefined): string | undefined;
113
+ /** dsnForProduct builds the product's Sentry DSN from the caller's resolved
114
+ * publishable `key` and the product's projectthe 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.20";
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 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. */
118
- declare function dsnForProduct(product: string | undefined): string | undefined;
113
+ /** dsnForProduct builds the product's Sentry DSN from the caller's resolved
114
+ * publishable `key` and the product's projectthe 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://${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;
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.20";
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 the SAME way the DSN below does, and now
827
- // ends the SAME way too — in a baked default, so declaring nothing is
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 (KMS `deploy/PUBLISHABLE_KEY` -> the PUBLISHABLE_KEY
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
- // (3) is why this is `publishable_key for all`: a hanzo surface that passes
836
- // no key in code and inlines no env still emits attributed, exactly as
837
- // declaring `product` is enough for the DSN. Without it that surface sent
838
- // its beacons to `$public` which drops every track/identify/group and
839
- // still answers 200 silent in the page and invisible until you read the
840
- // warehouse and find the host missing entirely. A white-label surface on
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(config.dsn ?? readEnvDsn() ?? dsnForProduct(this.cfg.product));
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