@hanzo/event 0.3.49 → 0.3.50
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.d.ts.map +1 -1
- package/dist/index.cjs +29 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +29 -8
- package/dist/index.mjs.map +1 -1
- package/dist/react.cjs +8 -7
- package/dist/react.cjs.map +1 -1
- package/dist/react.mjs +8 -7
- package/dist/react.mjs.map +1 -1
- package/dist/tags.d.ts +8 -0
- package/dist/tags.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core.test.ts +5 -5
- package/src/core.ts +15 -17
- package/src/index.ts +1 -1
- package/src/org.test.ts +9 -0
- package/src/org.ts +1 -1
- package/src/tags.ts +28 -0
package/dist/index.d.cts
CHANGED
|
@@ -10,7 +10,7 @@ export type { EventName } from './events';
|
|
|
10
10
|
export { CONSENT_COOKIE, CONSENT_EVENT, acceptAll, asks, gpc, read as readConsent, refused, region, rejectAll, render as renderConsent, save as saveConsent, stored as storedConsent, } from './consent';
|
|
11
11
|
export type { Choice, Region } from './consent';
|
|
12
12
|
export { CLICK_IDS, capture as captureClick, touch } from './touch';
|
|
13
|
-
export { start as startTags, track, mirror, reach, visit, SITE_KEY } from './tags';
|
|
13
|
+
export { start as startTags, ready as tagsReady, track, mirror, reach, visit, SITE_KEY } from './tags';
|
|
14
14
|
export type { BrowserTag, TagOptions } from './tags';
|
|
15
15
|
export { commerceItem, worth } from './items';
|
|
16
16
|
export type { CommerceItem, PlanLine } from './items';
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type { EventName } from './events';
|
|
|
10
10
|
export { CONSENT_COOKIE, CONSENT_EVENT, acceptAll, asks, gpc, read as readConsent, refused, region, rejectAll, render as renderConsent, save as saveConsent, stored as storedConsent, } from './consent';
|
|
11
11
|
export type { Choice, Region } from './consent';
|
|
12
12
|
export { CLICK_IDS, capture as captureClick, touch } from './touch';
|
|
13
|
-
export { start as startTags, track, mirror, reach, visit, SITE_KEY } from './tags';
|
|
13
|
+
export { start as startTags, ready as tagsReady, track, mirror, reach, visit, SITE_KEY } from './tags';
|
|
14
14
|
export type { BrowserTag, TagOptions } from './tags';
|
|
15
15
|
export { commerceItem, worth } from './items';
|
|
16
16
|
export type { CommerceItem, PlanLine } from './items';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EACL,SAAS,EACT,eAAe,EACf,YAAY,EACZ,OAAO,EACP,SAAS,EACT,aAAa,GACd,MAAM,QAAQ,CAAA;AACf,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAClE,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACtF,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,EACL,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,IAAI,WAAW,EAAE,OAAO,EAAE,MAAM,EACzF,SAAS,EAAE,MAAM,IAAI,aAAa,EAAE,IAAI,IAAI,WAAW,EAAE,MAAM,IAAI,aAAa,GAC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ORG_DOMAIN = Object.freeze({
|
|
|
110
110
|
zoo: Object.freeze(["zoo.ngo", "zoo.network", "zoolabs.id", "zoolabs.io"])
|
|
111
111
|
});
|
|
112
112
|
var ORG_KEY = Object.freeze({
|
|
113
|
-
hanzo: "pk-
|
|
113
|
+
hanzo: "pk-CmfLA2K6kvsPflrS9DSkt06H_kSoQB_21sjedt6VJdc",
|
|
114
114
|
lux: "pk-gUZp6ZVfhJzSwK-rb4oLbVkpCnMBx5uSCpxf_5yEhQk",
|
|
115
115
|
zoo: "pk-3TKpKnERV9AQSsBUERWkZejC1O1mUxc1jRzsP3MPbs4"
|
|
116
116
|
});
|
|
@@ -632,7 +632,7 @@ function stripLink(href) {
|
|
|
632
632
|
}
|
|
633
633
|
|
|
634
634
|
// package.json
|
|
635
|
-
var version = "0.3.
|
|
635
|
+
var version = "0.3.50";
|
|
636
636
|
|
|
637
637
|
// src/version.ts
|
|
638
638
|
var VERSION = version;
|
|
@@ -656,6 +656,7 @@ function normalizeError2(err) {
|
|
|
656
656
|
const frames = framesFromStack(n.stack).slice(-50).map((f) => ({ function: f.function, file: f.filename, line: f.lineno, column: f.colno }));
|
|
657
657
|
return { type: n.name, message: n.message, stack: n.stack, frames };
|
|
658
658
|
}
|
|
659
|
+
var viewport = () => isBrowser() ? { screen: `${window.screen?.width ?? 0}x${window.screen?.height ?? 0}`, language: navigator.language || "" } : {};
|
|
659
660
|
var isBrowser = () => typeof window !== "undefined" && typeof document !== "undefined";
|
|
660
661
|
function serializeBatch(batch) {
|
|
661
662
|
try {
|
|
@@ -690,13 +691,13 @@ var DefaultTransport = class {
|
|
|
690
691
|
}
|
|
691
692
|
}
|
|
692
693
|
if (typeof fetch !== "function") return;
|
|
693
|
-
const simple = opts.ingestKey !== void 0 && opts.contentType === void 0;
|
|
694
|
+
const simple = opts.ingestKey !== void 0 && opts.token === void 0 && opts.contentType === void 0;
|
|
694
695
|
const headers = {
|
|
695
696
|
"Content-Type": simple ? BEACON_CONTENT_TYPE : opts.contentType ?? "application/json"
|
|
696
697
|
};
|
|
697
|
-
const bearer = simple ? void 0 : opts.
|
|
698
|
+
const bearer = simple ? void 0 : opts.token ?? opts.ingestKey;
|
|
698
699
|
if (bearer) headers.Authorization = `Bearer ${bearer}`;
|
|
699
|
-
void fetch(
|
|
700
|
+
void fetch(opts.ingestKey ? appendQuery(url, "ingest_key", opts.ingestKey) : url, {
|
|
700
701
|
method: "POST",
|
|
701
702
|
headers,
|
|
702
703
|
body,
|
|
@@ -836,7 +837,7 @@ var Analytics = class {
|
|
|
836
837
|
const view = (p ?? "") + "\0" + (isBrowser() ? window.location.href : "");
|
|
837
838
|
if (view === this.counted) return;
|
|
838
839
|
this.counted = view;
|
|
839
|
-
this.enqueue("pageview", PAGEVIEW, { path: p, properties });
|
|
840
|
+
this.enqueue("pageview", PAGEVIEW, { path: p, properties: { ...viewport(), ...properties } });
|
|
840
841
|
}
|
|
841
842
|
/** capture records a named product event with optional properties. Commerce
|
|
842
843
|
* fields (productId/quantity/revenue/currency) may be passed for order events. */
|
|
@@ -892,7 +893,7 @@ var Analytics = class {
|
|
|
892
893
|
this.queue = [];
|
|
893
894
|
this.clearTimer();
|
|
894
895
|
const token = this.cfg.getToken?.() ?? void 0;
|
|
895
|
-
const key =
|
|
896
|
+
const key = this.cfg.ingestKey?.trim() || void 0;
|
|
896
897
|
const useBeacon = beacon && !token;
|
|
897
898
|
const body = serializeBatch(batch);
|
|
898
899
|
if (body === null) {
|
|
@@ -1200,6 +1201,11 @@ var SITE_KEY = Object.freeze({
|
|
|
1200
1201
|
"platform.hanzo.ai": "pk-My1RpZLEUnTj8vAdPbWKYdDUuhxZJ4dVjHcwjZN4rZ8",
|
|
1201
1202
|
"docs.hanzo.ai": "pk-jukhtjMT2ymoeBDAeFjINQWlBv-v9sNn1TPztiCrrwk",
|
|
1202
1203
|
"hanzo.bot": "pk-W5d7Mn7ZukT7igyscIy6Pqe8JpA0Ge604Yn4xNR4JCU",
|
|
1204
|
+
"hanzo.chat": "pk-ATxWeB2jNyRSxDgqnkGoDj3CCbzrmTxSktUh9zlrO-E",
|
|
1205
|
+
"hanzo.id": "pk-_GVF3KlaqprlPHDumBMRFeFU1lIGOaarQfgimNVDIo8",
|
|
1206
|
+
"hanzo.industries": "pk-Vh1wvL2HqIAv9qpVvmrznTI9uMHrTD-jyIC-vnlBsgY",
|
|
1207
|
+
"hanzo.market": "pk-DN3xQFa0H61epUVg9OkiOYLzCdteNt9hE6f-S-ednjQ",
|
|
1208
|
+
"hanzo.network": "pk-YJ2eiA_7ckLStMPte8Ar8FsmRp_ycmeIeRbpGprZYmM",
|
|
1203
1209
|
"cloud.hanzo.ai": "pk-RAfEGHPoNdCEU9fnA_cPd_Xo9Tci44rlYQV9xuJ1Ob0"
|
|
1204
1210
|
});
|
|
1205
1211
|
var page = () => window;
|
|
@@ -1217,6 +1223,21 @@ function settled() {
|
|
|
1217
1223
|
function flush() {
|
|
1218
1224
|
if (settled() || leaving) held.splice(0).forEach((send) => send());
|
|
1219
1225
|
}
|
|
1226
|
+
function ready(limit = 3e3) {
|
|
1227
|
+
if (typeof window === "undefined") return Promise.resolve();
|
|
1228
|
+
const start2 = Date.now();
|
|
1229
|
+
const meta = () => {
|
|
1230
|
+
const fbq = page().fbq;
|
|
1231
|
+
return ![...loaded].some((k) => k.startsWith("meta:")) || typeof fbq?.callMethod === "function";
|
|
1232
|
+
};
|
|
1233
|
+
return new Promise((resolve) => {
|
|
1234
|
+
const tick = () => {
|
|
1235
|
+
if (configured && settled() && meta() || Date.now() - start2 >= limit) return resolve();
|
|
1236
|
+
setTimeout(tick, 100);
|
|
1237
|
+
};
|
|
1238
|
+
tick();
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1220
1241
|
function script(src, onload, onerror) {
|
|
1221
1242
|
const s = document.createElement("script");
|
|
1222
1243
|
s.async = true;
|
|
@@ -1594,6 +1615,6 @@ var COHORTS = {
|
|
|
1594
1615
|
* curl -fsSL https://unpkg.com/@hanzo/event/src/anon.js -o apps/analytics/anon.js
|
|
1595
1616
|
*/
|
|
1596
1617
|
|
|
1597
|
-
export { Analytics, CLICK_IDS, COHORTS, CONSENT_COOKIE, CONSENT_EVENT, GOALS, LINK_PARAMS, ORG_DOMAIN, ORG_KEY, SITE_KEY, VERSION, acceptAll, asks, capture as captureClick, commerceItem, createAnalytics, deriveChannel, digest, exceptionEntry, exceptionProperties, fingerprint, framesFromStack, getCohort, getFirstTouch, gpc, hasAttribution, hostOf, isoWeek, keyFor, keyForPage, linkUrl, mirror, orgOf, parseAttribution, reach, read2 as readConsent, readLink, redactSecrets, refused, region, rejectAll, render as renderConsent, resetClients, save as saveConsent, scrubPII, scrubText, start as startTags, stored as storedConsent, stripLink, touch, track, hzUuidv7 as uuidv7, uuidv7Time, visit, worth };
|
|
1618
|
+
export { Analytics, CLICK_IDS, COHORTS, CONSENT_COOKIE, CONSENT_EVENT, GOALS, LINK_PARAMS, ORG_DOMAIN, ORG_KEY, SITE_KEY, VERSION, acceptAll, asks, capture as captureClick, commerceItem, createAnalytics, deriveChannel, digest, exceptionEntry, exceptionProperties, fingerprint, framesFromStack, getCohort, getFirstTouch, gpc, hasAttribution, hostOf, isoWeek, keyFor, keyForPage, linkUrl, mirror, orgOf, parseAttribution, reach, read2 as readConsent, readLink, redactSecrets, refused, region, rejectAll, render as renderConsent, resetClients, save as saveConsent, scrubPII, scrubText, start as startTags, stored as storedConsent, stripLink, ready as tagsReady, touch, track, hzUuidv7 as uuidv7, uuidv7Time, visit, worth };
|
|
1598
1619
|
//# sourceMappingURL=index.mjs.map
|
|
1599
1620
|
//# sourceMappingURL=index.mjs.map
|