@hanzo/event 0.3.44 → 0.3.48

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 CHANGED
@@ -407,7 +407,7 @@ function uuidv7Time(id) {
407
407
  }
408
408
 
409
409
  // package.json
410
- var version = "0.3.44";
410
+ var version = "0.3.48";
411
411
 
412
412
  // src/version.ts
413
413
  var VERSION = version;
@@ -1390,6 +1390,17 @@ function touch(c) {
1390
1390
  }
1391
1391
  return out;
1392
1392
  }
1393
+ var SITE_KEY = Object.freeze({
1394
+ "hanzo.ai": "pk-CmfLA2K6kvsPflrS9DSkt06H_kSoQB_21sjedt6VJdc",
1395
+ "www.hanzo.ai": "pk-CmfLA2K6kvsPflrS9DSkt06H_kSoQB_21sjedt6VJdc",
1396
+ "hanzo.app": "pk-wlnXN2a9_vmCm60yTFtQ629Q8TyuaxBNZbY1RWT72gQ",
1397
+ "hanzo.team": "pk-NCzD2FiHpZv8KUpkCX4olT1LJOJsMxBC_Z8NkiQsOFQ",
1398
+ "pay.hanzo.ai": "pk-eX6kv7JZNoiYn1WkeJH3tT_8OvkVYScmCXnLMwxTKf8",
1399
+ "platform.hanzo.ai": "pk-My1RpZLEUnTj8vAdPbWKYdDUuhxZJ4dVjHcwjZN4rZ8",
1400
+ "docs.hanzo.ai": "pk-jukhtjMT2ymoeBDAeFjINQWlBv-v9sNn1TPztiCrrwk",
1401
+ "hanzo.bot": "pk-W5d7Mn7ZukT7igyscIy6Pqe8JpA0Ge604Yn4xNR4JCU",
1402
+ "cloud.hanzo.ai": "pk-RAfEGHPoNdCEU9fnA_cPd_Xo9Tci44rlYQV9xuJ1Ob0"
1403
+ });
1393
1404
  var page = () => window;
1394
1405
  var tags = [];
1395
1406
  var configured = false;
@@ -1567,8 +1578,10 @@ function start(o = {}) {
1567
1578
  configured = true;
1568
1579
  const base = (o.base ?? "https://api.hanzo.ai").replace(/\/$/, "");
1569
1580
  const q = new URLSearchParams();
1570
- if (o.key) q.set("key", o.key);
1571
- q.set("host", o.host ?? window.location.hostname);
1581
+ const host = o.host ?? window.location.hostname;
1582
+ const key = o.key ?? SITE_KEY[host];
1583
+ if (key) q.set("key", key);
1584
+ q.set("host", host);
1572
1585
  const answer = (list) => {
1573
1586
  tags = list;
1574
1587
  configAnswered = true;
@@ -1680,16 +1693,17 @@ function mirror(name, params, id, to = reach()) {
1680
1693
  }
1681
1694
  }
1682
1695
  }
1683
- function track(stream, name, params = {}) {
1696
+ function track(stream, name, params = {}, only) {
1684
1697
  if (typeof window === "undefined") return;
1685
1698
  if (!leaving && !settled()) {
1686
- held.push(() => track(stream, name, params));
1699
+ held.push(() => track(stream, name, params, only));
1687
1700
  return;
1688
1701
  }
1689
1702
  const c = read2();
1690
- const event_id = crypto.randomUUID();
1703
+ const event_id = typeof params.event_id === "string" && params.event_id ? params.event_id : crypto.randomUUID();
1691
1704
  const to = reach();
1692
1705
  mirror(name, params, event_id, to);
1706
+ if (only === "tags") return;
1693
1707
  stream?.capture(name, {
1694
1708
  ...params,
1695
1709
  ...touch(c),
@@ -1705,6 +1719,20 @@ function visit() {
1705
1719
  return { ...touch(c), consent: render(c), tags: reach(), userAgent: navigator.userAgent, url: window.location.href };
1706
1720
  }
1707
1721
 
1722
+ // src/items.ts
1723
+ function commerceItem(p) {
1724
+ const annual = /^(year|yearly|annual)$/i.test(p.interval);
1725
+ return {
1726
+ item_id: p.id,
1727
+ ...p.name ? { item_name: p.name } : {},
1728
+ item_category: p.team ? "team" : "individual",
1729
+ item_variant: annual ? "annual" : "monthly",
1730
+ price: p.price ?? 0,
1731
+ quantity: p.quantity ?? 1
1732
+ };
1733
+ }
1734
+ var worth = (i) => i.price * i.quantity;
1735
+
1708
1736
  // src/goals.ts
1709
1737
  var GOALS = {
1710
1738
  // Signup: the conversion is signup_completed, along the site signup funnel.
@@ -1799,12 +1827,14 @@ exports.LINK_PARAMS = LINK_PARAMS;
1799
1827
  exports.ORG_DOMAIN = ORG_DOMAIN;
1800
1828
  exports.ORG_KEY = ORG_KEY;
1801
1829
  exports.PRODUCT_PROJECT = PRODUCT_PROJECT;
1830
+ exports.SITE_KEY = SITE_KEY;
1802
1831
  exports.VERSION = VERSION;
1803
1832
  exports.acceptAll = acceptAll;
1804
1833
  exports.asks = asks;
1805
1834
  exports.buildEnvelope = buildEnvelope;
1806
1835
  exports.buildSentryEvent = buildSentryEvent;
1807
1836
  exports.captureClick = capture;
1837
+ exports.commerceItem = commerceItem;
1808
1838
  exports.createAnalytics = createAnalytics;
1809
1839
  exports.deriveChannel = deriveChannel;
1810
1840
  exports.digest = digest;
@@ -1846,5 +1876,6 @@ exports.track = track;
1846
1876
  exports.uuidv7 = hzUuidv7;
1847
1877
  exports.uuidv7Time = uuidv7Time;
1848
1878
  exports.visit = visit;
1879
+ exports.worth = worth;
1849
1880
  //# sourceMappingURL=index.cjs.map
1850
1881
  //# sourceMappingURL=index.cjs.map