@formo/analytics 1.19.6 → 1.19.8

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.
@@ -4,14 +4,42 @@ export declare class FormoAnalytics implements IFormoAnalytics {
4
4
  readonly writeKey: string;
5
5
  options: Options;
6
6
  private _provider?;
7
- private _providerListeners;
7
+ private _providerListenersMap;
8
8
  private session;
9
9
  private eventManager;
10
+ /**
11
+ * EIP-6963 provider details discovered through the browser
12
+ * This array contains all available providers with their metadata
13
+ */
10
14
  private _providers;
15
+ /**
16
+ * Set of providers that have been tracked with event listeners
17
+ * This is separate from _providers because:
18
+ * - _providers contains all discovered providers (EIP-6963)
19
+ * - _trackedProviders contains only providers that have been set up with listeners
20
+ * - A provider can be discovered but not yet tracked (e.g., during initialization)
21
+ * - A provider can be tracked but later removed from discovery
22
+ */
23
+ private _trackedProviders;
24
+ private _injectedProviderDetail?;
25
+ private _processingAccountsChanged;
26
+ private _seenProviders;
11
27
  config: Config;
12
28
  currentChainId?: ChainID;
13
29
  currentAddress?: Address;
14
30
  currentUserId?: string;
31
+ /**
32
+ * Helper method to check if a provider is different from the currently active one
33
+ * @param provider The provider to check
34
+ * @returns true if there's a provider mismatch, false otherwise
35
+ */
36
+ private isProviderMismatch;
37
+ /**
38
+ * Check if a provider is in a valid state for switching
39
+ * @param provider The provider to validate
40
+ * @returns true if the provider is in a valid state
41
+ */
42
+ private isProviderInValidState;
15
43
  private constructor();
16
44
  static init(writeKey: string, options?: Options): Promise<FormoAnalytics>;
17
45
  /**
@@ -36,7 +64,6 @@ export declare class FormoAnalytics implements IFormoAnalytics {
36
64
  * @param {IFormoEventProperties} properties
37
65
  * @param {IFormoEventContext} context
38
66
  * @param {(...args: unknown[]) => void} callback
39
- * @throws {Error} If chainId or address is empty
40
67
  * @returns {Promise<void>}
41
68
  */
42
69
  connect({ chainId, address, }: {
@@ -63,8 +90,6 @@ export declare class FormoAnalytics implements IFormoAnalytics {
63
90
  * @param {IFormoEventProperties} properties
64
91
  * @param {IFormoEventContext} context
65
92
  * @param {(...args: unknown[]) => void} callback
66
- * @throws {Error} If chainId is empty, zero, or not a valid number
67
- * @throws {Error} If no address is provided and no previous address is recorded
68
93
  * @returns {Promise<void>}
69
94
  */
70
95
  chain({ chainId, address, }: {
@@ -153,11 +178,25 @@ export declare class FormoAnalytics implements IFormoAnalytics {
153
178
  */
154
179
  track(event: string, properties?: IFormoEventProperties, context?: IFormoEventContext, callback?: (...args: unknown[]) => void): Promise<void>;
155
180
  private trackProvider;
181
+ private trackProviders;
182
+ private addProviderListener;
156
183
  private registerAccountsChangedListener;
157
184
  private onAccountsChanged;
185
+ /**
186
+ * Handles changes to the accounts of a given EIP-1193 provider.
187
+ *
188
+ * @param provider - The EIP-1193 provider whose accounts have changed.
189
+ * @param accounts - The new array of account addresses. An empty array indicates a disconnect.
190
+ * @returns A promise that resolves when the account change has been processed.
191
+ *
192
+ * If the accounts array is empty and the provider is the active provider, this method triggers
193
+ * a disconnect flow. Otherwise, it updates the state to reflect the new accounts as needed.
194
+ */
195
+ private _handleAccountsChanged;
158
196
  private registerChainChangedListener;
159
197
  private onChainChanged;
160
198
  private registerConnectListener;
199
+ private registerDisconnectListener;
161
200
  private onConnected;
162
201
  private registerRequestListeners;
163
202
  private onLocationChange;
@@ -169,6 +208,18 @@ export declare class FormoAnalytics implements IFormoAnalytics {
169
208
  * @returns {boolean} True if tracking should be enabled
170
209
  */
171
210
  private shouldTrack;
211
+ /**
212
+ * Get provider information for a given provider
213
+ * @param provider The provider to get info for
214
+ * @returns Provider information
215
+ */
216
+ private getProviderInfo;
217
+ /**
218
+ * Attempts to detect information about an injected provider
219
+ * @param provider The injected provider to analyze
220
+ * @returns Provider information with fallback values
221
+ */
222
+ private detectInjectedProviderInfo;
172
223
  private getProviders;
173
224
  get providers(): readonly EIP6963ProviderDetail[];
174
225
  private detectWallets;
@@ -182,5 +233,47 @@ export declare class FormoAnalytics implements IFormoAnalytics {
182
233
  * Polls for transaction receipt and emits tx.status = CONFIRMED or REVERTED.
183
234
  */
184
235
  private pollTransactionReceipt;
236
+ private removeProviderListeners;
237
+ private untrackProvider;
238
+ getTrackedProvidersCount(): number;
239
+ /**
240
+ * Get current provider state for debugging
241
+ * @returns Object containing current provider state information
242
+ */
243
+ getProviderState(): {
244
+ totalProviders: number;
245
+ trackedProviders: number;
246
+ seenProviders: number;
247
+ activeProvider: boolean;
248
+ };
249
+ /**
250
+ * Clean up providers that are no longer available
251
+ * This helps maintain consistent state and prevents memory leaks
252
+ */
253
+ private cleanupUnavailableProviders;
254
+ /**
255
+ * Helper method to check if a provider is already wrapped
256
+ * @param provider The provider to check
257
+ * @param currentRequest The current request function
258
+ * @returns true if the provider is already wrapped
259
+ */
260
+ private isProviderAlreadyWrapped;
261
+ /**
262
+ * Handle provider mismatch by switching to the new provider and invalidating old tokens
263
+ * @param provider The new provider to switch to
264
+ */
265
+ private handleProviderMismatch;
266
+ /**
267
+ * Helper method to validate and checksum an address
268
+ * @param address The address to validate and checksum
269
+ * @returns The checksummed address or undefined if invalid
270
+ */
271
+ private validateAndChecksumAddress;
272
+ /**
273
+ * Helper method to safely add a provider detail to _providers array, ensuring no duplicates
274
+ * @param detail The provider detail to add
275
+ * @returns true if the provider was added, false if it was already present
276
+ */
277
+ private safeAddProviderDetail;
185
278
  }
186
279
  //# sourceMappingURL=FormoAnalytics.d.ts.map