@formo/analytics 1.19.8 → 1.19.10

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.
@@ -269,6 +269,11 @@ export declare class FormoAnalytics implements IFormoAnalytics {
269
269
  * @returns The checksummed address or undefined if invalid
270
270
  */
271
271
  private validateAndChecksumAddress;
272
+ /**
273
+ * Helper method to clear the active provider state
274
+ * Centralizes provider clearing logic for consistency
275
+ */
276
+ private clearActiveProvider;
272
277
  /**
273
278
  * Helper method to safely add a provider detail to _providers array, ensuring no duplicates
274
279
  * @param detail The provider detail to add
@@ -219,6 +219,7 @@ var FormoAnalytics = /** @class */ (function () {
219
219
  (0, lib_1.cookie)().remove(constants_1.LOCAL_ANONYMOUS_ID_KEY);
220
220
  (0, lib_1.cookie)().remove(constants_1.SESSION_USER_ID_KEY);
221
221
  (0, lib_1.cookie)().remove(constants_1.SESSION_WALLET_DETECTED_KEY);
222
+ (0, lib_1.cookie)().remove(constants_1.SESSION_WALLET_IDENTIFIED_KEY);
222
223
  };
223
224
  /**
224
225
  * Emits a connect wallet event.
@@ -295,7 +296,7 @@ var FormoAnalytics = /** @class */ (function () {
295
296
  _a.sent();
296
297
  this.currentAddress = undefined;
297
298
  this.currentChainId = undefined;
298
- this._provider = undefined;
299
+ this.clearActiveProvider();
299
300
  lib_1.logger.info("Wallet disconnected: Cleared currentAddress, currentChainId, and provider");
300
301
  return [2 /*return*/];
301
302
  }
@@ -406,51 +407,64 @@ var FormoAnalytics = /** @class */ (function () {
406
407
  */
407
408
  FormoAnalytics.prototype.identify = function (params, properties, context, callback) {
408
409
  return __awaiter(this, void 0, void 0, function () {
409
- var _i, _a, providerDetail, provider, address_2, err_1, userId, address, providerName, rdns, validAddress, e_1;
410
+ var _i, _a, providerDetail, provider, address_2, validAddress_1, err_1, userId, address, providerName, rdns, validAddress, isAlreadyIdentified, e_1;
410
411
  var _b;
411
412
  return __generator(this, function (_c) {
412
413
  switch (_c.label) {
413
414
  case 0:
414
- _c.trys.push([0, 11, , 12]);
415
- if (!!params) return [3 /*break*/, 9];
415
+ _c.trys.push([0, 12, , 13]);
416
+ if (!!params) return [3 /*break*/, 10];
416
417
  // If no params provided, auto-identify
417
418
  lib_1.logger.info("Auto-identifying with providers:", this._providers.map(function (p) { return p.info.name; }));
418
419
  _i = 0, _a = this._providers;
419
420
  _c.label = 1;
420
421
  case 1:
421
- if (!(_i < _a.length)) return [3 /*break*/, 8];
422
+ if (!(_i < _a.length)) return [3 /*break*/, 9];
422
423
  providerDetail = _a[_i];
423
424
  provider = providerDetail.provider;
424
425
  if (!provider)
425
- return [3 /*break*/, 7];
426
+ return [3 /*break*/, 8];
426
427
  _c.label = 2;
427
428
  case 2:
428
- _c.trys.push([2, 6, , 7]);
429
+ _c.trys.push([2, 7, , 8]);
429
430
  return [4 /*yield*/, this.getAddress(provider)];
430
431
  case 3:
431
432
  address_2 = _c.sent();
432
- if (!address_2) return [3 /*break*/, 5];
433
- lib_1.logger.info("Auto-identifying", address_2, providerDetail.info.name, providerDetail.info.rdns);
433
+ if (!address_2) return [3 /*break*/, 6];
434
+ validAddress_1 = this.validateAndChecksumAddress(address_2);
435
+ lib_1.logger.info("Auto-identify: Checking deduplication", {
436
+ validAddress: validAddress_1,
437
+ rdns: providerDetail.info.rdns,
438
+ providerName: providerDetail.info.name,
439
+ isAlreadyIdentified: validAddress_1 ? this.session.isWalletIdentified(validAddress_1, providerDetail.info.rdns) : false
440
+ });
441
+ if (!(validAddress_1 && !this.session.isWalletIdentified(validAddress_1, providerDetail.info.rdns))) return [3 /*break*/, 5];
442
+ lib_1.logger.info("Auto-identifying", validAddress_1, providerDetail.info.name, providerDetail.info.rdns);
434
443
  // NOTE: do not set this.currentAddress without explicit connect or identify
435
444
  return [4 /*yield*/, this.identify({
436
- address: address_2,
445
+ address: validAddress_1,
437
446
  providerName: providerDetail.info.name,
438
447
  rdns: providerDetail.info.rdns,
439
448
  }, properties, context, callback)];
440
449
  case 4:
441
450
  // NOTE: do not set this.currentAddress without explicit connect or identify
442
451
  _c.sent();
443
- _c.label = 5;
444
- case 5: return [3 /*break*/, 7];
445
- case 6:
452
+ return [3 /*break*/, 6];
453
+ case 5:
454
+ if (validAddress_1) {
455
+ lib_1.logger.info("Auto-identify: Skipping already identified wallet", validAddress_1, providerDetail.info.name, providerDetail.info.rdns);
456
+ }
457
+ _c.label = 6;
458
+ case 6: return [3 /*break*/, 8];
459
+ case 7:
446
460
  err_1 = _c.sent();
447
461
  lib_1.logger.error("Failed to identify provider ".concat(providerDetail.info.name, ":"), err_1);
448
- return [3 /*break*/, 7];
449
- case 7:
462
+ return [3 /*break*/, 8];
463
+ case 8:
450
464
  _i++;
451
465
  return [3 /*break*/, 1];
452
- case 8: return [2 /*return*/];
453
- case 9:
466
+ case 9: return [2 /*return*/];
467
+ case 10:
454
468
  userId = params.userId, address = params.address, providerName = params.providerName, rdns = params.rdns;
455
469
  lib_1.logger.info("Identify", address, userId, providerName, rdns);
456
470
  validAddress = undefined;
@@ -468,20 +482,38 @@ var FormoAnalytics = /** @class */ (function () {
468
482
  this.currentUserId = userId;
469
483
  (0, lib_1.cookie)().set(constants_1.SESSION_USER_ID_KEY, userId);
470
484
  }
485
+ isAlreadyIdentified = validAddress ? this.session.isWalletIdentified(validAddress, rdns || '') : false;
486
+ lib_1.logger.debug("Identify: Checking deduplication", {
487
+ validAddress: validAddress,
488
+ rdns: rdns,
489
+ providerName: providerName,
490
+ hasValidAddress: !!validAddress,
491
+ hasRdns: !!rdns,
492
+ isAlreadyIdentified: isAlreadyIdentified
493
+ });
494
+ if (isAlreadyIdentified) {
495
+ lib_1.logger.info("Identify: Wallet ".concat(providerName || 'Unknown', " with address ").concat(validAddress, " already identified in this session (rdns: ").concat(rdns || 'empty', ")"));
496
+ return [2 /*return*/];
497
+ }
498
+ // Mark as identified before emitting the event
499
+ // Mark even if rdns is empty to prevent duplicate empty identifies
500
+ if (validAddress) {
501
+ this.session.markWalletIdentified(validAddress, rdns || '');
502
+ }
471
503
  return [4 /*yield*/, this.trackEvent(constants_1.EventType.IDENTIFY, {
472
504
  address: validAddress,
473
505
  providerName: providerName,
474
506
  userId: userId,
475
507
  rdns: rdns,
476
508
  }, properties, context, callback)];
477
- case 10:
478
- _c.sent();
479
- return [3 /*break*/, 12];
480
509
  case 11:
510
+ _c.sent();
511
+ return [3 /*break*/, 13];
512
+ case 12:
481
513
  e_1 = _c.sent();
482
514
  lib_1.logger.log("identify error", e_1);
483
- return [3 /*break*/, 12];
484
- case 12: return [2 /*return*/];
515
+ return [3 /*break*/, 13];
516
+ case 13: return [2 /*return*/];
485
517
  }
486
518
  });
487
519
  });
@@ -709,7 +741,7 @@ var FormoAnalytics = /** @class */ (function () {
709
741
  // Emit disconnect for the old provider
710
742
  _a.sent();
711
743
  // Clear state and let the new provider become active
712
- this._provider = undefined;
744
+ this.clearActiveProvider();
713
745
  return [3 /*break*/, 12];
714
746
  case 11:
715
747
  lib_1.logger.info("OnAccountsChanged: Current provider still has accounts and same address, ignoring new provider", {
@@ -736,7 +768,7 @@ var FormoAnalytics = /** @class */ (function () {
736
768
  // Emit disconnect for the old provider that didn't signal properly
737
769
  _a.sent();
738
770
  // Clear state and let the new provider become active
739
- this._provider = undefined;
771
+ this.clearActiveProvider();
740
772
  _a.label = 15;
741
773
  case 15: return [3 /*break*/, 18];
742
774
  case 16:
@@ -756,7 +788,7 @@ var FormoAnalytics = /** @class */ (function () {
756
788
  case 17:
757
789
  // If we can't check the current provider, assume it's disconnected
758
790
  _a.sent();
759
- this._provider = undefined;
791
+ this.clearActiveProvider();
760
792
  return [3 /*break*/, 18];
761
793
  case 18:
762
794
  // Set provider if none exists (first connection)
@@ -1722,7 +1754,7 @@ var FormoAnalytics = /** @class */ (function () {
1722
1754
  this.removeProviderListeners(provider);
1723
1755
  this._trackedProviders.delete(provider);
1724
1756
  if (this._provider === provider) {
1725
- this._provider = undefined;
1757
+ this.clearActiveProvider();
1726
1758
  }
1727
1759
  }
1728
1760
  catch (e) {
@@ -1794,6 +1826,13 @@ var FormoAnalytics = /** @class */ (function () {
1794
1826
  var validAddress = (0, address_1.getValidAddress)(address);
1795
1827
  return validAddress ? (0, utils_1.toChecksumAddress)(validAddress) : undefined;
1796
1828
  };
1829
+ /**
1830
+ * Helper method to clear the active provider state
1831
+ * Centralizes provider clearing logic for consistency
1832
+ */
1833
+ FormoAnalytics.prototype.clearActiveProvider = function () {
1834
+ this._provider = undefined;
1835
+ };
1797
1836
  /**
1798
1837
  * Helper method to safely add a provider detail to _providers array, ensuring no duplicates
1799
1838
  * @param detail The provider detail to add
@@ -1823,6 +1862,10 @@ exports.FormoAnalytics = FormoAnalytics;
1823
1862
  var FormoAnalyticsSession = /** @class */ (function () {
1824
1863
  function FormoAnalyticsSession() {
1825
1864
  }
1865
+ FormoAnalyticsSession.prototype.generateIdentificationKey = function (address, rdns) {
1866
+ // If rdns is missing, use address-only key as fallback for empty identifies
1867
+ return rdns ? "".concat(address, ":").concat(rdns) : address;
1868
+ };
1826
1869
  FormoAnalyticsSession.prototype.isWalletDetected = function (rdns) {
1827
1870
  var _a;
1828
1871
  var rdnses = ((_a = (0, lib_1.cookie)().get(constants_1.SESSION_WALLET_DETECTED_KEY)) === null || _a === void 0 ? void 0 : _a.split(",")) || [];
@@ -1831,12 +1874,51 @@ var FormoAnalyticsSession = /** @class */ (function () {
1831
1874
  FormoAnalyticsSession.prototype.markWalletDetected = function (rdns) {
1832
1875
  var _a;
1833
1876
  var rdnses = ((_a = (0, lib_1.cookie)().get(constants_1.SESSION_WALLET_DETECTED_KEY)) === null || _a === void 0 ? void 0 : _a.split(",")) || [];
1834
- rdnses.push(rdns);
1835
- (0, lib_1.cookie)().set(constants_1.SESSION_WALLET_DETECTED_KEY, rdnses.join(","), {
1836
- // by the end of the day
1837
- expires: new Date(Date.now() + 86400 * 1000).toUTCString(),
1838
- path: "/",
1877
+ if (!rdnses.includes(rdns)) {
1878
+ rdnses.push(rdns);
1879
+ (0, lib_1.cookie)().set(constants_1.SESSION_WALLET_DETECTED_KEY, rdnses.join(","), {
1880
+ // by the end of the day
1881
+ expires: new Date(Date.now() + 86400 * 1000).toUTCString(),
1882
+ path: "/",
1883
+ });
1884
+ }
1885
+ };
1886
+ FormoAnalyticsSession.prototype.isWalletIdentified = function (address, rdns) {
1887
+ var identifiedKey = this.generateIdentificationKey(address, rdns);
1888
+ var cookieValue = (0, lib_1.cookie)().get(constants_1.SESSION_WALLET_IDENTIFIED_KEY);
1889
+ var identifiedWallets = (cookieValue === null || cookieValue === void 0 ? void 0 : cookieValue.split(",")) || [];
1890
+ var isIdentified = identifiedWallets.includes(identifiedKey);
1891
+ lib_1.logger.debug("Session: Checking wallet identification", {
1892
+ identifiedKey: identifiedKey,
1893
+ isIdentified: isIdentified,
1894
+ hasRdns: !!rdns
1839
1895
  });
1896
+ return isIdentified;
1897
+ };
1898
+ FormoAnalyticsSession.prototype.markWalletIdentified = function (address, rdns) {
1899
+ var _a;
1900
+ var identifiedKey = this.generateIdentificationKey(address, rdns);
1901
+ var identifiedWallets = ((_a = (0, lib_1.cookie)().get(constants_1.SESSION_WALLET_IDENTIFIED_KEY)) === null || _a === void 0 ? void 0 : _a.split(",")) || [];
1902
+ if (!identifiedWallets.includes(identifiedKey)) {
1903
+ identifiedWallets.push(identifiedKey);
1904
+ var newValue = identifiedWallets.join(",");
1905
+ (0, lib_1.cookie)().set(constants_1.SESSION_WALLET_IDENTIFIED_KEY, newValue, {
1906
+ // by the end of the day
1907
+ expires: new Date(Date.now() + 86400 * 1000).toUTCString(),
1908
+ path: "/",
1909
+ });
1910
+ lib_1.logger.debug("Session: Marked wallet as identified", {
1911
+ identifiedKey: identifiedKey,
1912
+ hasRdns: !!rdns
1913
+ });
1914
+ }
1915
+ else {
1916
+ lib_1.logger.info("Session: Wallet already marked as identified", {
1917
+ identifiedKey: identifiedKey,
1918
+ existingWallets: identifiedWallets,
1919
+ hasRdns: !!rdns
1920
+ });
1921
+ }
1840
1922
  };
1841
1923
  return FormoAnalyticsSession;
1842
1924
  }());
@@ -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,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_PROVIDER_ICON = exports.LOCAL_ANONYMOUS_ID_KEY = exports.SESSION_USER_ID_KEY = exports.SESSION_CURRENT_URL_KEY = exports.SESSION_WALLET_DETECTED_KEY = exports.SESSION_TRAFFIC_SOURCE_KEY = void 0;
3
+ exports.DEFAULT_PROVIDER_ICON = exports.LOCAL_ANONYMOUS_ID_KEY = exports.SESSION_USER_ID_KEY = exports.SESSION_CURRENT_URL_KEY = exports.SESSION_WALLET_IDENTIFIED_KEY = exports.SESSION_WALLET_DETECTED_KEY = exports.SESSION_TRAFFIC_SOURCE_KEY = void 0;
4
4
  exports.SESSION_TRAFFIC_SOURCE_KEY = "traffic-source";
5
5
  exports.SESSION_WALLET_DETECTED_KEY = "wallet-detected";
6
+ exports.SESSION_WALLET_IDENTIFIED_KEY = "wallet-identified";
6
7
  exports.SESSION_CURRENT_URL_KEY = "analytics-current-url";
7
8
  exports.SESSION_USER_ID_KEY = "user-id";
8
9
  exports.LOCAL_ANONYMOUS_ID_KEY = "anonymous-id";
@@ -1,2 +1,2 @@
1
- export declare const version = "1.19.7";
1
+ export declare const version = "1.19.10";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // Generated by genversion.
5
- exports.version = '1.19.7';
5
+ exports.version = '1.19.10';
6
6
  //# sourceMappingURL=version.js.map
@@ -269,6 +269,11 @@ export declare class FormoAnalytics implements IFormoAnalytics {
269
269
  * @returns The checksummed address or undefined if invalid
270
270
  */
271
271
  private validateAndChecksumAddress;
272
+ /**
273
+ * Helper method to clear the active provider state
274
+ * Centralizes provider clearing logic for consistency
275
+ */
276
+ private clearActiveProvider;
272
277
  /**
273
278
  * Helper method to safely add a provider detail to _providers array, ensuring no duplicates
274
279
  * @param detail The provider detail to add
@@ -55,7 +55,7 @@ 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";
@@ -216,6 +216,7 @@ var FormoAnalytics = /** @class */ (function () {
216
216
  cookie().remove(LOCAL_ANONYMOUS_ID_KEY);
217
217
  cookie().remove(SESSION_USER_ID_KEY);
218
218
  cookie().remove(SESSION_WALLET_DETECTED_KEY);
219
+ cookie().remove(SESSION_WALLET_IDENTIFIED_KEY);
219
220
  };
220
221
  /**
221
222
  * Emits a connect wallet event.
@@ -292,7 +293,7 @@ var FormoAnalytics = /** @class */ (function () {
292
293
  _a.sent();
293
294
  this.currentAddress = undefined;
294
295
  this.currentChainId = undefined;
295
- this._provider = undefined;
296
+ this.clearActiveProvider();
296
297
  logger.info("Wallet disconnected: Cleared currentAddress, currentChainId, and provider");
297
298
  return [2 /*return*/];
298
299
  }
@@ -403,51 +404,64 @@ var FormoAnalytics = /** @class */ (function () {
403
404
  */
404
405
  FormoAnalytics.prototype.identify = function (params, properties, context, callback) {
405
406
  return __awaiter(this, void 0, void 0, function () {
406
- 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, isAlreadyIdentified, e_1;
407
408
  var _b;
408
409
  return __generator(this, function (_c) {
409
410
  switch (_c.label) {
410
411
  case 0:
411
- _c.trys.push([0, 11, , 12]);
412
- if (!!params) return [3 /*break*/, 9];
412
+ _c.trys.push([0, 12, , 13]);
413
+ if (!!params) return [3 /*break*/, 10];
413
414
  // If no params provided, auto-identify
414
415
  logger.info("Auto-identifying with providers:", this._providers.map(function (p) { return p.info.name; }));
415
416
  _i = 0, _a = this._providers;
416
417
  _c.label = 1;
417
418
  case 1:
418
- if (!(_i < _a.length)) return [3 /*break*/, 8];
419
+ if (!(_i < _a.length)) return [3 /*break*/, 9];
419
420
  providerDetail = _a[_i];
420
421
  provider = providerDetail.provider;
421
422
  if (!provider)
422
- return [3 /*break*/, 7];
423
+ return [3 /*break*/, 8];
423
424
  _c.label = 2;
424
425
  case 2:
425
- _c.trys.push([2, 6, , 7]);
426
+ _c.trys.push([2, 7, , 8]);
426
427
  return [4 /*yield*/, this.getAddress(provider)];
427
428
  case 3:
428
429
  address_1 = _c.sent();
429
- if (!address_1) return [3 /*break*/, 5];
430
- 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
+ logger.info("Auto-identify: Checking deduplication", {
433
+ validAddress: validAddress_1,
434
+ rdns: providerDetail.info.rdns,
435
+ providerName: providerDetail.info.name,
436
+ isAlreadyIdentified: validAddress_1 ? this.session.isWalletIdentified(validAddress_1, providerDetail.info.rdns) : false
437
+ });
438
+ if (!(validAddress_1 && !this.session.isWalletIdentified(validAddress_1, providerDetail.info.rdns))) return [3 /*break*/, 5];
439
+ logger.info("Auto-identifying", validAddress_1, providerDetail.info.name, providerDetail.info.rdns);
431
440
  // NOTE: do not set this.currentAddress without explicit connect or identify
432
441
  return [4 /*yield*/, this.identify({
433
- address: address_1,
442
+ address: validAddress_1,
434
443
  providerName: providerDetail.info.name,
435
444
  rdns: providerDetail.info.rdns,
436
445
  }, properties, context, callback)];
437
446
  case 4:
438
447
  // NOTE: do not set this.currentAddress without explicit connect or identify
439
448
  _c.sent();
440
- _c.label = 5;
441
- case 5: return [3 /*break*/, 7];
442
- case 6:
449
+ return [3 /*break*/, 6];
450
+ case 5:
451
+ if (validAddress_1) {
452
+ logger.info("Auto-identify: Skipping already identified wallet", validAddress_1, providerDetail.info.name, providerDetail.info.rdns);
453
+ }
454
+ _c.label = 6;
455
+ case 6: return [3 /*break*/, 8];
456
+ case 7:
443
457
  err_1 = _c.sent();
444
458
  logger.error("Failed to identify provider ".concat(providerDetail.info.name, ":"), err_1);
445
- return [3 /*break*/, 7];
446
- case 7:
459
+ return [3 /*break*/, 8];
460
+ case 8:
447
461
  _i++;
448
462
  return [3 /*break*/, 1];
449
- case 8: return [2 /*return*/];
450
- case 9:
463
+ case 9: return [2 /*return*/];
464
+ case 10:
451
465
  userId = params.userId, address = params.address, providerName = params.providerName, rdns = params.rdns;
452
466
  logger.info("Identify", address, userId, providerName, rdns);
453
467
  validAddress = undefined;
@@ -465,20 +479,38 @@ var FormoAnalytics = /** @class */ (function () {
465
479
  this.currentUserId = userId;
466
480
  cookie().set(SESSION_USER_ID_KEY, userId);
467
481
  }
482
+ isAlreadyIdentified = validAddress ? this.session.isWalletIdentified(validAddress, rdns || '') : false;
483
+ logger.debug("Identify: Checking deduplication", {
484
+ validAddress: validAddress,
485
+ rdns: rdns,
486
+ providerName: providerName,
487
+ hasValidAddress: !!validAddress,
488
+ hasRdns: !!rdns,
489
+ isAlreadyIdentified: isAlreadyIdentified
490
+ });
491
+ if (isAlreadyIdentified) {
492
+ logger.info("Identify: Wallet ".concat(providerName || 'Unknown', " with address ").concat(validAddress, " already identified in this session (rdns: ").concat(rdns || 'empty', ")"));
493
+ return [2 /*return*/];
494
+ }
495
+ // Mark as identified before emitting the event
496
+ // Mark even if rdns is empty to prevent duplicate empty identifies
497
+ if (validAddress) {
498
+ this.session.markWalletIdentified(validAddress, rdns || '');
499
+ }
468
500
  return [4 /*yield*/, this.trackEvent(EventType.IDENTIFY, {
469
501
  address: validAddress,
470
502
  providerName: providerName,
471
503
  userId: userId,
472
504
  rdns: rdns,
473
505
  }, properties, context, callback)];
474
- case 10:
475
- _c.sent();
476
- return [3 /*break*/, 12];
477
506
  case 11:
507
+ _c.sent();
508
+ return [3 /*break*/, 13];
509
+ case 12:
478
510
  e_1 = _c.sent();
479
511
  logger.log("identify error", e_1);
480
- return [3 /*break*/, 12];
481
- case 12: return [2 /*return*/];
512
+ return [3 /*break*/, 13];
513
+ case 13: return [2 /*return*/];
482
514
  }
483
515
  });
484
516
  });
@@ -706,7 +738,7 @@ var FormoAnalytics = /** @class */ (function () {
706
738
  // Emit disconnect for the old provider
707
739
  _a.sent();
708
740
  // Clear state and let the new provider become active
709
- this._provider = undefined;
741
+ this.clearActiveProvider();
710
742
  return [3 /*break*/, 12];
711
743
  case 11:
712
744
  logger.info("OnAccountsChanged: Current provider still has accounts and same address, ignoring new provider", {
@@ -733,7 +765,7 @@ var FormoAnalytics = /** @class */ (function () {
733
765
  // Emit disconnect for the old provider that didn't signal properly
734
766
  _a.sent();
735
767
  // Clear state and let the new provider become active
736
- this._provider = undefined;
768
+ this.clearActiveProvider();
737
769
  _a.label = 15;
738
770
  case 15: return [3 /*break*/, 18];
739
771
  case 16:
@@ -753,7 +785,7 @@ var FormoAnalytics = /** @class */ (function () {
753
785
  case 17:
754
786
  // If we can't check the current provider, assume it's disconnected
755
787
  _a.sent();
756
- this._provider = undefined;
788
+ this.clearActiveProvider();
757
789
  return [3 /*break*/, 18];
758
790
  case 18:
759
791
  // Set provider if none exists (first connection)
@@ -1719,7 +1751,7 @@ var FormoAnalytics = /** @class */ (function () {
1719
1751
  this.removeProviderListeners(provider);
1720
1752
  this._trackedProviders.delete(provider);
1721
1753
  if (this._provider === provider) {
1722
- this._provider = undefined;
1754
+ this.clearActiveProvider();
1723
1755
  }
1724
1756
  }
1725
1757
  catch (e) {
@@ -1791,6 +1823,13 @@ var FormoAnalytics = /** @class */ (function () {
1791
1823
  var validAddress = getValidAddress(address);
1792
1824
  return validAddress ? toChecksumAddress(validAddress) : undefined;
1793
1825
  };
1826
+ /**
1827
+ * Helper method to clear the active provider state
1828
+ * Centralizes provider clearing logic for consistency
1829
+ */
1830
+ FormoAnalytics.prototype.clearActiveProvider = function () {
1831
+ this._provider = undefined;
1832
+ };
1794
1833
  /**
1795
1834
  * Helper method to safely add a provider detail to _providers array, ensuring no duplicates
1796
1835
  * @param detail The provider detail to add
@@ -1820,6 +1859,10 @@ export { FormoAnalytics };
1820
1859
  var FormoAnalyticsSession = /** @class */ (function () {
1821
1860
  function FormoAnalyticsSession() {
1822
1861
  }
1862
+ FormoAnalyticsSession.prototype.generateIdentificationKey = function (address, rdns) {
1863
+ // If rdns is missing, use address-only key as fallback for empty identifies
1864
+ return rdns ? "".concat(address, ":").concat(rdns) : address;
1865
+ };
1823
1866
  FormoAnalyticsSession.prototype.isWalletDetected = function (rdns) {
1824
1867
  var _a;
1825
1868
  var rdnses = ((_a = cookie().get(SESSION_WALLET_DETECTED_KEY)) === null || _a === void 0 ? void 0 : _a.split(",")) || [];
@@ -1828,12 +1871,51 @@ var FormoAnalyticsSession = /** @class */ (function () {
1828
1871
  FormoAnalyticsSession.prototype.markWalletDetected = function (rdns) {
1829
1872
  var _a;
1830
1873
  var rdnses = ((_a = cookie().get(SESSION_WALLET_DETECTED_KEY)) === null || _a === void 0 ? void 0 : _a.split(",")) || [];
1831
- rdnses.push(rdns);
1832
- cookie().set(SESSION_WALLET_DETECTED_KEY, rdnses.join(","), {
1833
- // by the end of the day
1834
- expires: new Date(Date.now() + 86400 * 1000).toUTCString(),
1835
- path: "/",
1874
+ if (!rdnses.includes(rdns)) {
1875
+ rdnses.push(rdns);
1876
+ cookie().set(SESSION_WALLET_DETECTED_KEY, rdnses.join(","), {
1877
+ // by the end of the day
1878
+ expires: new Date(Date.now() + 86400 * 1000).toUTCString(),
1879
+ path: "/",
1880
+ });
1881
+ }
1882
+ };
1883
+ FormoAnalyticsSession.prototype.isWalletIdentified = function (address, rdns) {
1884
+ var identifiedKey = this.generateIdentificationKey(address, rdns);
1885
+ var cookieValue = cookie().get(SESSION_WALLET_IDENTIFIED_KEY);
1886
+ var identifiedWallets = (cookieValue === null || cookieValue === void 0 ? void 0 : cookieValue.split(",")) || [];
1887
+ var isIdentified = identifiedWallets.includes(identifiedKey);
1888
+ logger.debug("Session: Checking wallet identification", {
1889
+ identifiedKey: identifiedKey,
1890
+ isIdentified: isIdentified,
1891
+ hasRdns: !!rdns
1836
1892
  });
1893
+ return isIdentified;
1894
+ };
1895
+ FormoAnalyticsSession.prototype.markWalletIdentified = function (address, rdns) {
1896
+ var _a;
1897
+ var identifiedKey = this.generateIdentificationKey(address, rdns);
1898
+ var identifiedWallets = ((_a = cookie().get(SESSION_WALLET_IDENTIFIED_KEY)) === null || _a === void 0 ? void 0 : _a.split(",")) || [];
1899
+ if (!identifiedWallets.includes(identifiedKey)) {
1900
+ identifiedWallets.push(identifiedKey);
1901
+ var newValue = identifiedWallets.join(",");
1902
+ cookie().set(SESSION_WALLET_IDENTIFIED_KEY, newValue, {
1903
+ // by the end of the day
1904
+ expires: new Date(Date.now() + 86400 * 1000).toUTCString(),
1905
+ path: "/",
1906
+ });
1907
+ logger.debug("Session: Marked wallet as identified", {
1908
+ identifiedKey: identifiedKey,
1909
+ hasRdns: !!rdns
1910
+ });
1911
+ }
1912
+ else {
1913
+ logger.info("Session: Wallet already marked as identified", {
1914
+ identifiedKey: identifiedKey,
1915
+ existingWallets: identifiedWallets,
1916
+ hasRdns: !!rdns
1917
+ });
1918
+ }
1837
1919
  };
1838
1920
  return FormoAnalyticsSession;
1839
1921
  }());
@@ -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.7";
1
+ export declare const version = "1.19.10";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // Generated by genversion.
2
- export var version = '1.19.7';
2
+ export var version = '1.19.10';
3
3
  //# sourceMappingURL=version.js.map