@hanzo/event 0.3.26 → 0.3.27
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/{core-DO8tBUy7.d.cts → core-usULsfUB.d.cts} +16 -4
- package/dist/{core-DO8tBUy7.d.ts → core-usULsfUB.d.ts} +16 -4
- package/dist/index.cjs +43 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +43 -5
- package/dist/index.mjs.map +1 -1
- package/dist/react.cjs +45 -10
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.mjs +46 -11
- package/dist/react.mjs.map +1 -1
- package/hz.js +1 -1
- package/package.json +1 -1
- package/src/core.ts +93 -17
- package/src/react.tsx +7 -7
- package/src/stream.test.ts +169 -0
- package/src/version.ts +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as Cohort, A as Attribution, S as SentryEvent, D as Dsn, a as CaptureErrorOptions, b as SentryFrame, E as ExceptionEntry, c as SentryLevel, d as ExceptionProperties } from './core-
|
|
2
|
-
export { e as Analytics, f as AnalyticsConfig, g as EventKind, h as Exception, i as ExceptionFrame, T as Transport, W as WireEvent, j as createAnalytics } from './core-
|
|
1
|
+
import { C as Cohort, A as Attribution, S as SentryEvent, D as Dsn, a as CaptureErrorOptions, b as SentryFrame, E as ExceptionEntry, c as SentryLevel, d as ExceptionProperties } from './core-usULsfUB.cjs';
|
|
2
|
+
export { e as Analytics, f as AnalyticsConfig, g as EventKind, h as Exception, i as ExceptionFrame, T as Transport, W as WireEvent, j as createAnalytics } from './core-usULsfUB.cjs';
|
|
3
3
|
import { FunnelId } from '@hanzo/events';
|
|
4
4
|
export { EVENTS, EXCEPTION, EventName, FUNNELS, FunnelDef, FunnelId, FunnelStep, PAGEVIEW, PRODUCTS, ProductId, eventsOf } from '@hanzo/events';
|
|
5
5
|
|
|
@@ -8,7 +8,7 @@ declare function getFirstTouch(): Attribution | undefined;
|
|
|
8
8
|
/** Read persisted cohort dimensions. */
|
|
9
9
|
declare function getCohort(): Cohort | undefined;
|
|
10
10
|
|
|
11
|
-
declare const VERSION = "0.3.
|
|
11
|
+
declare const VERSION = "0.3.27";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* parseDsn parses "https://<version>:<hmac>@<host>/v1/sentry/<projectId>" into its
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as Cohort, A as Attribution, S as SentryEvent, D as Dsn, a as CaptureErrorOptions, b as SentryFrame, E as ExceptionEntry, c as SentryLevel, d as ExceptionProperties } from './core-
|
|
2
|
-
export { e as Analytics, f as AnalyticsConfig, g as EventKind, h as Exception, i as ExceptionFrame, T as Transport, W as WireEvent, j as createAnalytics } from './core-
|
|
1
|
+
import { C as Cohort, A as Attribution, S as SentryEvent, D as Dsn, a as CaptureErrorOptions, b as SentryFrame, E as ExceptionEntry, c as SentryLevel, d as ExceptionProperties } from './core-usULsfUB.js';
|
|
2
|
+
export { e as Analytics, f as AnalyticsConfig, g as EventKind, h as Exception, i as ExceptionFrame, T as Transport, W as WireEvent, j as createAnalytics } from './core-usULsfUB.js';
|
|
3
3
|
import { FunnelId } from '@hanzo/events';
|
|
4
4
|
export { EVENTS, EXCEPTION, EventName, FUNNELS, FunnelDef, FunnelId, FunnelStep, PAGEVIEW, PRODUCTS, ProductId, eventsOf } from '@hanzo/events';
|
|
5
5
|
|
|
@@ -8,7 +8,7 @@ declare function getFirstTouch(): Attribution | undefined;
|
|
|
8
8
|
/** Read persisted cohort dimensions. */
|
|
9
9
|
declare function getCohort(): Cohort | undefined;
|
|
10
10
|
|
|
11
|
-
declare const VERSION = "0.3.
|
|
11
|
+
declare const VERSION = "0.3.27";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* parseDsn parses "https://<version>:<hmac>@<host>/v1/sentry/<projectId>" into its
|
package/dist/index.mjs
CHANGED
|
@@ -318,7 +318,7 @@ function uuidv7Time(id) {
|
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
// src/version.ts
|
|
321
|
-
var VERSION = "0.3.
|
|
321
|
+
var VERSION = "0.3.27";
|
|
322
322
|
|
|
323
323
|
// src/sentry.ts
|
|
324
324
|
var MAX_FRAMES = 50;
|
|
@@ -795,6 +795,20 @@ var Analytics = class {
|
|
|
795
795
|
config.dsn ?? readEnvDsn() ?? dsnForProduct(this.cfg.product, this.cfg.ingestKey)
|
|
796
796
|
);
|
|
797
797
|
}
|
|
798
|
+
/** adopt gives this client a credential it does not have. The key belongs to
|
|
799
|
+
* the stream, not to whichever caller happened to ask for the handle first,
|
|
800
|
+
* so a later caller carrying one hands it over. The error plane derives from
|
|
801
|
+
* the key, so it comes up here too when it was inert for want of one.
|
|
802
|
+
* Present fields are never overwritten: the first caller's key stays. */
|
|
803
|
+
adopt(config) {
|
|
804
|
+
if (config.ingestKey && !this.cfg.ingestKey) this.cfg.ingestKey = config.ingestKey;
|
|
805
|
+
if (config.getToken && !this.cfg.getToken) this.cfg.getToken = config.getToken;
|
|
806
|
+
if (!this.dsn) {
|
|
807
|
+
this.dsn = parseDsn(
|
|
808
|
+
config.dsn ?? readEnvDsn() ?? dsnForProduct(this.cfg.product, this.cfg.ingestKey)
|
|
809
|
+
);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
798
812
|
/** errorPlaneEnabled reports whether captured exceptions can actually reach the
|
|
799
813
|
* error host. False means a DSN was never configured — the documented
|
|
800
814
|
* fail-safe. Exposed so an app (or a test) can assert its wiring instead of
|
|
@@ -845,9 +859,14 @@ var Analytics = class {
|
|
|
845
859
|
group(groupId, traits) {
|
|
846
860
|
this.enqueue("group", void 0, { groupId, properties: traits });
|
|
847
861
|
}
|
|
848
|
-
/** pageview records a $pageview for the current (or given) location
|
|
862
|
+
/** pageview records a $pageview for the current (or given) location, once per
|
|
863
|
+
* view. A view is the path plus the full location, so a query or hash change
|
|
864
|
+
* is a new one and a repeat call for the same place is not. */
|
|
849
865
|
pageview(path, properties) {
|
|
850
866
|
const p = path ?? (isBrowser() ? window.location.pathname : void 0);
|
|
867
|
+
const view = (p ?? "") + "\0" + (isBrowser() ? window.location.href : "");
|
|
868
|
+
if (view === this.counted) return;
|
|
869
|
+
this.counted = view;
|
|
851
870
|
this.enqueue("pageview", PAGEVIEW, { path: p, properties });
|
|
852
871
|
}
|
|
853
872
|
/** capture records a named product event with optional properties. Commerce
|
|
@@ -908,8 +927,8 @@ var Analytics = class {
|
|
|
908
927
|
* front door POST /v1/event, body { batch: [Event…] }. beacon=true selects the
|
|
909
928
|
* unload-safe transport. Auth is orthogonal to the wire:
|
|
910
929
|
*
|
|
911
|
-
* • publishable key set → rides
|
|
912
|
-
*
|
|
930
|
+
* • publishable key set → rides ?ingest_key=pk-… on both sends, keeping each
|
|
931
|
+
* a CORS-simple request that any origin may send.
|
|
913
932
|
* • else a bearer JWT rides Authorization (fetch only — sendBeacon cannot
|
|
914
933
|
* carry a header, so token apps fall back to keepalive fetch on unload).
|
|
915
934
|
* • else a cookie app rides same-origin credentials (beacon carries the
|
|
@@ -1032,8 +1051,27 @@ var Analytics = class {
|
|
|
1032
1051
|
}
|
|
1033
1052
|
}
|
|
1034
1053
|
};
|
|
1054
|
+
var CLIENTS = /* @__PURE__ */ Symbol.for("hanzo.event.clients");
|
|
1055
|
+
function registry() {
|
|
1056
|
+
const g = globalThis;
|
|
1057
|
+
const existing = g[CLIENTS];
|
|
1058
|
+
if (existing) return existing;
|
|
1059
|
+
const fresh = /* @__PURE__ */ new Map();
|
|
1060
|
+
g[CLIENTS] = fresh;
|
|
1061
|
+
return fresh;
|
|
1062
|
+
}
|
|
1035
1063
|
function createAnalytics(config) {
|
|
1036
|
-
return new Analytics(config);
|
|
1064
|
+
if (!isBrowser()) return new Analytics(config);
|
|
1065
|
+
const key = (config.host ?? DEFAULT_HOST) + "\0" + config.product;
|
|
1066
|
+
const clients = registry();
|
|
1067
|
+
const existing = clients.get(key);
|
|
1068
|
+
if (existing) {
|
|
1069
|
+
existing.adopt(config);
|
|
1070
|
+
return existing;
|
|
1071
|
+
}
|
|
1072
|
+
const fresh = new Analytics(config);
|
|
1073
|
+
clients.set(key, fresh);
|
|
1074
|
+
return fresh;
|
|
1037
1075
|
}
|
|
1038
1076
|
|
|
1039
1077
|
// src/goals.ts
|