@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/react.mjs CHANGED
@@ -104,7 +104,7 @@ var ORG_DOMAIN = Object.freeze({
104
104
  zoo: Object.freeze(["zoo.ngo", "zoo.network", "zoolabs.id", "zoolabs.io"])
105
105
  });
106
106
  var ORG_KEY = Object.freeze({
107
- hanzo: "pk-rM_CdaF2MQckGCrla113SrR1oH4zvqN8xh2I95Z9tY8",
107
+ hanzo: "pk-CmfLA2K6kvsPflrS9DSkt06H_kSoQB_21sjedt6VJdc",
108
108
  lux: "pk-gUZp6ZVfhJzSwK-rb4oLbVkpCnMBx5uSCpxf_5yEhQk",
109
109
  zoo: "pk-3TKpKnERV9AQSsBUERWkZejC1O1mUxc1jRzsP3MPbs4"
110
110
  });
@@ -621,7 +621,7 @@ function stripLink(href) {
621
621
  }
622
622
 
623
623
  // package.json
624
- var version = "0.3.49";
624
+ var version = "0.3.50";
625
625
 
626
626
  // src/version.ts
627
627
  var VERSION = version;
@@ -645,6 +645,7 @@ function normalizeError2(err) {
645
645
  const frames = framesFromStack(n.stack).slice(-50).map((f) => ({ function: f.function, file: f.filename, line: f.lineno, column: f.colno }));
646
646
  return { type: n.name, message: n.message, stack: n.stack, frames };
647
647
  }
648
+ var viewport = () => isBrowser() ? { screen: `${window.screen?.width ?? 0}x${window.screen?.height ?? 0}`, language: navigator.language || "" } : {};
648
649
  var isBrowser = () => typeof window !== "undefined" && typeof document !== "undefined";
649
650
  function serializeBatch(batch) {
650
651
  try {
@@ -679,13 +680,13 @@ var DefaultTransport = class {
679
680
  }
680
681
  }
681
682
  if (typeof fetch !== "function") return;
682
- const simple = opts.ingestKey !== void 0 && opts.contentType === void 0;
683
+ const simple = opts.ingestKey !== void 0 && opts.token === void 0 && opts.contentType === void 0;
683
684
  const headers = {
684
685
  "Content-Type": simple ? BEACON_CONTENT_TYPE : opts.contentType ?? "application/json"
685
686
  };
686
- const bearer = simple ? void 0 : opts.ingestKey ?? opts.token;
687
+ const bearer = simple ? void 0 : opts.token ?? opts.ingestKey;
687
688
  if (bearer) headers.Authorization = `Bearer ${bearer}`;
688
- void fetch(simple ? appendQuery(url, "ingest_key", opts.ingestKey) : url, {
689
+ void fetch(opts.ingestKey ? appendQuery(url, "ingest_key", opts.ingestKey) : url, {
689
690
  method: "POST",
690
691
  headers,
691
692
  body,
@@ -825,7 +826,7 @@ var Analytics = class {
825
826
  const view = (p ?? "") + "\0" + (isBrowser() ? window.location.href : "");
826
827
  if (view === this.counted) return;
827
828
  this.counted = view;
828
- this.enqueue("pageview", PAGEVIEW, { path: p, properties });
829
+ this.enqueue("pageview", PAGEVIEW, { path: p, properties: { ...viewport(), ...properties } });
829
830
  }
830
831
  /** capture records a named product event with optional properties. Commerce
831
832
  * fields (productId/quantity/revenue/currency) may be passed for order events. */
@@ -881,7 +882,7 @@ var Analytics = class {
881
882
  this.queue = [];
882
883
  this.clearTimer();
883
884
  const token = this.cfg.getToken?.() ?? void 0;
884
- const key = token ? void 0 : this.cfg.ingestKey?.trim() || void 0;
885
+ const key = this.cfg.ingestKey?.trim() || void 0;
885
886
  const useBeacon = beacon && !token;
886
887
  const body = serializeBatch(batch);
887
888
  if (body === null) {