@formo/analytics 1.38.0 → 1.38.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.
Files changed (34) hide show
  1. package/dist/cjs/src/FormoAnalytics.d.ts +15 -4
  2. package/dist/cjs/src/FormoAnalytics.js +37 -6
  3. package/dist/cjs/src/FormoAnalyticsProvider.d.ts +8 -0
  4. package/dist/cjs/src/FormoAnalyticsProvider.js +41 -32
  5. package/dist/cjs/src/evm/EvmEventTracker.d.ts +100 -9
  6. package/dist/cjs/src/evm/EvmEventTracker.js +357 -19
  7. package/dist/cjs/src/evm/EvmProviderRegistry.d.ts +34 -2
  8. package/dist/cjs/src/evm/EvmProviderRegistry.js +61 -4
  9. package/dist/cjs/src/evm/EvmRequestTracker.d.ts +21 -4
  10. package/dist/cjs/src/evm/EvmRequestTracker.js +54 -28
  11. package/dist/cjs/src/version.d.ts +1 -1
  12. package/dist/cjs/src/version.js +1 -1
  13. package/dist/cjs/src/wagmi/WagmiEventHandler.d.ts +67 -1
  14. package/dist/cjs/src/wagmi/WagmiEventHandler.js +286 -39
  15. package/dist/cjs/src/wagmi/types.d.ts +6 -0
  16. package/dist/cjs/src/wagmi/utils.js +9 -1
  17. package/dist/esm/src/FormoAnalytics.d.ts +15 -4
  18. package/dist/esm/src/FormoAnalytics.js +37 -6
  19. package/dist/esm/src/FormoAnalyticsProvider.d.ts +8 -0
  20. package/dist/esm/src/FormoAnalyticsProvider.js +39 -31
  21. package/dist/esm/src/evm/EvmEventTracker.d.ts +100 -9
  22. package/dist/esm/src/evm/EvmEventTracker.js +357 -19
  23. package/dist/esm/src/evm/EvmProviderRegistry.d.ts +34 -2
  24. package/dist/esm/src/evm/EvmProviderRegistry.js +61 -4
  25. package/dist/esm/src/evm/EvmRequestTracker.d.ts +21 -4
  26. package/dist/esm/src/evm/EvmRequestTracker.js +54 -28
  27. package/dist/esm/src/version.d.ts +1 -1
  28. package/dist/esm/src/version.js +1 -1
  29. package/dist/esm/src/wagmi/WagmiEventHandler.d.ts +67 -1
  30. package/dist/esm/src/wagmi/WagmiEventHandler.js +286 -39
  31. package/dist/esm/src/wagmi/types.d.ts +6 -0
  32. package/dist/esm/src/wagmi/utils.js +9 -1
  33. package/dist/index.umd.min.js +1 -1
  34. package/package.json +2 -2
