@hanzo/event 0.3.20 → 0.3.22

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
@@ -1,4 +1,5 @@
1
1
  import { createContext, Component, useMemo, useEffect, createElement, useContext, useRef } from 'react';
2
+ import { PAGEVIEW, EXCEPTION } from '@hanzo/events';
2
3
 
3
4
  // src/react.tsx
4
5
 
@@ -76,20 +77,12 @@ var PRODUCT_PROJECT = Object.freeze({
76
77
  site: "019f9b1e-5785-7359-ad0b-f75db8e58c99"
77
78
  // hanzo.ai (marketing; product `site`)
78
79
  });
79
- function dsnForProduct(product) {
80
- if (!product) return void 0;
80
+ function dsnForProduct(product, key) {
81
+ if (!product || !key) return void 0;
81
82
  const projectId = PRODUCT_PROJECT[product];
82
83
  if (!projectId) return void 0;
83
- return `https://${HANZO_PUBLISHABLE_KEY}@api.hanzo.ai/v1/sentry/${projectId}`;
84
+ return `https://${key}@api.hanzo.ai/v1/sentry/${projectId}`;
84
85
  }
85
- var HANZO_PUBLISHABLE_KEY = "pk-live-c88649f1085fb6ad441d8a0072933a9b";
86
- function defaultPublishableKey(host) {
87
- return host === void 0 || host === "https://api.hanzo.ai" ? HANZO_PUBLISHABLE_KEY : void 0;
88
- }
89
-
90
- // src/events.ts
91
- var PAGEVIEW = "$pageview";
92
- var EXCEPTION = "$exception";
93
86
 
94
87
  // src/scrub.ts
95
88
  var REDACTED = "[redacted]";
@@ -314,7 +307,7 @@ function hzAnonId() {
314
307
  }
315
308
 
316
309
  // src/version.ts
317
- var VERSION = "0.3.20";
310
+ var VERSION = "0.3.21";
318
311
 
319
312
  // src/sentry.ts
320
313
  var MAX_FRAMES = 50;
@@ -765,27 +758,24 @@ var Analytics = class {
765
758
  enabled: true,
766
759
  captureErrors: true,
767
760
  ...config,
768
- // The publishable key resolves the SAME way the DSN below does, and now
769
- // ends the SAME way too — in a baked default, so declaring nothing is
770
- // enough. Most specific first:
761
+ // The publishable key resolves from ONE live source, never a literal baked
762
+ // beside the code. Most specific first:
771
763
  // 1. an explicit `ingestKey` in config;
772
764
  // 2. NEXT_PUBLIC_PUBLISHABLE_KEY, the inlined build-time env the fleet
773
- // carries end to end (KMS `deploy/PUBLISHABLE_KEY` -> the PUBLISHABLE_KEY
774
- // build-arg -> the NEXT_PUBLIC_ prefix Next inlines);
775
- // 3. the hanzo org key baked in `dsn.ts`, on the hanzo cloud only.
765
+ // carries end to end KMS `deploy/PUBLISHABLE_KEY` -> the PUBLISHABLE_KEY
766
+ // build-arg -> the NEXT_PUBLIC_ prefix Next inlines.
776
767
  //
777
- // (3) is why this is `publishable_key for all`: a hanzo surface that passes
778
- // no key in code and inlines no env still emits attributed, exactly as
779
- // declaring `product` is enough for the DSN. Without it that surface sent
780
- // its beacons to `$public` which drops every track/identify/group and
781
- // still answers 200 silent in the page and invisible until you read the
782
- // warehouse and find the host missing entirely. A white-label surface on
783
- // its own cloud (a non-default host) gets no default, so the org this
784
- // attributes to is never the wrong one.
785
- ingestKey: config.ingestKey ?? readEnv("NEXT_PUBLIC_PUBLISHABLE_KEY") ?? defaultPublishableKey(config.host ?? DEFAULT_HOST)
768
+ // A surface that provides neither has no key, and its anonymous traffic
769
+ // files under `$public` (which drops track/identify/group and answers 200);
770
+ // the fix is to give it the KMS-sourced env, not to hardcode the org key
771
+ // here. The key is a credential-class value: its home is KMS, and the ONE
772
+ // build reads it from there.
773
+ ingestKey: config.ingestKey ?? readEnv("NEXT_PUBLIC_PUBLISHABLE_KEY")
786
774
  };
787
775
  this.transport = config.transport ?? new DefaultTransport();
788
- this.dsn = parseDsn(config.dsn ?? readEnvDsn() ?? dsnForProduct(this.cfg.product));
776
+ this.dsn = parseDsn(
777
+ config.dsn ?? readEnvDsn() ?? dsnForProduct(this.cfg.product, this.cfg.ingestKey)
778
+ );
789
779
  }
790
780
  /** errorPlaneEnabled reports whether captured exceptions can actually reach the
791
781
  * error host. False means a DSN was never configured — the documented