@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.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var react = require('react');
4
+ var events = require('@hanzo/events');
4
5
 
5
6
  // src/react.tsx
6
7
 
@@ -78,20 +79,12 @@ var PRODUCT_PROJECT = Object.freeze({
78
79
  site: "019f9b1e-5785-7359-ad0b-f75db8e58c99"
79
80
  // hanzo.ai (marketing; product `site`)
80
81
  });
81
- function dsnForProduct(product) {
82
- if (!product) return void 0;
82
+ function dsnForProduct(product, key) {
83
+ if (!product || !key) return void 0;
83
84
  const projectId = PRODUCT_PROJECT[product];
84
85
  if (!projectId) return void 0;
85
- return `https://${HANZO_PUBLISHABLE_KEY}@api.hanzo.ai/v1/sentry/${projectId}`;
86
+ return `https://${key}@api.hanzo.ai/v1/sentry/${projectId}`;
86
87
  }
87
- var HANZO_PUBLISHABLE_KEY = "pk-live-c88649f1085fb6ad441d8a0072933a9b";
88
- function defaultPublishableKey(host) {
89
- return host === void 0 || host === "https://api.hanzo.ai" ? HANZO_PUBLISHABLE_KEY : void 0;
90
- }
91
-
92
- // src/events.ts
93
- var PAGEVIEW = "$pageview";
94
- var EXCEPTION = "$exception";
95
88
 
96
89
  // src/scrub.ts
97
90
  var REDACTED = "[redacted]";
@@ -316,7 +309,7 @@ function hzAnonId() {
316
309
  }
317
310
 
318
311
  // src/version.ts
319
- var VERSION = "0.3.20";
312
+ var VERSION = "0.3.21";
320
313
 
321
314
  // src/sentry.ts
322
315
  var MAX_FRAMES = 50;
@@ -767,27 +760,24 @@ var Analytics = class {
767
760
  enabled: true,
768
761
  captureErrors: true,
769
762
  ...config,
770
- // The publishable key resolves the SAME way the DSN below does, and now
771
- // ends the SAME way too — in a baked default, so declaring nothing is
772
- // enough. Most specific first:
763
+ // The publishable key resolves from ONE live source, never a literal baked
764
+ // beside the code. Most specific first:
773
765
  // 1. an explicit `ingestKey` in config;
774
766
  // 2. NEXT_PUBLIC_PUBLISHABLE_KEY, the inlined build-time env the fleet
775
- // carries end to end (KMS `deploy/PUBLISHABLE_KEY` -> the PUBLISHABLE_KEY
776
- // build-arg -> the NEXT_PUBLIC_ prefix Next inlines);
777
- // 3. the hanzo org key baked in `dsn.ts`, on the hanzo cloud only.
767
+ // carries end to end KMS `deploy/PUBLISHABLE_KEY` -> the PUBLISHABLE_KEY
768
+ // build-arg -> the NEXT_PUBLIC_ prefix Next inlines.
778
769
  //
779
- // (3) is why this is `publishable_key for all`: a hanzo surface that passes
780
- // no key in code and inlines no env still emits attributed, exactly as
781
- // declaring `product` is enough for the DSN. Without it that surface sent
782
- // its beacons to `$public` which drops every track/identify/group and
783
- // still answers 200 silent in the page and invisible until you read the
784
- // warehouse and find the host missing entirely. A white-label surface on
785
- // its own cloud (a non-default host) gets no default, so the org this
786
- // attributes to is never the wrong one.
787
- ingestKey: config.ingestKey ?? readEnv("NEXT_PUBLIC_PUBLISHABLE_KEY") ?? defaultPublishableKey(config.host ?? DEFAULT_HOST)
770
+ // A surface that provides neither has no key, and its anonymous traffic
771
+ // files under `$public` (which drops track/identify/group and answers 200);
772
+ // the fix is to give it the KMS-sourced env, not to hardcode the org key
773
+ // here. The key is a credential-class value: its home is KMS, and the ONE
774
+ // build reads it from there.
775
+ ingestKey: config.ingestKey ?? readEnv("NEXT_PUBLIC_PUBLISHABLE_KEY")
788
776
  };
789
777
  this.transport = config.transport ?? new DefaultTransport();
790
- this.dsn = parseDsn(config.dsn ?? readEnvDsn() ?? dsnForProduct(this.cfg.product));
778
+ this.dsn = parseDsn(
779
+ config.dsn ?? readEnvDsn() ?? dsnForProduct(this.cfg.product, this.cfg.ingestKey)
780
+ );
791
781
  }
792
782
  /** errorPlaneEnabled reports whether captured exceptions can actually reach the
793
783
  * error host. False means a DSN was never configured — the documented
@@ -842,7 +832,7 @@ var Analytics = class {
842
832
  /** pageview records a $pageview for the current (or given) location. */
843
833
  pageview(path, properties) {
844
834
  const p = path ?? (isBrowser() ? window.location.pathname : void 0);
845
- this.enqueue("pageview", PAGEVIEW, { path: p, properties });
835
+ this.enqueue("pageview", events.PAGEVIEW, { path: p, properties });
846
836
  }
847
837
  /** capture records a named product event with optional properties. Commerce
848
838
  * fields (productId/quantity/revenue/currency) may be passed for order events. */
@@ -875,7 +865,7 @@ var Analytics = class {
875
865
  const handled = context?.handled ?? true;
876
866
  const ex = normalizeError2(err);
877
867
  ex.handled = handled;
878
- this.enqueue("event", EXCEPTION, {
868
+ this.enqueue("event", events.EXCEPTION, {
879
869
  error: ex,
880
870
  properties: {
881
871
  ...context?.properties,