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.
@@ -1,2 +1,2 @@
1
1
  export { CapturedError, CronCheckinOptions, CronHandle, DEFAULT_SUPERLINK_ENDPOINT, DatabaseQueryEvent, DatabaseTrackerConfig, DeferredDeepLinkHandler, DeviceInfo, DeviceSignals, EnvironmentAdapter, ErrorContext, FraudCheckResult, MetricOptions, MutableRNEnvironmentAdapter, PerformanceConfig, PerformanceSpan, PerformanceTransaction, PlatformName, ProfileData, ProfileFrame, ProfilerConfig, RemoteConfig, RemoteConfigFeatures, RemoteConfigSampling, ResourceTimingBreakdown, SitePongConfig, SitePongInitConfig, SuperLinkClient, SuperLinkConfig, SuperLinkDeepLink, SuperLinkEventType, SuperLinkFingerprint, SuperLinkIdentityMetadata, SuperLinkMatchRequest, SuperLinkMatchResponse, SuperLinkMatchType, SuperLinkPlatform, TraceContext, TracePropagator, VisitorIdResult, WebManagerFactories, WebVitals, addBreadcrumb, areFlagsReady, captureError, captureMessage, captureWebDeepLink, clearAnonymousId, clearUser, client, completeFromScan, createTraceContext, cronCheckin, cronStart, cronWrap, dbTrack, dbTrackSync, client as default, endSpan, endTransaction, extractIdentityMetadata, extractTrace, flush, flushMetrics, flushProfiles, generateSpanId, generateTraceId, getAllFlags, getAnonymousId, getDbNPlusOnePatterns, getDbQueryCount, getDeepLink, getDeviceSignals, getFlag, getFraudCheck, getLatestProfile, getMatchedDeepLink, getProfiles, getRemoteConfig, getReplaySessionId, getVariant, getVariantPayload, getVisitorId, getWebVitals, group, identify, init, initRN, initSuperLink, isInitialized, isRemoteConfigFeatureEnabled, isReplayRecording, metricDistribution, metricGauge, metricHistogram, metricIncrement, metricStartTimer, metricTime, onDeferredDeepLink, onRemoteConfigChange, parseUniversalLink, profile, propagateTrace, refreshFlags, registerIdentifyHook, registerWebManagerFactories, resetAnalytics, resetDbQueryCount, setAnonymousId, setContext, setCurrentScreen, setEnvironment, setRNGetCurrentScreen, setTags, setUser, startProfileSpan, startReplay, startSpan, startTransaction, stopReplay, superlinkClient, superlinkIdentify, track, trackPageView, waitForFlags, writeClipboardToken } from '../index.mjs';
2
- export { G as GroupTraits, R as ReplayConfig, a as ReplayEvent, T as TrackProperties, U as UserTraits } from '../types-BEqbz0tw.mjs';
2
+ export { G as GroupTraits, R as ReplayConfig, a as ReplayEvent, T as TrackProperties, U as UserTraits } from '../types-DPINdOQW.mjs';
@@ -1,2 +1,2 @@
1
1
  export { CapturedError, CronCheckinOptions, CronHandle, DEFAULT_SUPERLINK_ENDPOINT, DatabaseQueryEvent, DatabaseTrackerConfig, DeferredDeepLinkHandler, DeviceInfo, DeviceSignals, EnvironmentAdapter, ErrorContext, FraudCheckResult, MetricOptions, MutableRNEnvironmentAdapter, PerformanceConfig, PerformanceSpan, PerformanceTransaction, PlatformName, ProfileData, ProfileFrame, ProfilerConfig, RemoteConfig, RemoteConfigFeatures, RemoteConfigSampling, ResourceTimingBreakdown, SitePongConfig, SitePongInitConfig, SuperLinkClient, SuperLinkConfig, SuperLinkDeepLink, SuperLinkEventType, SuperLinkFingerprint, SuperLinkIdentityMetadata, SuperLinkMatchRequest, SuperLinkMatchResponse, SuperLinkMatchType, SuperLinkPlatform, TraceContext, TracePropagator, VisitorIdResult, WebManagerFactories, WebVitals, addBreadcrumb, areFlagsReady, captureError, captureMessage, captureWebDeepLink, clearAnonymousId, clearUser, client, completeFromScan, createTraceContext, cronCheckin, cronStart, cronWrap, dbTrack, dbTrackSync, client as default, endSpan, endTransaction, extractIdentityMetadata, extractTrace, flush, flushMetrics, flushProfiles, generateSpanId, generateTraceId, getAllFlags, getAnonymousId, getDbNPlusOnePatterns, getDbQueryCount, getDeepLink, getDeviceSignals, getFlag, getFraudCheck, getLatestProfile, getMatchedDeepLink, getProfiles, getRemoteConfig, getReplaySessionId, getVariant, getVariantPayload, getVisitorId, getWebVitals, group, identify, init, initRN, initSuperLink, isInitialized, isRemoteConfigFeatureEnabled, isReplayRecording, metricDistribution, metricGauge, metricHistogram, metricIncrement, metricStartTimer, metricTime, onDeferredDeepLink, onRemoteConfigChange, parseUniversalLink, profile, propagateTrace, refreshFlags, registerIdentifyHook, registerWebManagerFactories, resetAnalytics, resetDbQueryCount, setAnonymousId, setContext, setCurrentScreen, setEnvironment, setRNGetCurrentScreen, setTags, setUser, startProfileSpan, startReplay, startSpan, startTransaction, stopReplay, superlinkClient, superlinkIdentify, track, trackPageView, waitForFlags, writeClipboardToken } from '../index.js';
