@formo/analytics 1.19.7 → 1.19.9

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.
@@ -55,13 +55,21 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
55
55
  return to.concat(ar || Array.prototype.slice.call(from));
56
56
  };
57
57
  import { createStore } from "mipd";
58
- import { EVENTS_API_URL, EventType, LOCAL_ANONYMOUS_ID_KEY, SESSION_CURRENT_URL_KEY, SESSION_USER_ID_KEY, SESSION_WALLET_DETECTED_KEY, DEFAULT_PROVIDER_ICON, } from "./constants";
58
+ import { EVENTS_API_URL, EventType, LOCAL_ANONYMOUS_ID_KEY, SESSION_CURRENT_URL_KEY, SESSION_USER_ID_KEY, SESSION_WALLET_DETECTED_KEY, SESSION_WALLET_IDENTIFIED_KEY, DEFAULT_PROVIDER_ICON, } from "./constants";
59
59
  import { cookie, EventManager, EventQueue, initStorageManager, logger, Logger, } from "./lib";
60
60
  import { SignatureStatus, TransactionStatus, WRAPPED_REQUEST_SYMBOL, WRAPPED_REQUEST_REF_SYMBOL, } from "./types";
61
61
  import { toChecksumAddress } from "./utils";
62
62
  import { getValidAddress } from "./utils/address";
63
63
  import { isLocalhost } from "./validators";
64
64
  import { parseChainId } from "./utils/chain";