@@ -52,10 +52,91 @@ export declare class EvmEventTracker {
52
52
  * Announcement-driven cleanup must not touch them: they are never in an
53
53
  * announcement list, so "missing from the announcement" is their normal
54
54
  * state, not evidence of removal. A Set rather than a WeakSet because
55
- * suppressed adoptions retry from it; the registry holds these providers
56
- * strongly anyway, and untrack removes them.
55
+ * the corrected-detect pass iterates it; the registry's detail list
56
+ * holds these providers strongly for the instance's life anyway.
57
57
  */
58
58
  private externallyRegistered;
59
+ /**
60
+ * Registered providers whose session this SDK has NOT yet learned.
61
+ *
62
+ * Only these are retried on page hits and opt-in. Re-running adoption for
63
+ * every registered provider looked idempotent but was not: adoption is
64
+ * the same path a live `accountsChanged` takes, and that path treats a
65
+ * provider with a different address from the active one as a wallet
66
+ * switch. With two registered providers, or one registered next to a
67
+ * discovered wallet, every page hit emitted a disconnect and a connect
68
+ * that no user action caused.
69
+ *
70
+ * A provider enters at registration (it may have no session yet, or be
71
+ * refused because tracking is suppressed), again whenever a handler
72
+ * refuses its signal while suppressed (noted on entry AND at the
73
+ * suppressed commit, since the handlers gate on the active provider and
74
+ * re-check suppression after an await), and again for all of them when
75
+ * an opt-out purges identity. It leaves the first time a handler commits
76
+ * its session unsuppressed, or when it is untracked. Retrying reads the
77
+ * provider's SYNCHRONOUS accounts only - no RPC - so a registered
78
+ * provider whose session never fires `accountsChanged` (a wallet that
79
+ * signals `connect` alone while `autocapture.connect` is off, which
80
+ * installs a chain-only observer) is still adopted on the next hit. "No
81
+ * RPC" holds for the pending provider itself; the handler's switch
82
+ * arbitration may still ask the ACTIVE provider for its accounts, as it
83
+ * does for any live signal.
84
+ *
85
+ * Replay goes through the accounts handler, which has live wallet-switch
86
+ * semantics: a different provider with a different address is a switch.
87
+ * So a pending provider is replayed only while no OTHER wallet is active
88
+ * and known - it waits, at no cost, until that wallet is gone - unless
89
+ * its own signal was refused (`latestRefused`): then the replay does
90
+ * exactly what the live signal would have done, switch included.
91
+ */
92
+ private pendingAdoptions;
93
+ /**
94
+ * The pending provider whose own live signal was refused while
95
+ * suppressed, LATEST only. The SDK follows one active wallet and the
96
+ * newest signal wins, so replaying only the last refused signal reaches
97
+ * the state the live signals would have reached, without the switches
98
+ * in between; an earlier refused provider stays pending, unprivileged.
99
+ */
100
+ private latestRefused?;
101
+ private dropRefusal;
102
+ /**
103
+ * An opt-out purges wallet identity. Every registered session is then
104
+ * unknown again (pending; no refusal is ADDED, so the opt-in replay of a
105
+ * merely connected wallet does not switch, while a refusal already
106
+ * standing from an excluded route keeps its meaning), and the
107
+ * opt-in retry must re-learn all of them: with the active wallet's
108
+ * address gone, the accounts handler cannot even tell a second wallet's
109
+ * accounts apart from the active one's, and would ignore them.
110
+ */
111
+ markRegisteredAdoptionsPending(): void;
112
+ /**
113
+ * Remember a registered provider's signal that suppression refuses.
114
+ *
115
+ * Replay privilege (`latestRefused`) goes only to a provider whose
116
+ * session the replay can actually read - synchronous accounts - so an
117
+ * accountless `connect` (a chain-only observation, or a session still
118
+ * pairing) cannot displace an earlier refusal that is adoptable.
119
+ */
120
+ private noteRefusalIfSuppressed;
121
+ /**
122
+ * Registered providers whose session ended and have not signalled a
123
+ * new one. Some providers keep stale synchronous `accounts` after a
124
+ * disconnect; replaying those would re-install a session that is over.
125
+ * Any later session signal (connect, accountsChanged) lifts this.
126
+ */
127
+ private awaitingNewSession;
128
+ /** A handler has learned this provider's session; nothing is pending. */
129
+ private settleAdoption;
130
+ /**
131
+ * A registered provider's session has ended. Its NEXT session is not
132
+ * yet learned, and may announce itself in a way no handler adopts (a
133
+ * `connect` alone while `autocapture.connect` is off installs a
134
+ * chain-only observer), so it is pending again for the page-hit retry.
135
+ */
136
+ private reopenAdoption;
137
+ /** One retry scan at a time; a call during a scan queues one more. */
138
+ private retryInFlight;
139
+ private retryRequested;
59
140
  /**
60
141
  * The connect this SDK has already reported for a provider.
61
142
  *
@@ -74,6 +155,11 @@ export declare class EvmEventTracker {
74
155
  constructor(wallet: WalletStateStore, registry: EvmProviderRegistry, deps: EvmEventTrackerDeps);
75
156
  /** Stop listening for wallet announcements. Called from SDK teardown. */
76
157
  cleanup(): void;
158
+ /** Set by `cleanup()`; every awaited continuation checks it. */
159
+ private disposed;
160
+ /** Bumped when a registered provider's session ends. See reopenAdoption. */
161
+ private sessionGenerations;
162
+ private sessionGeneration;
77
163
  /** Drop a provider's reported connect. Called when it stops being active. */
78
164
  forgetAnnouncedConnect(provider: EIP1193Provider): void;
79
165
  /**
@@ -109,14 +195,19 @@ export declare class EvmEventTracker {
109
195
  */
110
196
  adoptExternalProvider(detail: EIP6963ProviderDetail): boolean;
111
197
  /**
112
- * Re-run session adoption for every registered external provider.
198
+ * Finish what registration could not.
199
+ *
200
+ * A registered provider's session may not have existed at registration,
201
+ * or its adoption was refused because tracking was suppressed (opt-out,
202
+ * excluded route) - and an existing session may never emit another
203
+ * accountsChanged, so nothing else would ever retry. Called when
204
+ * suppression can have ended (opt-in, page navigation).
113
205
  *
114
- * Registration while tracking was suppressed (opt-out, excluded route)
115
- * reached the adoption path and was refused - and a provider whose
116
- * session already exists may never emit another accountsChanged, so
117
- * nothing would ever retry. Called when suppression can have ended
118
- * (opt-in, page navigation). Idempotent: an already-adopted wallet is
119
- * deduplicated by the same state and markers as any repeated signal.
206
+ * Adoption is retried ONLY for providers not yet adopted
207
+ * (`pendingAdoptions`), only from their synchronous accounts, and only
208
+ * once suppression has actually ended. The corrected-detect pass below
209
+ * runs for every registered provider: it is deduplicated per session by
210
+ * rdns, so repeating it is free.
120
211
  */
121
212
  retryExternalAdoptions(): void;
122
213
  private registerAccountsChangedListener;