sitepong 0.2.13 → 0.2.14

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.
@@ -749,7 +749,7 @@ declare function startWatchtower(config: WatchtowerConfig): void;
749
749
  * Set user identity — stamped as distinct_id on every subsequent event. Call
750
750
  * this wherever you call the SDK's identify(), with the same id.
751
751
  */
752
- declare function setWatchtowerUser(distinctId: string | null): void;
752
+ declare function setWatchtowerUser(distinctId: string | null, email?: string | null, name?: string | null): void;
753
753
  /**
754
754
  * The engine's current capture session id (null when not running). Attach it
755
755
  * to error reports/analytics — it is the key that joins an error to its
@@ -2625,7 +2625,7 @@ var SitePongClient = class {
2625
2625
  }
2626
2626
  for (const hook of this.identifyHooks) {
2627
2627
  try {
2628
- hook(userId);
2628
+ hook(userId, traits);
2629
2629
  } catch (err) {
2630
2630
  this.log("identify hook failed:", err);
2631
2631
  }
@@ -3149,7 +3149,7 @@ sitepong.flushProfiles.bind(sitepong);
3149
3149
  var getRemoteConfig = sitepong.getRemoteConfig.bind(sitepong);
3150
3150
  var isRemoteConfigFeatureEnabled = sitepong.isRemoteConfigFeatureEnabled.bind(sitepong);
3151
3151
  var onRemoteConfigChange = sitepong.onRemoteConfigChange.bind(sitepong);
3152
- sitepong.registerIdentifyHook.bind(sitepong);
3152
+ var registerIdentifyHook = sitepong.registerIdentifyHook.bind(sitepong);
3153
3153
 
3154
3154
  // src/react-native/storage.ts
3155
3155
  function createAsyncStorageAdapter(asyncStorage) {
@@ -4725,6 +4725,7 @@ function loadBridge() {
4725
4725
  return getScreenRecorderModule();
4726
4726
  }
4727
4727
  var started = false;
4728
+ var identifyHookUnsub = null;
4728
4729
  function startWatchtower(config) {
4729
4730
  if (started) return;
4730
4731
  const bridge = loadBridge();
@@ -4747,10 +4748,15 @@ function startWatchtower(config) {
4747
4748
  });
4748
4749
  started = true;
4749
4750
  if (config.distinctId) setWatchtowerUser(config.distinctId);
4751
+ if (!identifyHookUnsub) {
4752
+ identifyHookUnsub = registerIdentifyHook(
4753
+ (userId, traits) => setWatchtowerUser(userId, traits?.email ?? null, traits?.name ?? null)
4754
+ );
4755
+ }
4750
4756
  }
4751
- function setWatchtowerUser(distinctId) {
4757
+ function setWatchtowerUser(distinctId, email = null, name = null) {
4752
4758
  try {
4753
- loadBridge()?.watchtowerSetUser(distinctId);
4759
+ loadBridge()?.watchtowerSetUser(distinctId, email, name);
4754
4760
  } catch {
4755
4761
  }
4756
4762
  }
@@ -4765,6 +4771,8 @@ function stopWatchtower() {
4765
4771
  if (!started) return;
4766
4772
  loadBridge()?.watchtowerStop();
4767
4773
  started = false;
4774
+ identifyHookUnsub?.();
4775
+ identifyHookUnsub = null;
4768
4776
  }
4769
4777
  function subscribeNavigationToWatchtower(navigationRef) {
4770
4778
  const unsubscribe = createNavigationTracker(navigationRef, {