65
+ /**
66
+ * Constants for provider switching reasons
67
+ */
68
+ var PROVIDER_SWITCH_REASONS = {
69
+ ADDRESS_MISMATCH: "Address mismatch indicates wallet switch",
70
+ NO_ACCOUNTS: "Current provider has no accounts",
71
+ CHECK_FAILED: "Could not check current provider accounts"
72
+ };
65
73
  var FormoAnalytics = /** @class */ (function () {
66
74
  function FormoAnalytics(writeKey, options) {
67
75
  if (options === void 0) { options = {}; }
@@ -83,6 +91,8 @@ var FormoAnalytics = /** @class */ (function () {
83
91
  * - A provider can be tracked but later removed from discovery
84
92
  */
85
93
  this._trackedProviders = new Set();
94
+ // Flag to prevent concurrent processing of accountsChanged events
95
+ this._processingAccountsChanged = false;
86
96
  // Set to efficiently track seen providers for deduplication and O(1) lookup
87
97
  this._seenProviders = new Set();
88
98
  this.currentUserId = "";
@@ -206,6 +216,7 @@ var FormoAnalytics = /** @class */ (function () {
206
216
  cookie().remove(LOCAL_ANONYMOUS_ID_KEY);
207
217
  cookie().remove(SESSION_USER_ID_KEY);
208
218
  cookie().remove(SESSION_WALLET_DETECTED_KEY);
219
+ cookie().remove(SESSION_WALLET_IDENTIFIED_KEY);
209
220
  };
210
221
  /**
211
222
  * Emits a connect wallet event.
@@ -282,7 +293,8 @@ var FormoAnalytics = /** @class */ (function () {
282
293
  _a.sent();
283
294
  this.currentAddress = undefined;
284
295
  this.currentChainId = undefined;
285
- logger.info("Wallet disconnected: Cleared currentAddress and currentChainId");
296
+ this.clearActiveProvider();
297
+ logger.info("Wallet disconnected: Cleared currentAddress, currentChainId, and provider");
286
298
  return [2 /*return*/];
287
299
  }
288
300
  });
@@ -392,51 +404,58 @@ var FormoAnalytics = /** @class */ (function () {
392
404
  */
393
405
  FormoAnalytics.prototype.identify = function (params, properties, context, callback) {
394
406
  return __awaiter(this, void 0, void 0, function () {
395
- var _i, _a, providerDetail, provider, address_1, err_1, userId, address, providerName, rdns, validAddress, e_1;
407
+ var _i, _a, providerDetail, provider, address_1, validAddress_1, err_1, userId, address, providerName, rdns, validAddress, e_1;
396
408
  var _b;
397
409
  return __generator(this, function (_c) {
398
410
  switch (_c.label) {
399
411
  case 0:
400
- _c.trys.push([0, 11, , 12]);
401
- if (!!params) return [3 /*break*/, 9];
412
+ _c.trys.push([0, 12, , 13]);
413
+ if (!!params) return [3 /*break*/, 10];
402
414
  // If no params provided, auto-identify
403
415
  logger.info("Auto-identifying with providers:", this._providers.map(function (p) { return p.info.name; }));
404
416
  _i = 0, _a = this._providers;
405
417
  _c.label = 1;
406
418
  case 1:
407
- if (!(_i < _a.length)) return [3 /*break*/, 8];
419
+ if (!(_i < _a.length)) return [3 /*break*/, 9];
408
420
  providerDetail = _a[_i];
409
421
  provider = providerDetail.provider;
410
422
  if (!provider)
411
- return [3 /*break*/, 7];
423
+ return [3 /*break*/, 8];
412
424
  _c.label = 2;
413
425
  case 2:
414
- _c.trys.push([2, 6, , 7]);
426
+ _c.trys.push([2, 7, , 8]);
415
427
  return [4 /*yield*/, this.getAddress(provider)];
416
428
  case 3:
417
429
  address_1 = _c.sent();
418
- if (!address_1) return [3 /*break*/, 5];
419
- logger.info("Auto-identifying", address_1, providerDetail.info.name, providerDetail.info.rdns);
430
+ if (!address_1) return [3 /*break*/, 6];
431
+ validAddress_1 = this.validateAndChecksumAddress(address_1);
432
+ if (!(validAddress_1 && !this.session.isWalletIdentified(validAddress_1, providerDetail.info.rdns))) return [3 /*break*/, 5];
433
+ logger.info("Auto-identifying", validAddress_1, providerDetail.info.name, providerDetail.info.rdns);
420
434
  // NOTE: do not set this.currentAddress without explicit connect or identify
421
435
  return [4 /*yield*/, this.identify({
422
- address: address_1,
436
+ address: validAddress_1,
423
437
  providerName: providerDetail.info.name,
424
438
  rdns: providerDetail.info.rdns,
425
439
  }, properties, context, callback)];
426
440
  case 4:
427
441
  // NOTE: do not set this.currentAddress without explicit connect or identify
428
442
  _c.sent();
429
- _c.label = 5;
430
- case 5: return [3 /*break*/, 7];
431
- case 6:
443
+ return [3 /*break*/, 6];
444
+ case 5:
445
+ if (validAddress_1) {
446
+ logger.info("Auto-identify: Skipping already identified wallet", validAddress_1, providerDetail.info.name, providerDetail.info.rdns);
447
+ }
448
+ _c.label = 6;
449
+ case 6: return [3 /*break*/, 8];
450
+ case 7:
432
451
  err_1 = _c.sent();
433
452
  logger.error("Failed to identify provider ".concat(providerDetail.info.name, ":"), err_1);
434
- return [3 /*break*/, 7];
435
- case 7:
453
+ return [3 /*break*/, 8];
454
+ case 8:
436
455
  _i++;
437
456
  return [3 /*break*/, 1];
438
- case 8: return [2 /*return*/];
439
- case 9:
457
+ case 9: return [2 /*return*/];
458
+ case 10:
440
459
  userId = params.userId, address = params.address, providerName = params.providerName, rdns = params.rdns;
441
460
  logger.info("Identify", address, userId, providerName, rdns);
442
461
  validAddress = undefined;
@@ -454,20 +473,29 @@ var FormoAnalytics = /** @class */ (function () {
454
473
  this.currentUserId = userId;
455
474
  cookie().set(SESSION_USER_ID_KEY, userId);
456
475
  }
476
+ // Check for duplicate identify events in this session
477
+ if (validAddress && rdns && this.session.isWalletIdentified(validAddress, rdns)) {
478
+ logger.warn("Identify: Wallet ".concat(providerName || 'Unknown', " with address ").concat(validAddress, " already identified in this session"));
479
+ return [2 /*return*/];
480
+ }
481
+ // Mark as identified before emitting the event
482
+ if (validAddress && rdns) {
483
+ this.session.markWalletIdentified(validAddress, rdns);
484
+ }
457
485
  return [4 /*yield*/, this.trackEvent(EventType.IDENTIFY, {
458
486
  address: validAddress,
459
487
  providerName: providerName,
460
488
  userId: userId,
461
489
  rdns: rdns,
462
490
  }, properties, context, callback)];
463
- case 10:
464
- _c.sent();
465
- return [3 /*break*/, 12];
466
491
  case 11:
492
+ _c.sent();
493
+ return [3 /*break*/, 13];
494
+ case 12:
467
495
  e_1 = _c.sent();
468
496
  logger.log("identify error", e_1);
469
- return [3 /*break*/, 12];
470
- case 12: return [2 /*return*/];
497
+ return [3 /*break*/, 13];
498
+ case 13: return [2 /*return*/];
471
499
  }
472
500
  });
473
501
  });
@@ -580,12 +608,49 @@ var FormoAnalytics = /** @class */ (function () {
580
608
  };
581
609
  FormoAnalytics.prototype.onAccountsChanged = function (provider, accounts) {
582
610
  return __awaiter(this, void 0, void 0, function () {
583
- var error_1, address, nextChainId, wasDisconnected, isProviderSwitch, hadPreviousConnection, error_2, providerInfo, effectiveChainId;
584
- var _a, _b, _c;
585
- return __generator(this, function (_d) {
586
- switch (_d.label) {
611
+ return __generator(this, function (_a) {
612
+ switch (_a.label) {
587
613
  case 0:
588
614
  logger.info("onAccountsChanged", accounts);
615
+ // Prevent concurrent processing of accountsChanged events to avoid race conditions
616
+ if (this._processingAccountsChanged) {
617
+ logger.debug("OnAccountsChanged: Already processing accountsChanged, skipping", {
618
+ provider: this.getProviderInfo(provider).name
619
+ });
620
+ return [2 /*return*/];
621
+ }
622
+ this._processingAccountsChanged = true;
623
+ _a.label = 1;
624
+ case 1:
625
+ _a.trys.push([1, , 3, 4]);
626
+ return [4 /*yield*/, this._handleAccountsChanged(provider, accounts)];
627
+ case 2:
628
+ _a.sent();
629
+ return [3 /*break*/, 4];
630
+ case 3:
631
+ this._processingAccountsChanged = false;
632
+ return [7 /*endfinally*/];
633
+ case 4: return [2 /*return*/];
634
+ }
635
+ });
636
+ });
637
+ };
638
+ /**
639
+ * Handles changes to the accounts of a given EIP-1193 provider.
640
+ *
641
+ * @param provider - The EIP-1193 provider whose accounts have changed.
642
+ * @param accounts - The new array of account addresses. An empty array indicates a disconnect.
643
+ * @returns A promise that resolves when the account change has been processed.
644
+ *
645
+ * If the accounts array is empty and the provider is the active provider, this method triggers
646
+ * a disconnect flow. Otherwise, it updates the state to reflect the new accounts as needed.
647
+ */
648
+ FormoAnalytics.prototype._handleAccountsChanged = function (provider, accounts) {
649
+ return __awaiter(this, void 0, void 0, function () {
650
+ var error_1, address, currentStoredAddress, newProviderAddress, activeProviderAccounts, error_2, nextChainId, wasDisconnected, providerInfo, effectiveChainId;
651
+ return __generator(this, function (_a) {
652
+ switch (_a.label) {
653
+ case 0:
589
654
  if (!(accounts.length === 0)) return [3 /*break*/, 7];
590
655
  if (!(this._provider === provider)) return [3 /*break*/, 5];
591
656
  logger.info("OnAccountsChanged: Detecting disconnect, current state:", {
@@ -593,9 +658,9 @@ var FormoAnalytics = /** @class */ (function () {
593
658
  currentChainId: this.currentChainId,
594
659
  providerMatch: this._provider === provider
595
660
  });
596
- _d.label = 1;
661
+ _a.label = 1;
597
662
  case 1:
598
- _d.trys.push([1, 3, , 4]);
663
+ _a.trys.push([1, 3, , 4]);
599
664
  // Pass current state explicitly to ensure we have the data for the disconnect event
600
665
  return [4 /*yield*/, this.disconnect({
601
666
  chainId: this.currentChainId,
@@ -603,16 +668,16 @@ var FormoAnalytics = /** @class */ (function () {
603
668
  })];
604
669
  case 2:
605
670
  // Pass current state explicitly to ensure we have the data for the disconnect event
606
- _d.sent();
671
+ _a.sent();
607
672
  return [3 /*break*/, 4];
608
673
  case 3:
609
- error_1 = _d.sent();
674
+ error_1 = _a.sent();
610
675
  logger.error("Failed to disconnect provider on accountsChanged", error_1);
611
676
  return [3 /*break*/, 4];
612
677
  case 4: return [3 /*break*/, 6];
613
678
  case 5:
614
679
  logger.info("OnAccountsChanged: Ignoring disconnect for non-active provider");
615
- _d.label = 6;
680
+ _a.label = 6;
616
681
  case 6: return [2 /*return*/];
617
682
  case 7:
618
683
  address = this.validateAndChecksumAddress(accounts[0]);
@@ -620,54 +685,106 @@ var FormoAnalytics = /** @class */ (function () {
620
685
  logger.warn("onAccountsChanged: Invalid address received", accounts[0]);
621
686
  return [2 /*return*/];
622
687
  }
623
- // If both the provider and address are the same, no-op. Allow provider switches even if address is the same.
624
- if (this._provider === provider && address === this.currentAddress) {
625
- return [2 /*return*/];
626
- }
627
- return [4 /*yield*/, this.getCurrentChainId(provider)];
628
- case 8:
629
- nextChainId = _d.sent();
630
- wasDisconnected = !this.currentAddress;
631
- isProviderSwitch = this._provider && this._provider !== provider;
632
- logger.info("OnAccountsChanged: Provider switching analysis:", {
633
- currentProvider: ((_b = (_a = this._provider) === null || _a === void 0 ? void 0 : _a.constructor) === null || _b === void 0 ? void 0 : _b.name) || 'none',
634
- newProvider: ((_c = provider === null || provider === void 0 ? void 0 : provider.constructor) === null || _c === void 0 ? void 0 : _c.name) || 'unknown',
635
- currentAddress: this.currentAddress,
636
- wasDisconnected: wasDisconnected,
637
- isProviderMismatch: isProviderSwitch
688
+ if (!(this._provider && this._provider !== provider)) return [3 /*break*/, 18];
689
+ currentStoredAddress = this.currentAddress;
690
+ newProviderAddress = this.validateAndChecksumAddress(address);
691
+ logger.info("OnAccountsChanged: Different provider attempting to connect", {
692
+ activeProvider: this.getProviderInfo(this._provider).name,
693
+ eventProvider: this.getProviderInfo(provider).name,
694
+ currentStoredAddress: currentStoredAddress,
695
+ newProviderAddress: newProviderAddress
638
696
  });
639
- if (!isProviderSwitch) return [3 /*break*/, 13];
640
- hadPreviousConnection = !!this.currentAddress;
641
- if (!hadPreviousConnection) return [3 /*break*/, 12];
642
- logger.info("OnAccountsChanged: Detected provider switch with existing connection - emitting disconnect for previous provider");
643
- _d.label = 9;
697
+ _a.label = 8;
698
+ case 8:
699
+ _a.trys.push([8, 16, , 18]);
700
+ return [4 /*yield*/, this.getAccounts(this._provider)];
644
701
  case 9:
645
- _d.trys.push([9, 11, , 12]);
702
+ activeProviderAccounts = _a.sent();
703
+ logger.info("OnAccountsChanged: Checking current provider accounts", {
704
+ activeProvider: this.getProviderInfo(this._provider).name,
705
+ accountsLength: activeProviderAccounts ? activeProviderAccounts.length : 0,
706
+ accounts: activeProviderAccounts
707
+ });
708
+ if (!(activeProviderAccounts && activeProviderAccounts.length > 0)) return [3 /*break*/, 13];
709
+ if (!(newProviderAddress && currentStoredAddress && newProviderAddress !== currentStoredAddress)) return [3 /*break*/, 11];
710
+ logger.info("OnAccountsChanged: Different address detected, switching providers despite current provider having accounts", {
711
+ activeProvider: this.getProviderInfo(this._provider).name,
712
+ eventProvider: this.getProviderInfo(provider).name,
713
+ currentAddress: currentStoredAddress,
714
+ newAddress: newProviderAddress,
715
+ reason: PROVIDER_SWITCH_REASONS.ADDRESS_MISMATCH
716
+ });
717
+ // Emit disconnect for the old provider
646
718
  return [4 /*yield*/, this.disconnect({
647
719
  chainId: this.currentChainId,
648
720
  address: this.currentAddress
649
721
  })];
650
722
  case 10:
651
- _d.sent();
723
+ // Emit disconnect for the old provider
724
+ _a.sent();
725
+ // Clear state and let the new provider become active
726
+ this.clearActiveProvider();
652
727
  return [3 /*break*/, 12];
653
728
  case 11:
654
- error_2 = _d.sent();
655
- logger.error("Failed to emit disconnect during provider switch:", error_2);
656
- return [3 /*break*/, 12];
657
- case 12:
658
- // Validate that the new provider is in a valid state before switching
659
- if (this.isProviderInValidState(provider)) {
660
- logger.info("OnAccountsChanged: Handling provider mismatch - switching providers");
661
- this.handleProviderMismatch(provider);
729
+ logger.info("OnAccountsChanged: Current provider still has accounts and same address, ignoring new provider", {
730
+ activeProvider: this.getProviderInfo(this._provider).name,
731
+ eventProvider: this.getProviderInfo(provider).name,
732
+ activeProviderAccountsCount: activeProviderAccounts.length,
733
+ currentAddress: currentStoredAddress,
734
+ newAddress: newProviderAddress
735
+ });
736
+ return [2 /*return*/];
737
+ case 12: return [3 /*break*/, 15];
738
+ case 13:
739
+ logger.info("OnAccountsChanged: Current provider has no accounts, switching to new provider", {
740
+ oldProvider: this.getProviderInfo(this._provider).name,
741
+ newProvider: this.getProviderInfo(provider).name,
742
+ reason: PROVIDER_SWITCH_REASONS.NO_ACCOUNTS
743
+ });
744
+ // Emit disconnect for the old provider that didn't signal properly
745
+ return [4 /*yield*/, this.disconnect({
746
+ chainId: this.currentChainId,
747
+ address: this.currentAddress
748
+ })];
749
+ case 14:
750
+ // Emit disconnect for the old provider that didn't signal properly
751
+ _a.sent();
752
+ // Clear state and let the new provider become active
753
+ this.clearActiveProvider();
754
+ _a.label = 15;
755
+ case 15: return [3 /*break*/, 18];
756
+ case 16:
757
+ error_2 = _a.sent();
758
+ logger.warn("OnAccountsChanged: Could not check current provider accounts, switching to new provider", {
759
+ error: error_2 instanceof Error ? error_2.message : String(error_2),
760
+ errorType: error_2 instanceof Error ? error_2.constructor.name : typeof error_2,
761
+ oldProvider: this._provider ? this.getProviderInfo(this._provider).name : 'unknown',
762
+ newProvider: this.getProviderInfo(provider).name,
763
+ reason: PROVIDER_SWITCH_REASONS.CHECK_FAILED
764
+ });
765
+ // If we can't check the current provider, assume it's disconnected
766
+ return [4 /*yield*/, this.disconnect({
767
+ chainId: this.currentChainId,
768
+ address: this.currentAddress
769
+ })];
770
+ case 17:
771
+ // If we can't check the current provider, assume it's disconnected
772
+ _a.sent();
773
+ this.clearActiveProvider();
774
+ return [3 /*break*/, 18];
775
+ case 18:
776
+ // Set provider if none exists (first connection)
777
+ if (!this._provider) {
778
+ this._provider = provider;
662
779
  }
663
- else {
664
- logger.warn("Provider switching blocked: new provider is not in a valid state");
780
+ // If both the provider and address are the same, no-op
781
+ if (this._provider === provider && address === this.currentAddress) {
665
782
  return [2 /*return*/];
666
783
  }
667
- _d.label = 13;
668
- case 13:
669
- // Commit new active provider and state
670
- this._provider = provider;
784
+ return [4 /*yield*/, this.getCurrentChainId(provider)];
785
+ case 19:
786
+ nextChainId = _a.sent();
787
+ wasDisconnected = !this.currentAddress;
671
788
  this.currentAddress = address;
672
789
  this.currentChainId = nextChainId;
673
790
  providerInfo = this.getProviderInfo(provider);
@@ -675,7 +792,6 @@ var FormoAnalytics = /** @class */ (function () {
675
792
  chainId: nextChainId,
676
793
  address: address,
677
794
  wasDisconnected: wasDisconnected,
678
- isProviderSwitch: isProviderSwitch,
679
795
  providerName: providerInfo.name,
680
796
  rdns: providerInfo.rdns,
681
797
  hasChainId: !!nextChainId
@@ -798,7 +914,7 @@ var FormoAnalytics = /** @class */ (function () {
798
914
  };
799
915
  FormoAnalytics.prototype.onConnected = function (provider, connection) {
800
916
  return __awaiter(this, void 0, void 0, function () {
801
- var chainId, address, wasDisconnected, providerInfo, effectiveChainId, e_3;
917
+ var chainId, address, wasDisconnected, isActiveProvider, providerInfo, effectiveChainId, providerInfo, e_3;
802
918
  return __generator(this, function (_a) {
803
919
  switch (_a.label) {
804
920
  case 0:
@@ -818,17 +934,21 @@ var FormoAnalytics = /** @class */ (function () {
818
934
  if (!this._provider) {
819
935
  this._provider = provider;
820
936
  }
821
- this.currentChainId = chainId;
822
- this.currentAddress = this.validateAndChecksumAddress(address) || undefined;
823
- // Always emit connect event for better analytics capture
824
- if (this.currentAddress) {
937
+ isActiveProvider = this._provider === provider;
938
+ // Only update global state (chainId/address) from the active provider
939
+ if (isActiveProvider) {
940
+ this.currentChainId = chainId;
941
+ this.currentAddress = this.validateAndChecksumAddress(address) || undefined;
942
+ }
943
+ if (isActiveProvider && this.currentAddress) {
825
944
  providerInfo = this.getProviderInfo(provider);
826
945
  logger.info("OnConnected: Detected wallet connection, emitting connect event", {
827
946
  chainId: chainId,
828
947
  wasDisconnected: wasDisconnected,
829
948
  providerName: providerInfo.name,
830
949
  rdns: providerInfo.rdns,
831
- hasChainId: !!chainId
950
+ hasChainId: !!chainId,
951
+ isActiveProvider: isActiveProvider
832
952
  });
833
953
  effectiveChainId = chainId || 0;
834
954
  if (effectiveChainId === 0) {
@@ -844,6 +964,16 @@ var FormoAnalytics = /** @class */ (function () {
844
964
  logger.error("Failed to track connect event during provider connection:", error);
845
965
  });
846
966
  }
967
+ else if (address && !isActiveProvider) {
968
+ providerInfo = this.getProviderInfo(provider);
969
+ logger.debug("OnConnected: Skipping connect event for non-active provider", {
970
+ chainId: chainId,
971
+ providerName: providerInfo.name,
972
+ rdns: providerInfo.rdns,
973
+ isActiveProvider: isActiveProvider,
974
+ activeProviderInfo: this._provider ? this.getProviderInfo(this._provider) : null
975
+ });
976
+ }
847
977
  }
848
978
  return [3 /*break*/, 4];
849
979
  case 3:
@@ -1606,7 +1736,7 @@ var FormoAnalytics = /** @class */ (function () {
1606
1736
  this.removeProviderListeners(provider);
1607
1737
  this._trackedProviders.delete(provider);
1608
1738
  if (this._provider === provider) {
1609
- this._provider = undefined;
1739
+ this.clearActiveProvider();
1610
1740
  }
1611
1741
  }
1612
1742
  catch (e) {
@@ -1678,6 +1808,13 @@ var FormoAnalytics = /** @class */ (function () {
1678
1808
  var validAddress = getValidAddress(address);
1679
1809
  return validAddress ? toChecksumAddress(validAddress) : undefined;
1680
1810
  };
1811
+ /**
1812
+ * Helper method to clear the active provider state
1813
+ * Centralizes provider clearing logic for consistency
1814
+ */
1815
+ FormoAnalytics.prototype.clearActiveProvider = function () {
1816
+ this._provider = undefined;
1817
+ };
1681
1818
  /**
1682
1819
  * Helper method to safely add a provider detail to _providers array, ensuring no duplicates
1683
1820
  * @param detail The provider detail to add
@@ -1715,12 +1852,33 @@ var FormoAnalyticsSession = /** @class */ (function () {
1715
1852
  FormoAnalyticsSession.prototype.markWalletDetected = function (rdns) {
1716
1853
  var _a;
1717
1854
  var rdnses = ((_a = cookie().get(SESSION_WALLET_DETECTED_KEY)) === null || _a === void 0 ? void 0 : _a.split(",")) || [];
1718
- rdnses.push(rdns);
1719
- cookie().set(SESSION_WALLET_DETECTED_KEY, rdnses.join(","), {
1720
- // by the end of the day
1721
- expires: new Date(Date.now() + 86400 * 1000).toUTCString(),
1722
- path: "/",
1723
- });
1855
+ if (!rdnses.includes(rdns)) {
1856
+ rdnses.push(rdns);
1857
+ cookie().set(SESSION_WALLET_DETECTED_KEY, rdnses.join(","), {
1858
+ // by the end of the day
1859
+ expires: new Date(Date.now() + 86400 * 1000).toUTCString(),
1860
+ path: "/",
1861
+ });
1862
+ }
1863
+ };
1864
+ FormoAnalyticsSession.prototype.isWalletIdentified = function (address, rdns) {
1865
+ var _a;
1866
+ var identifiedKey = "".concat(address, ":").concat(rdns);
1867
+ var identifiedWallets = ((_a = cookie().get(SESSION_WALLET_IDENTIFIED_KEY)) === null || _a === void 0 ? void 0 : _a.split(",")) || [];
1868
+ return identifiedWallets.includes(identifiedKey);
1869
+ };
1870
+ FormoAnalyticsSession.prototype.markWalletIdentified = function (address, rdns) {
1871
+ var _a;
1872
+ var identifiedKey = "".concat(address, ":").concat(rdns);
1873
+ var identifiedWallets = ((_a = cookie().get(SESSION_WALLET_IDENTIFIED_KEY)) === null || _a === void 0 ? void 0 : _a.split(",")) || [];
1874
+ if (!identifiedWallets.includes(identifiedKey)) {
1875
+ identifiedWallets.push(identifiedKey);
1876
+ cookie().set(SESSION_WALLET_IDENTIFIED_KEY, identifiedWallets.join(","), {
1877
+ // by the end of the day
1878
+ expires: new Date(Date.now() + 86400 * 1000).toUTCString(),
1879
+ path: "/",
1880
+ });
1881
+ }
1724
1882
  };
1725
1883
  return FormoAnalyticsSession;
1726
1884
  }());
@@ -1,5 +1,6 @@
1
1
  export declare const SESSION_TRAFFIC_SOURCE_KEY = "traffic-source";
2
2
  export declare const SESSION_WALLET_DETECTED_KEY = "wallet-detected";
3
+ export declare const SESSION_WALLET_IDENTIFIED_KEY = "wallet-identified";
3
4
  export declare const SESSION_CURRENT_URL_KEY = "analytics-current-url";
4
5
  export declare const SESSION_USER_ID_KEY = "user-id";
5
6
  export declare const LOCAL_ANONYMOUS_ID_KEY = "anonymous-id";
@@ -1,5 +1,6 @@
1
1
  export var SESSION_TRAFFIC_SOURCE_KEY = "traffic-source";
2
2
  export var SESSION_WALLET_DETECTED_KEY = "wallet-detected";
3
+ export var SESSION_WALLET_IDENTIFIED_KEY = "wallet-identified";
3
4
  export var SESSION_CURRENT_URL_KEY = "analytics-current-url";
4
5
  export var SESSION_USER_ID_KEY = "user-id";
5
6
  export var LOCAL_ANONYMOUS_ID_KEY = "anonymous-id";
@@ -1,2 +1,2 @@
1
- export declare const version = "1.19.5";
1
+ export declare const version = "1.19.7";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // Generated by genversion.
2
- export var version = '1.19.5';
2
+ export var version = '1.19.7';
3
3
  //# sourceMappingURL=version.js.map
@@ -1,4 +1,13 @@
1
1
  export var getActionDescriptor = function (type, properties) {
2
- return "".concat(type).concat((properties === null || properties === void 0 ? void 0 : properties.status) ? " ".concat(properties === null || properties === void 0 ? void 0 : properties.status) : "");
2
+ var descriptor = type;
3
+ // Add status for events that have it (e.g., signature, transaction)
4
+ if (properties === null || properties === void 0 ? void 0 : properties.status) {
5
+ descriptor += " ".concat(properties.status);
6
+ }
7
+ // Add RDNS for connect/disconnect events to identify the wallet provider
8
+ if ((type === 'connect' || type === 'disconnect') && (properties === null || properties === void 0 ? void 0 : properties.rdns)) {
9
+ descriptor += " (".concat(properties.rdns, ")");
10
+ }
11
+ return descriptor;
3
12
  };
4
13
  //# sourceMappingURL=base.js.map