sitepong 0.2.0 → 0.2.1

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.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as ReplayConfig, T as TrackProperties, U as UserTraits, G as GroupTraits } from './types-BEqbz0tw.mjs';
2
- export { a as ReplayEvent } from './types-BEqbz0tw.mjs';
1
+ import { R as ReplayConfig, T as TrackProperties, U as UserTraits, G as GroupTraits } from './types-DPINdOQW.mjs';
2
+ export { a as ReplayEvent } from './types-DPINdOQW.mjs';
3
3
 
4
4
  /**
5
5
  * Fingerprint Types
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as ReplayConfig, T as TrackProperties, U as UserTraits, G as GroupTraits } from './types-BEqbz0tw.js';
2
- export { a as ReplayEvent } from './types-BEqbz0tw.js';
1
+ import { R as ReplayConfig, T as TrackProperties, U as UserTraits, G as GroupTraits } from './types-DPINdOQW.js';
2
+ export { a as ReplayEvent } from './types-DPINdOQW.js';
3
3
 
4
4
  /**
5
5
  * Fingerprint Types
package/dist/index.js CHANGED
@@ -522,6 +522,60 @@ function clearSession() {
522
522
  memorySessionTs = null;
523
523
  }
524
524
 
525
+ // src/analytics/utm.ts
526
+ var STORAGE_KEY2 = "sp_utm";
527
+ var UTM_KEYS = [
528
+ ["source", "utm_source"],
529
+ ["medium", "utm_medium"],
530
+ ["campaign", "utm_campaign"],
531
+ ["term", "utm_term"],
532
+ ["content", "utm_content"]
533
+ ];
534
+ function parseFromLocation() {
535
+ if (typeof window === "undefined" || !window.location || !window.location.search) return null;
536
+ let params;
537
+ try {
538
+ params = new URLSearchParams(window.location.search);
539
+ } catch {
540
+ return null;
541
+ }
542
+ const result = {};
543
+ let found = false;
544
+ for (const [key, queryKey] of UTM_KEYS) {
545
+ const value = params.get(queryKey);
546
+ if (value) {
547
+ result[key] = value;
548
+ found = true;
549
+ }
550
+ }
551
+ return found ? result : null;
552
+ }
553
+ function readStored() {
554
+ if (typeof sessionStorage === "undefined") return null;
555
+ try {
556
+ const raw = sessionStorage.getItem(STORAGE_KEY2);
557
+ if (!raw) return null;
558
+ const parsed = JSON.parse(raw);
559
+ return parsed && typeof parsed === "object" ? parsed : null;
560
+ } catch {
561
+ return null;
562
+ }
563
+ }
564
+ function writeStored(utm) {
565
+ if (typeof sessionStorage === "undefined") return;
566
+ try {
567
+ sessionStorage.setItem(STORAGE_KEY2, JSON.stringify(utm));
568
+ } catch {
569
+ }
570
+ }
571
+ function getSessionUtm() {
572
+ const stored = readStored();
573
+ if (stored) return stored;
574
+ const fresh = parseFromLocation();
575
+ if (fresh) writeStored(fresh);
576
+ return fresh;
577
+ }
578
+
525
579
  // src/analytics/autocapture.ts
526
580
  var DEFAULT_BLOCK_SELECTORS = [
527
581
  "[data-sp-no-capture]",
@@ -928,7 +982,9 @@ var AnalyticsManager = class {
928
982
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
929
983
  url: typeof window !== "undefined" && window.location ? window.location.href : void 0,
930
984
  referrer: typeof document !== "undefined" && typeof document.referrer === "string" ? document.referrer : void 0,
931
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0
985
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
986
+ utm: getSessionUtm() || void 0,
987
+ appVersion: this.config.appVersion || void 0
932
988
  };
933
989
  }
934
990
  enqueue(event) {
@@ -1626,7 +1682,7 @@ var DEFAULT_REMOTE_CONFIG = {
1626
1682
  };
1627
1683
 
1628
1684
  // src/remote-config/manager.ts
1629
- var STORAGE_KEY2 = "sitepong_remote_config";
1685
+ var STORAGE_KEY3 = "sitepong_remote_config";
1630
1686
  var STORAGE_TS_KEY = "sitepong_remote_config_ts";
1631
1687
  var RemoteConfigManager = class {
1632
1688
  constructor(options) {
@@ -1669,7 +1725,7 @@ var RemoteConfigManager = class {
1669
1725
  const storage = this.options.storage;
1670
1726
  if (!storage) return;
1671
1727
  try {
1672
- const cached = await storage.getItem(STORAGE_KEY2);
1728
+ const cached = await storage.getItem(STORAGE_KEY3);
1673
1729
  const cachedTs = await storage.getItem(STORAGE_TS_KEY);
1674
1730
  if (cached && cachedTs) {
1675
1731
  const age = Date.now() - parseInt(cachedTs, 10);
@@ -1730,7 +1786,7 @@ var RemoteConfigManager = class {
1730
1786
  const storage = this.options.storage;
1731
1787
  if (!storage) return;
1732
1788
  try {
1733
- await storage.setItem(STORAGE_KEY2, JSON.stringify(this.config));
1789
+ await storage.setItem(STORAGE_KEY3, JSON.stringify(this.config));
1734
1790
  await storage.setItem(STORAGE_TS_KEY, String(Date.now()));
1735
1791
  } catch {
1736
1792
  this.log("Failed to cache remote config");
@@ -1986,7 +2042,7 @@ function stripTrailingSlash(url) {
1986
2042
  var superlinkClient = new SuperLinkClient();
1987
2043
 
1988
2044
  // src/superlink/parse.ts
1989
- var UTM_KEYS = [
2045
+ var UTM_KEYS2 = [
1990
2046
  ["source", "utm_source"],
1991
2047
  ["medium", "utm_medium"],
1992
2048
  ["campaign", "utm_campaign"],
@@ -2002,7 +2058,7 @@ function parseUniversalLink(url) {
2002
2058
  }
2003
2059
  const params = parsed.searchParams;
2004
2060
  const utm = {};
2005
- for (const [key, queryKey] of UTM_KEYS) {
2061
+ for (const [key, queryKey] of UTM_KEYS2) {
2006
2062
  const value = params.get(queryKey);
2007
2063
  if (value) utm[key] = value;
2008
2064
  }
@@ -2069,13 +2125,13 @@ function getMatchedDeepLink() {
2069
2125
  }
2070
2126
 
2071
2127
  // src/superlink/web.ts
2072
- var STORAGE_KEY3 = "sp_superlink";
2128
+ var STORAGE_KEY4 = "sp_superlink";
2073
2129
  var captured = null;
2074
2130
  var didCapture = false;
2075
- function readStored() {
2131
+ function readStored2() {
2076
2132
  if (typeof sessionStorage === "undefined") return null;
2077
2133
  try {
2078
- const raw = sessionStorage.getItem(STORAGE_KEY3);
2134
+ const raw = sessionStorage.getItem(STORAGE_KEY4);
2079
2135
  if (!raw) return null;
2080
2136
  const parsed = JSON.parse(raw);
2081
2137
  return parsed && typeof parsed === "object" ? parsed : null;
@@ -2083,10 +2139,10 @@ function readStored() {
2083
2139
  return null;
2084
2140
  }
2085
2141
  }
2086
- function writeStored(link) {
2142
+ function writeStored2(link) {
2087
2143
  if (typeof sessionStorage === "undefined") return;
2088
2144
  try {
2089
- sessionStorage.setItem(STORAGE_KEY3, JSON.stringify(link));
2145
+ sessionStorage.setItem(STORAGE_KEY4, JSON.stringify(link));
2090
2146
  } catch {
2091
2147
  }
2092
2148
  }
@@ -2134,7 +2190,7 @@ function extractIdentityMetadata(url) {
2134
2190
  function captureWebDeepLink() {
2135
2191
  if (didCapture) return captured;
2136
2192
  didCapture = true;
2137
- const stored = readStored();
2193
+ const stored = readStored2();
2138
2194
  if (stored) {
2139
2195
  captured = stored;
2140
2196
  return captured;
@@ -2143,7 +2199,7 @@ function captureWebDeepLink() {
2143
2199
  const link = parseUniversalLink(window.location.href);
2144
2200
  if (link && hasPayload(link)) {
2145
2201
  captured = link;
2146
- writeStored(link);
2202
+ writeStored2(link);
2147
2203
  void superlinkClient.reportEvent({
2148
2204
  type: "opened",
2149
2205
  click_id: link.click_id,