@formo/analytics 1.19.6 → 1.19.7
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.
- package/dist/cjs/src/FormoAnalytics.d.ts +85 -4
- package/dist/cjs/src/FormoAnalytics.js +801 -273
- package/dist/cjs/src/constants/base.d.ts +1 -0
- package/dist/cjs/src/constants/base.js +3 -1
- package/dist/cjs/src/lib/event/EventFactory.d.ts +1 -1
- package/dist/cjs/src/lib/event/EventFactory.js +1 -1
- package/dist/cjs/src/types/events.d.ts +2 -2
- package/dist/cjs/src/types/provider.d.ts +8 -0
- package/dist/cjs/src/types/provider.js +3 -0
- package/dist/esm/src/FormoAnalytics.d.ts +85 -4
- package/dist/esm/src/FormoAnalytics.js +803 -275
- package/dist/esm/src/constants/base.d.ts +1 -0
- package/dist/esm/src/constants/base.js +2 -0
- package/dist/esm/src/lib/event/EventFactory.d.ts +1 -1
- package/dist/esm/src/lib/event/EventFactory.js +1 -1
- package/dist/esm/src/types/events.d.ts +2 -2
- package/dist/esm/src/types/provider.d.ts +8 -0
- package/dist/esm/src/types/provider.js +2 -1
- package/dist/index.umd.min.js +1 -1
- package/package.json +2 -2
|
@@ -4,14 +4,41 @@ export declare class FormoAnalytics implements IFormoAnalytics {
|
|
|
4
4
|
readonly writeKey: string;
|
|
5
5
|
options: Options;
|
|
6
6
|
private _provider?;
|
|
7
|
-
private
|
|
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 _seenProviders;
|
|
11
26
|
config: Config;
|
|
12
27
|
currentChainId?: ChainID;
|
|
13
28
|
currentAddress?: Address;
|
|
14
29
|
currentUserId?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Helper method to check if a provider is different from the currently active one
|
|
32
|
+
* @param provider The provider to check
|
|
33
|
+
* @returns true if there's a provider mismatch, false otherwise
|
|
34
|
+
*/
|
|
35
|
+
private isProviderMismatch;
|
|
36
|
+
/**
|
|
37
|
+
* Check if a provider is in a valid state for switching
|
|
38
|
+
* @param provider The provider to validate
|
|
39
|
+
* @returns true if the provider is in a valid state
|
|
40
|
+
*/
|
|
41
|
+
private isProviderInValidState;
|
|
15
42
|
private constructor();
|
|
16
43
|
static init(writeKey: string, options?: Options): Promise<FormoAnalytics>;
|
|
17
44
|
/**
|
|
@@ -36,7 +63,6 @@ export declare class FormoAnalytics implements IFormoAnalytics {
|
|
|
36
63
|
* @param {IFormoEventProperties} properties
|
|
37
64
|
* @param {IFormoEventContext} context
|
|
38
65
|
* @param {(...args: unknown[]) => void} callback
|
|
39
|
-
* @throws {Error} If chainId or address is empty
|
|
40
66
|
* @returns {Promise<void>}
|
|
41
67
|
*/
|
|
42
68
|
connect({ chainId, address, }: {
|
|
@@ -63,8 +89,6 @@ export declare class FormoAnalytics implements IFormoAnalytics {
|
|
|
63
89
|
* @param {IFormoEventProperties} properties
|
|
64
90
|
* @param {IFormoEventContext} context
|
|
65
91
|
* @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
92
|
* @returns {Promise<void>}
|
|
69
93
|
*/
|
|
70
94
|
chain({ chainId, address, }: {
|
|
@@ -153,11 +177,14 @@ export declare class FormoAnalytics implements IFormoAnalytics {
|
|
|
153
177
|
*/
|
|
154
178
|
track(event: string, properties?: IFormoEventProperties, context?: IFormoEventContext, callback?: (...args: unknown[]) => void): Promise<void>;
|
|
155
179
|
private trackProvider;
|
|
180
|
+
private trackProviders;
|
|
181
|
+
private addProviderListener;
|
|
156
182
|
private registerAccountsChangedListener;
|
|
157
183
|
private onAccountsChanged;
|
|
158
184
|
private registerChainChangedListener;
|
|
159
185
|
private onChainChanged;
|
|
160
186
|
private registerConnectListener;
|
|
187
|
+
private registerDisconnectListener;
|
|
161
188
|
private onConnected;
|
|
162
189
|
private registerRequestListeners;
|
|
163
190
|
private onLocationChange;
|
|
@@ -169,6 +196,18 @@ export declare class FormoAnalytics implements IFormoAnalytics {
|
|
|
169
196
|
* @returns {boolean} True if tracking should be enabled
|
|
170
197
|
*/
|
|
171
198
|
private shouldTrack;
|
|
199
|
+
/**
|
|
200
|
+
* Get provider information for a given provider
|
|
201
|
+
* @param provider The provider to get info for
|
|
202
|
+
* @returns Provider information
|
|
203
|
+
*/
|
|
204
|
+
private getProviderInfo;
|
|
205
|
+
/**
|
|
206
|
+
* Attempts to detect information about an injected provider
|
|
207
|
+
* @param provider The injected provider to analyze
|
|
208
|
+
* @returns Provider information with fallback values
|
|
209
|
+
*/
|
|
210
|
+
private detectInjectedProviderInfo;
|
|
172
211
|
private getProviders;
|
|
173
212
|
get providers(): readonly EIP6963ProviderDetail[];
|
|
174
213
|
private detectWallets;
|
|
@@ -182,5 +221,47 @@ export declare class FormoAnalytics implements IFormoAnalytics {
|
|
|
182
221
|
* Polls for transaction receipt and emits tx.status = CONFIRMED or REVERTED.
|
|
183
222
|
*/
|
|
184
223
|
private pollTransactionReceipt;
|
|
224
|
+
private removeProviderListeners;
|
|
225
|
+
private untrackProvider;
|
|
226
|
+
getTrackedProvidersCount(): number;
|
|
227
|
+
/**
|
|
228
|
+
* Get current provider state for debugging
|
|
229
|
+
* @returns Object containing current provider state information
|
|
230
|
+
*/
|
|
231
|
+
getProviderState(): {
|
|
232
|
+
totalProviders: number;
|
|
233
|
+
trackedProviders: number;
|
|
234
|
+
seenProviders: number;
|
|
235
|
+
activeProvider: boolean;
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Clean up providers that are no longer available
|
|
239
|
+
* This helps maintain consistent state and prevents memory leaks
|
|
240
|
+
*/
|
|
241
|
+
private cleanupUnavailableProviders;
|
|
242
|
+
/**
|
|
243
|
+
* Helper method to check if a provider is already wrapped
|
|
244
|
+
* @param provider The provider to check
|
|
245
|
+
* @param currentRequest The current request function
|
|
246
|
+
* @returns true if the provider is already wrapped
|
|
247
|
+
*/
|
|
248
|
+
private isProviderAlreadyWrapped;
|
|
249
|
+
/**
|
|
250
|
+
* Handle provider mismatch by switching to the new provider and invalidating old tokens
|
|
251
|
+
* @param provider The new provider to switch to
|
|
252
|
+
*/
|
|
253
|
+
private handleProviderMismatch;
|
|
254
|
+
/**
|
|
255
|
+
* Helper method to validate and checksum an address
|
|
256
|
+
* @param address The address to validate and checksum
|
|
257
|
+
* @returns The checksummed address or undefined if invalid
|
|
258
|
+
*/
|
|
259
|
+
private validateAndChecksumAddress;
|
|
260
|
+
/**
|
|
261
|
+
* Helper method to safely add a provider detail to _providers array, ensuring no duplicates
|
|
262
|
+
* @param detail The provider detail to add
|
|
263
|
+
* @returns true if the provider was added, false if it was already present
|
|
264
|
+
*/
|
|
265
|
+
private safeAddProviderDetail;
|
|
185
266
|
}
|
|
186
267
|
//# sourceMappingURL=FormoAnalytics.d.ts.map
|