2
- export { G as GroupTraits, R as ReplayConfig, a as ReplayEvent, T as TrackProperties, U as UserTraits } from '../types-BEqbz0tw.js';
2
+ export { G as GroupTraits, R as ReplayConfig, a as ReplayEvent, T as TrackProperties, U as UserTraits } from '../types-DPINdOQW.js';
@@ -626,6 +626,60 @@ function clearSession() {
626
626
  memorySessionTs = null;
627
627
  }
628
628
 
629
+ // src/analytics/utm.ts
630
+ var STORAGE_KEY2 = "sp_utm";
631
+ var UTM_KEYS = [
632
+ ["source", "utm_source"],
633
+ ["medium", "utm_medium"],
634
+ ["campaign", "utm_campaign"],
635
+ ["term", "utm_term"],
636
+ ["content", "utm_content"]
637
+ ];
638
+ function parseFromLocation() {
639
+ if (typeof window === "undefined" || !window.location || !window.location.search) return null;
640
+ let params;
641
+ try {
642
+ params = new URLSearchParams(window.location.search);
643
+ } catch {
644
+ return null;
645
+ }
646
+ const result = {};
647
+ let found = false;
648
+ for (const [key, queryKey] of UTM_KEYS) {
649
+ const value = params.get(queryKey);
650
+ if (value) {
651
+ result[key] = value;
652
+ found = true;
653
+ }
654
+ }
655
+ return found ? result : null;
656
+ }
657
+ function readStored() {
658
+ if (typeof sessionStorage === "undefined") return null;
659
+ try {
660
+ const raw = sessionStorage.getItem(STORAGE_KEY2);
661
+ if (!raw) return null;
662
+ const parsed = JSON.parse(raw);
663
+ return parsed && typeof parsed === "object" ? parsed : null;
664
+ } catch {
665
+ return null;
666
+ }
667
+ }
668
+ function writeStored(utm) {
669
+ if (typeof sessionStorage === "undefined") return;
670
+ try {
671
+ sessionStorage.setItem(STORAGE_KEY2, JSON.stringify(utm));
672
+ } catch {
673
+ }
674
+ }
675
+ function getSessionUtm() {
676
+ const stored = readStored();
677
+ if (stored) return stored;
678
+ const fresh = parseFromLocation();
679
+ if (fresh) writeStored(fresh);
680
+ return fresh;
681
+ }
682
+
629
683
  // src/analytics/autocapture.ts
630
684
  var DEFAULT_BLOCK_SELECTORS = [
631
685
  "[data-sp-no-capture]",
@@ -1032,7 +1086,9 @@ var AnalyticsManager = class {
1032
1086
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1033
1087
  url: typeof window !== "undefined" && window.location ? window.location.href : void 0,
1034
1088
  referrer: typeof document !== "undefined" && typeof document.referrer === "string" ? document.referrer : void 0,
1035
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0
1089
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
1090
+ utm: getSessionUtm() || void 0,
1091
+ appVersion: this.config.appVersion || void 0
1036
1092
  };
1037
1093
  }
