sitepong 0.2.1 → 0.2.2

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,6 +1,6 @@
1
1
  import React, { Component, ReactNode, ErrorInfo } from 'react';
2
2
  import { SitePongInitConfig, ErrorContext, addBreadcrumb, DeviceSignals, WebVitals } from '../index.mjs';
3
- export { CapturedError, CronCheckinOptions, CronHandle, DEFAULT_SUPERLINK_ENDPOINT, DatabaseQueryEvent, DatabaseTrackerConfig, DeferredDeepLinkHandler, DeviceInfo, EnvironmentAdapter, FraudCheckResult, MetricOptions, MutableRNEnvironmentAdapter, PerformanceConfig, PerformanceSpan, PerformanceTransaction, PlatformName, ProfileData, ProfileFrame, ProfilerConfig, RemoteConfig, RemoteConfigFeatures, RemoteConfigSampling, ResourceTimingBreakdown, SitePongConfig, SuperLinkClient, SuperLinkConfig, SuperLinkDeepLink, SuperLinkEventType, SuperLinkFingerprint, SuperLinkIdentityMetadata, SuperLinkMatchRequest, SuperLinkMatchResponse, SuperLinkMatchType, SuperLinkPlatform, TraceContext, TracePropagator, VisitorIdResult, WebManagerFactories, areFlagsReady, captureError, captureMessage, captureWebDeepLink, clearAnonymousId, clearUser, client, completeFromScan, createTraceContext, cronCheckin, cronStart, cronWrap, dbTrack, dbTrackSync, 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';
3
+ export { CapturedError, CronCheckinOptions, CronHandle, DEFAULT_SUPERLINK_ENDPOINT, DatabaseQueryEvent, DatabaseTrackerConfig, DeferredDeepLinkHandler, DeviceInfo, EnvironmentAdapter, FraudCheckResult, MetricOptions, MutableRNEnvironmentAdapter, PerformanceConfig, PerformanceSpan, PerformanceTransaction, PlatformName, ProfileData, ProfileFrame, ProfilerConfig, RemoteConfig, RemoteConfigFeatures, RemoteConfigSampling, ResourceTimingBreakdown, SitePongConfig, SuperLinkClient, SuperLinkConfig, SuperLinkDeepLink, SuperLinkEventType, SuperLinkFingerprint, SuperLinkIdentityMetadata, SuperLinkMatchRequest, SuperLinkMatchResponse, SuperLinkMatchType, SuperLinkPlatform, TraceContext, TracePropagator, VisitorIdResult, WebManagerFactories, areFlagsReady, captureError, captureMessage, captureWebDeepLink, clearAnonymousId, clearUser, client, completeFromScan, createTraceContext, cronCheckin, cronStart, cronWrap, dbTrack, dbTrackSync, 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, startWatchtowerCapture, stopReplay, stopWatchtowerCapture, superlinkClient, superlinkIdentify, track, trackPageView, waitForFlags, writeClipboardToken } from '../index.mjs';
4
4
  import { C as CaptureContext, U as User } from '../types-CphqOTfm.mjs';
5
5
  import { T as TrackProperties, U as UserTraits, G as GroupTraits } from '../types-DPINdOQW.mjs';
6
6
  export { R as ReplayConfig, a as ReplayEvent } from '../types-DPINdOQW.mjs';
@@ -1,6 +1,6 @@
1
1
  import React, { Component, ReactNode, ErrorInfo } from 'react';
2
2
  import { SitePongInitConfig, ErrorContext, addBreadcrumb, DeviceSignals, WebVitals } from '../index.js';
3
- export { CapturedError, CronCheckinOptions, CronHandle, DEFAULT_SUPERLINK_ENDPOINT, DatabaseQueryEvent, DatabaseTrackerConfig, DeferredDeepLinkHandler, DeviceInfo, EnvironmentAdapter, FraudCheckResult, MetricOptions, MutableRNEnvironmentAdapter, PerformanceConfig, PerformanceSpan, PerformanceTransaction, PlatformName, ProfileData, ProfileFrame, ProfilerConfig, RemoteConfig, RemoteConfigFeatures, RemoteConfigSampling, ResourceTimingBreakdown, SitePongConfig, SuperLinkClient, SuperLinkConfig, SuperLinkDeepLink, SuperLinkEventType, SuperLinkFingerprint, SuperLinkIdentityMetadata, SuperLinkMatchRequest, SuperLinkMatchResponse, SuperLinkMatchType, SuperLinkPlatform, TraceContext, TracePropagator, VisitorIdResult, WebManagerFactories, areFlagsReady, captureError, captureMessage, captureWebDeepLink, clearAnonymousId, clearUser, client, completeFromScan, createTraceContext, cronCheckin, cronStart, cronWrap, dbTrack, dbTrackSync, 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';
3
+ export { CapturedError, CronCheckinOptions, CronHandle, DEFAULT_SUPERLINK_ENDPOINT, DatabaseQueryEvent, DatabaseTrackerConfig, DeferredDeepLinkHandler, DeviceInfo, EnvironmentAdapter, FraudCheckResult, MetricOptions, MutableRNEnvironmentAdapter, PerformanceConfig, PerformanceSpan, PerformanceTransaction, PlatformName, ProfileData, ProfileFrame, ProfilerConfig, RemoteConfig, RemoteConfigFeatures, RemoteConfigSampling, ResourceTimingBreakdown, SitePongConfig, SuperLinkClient, SuperLinkConfig, SuperLinkDeepLink, SuperLinkEventType, SuperLinkFingerprint, SuperLinkIdentityMetadata, SuperLinkMatchRequest, SuperLinkMatchResponse, SuperLinkMatchType, SuperLinkPlatform, TraceContext, TracePropagator, VisitorIdResult, WebManagerFactories, areFlagsReady, captureError, captureMessage, captureWebDeepLink, clearAnonymousId, clearUser, client, completeFromScan, createTraceContext, cronCheckin, cronStart, cronWrap, dbTrack, dbTrackSync, 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, startWatchtowerCapture, stopReplay, stopWatchtowerCapture, superlinkClient, superlinkIdentify, track, trackPageView, waitForFlags, writeClipboardToken } from '../index.js';
4
4
  import { C as CaptureContext, U as User } from '../types-BTA43eyz.js';
5
5
  import { T as TrackProperties, U as UserTraits, G as GroupTraits } from '../types-DPINdOQW.js';
6
6
  export { R as ReplayConfig, a as ReplayEvent } from '../types-DPINdOQW.js';
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var react = require('react');
4
- require('web-vitals');
5
4
  var jsxRuntime = require('react/jsx-runtime');
6
5
 
7
6
  // src/react/provider.tsx
@@ -586,6 +585,7 @@ var DEFAULT_BLOCK_SELECTORS = [
586
585
  var MAX_TEXT_LENGTH = 255;
587
586
  var AutocaptureModule = class {
588
587
  constructor(config, callback) {
588
+ this.listeners = [];
589
589
  this.clickHandler = null;
590
590
  this.submitHandler = null;
591
591
  this.active = false;
@@ -600,6 +600,27 @@ var AutocaptureModule = class {
600
600
  };
601
601
  this.callback = callback;
602
602
  }
603
+ /**
604
+ * Register a secondary listener that receives the same events as the
605
+ * primary callback (e.g. Watchtower tap capture reusing the single click
606
+ * listener + selector resolution). Returns an unsubscribe function.
607
+ */
608
+ addListener(cb) {
609
+ this.listeners.push(cb);
610
+ return () => {
611
+ const idx = this.listeners.indexOf(cb);
612
+ if (idx >= 0) this.listeners.splice(idx, 1);
613
+ };
614
+ }
615
+ emit(event) {
616
+ this.callback(event);
617
+ for (const listener of this.listeners) {
618
+ try {
619
+ listener(event);
620
+ } catch {
621
+ }
622
+ }
623
+ }
603
624
  start() {
604
625
  if (this.active || typeof document === "undefined" || typeof document.addEventListener !== "function") return;
605
626
  this.active = true;
@@ -632,7 +653,7 @@ var AutocaptureModule = class {
632
653
  properties.$event_type = "click";
633
654
  properties.$x = e.clientX;
634
655
  properties.$y = e.clientY;
635
- this.callback({
656
+ this.emit({
636
657
  type: "click",
637
658
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
638
659
  properties
@@ -654,7 +675,7 @@ var AutocaptureModule = class {
654
675
  };
655
676
  const elemProps = this.getElementProperties(form);
656
677
  Object.assign(properties, elemProps);
657
- this.callback({
678
+ this.emit({
658
679
  type: "form_submit",
659
680
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
660
681
  properties
@@ -871,6 +892,14 @@ var AnalyticsManager = class {
871
892
  );
872
893
  this.autocaptureModule.start();
873
894
  }
895
+ /**
896
+ * The live AutocaptureModule (if click/form autocapture is enabled) —
897
+ * Watchtower tap capture attaches to it so there is only ONE document-level
898
+ * click listener and one selector/element resolution path.
899
+ */
900
+ getAutocaptureModule() {
901
+ return this.autocaptureModule;
902
+ }
874
903
  track(eventName, properties) {
875
904
  if (!this.config.enabled) return;
876
905
  const event = this.createEvent("track", { name: eventName, properties });
@@ -2382,6 +2411,8 @@ var SitePongClient = class {
2382
2411
  this.databaseTracker = null;
2383
2412
  this.profiler = null;
2384
2413
  this.remoteConfigManager = null;
2414
+ this.watchtowerCapture = null;
2415
+ this.watchtowerOptions = void 0;
2385
2416
  this.envUnsubs = [];
2386
2417
  this.identifyHooks = [];
2387
2418
  this.config = {
@@ -2501,6 +2532,12 @@ var SitePongClient = class {
2501
2532
  } else if (config.replay?.enabled) {
2502
2533
  this.log("Replay requested but not available on this platform (web only).");
2503
2534
  }
2535
+ this.watchtowerOptions = config.watchtower;
2536
+ if (config.watchtower?.enabled && webManagerFactories.createWatchtowerCapture) {
2537
+ this.startWatchtowerCapture();
2538
+ } else if (config.watchtower?.enabled) {
2539
+ this.log("Watchtower capture requested but not available on this platform (web only).");
2540
+ }
2504
2541
  if (config.crons?.enabled) {
2505
2542
  this.cronManager = new CronMonitorManager({
2506
2543
  apiKey: config.apiKey,
@@ -2740,6 +2777,7 @@ var SitePongClient = class {
2740
2777
  this.log("identify hook failed:", err);
2741
2778
  }
2742
2779
  }
2780
+ this.watchtowerCapture?.setDistinctId(userId);
2743
2781
  if (!this.analyticsManager) {
2744
2782
  this.log("Analytics not enabled. Set analytics.enabled: true in init()");
2745
2783
  return;
@@ -2807,6 +2845,49 @@ var SitePongClient = class {
2807
2845
  getReplaySessionId() {
2808
2846
  return this.replayManager?.getSessionId() ?? null;
2809
2847
  }
2848
+ // --- Watchtower tap capture (web) ---
2849
+ /**
2850
+ * Start Watchtower web tap capture. Options merge over `watchtower` from
2851
+ * init(); `projectId` is required (either here or in init config). Reuses
2852
+ * the analytics AutocaptureModule's click listener when autocapture is on.
2853
+ */
2854
+ startWatchtowerCapture(options) {
2855
+ if (!webManagerFactories.createWatchtowerCapture) {
2856
+ this.log("Watchtower capture not available on this platform (web only).");
2857
+ return false;
2858
+ }
2859
+ if (!this.initialized || !this.config.apiKey) {
2860
+ this.log("Watchtower capture requires init() to be called first.");
2861
+ return false;
2862
+ }
2863
+ const opts = { ...this.watchtowerOptions, ...options };
2864
+ if (!opts.projectId) {
2865
+ this.log("Watchtower capture requires watchtower.projectId.");
2866
+ return false;
2867
+ }
2868
+ if (this.watchtowerCapture) {
2869
+ this.watchtowerCapture.stop();
2870
+ this.watchtowerCapture = null;
2871
+ }
2872
+ this.watchtowerCapture = webManagerFactories.createWatchtowerCapture({
2873
+ apiKey: this.config.apiKey,
2874
+ projectId: opts.projectId,
2875
+ endpoint: opts.endpoint || this.config.endpoint || DEFAULT_ENDPOINT3,
2876
+ appVersion: this.config.release || void 0,
2877
+ maxBatchSize: opts.maxBatchSize,
2878
+ flushInterval: opts.flushInterval,
2879
+ blockSelector: opts.blockSelector,
2880
+ maskSelector: opts.maskSelector,
2881
+ debug: this.config.debug
2882
+ });
2883
+ this.watchtowerCapture.start(this.analyticsManager?.getAutocaptureModule() ?? null);
2884
+ return true;
2885
+ }
2886
+ stopWatchtowerCapture() {
2887
+ if (!this.watchtowerCapture) return;
2888
+ this.watchtowerCapture.stop();
2889
+ this.watchtowerCapture = null;
2890
+ }
2810
2891
  // --- Performance (Tier 7) ---
2811
2892
  startTransaction(name, data) {
2812
2893
  if (!this.performanceManager) {
@@ -2958,6 +3039,7 @@ var SitePongClient = class {
2958
3039
  if (this.replayManager) {
2959
3040
  this.replayManager.setUser(null);
2960
3041
  }
3042
+ this.watchtowerCapture?.setDistinctId(null);
2961
3043
  }
2962
3044
  addBreadcrumb(breadcrumb) {
2963
3045
  this.log("Breadcrumb added:", breadcrumb);
@@ -3182,6 +3264,8 @@ var getDeviceSignals = sitepong.getDeviceSignals.bind(sitepong);
3182
3264
  var getFraudCheck = sitepong.getFraudCheck.bind(sitepong);
3183
3265
  var startReplay = sitepong.startReplay.bind(sitepong);
3184
3266
  var stopReplay = sitepong.stopReplay.bind(sitepong);
3267
+ var startWatchtowerCapture = sitepong.startWatchtowerCapture.bind(sitepong);
3268
+ var stopWatchtowerCapture = sitepong.stopWatchtowerCapture.bind(sitepong);
3185
3269
  var isReplayRecording = sitepong.isReplayRecording.bind(sitepong);
3186
3270
  var getReplaySessionId = sitepong.getReplaySessionId.bind(sitepong);
3187
3271
  var startTransaction = sitepong.startTransaction.bind(sitepong);
@@ -3664,7 +3748,9 @@ exports.startProfileSpan = startProfileSpan;
3664
3748
  exports.startReplay = startReplay;
3665
3749
  exports.startSpan = startSpan;
3666
3750
  exports.startTransaction = startTransaction;
3751
+ exports.startWatchtowerCapture = startWatchtowerCapture;
3667
3752
  exports.stopReplay = stopReplay;
3753
+ exports.stopWatchtowerCapture = stopWatchtowerCapture;
3668
3754
  exports.superlinkClient = superlinkClient;
3669
3755
  exports.superlinkIdentify = identify;
3670
3756
  exports.track = track;