@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.
- package/dist/cjs/src/FormoAnalytics.d.ts +97 -4
- package/dist/cjs/src/FormoAnalytics.js +915 -274
- 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/lib/version.d.ts +1 -1
- package/dist/cjs/src/lib/version.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/cjs/src/utils/base.js +10 -1
- package/dist/esm/src/FormoAnalytics.d.ts +97 -4
- package/dist/esm/src/FormoAnalytics.js +917 -276
- 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/lib/version.d.ts +1 -1
- package/dist/esm/src/lib/version.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/esm/src/utils/base.js +10 -1
- package/dist/index.umd.min.js +1 -1
- package/package.json +2 -2
|
@@ -3,4 +3,5 @@ export declare const SESSION_WALLET_DETECTED_KEY = "wallet-detected";
|
|
|
3
3
|
export declare const SESSION_CURRENT_URL_KEY = "analytics-current-url";
|
|
4
4
|
export declare const SESSION_USER_ID_KEY = "user-id";
|
|
5
5
|
export declare const LOCAL_ANONYMOUS_ID_KEY = "anonymous-id";
|
|
6
|
+
export declare const DEFAULT_PROVIDER_ICON = "data:image/svg+xml;base64,";
|
|
6
7
|
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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_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
6
|
exports.SESSION_CURRENT_URL_KEY = "analytics-current-url";
|
|
7
7
|
exports.SESSION_USER_ID_KEY = "user-id";
|
|
8
8
|
exports.LOCAL_ANONYMOUS_ID_KEY = "anonymous-id";
|
|
9
|
+
// Default provider icon (empty data URL)
|
|
10
|
+
exports.DEFAULT_PROVIDER_ICON = 'data:image/svg+xml;base64,';
|
|
9
11
|
//# sourceMappingURL=base.js.map
|
|
@@ -20,7 +20,7 @@ declare class EventFactory implements IEventFactory {
|
|
|
20
20
|
generateDetectWalletEvent(providerName: string, rdns: string, properties?: IFormoEventProperties, context?: IFormoEventContext): IFormoEvent;
|
|
21
21
|
generateIdentifyEvent(providerName: string, rdns: string, address: Nullable<Address>, userId?: Nullable<string>, properties?: IFormoEventProperties, context?: IFormoEventContext): IFormoEvent;
|
|
22
22
|
generateConnectEvent(chainId: ChainID, address: Address, properties?: IFormoEventProperties, context?: IFormoEventContext): IFormoEvent;
|
|
23
|
-
generateDisconnectEvent(chainId
|
|
23
|
+
generateDisconnectEvent(chainId?: ChainID, address?: Address, properties?: IFormoEventProperties, context?: IFormoEventContext): IFormoEvent;
|
|
24
24
|
generateChainChangedEvent(chainId: ChainID, address: Address, properties?: IFormoEventProperties, context?: IFormoEventContext): IFormoEvent;
|
|
25
25
|
generateSignatureEvent(status: SignatureStatus, chainId: ChainID, address: Address, message: string, signatureHash?: string, properties?: IFormoEventProperties, context?: IFormoEventContext): IFormoEvent;
|
|
26
26
|
generateTransactionEvent(status: TransactionStatus, chainId: ChainID, address: Address, data: string, to: string, value: string, transactionHash?: string, properties?: IFormoEventProperties, context?: IFormoEventContext): IFormoEvent;
|
|
@@ -66,7 +66,7 @@ var EventFactory = /** @class */ (function () {
|
|
|
66
66
|
var storedTrafficSources = (0, storage_1.session)().get(constants_1.SESSION_TRAFFIC_SOURCE_KEY) || {};
|
|
67
67
|
var finalTrafficSources = {
|
|
68
68
|
ref: contextTrafficSources.ref || (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.ref) || "",
|
|
69
|
-
referrer: contextTrafficSources.referrer || (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.referrer),
|
|
69
|
+
referrer: contextTrafficSources.referrer || (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.referrer) || "",
|
|
70
70
|
utm_campaign: contextTrafficSources.utm_campaign ||
|
|
71
71
|
(storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.utm_campaign) ||
|
|
72
72
|
"",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "1.19.
|
|
1
|
+
export declare const version = "1.19.7";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -15,4 +15,12 @@ export interface RPCError extends Error {
|
|
|
15
15
|
export interface ConnectInfo {
|
|
16
16
|
chainId: string;
|
|
17
17
|
}
|
|
18
|
+
export declare const WRAPPED_REQUEST_SYMBOL: unique symbol;
|
|
19
|
+
export type WrappedRequestFunction = (<T>(args: RequestArguments) => Promise<T | null | undefined>) & {
|
|
20
|
+
[WRAPPED_REQUEST_SYMBOL]?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare const WRAPPED_REQUEST_REF_SYMBOL: unique symbol;
|
|
23
|
+
export interface WrappedEIP1193Provider extends EIP1193Provider {
|
|
24
|
+
[WRAPPED_REQUEST_REF_SYMBOL]?: WrappedRequestFunction;
|
|
25
|
+
}
|
|
18
26
|
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WRAPPED_REQUEST_REF_SYMBOL = exports.WRAPPED_REQUEST_SYMBOL = void 0;
|
|
4
|
+
exports.WRAPPED_REQUEST_SYMBOL = Symbol("formoWrappedRequest");
|
|
5
|
+
exports.WRAPPED_REQUEST_REF_SYMBOL = Symbol("formoWrappedRequestRef");
|
|
3
6
|
//# sourceMappingURL=provider.js.map
|
|
@@ -2,7 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getActionDescriptor = void 0;
|
|
4
4
|
var getActionDescriptor = function (type, properties) {
|
|
5
|
-
|
|
5
|
+
var descriptor = type;
|
|
6
|
+
// Add status for events that have it (e.g., signature, transaction)
|
|
7
|
+
if (properties === null || properties === void 0 ? void 0 : properties.status) {
|
|
8
|
+
descriptor += " ".concat(properties.status);
|
|
9
|
+
}
|
|
10
|
+
// Add RDNS for connect/disconnect events to identify the wallet provider
|
|
11
|
+
if ((type === 'connect' || type === 'disconnect') && (properties === null || properties === void 0 ? void 0 : properties.rdns)) {
|
|
12
|
+
descriptor += " (".concat(properties.rdns, ")");
|
|
13
|
+
}
|
|
14
|
+
return descriptor;
|
|
6
15
|
};
|
|
7
16
|
exports.getActionDescriptor = getActionDescriptor;
|
|
8
17
|
//# sourceMappingURL=base.js.map
|
|
@@ -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
|
|
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
|