1038
1094
  enqueue(event) {
@@ -1730,7 +1786,7 @@ var DEFAULT_REMOTE_CONFIG = {
1730
1786
  };
1731
1787
 
1732
1788
  // src/remote-config/manager.ts
1733
- var STORAGE_KEY2 = "sitepong_remote_config";
1789
+ var STORAGE_KEY3 = "sitepong_remote_config";
1734
1790
  var STORAGE_TS_KEY = "sitepong_remote_config_ts";
1735
1791
  var RemoteConfigManager = class {
1736
1792
  constructor(options) {
@@ -1773,7 +1829,7 @@ var RemoteConfigManager = class {
1773
1829
  const storage = this.options.storage;
1774
1830
  if (!storage) return;
1775
1831
  try {
1776
- const cached = await storage.getItem(STORAGE_KEY2);
1832
+ const cached = await storage.getItem(STORAGE_KEY3);
1777
1833
  const cachedTs = await storage.getItem(STORAGE_TS_KEY);
1778
1834
  if (cached && cachedTs) {
1779
1835
  const age = Date.now() - parseInt(cachedTs, 10);
@@ -1834,7 +1890,7 @@ var RemoteConfigManager = class {
1834
1890
  const storage = this.options.storage;
1835
1891
  if (!storage) return;
1836
1892
  try {
1837
- await storage.setItem(STORAGE_KEY2, JSON.stringify(this.config));
1893
+ await storage.setItem(STORAGE_KEY3, JSON.stringify(this.config));
1838
1894
  await storage.setItem(STORAGE_TS_KEY, String(Date.now()));
1839
1895
  } catch {
1840
1896
  this.log("Failed to cache remote config");
@@ -2589,7 +2645,7 @@ function stripTrailingSlash(url) {
2589
2645
  var superlinkClient = new SuperLinkClient();
2590
2646
 
2591
2647
  // src/superlink/parse.ts
2592
- var UTM_KEYS = [
2648
+ var UTM_KEYS2 = [
2593
2649
  ["source", "utm_source"],
2594
2650
  ["medium", "utm_medium"],
2595
2651
  ["campaign", "utm_campaign"],
@@ -2605,7 +2661,7 @@ function parseUniversalLink(url) {
2605
2661
  }
2606
2662
  const params = parsed.searchParams;
2607
2663
  const utm = {};
2608
- for (const [key, queryKey] of UTM_KEYS) {
2664
+ for (const [key, queryKey] of UTM_KEYS2) {
2609
2665
  const value = params.get(queryKey);
2610
2666
  if (value) utm[key] = value;
2611
2667
  }
@@ -2672,13 +2728,13 @@ function getMatchedDeepLink() {
2672
2728
  }
2673
2729
 
2674
2730
  // src/superlink/web.ts
2675
- var STORAGE_KEY3 = "sp_superlink";
2731
+ var STORAGE_KEY4 = "sp_superlink";
2676
2732
  var captured = null;
2677
2733
  var didCapture = false;
2678
- function readStored() {
2734
+ function readStored2() {
2679
2735
  if (typeof sessionStorage === "undefined") return null;
2680
2736
  try {
2681
- const raw = sessionStorage.getItem(STORAGE_KEY3);
2737
+ const raw = sessionStorage.getItem(STORAGE_KEY4);
2682
2738
  if (!raw) return null;
2683
2739
  const parsed = JSON.parse(raw);
2684
2740
  return parsed && typeof parsed === "object" ? parsed : null;
@@ -2686,10 +2742,10 @@ function readStored() {
2686
2742
  return null;
2687
2743
  }
2688
2744
  }
2689
- function writeStored(link) {
2745
+ function writeStored2(link) {
2690
2746
  if (typeof sessionStorage === "undefined") return;
2691
2747
  try {
2692
- sessionStorage.setItem(STORAGE_KEY3, JSON.stringify(link));
2748
+ sessionStorage.setItem(STORAGE_KEY4, JSON.stringify(link));
2693
2749
  } catch {
2694
2750
  }
2695
2751
  }
@@ -2737,7 +2793,7 @@ function extractIdentityMetadata(url) {
2737
2793
  function captureWebDeepLink() {
2738
2794
  if (didCapture) return captured;
2739
2795
  didCapture = true;
2740
- const stored = readStored();
2796
+ const stored = readStored2();
2741
2797
  if (stored) {
2742
2798
  captured = stored;
2743
2799
  return captured;
@@ -2746,7 +2802,7 @@ function captureWebDeepLink() {
2746
2802
  const link = parseUniversalLink(window.location.href);
2747
2803
  if (link && hasPayload(link)) {
2748
2804
  captured = link;
2749
- writeStored(link);
2805
+ writeStored2(link);
2750
2806
  void superlinkClient.reportEvent({
2751
2807
  type: "opened",
2752
2808
  click_id: link.click_id,
@@ -5655,11 +5711,11 @@ function getNotificationsPermission() {
5655
5711
  return Notification.permission === "granted";
5656
5712
  }
5657
5713
  function getDeviceAge() {
5658
- const STORAGE_KEY4 = "sitepong_device_age";
5714
+ const STORAGE_KEY5 = "sitepong_device_age";
5659
5715
  const result = { visitCount: 1 };
5660
5716
  if (typeof localStorage === "undefined") return result;
5661
5717
  try {
5662
- const stored = localStorage.getItem(STORAGE_KEY4);
5718
+ const stored = localStorage.getItem(STORAGE_KEY5);
5663
5719
  if (stored) {
5664
5720
  const parsed = JSON.parse(stored);
5665
5721
  result.firstSeen = parsed.firstSeen;
@@ -5667,7 +5723,7 @@ function getDeviceAge() {
5667
5723
  } else {
5668
5724
  result.firstSeen = (/* @__PURE__ */ new Date()).toISOString();
5669
5725
  }
5670
- localStorage.setItem(STORAGE_KEY4, JSON.stringify({
5726
+ localStorage.setItem(STORAGE_KEY5, JSON.stringify({
5671
5727
  firstSeen: result.firstSeen,
5672
5728
  visitCount: result.visitCount
5673
5729
  }));