@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.cjs +33 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -8
- package/dist/index.d.ts +15 -8
- package/dist/index.mjs +33 -25
- package/dist/index.mjs.map +1 -1
- package/dist/react.cjs +32 -24
- package/dist/react.cjs.map +1 -1
- package/dist/react.mjs +32 -24
- package/dist/react.mjs.map +1 -1
- package/hz.js +7 -3
- package/package.json +1 -1
- package/src/core.test.ts +37 -1
- package/src/core.ts +21 -16
- package/src/dsn.test.ts +14 -11
- package/src/dsn.ts +45 -14
- package/src/hz.test.ts +10 -1
- package/src/index.ts +1 -1
- package/src/version.ts +1 -1
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.
|
|
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
|
-
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
*
|
|
109
|
-
*
|
|
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,
|
|
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.
|
|
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
|
-
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
*
|
|
109
|
-
*
|
|
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,
|
|
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
|
|
76
|
-
|
|
77
|
-
console
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
|
732
|
-
//
|
|
733
|
-
//
|
|
734
|
-
//
|
|
735
|
-
//
|
|
736
|
-
//
|
|
737
|
-
//
|
|
738
|
-
//
|
|
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
|
-
//
|
|
741
|
-
//
|
|
742
|
-
//
|
|
743
|
-
//
|
|
744
|
-
// in the page and invisible until you read the
|
|
745
|
-
// missing entirely.
|
|
746
|
-
|
|
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,
|
|
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
|