@formo/analytics 1.28.5 → 1.29.0
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 +9 -3
- package/dist/cjs/src/FormoAnalytics.js +29 -16
- package/dist/cjs/src/constants/base.d.ts +0 -1
- package/dist/cjs/src/constants/base.js +1 -2
- package/dist/cjs/src/event/EventFactory.d.ts +1 -0
- package/dist/cjs/src/event/EventFactory.js +21 -14
- package/dist/cjs/src/event/constants.d.ts +8 -2
- package/dist/cjs/src/event/constants.js +31 -5
- package/dist/cjs/src/index.d.ts +3 -1
- package/dist/cjs/src/index.js +5 -1
- package/dist/cjs/src/solana/SolanaManager.d.ts +36 -11
- package/dist/cjs/src/solana/SolanaManager.js +47 -49
- package/dist/cjs/src/solana/SolanaStoreHandler.d.ts +88 -0
- package/dist/cjs/src/solana/SolanaStoreHandler.js +471 -0
- package/dist/cjs/src/solana/index.d.ts +8 -4
- package/dist/cjs/src/solana/index.js +10 -6
- package/dist/cjs/src/solana/storeTypes.d.ts +107 -0
- package/dist/cjs/src/solana/storeTypes.js +12 -0
- package/dist/cjs/src/solana/types.d.ts +23 -154
- package/dist/cjs/src/solana/types.js +4 -37
- package/dist/cjs/src/storage/StorageManager.d.ts +1 -0
- package/dist/cjs/src/storage/StorageManager.js +10 -2
- package/dist/cjs/src/types/base.d.ts +16 -5
- package/dist/cjs/src/types/events.d.ts +5 -1
- package/dist/cjs/src/version.d.ts +1 -1
- package/dist/cjs/src/version.js +1 -1
- package/dist/esm/src/FormoAnalytics.d.ts +9 -3
- package/dist/esm/src/FormoAnalytics.js +30 -17
- package/dist/esm/src/constants/base.d.ts +0 -1
- package/dist/esm/src/constants/base.js +0 -1
- package/dist/esm/src/event/EventFactory.d.ts +1 -0
- package/dist/esm/src/event/EventFactory.js +22 -15
- package/dist/esm/src/event/constants.d.ts +8 -2
- package/dist/esm/src/event/constants.js +30 -5
- package/dist/esm/src/index.d.ts +3 -1
- package/dist/esm/src/index.js +1 -0
- package/dist/esm/src/solana/SolanaManager.d.ts +36 -11
- package/dist/esm/src/solana/SolanaManager.js +47 -49
- package/dist/esm/src/solana/SolanaStoreHandler.d.ts +88 -0
- package/dist/esm/src/solana/SolanaStoreHandler.js +468 -0
- package/dist/esm/src/solana/index.d.ts +8 -4
- package/dist/esm/src/solana/index.js +8 -4
- package/dist/esm/src/solana/storeTypes.d.ts +107 -0
- package/dist/esm/src/solana/storeTypes.js +11 -0
- package/dist/esm/src/solana/types.d.ts +23 -154
- package/dist/esm/src/solana/types.js +3 -34
- package/dist/esm/src/storage/StorageManager.d.ts +1 -0
- package/dist/esm/src/storage/StorageManager.js +10 -2
- package/dist/esm/src/types/base.d.ts +16 -5
- package/dist/esm/src/types/events.d.ts +5 -1
- package/dist/esm/src/version.d.ts +1 -1
- package/dist/esm/src/version.js +1 -1
- package/dist/index.umd.min.js +1 -1
- package/package.json +14 -14
- package/dist/cjs/src/solana/SolanaAdapter.d.ts +0 -210
- package/dist/cjs/src/solana/SolanaAdapter.js +0 -988
- package/dist/esm/src/solana/SolanaAdapter.d.ts +0 -210
- package/dist/esm/src/solana/SolanaAdapter.js +0 -985
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Solana-specific type definitions for wallet event tracking
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Core types for the Solana integration: cluster mappings, chain ID utilities,
|
|
5
|
+
* and configuration options. Framework-kit store types are in storeTypes.ts.
|
|
6
6
|
*
|
|
7
|
-
* @see https://github.com/
|
|
7
|
+
* @see https://github.com/solana-foundation/framework-kit
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
10
|
* Solana cluster/network types
|
|
@@ -33,7 +33,7 @@ export declare const DEFAULT_SOLANA_CHAIN_ID: number;
|
|
|
33
33
|
export declare function isSolanaChainId(chainId: number | undefined | null): boolean;
|
|
34
34
|
/**
|
|
35
35
|
* Solana PublicKey interface
|
|
36
|
-
*
|
|
36
|
+
* Used by address validation utilities.
|
|
37
37
|
*/
|
|
38
38
|
export interface SolanaPublicKey {
|
|
39
39
|
toBase58(): string;
|
|
@@ -42,165 +42,34 @@ export interface SolanaPublicKey {
|
|
|
42
42
|
equals(other: SolanaPublicKey): boolean;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
46
|
-
*/
|
|
47
|
-
export type TransactionSignature = string;
|
|
48
|
-
/**
|
|
49
|
-
* Solana wallet adapter state
|
|
50
|
-
*/
|
|
51
|
-
export type WalletAdapterState = "connected" | "disconnected" | "connecting" | "disconnecting";
|
|
52
|
-
/**
|
|
53
|
-
* Solana wallet adapter interface
|
|
54
|
-
* Based on @solana/wallet-adapter-base WalletAdapter
|
|
55
|
-
*/
|
|
56
|
-
export interface ISolanaAdapter {
|
|
57
|
-
name: string;
|
|
58
|
-
url: string;
|
|
59
|
-
icon: string;
|
|
60
|
-
readyState: WalletReadyState;
|
|
61
|
-
publicKey: SolanaPublicKey | null;
|
|
62
|
-
connecting: boolean;
|
|
63
|
-
connected: boolean;
|
|
64
|
-
connect(): Promise<void>;
|
|
65
|
-
disconnect(): Promise<void>;
|
|
66
|
-
sendTransaction?(transaction: SolanaTransaction, connection: SolanaConnection, options?: SendTransactionOptions): Promise<TransactionSignature>;
|
|
67
|
-
signTransaction?(transaction: SolanaTransaction): Promise<SolanaTransaction>;
|
|
68
|
-
signAllTransactions?(transactions: SolanaTransaction[]): Promise<SolanaTransaction[]>;
|
|
69
|
-
signMessage?(message: Uint8Array): Promise<Uint8Array>;
|
|
70
|
-
on(event: "connect", listener: (publicKey: SolanaPublicKey) => void): void;
|
|
71
|
-
on(event: "disconnect", listener: () => void): void;
|
|
72
|
-
on(event: "error", listener: (error: WalletError) => void): void;
|
|
73
|
-
on(event: "readyStateChange", listener: (readyState: WalletReadyState) => void): void;
|
|
74
|
-
off(event: string, listener: (...args: unknown[]) => void): void;
|
|
75
|
-
removeAllListeners?(event?: string): void;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Solana wallet ready state
|
|
79
|
-
*/
|
|
80
|
-
export declare enum WalletReadyState {
|
|
81
|
-
Installed = "Installed",
|
|
82
|
-
NotDetected = "NotDetected",
|
|
83
|
-
Loadable = "Loadable",
|
|
84
|
-
Unsupported = "Unsupported"
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Solana wallet error
|
|
88
|
-
*/
|
|
89
|
-
export interface WalletError extends Error {
|
|
90
|
-
error?: unknown;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Solana transaction interface (minimal)
|
|
94
|
-
*/
|
|
95
|
-
export interface SolanaTransaction {
|
|
96
|
-
signature?: Uint8Array;
|
|
97
|
-
serialize(): Uint8Array;
|
|
98
|
-
feePayer?: SolanaPublicKey;
|
|
99
|
-
recentBlockhash?: string;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Solana connection interface (minimal)
|
|
103
|
-
*/
|
|
104
|
-
export interface SolanaConnection {
|
|
105
|
-
rpcEndpoint: string;
|
|
106
|
-
commitment?: string;
|
|
107
|
-
getSignatureStatus?(signature: string): Promise<{
|
|
108
|
-
value: SignatureStatus | null;
|
|
109
|
-
}>;
|
|
110
|
-
getSignatureStatuses?(signatures: string[]): Promise<{
|
|
111
|
-
value: (SignatureStatus | null)[];
|
|
112
|
-
}>;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Solana signature status
|
|
116
|
-
*/
|
|
117
|
-
export interface SignatureStatus {
|
|
118
|
-
slot: number;
|
|
119
|
-
confirmations: number | null;
|
|
120
|
-
err: unknown | null;
|
|
121
|
-
confirmationStatus?: "processed" | "confirmed" | "finalized";
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Send transaction options
|
|
125
|
-
*/
|
|
126
|
-
export interface SendTransactionOptions {
|
|
127
|
-
skipPreflight?: boolean;
|
|
128
|
-
preflightCommitment?: string;
|
|
129
|
-
maxRetries?: number;
|
|
130
|
-
minContextSlot?: number;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Wallet entry as returned by @solana/wallet-adapter-react useWallet().wallet
|
|
134
|
-
* This is { adapter, readyState }, not a direct adapter.
|
|
135
|
-
*/
|
|
136
|
-
export interface SolanaWalletEntry {
|
|
137
|
-
adapter: ISolanaAdapter;
|
|
138
|
-
readyState: WalletReadyState;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* @deprecated Use SolanaWalletEntry instead
|
|
142
|
-
*/
|
|
143
|
-
export type SolanaWallet = SolanaWalletEntry;
|
|
144
|
-
/**
|
|
145
|
-
* Solana Wallet Context interface
|
|
146
|
-
* Based on @solana/wallet-adapter-react useWallet hook
|
|
147
|
-
* @see https://github.com/anza-xyz/wallet-adapter/blob/master/packages/core/react/src/useWallet.ts
|
|
45
|
+
* Unsubscribe function type
|
|
148
46
|
*/
|
|
149
|
-
export
|
|
150
|
-
autoConnect: boolean;
|
|
151
|
-
wallets: SolanaWalletEntry[];
|
|
152
|
-
wallet: SolanaWalletEntry | null;
|
|
153
|
-
publicKey: SolanaPublicKey | null;
|
|
154
|
-
connecting: boolean;
|
|
155
|
-
connected: boolean;
|
|
156
|
-
disconnecting: boolean;
|
|
157
|
-
select(walletName: string | null): void;
|
|
158
|
-
connect(): Promise<void>;
|
|
159
|
-
disconnect(): Promise<void>;
|
|
160
|
-
sendTransaction(transaction: SolanaTransaction, connection: SolanaConnection, options?: SendTransactionOptions): Promise<TransactionSignature>;
|
|
161
|
-
signTransaction?(transaction: SolanaTransaction): Promise<SolanaTransaction>;
|
|
162
|
-
signAllTransactions?(transactions: SolanaTransaction[]): Promise<SolanaTransaction[]>;
|
|
163
|
-
signMessage?(message: Uint8Array): Promise<Uint8Array>;
|
|
164
|
-
}
|
|
47
|
+
export type UnsubscribeFn = () => void;
|
|
165
48
|
/**
|
|
166
49
|
* Solana options for FormoAnalytics
|
|
167
50
|
*/
|
|
168
51
|
export interface SolanaOptions {
|
|
169
52
|
/**
|
|
170
|
-
* The
|
|
171
|
-
*
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
*
|
|
53
|
+
* The framework-kit client store (client.store) for automatic event tracking.
|
|
54
|
+
* When provided, wallet connect/disconnect and transaction events are tracked
|
|
55
|
+
* automatically by subscribing to zustand store state changes.
|
|
56
|
+
*
|
|
57
|
+
* This is the recommended approach for apps using @solana-foundation/framework-kit.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* import { createClient } from '@solana-foundation/framework-kit';
|
|
62
|
+
* const client = createClient({ endpoint, walletConnectors: autoDiscover() });
|
|
63
|
+
* const formo = await Formo.init(writeKey, { solana: { store: client.store } });
|
|
64
|
+
* ```
|
|
176
65
|
*/
|
|
177
|
-
|
|
66
|
+
store?: import("./storeTypes").SolanaClientStore;
|
|
178
67
|
/**
|
|
179
|
-
* The Solana cluster/network
|
|
180
|
-
*
|
|
68
|
+
* The Solana cluster/network.
|
|
69
|
+
* Usually auto-detected from the store's endpoint URL.
|
|
70
|
+
* Only needed for custom RPC URLs that don't contain a recognizable cluster name.
|
|
71
|
+
* @default auto-detected, or "mainnet-beta" if detection fails
|
|
181
72
|
*/
|
|
182
73
|
cluster?: SolanaCluster;
|
|
183
74
|
}
|
|
184
|
-
/**
|
|
185
|
-
* Internal connection state for Solana event handler.
|
|
186
|
-
* Tracks the last known wallet connection for disconnect event payloads
|
|
187
|
-
* and provides a reentrancy guard for concurrent event handling.
|
|
188
|
-
*/
|
|
189
|
-
export interface SolanaConnectionState {
|
|
190
|
-
lastAddress?: string;
|
|
191
|
-
lastChainId?: number;
|
|
192
|
-
isProcessing: boolean;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Unsubscribe function type
|
|
196
|
-
*/
|
|
197
|
-
export type UnsubscribeFn = () => void;
|
|
198
|
-
/**
|
|
199
|
-
* Check if an object is a SolanaWalletContext (has wallets array)
|
|
200
|
-
*/
|
|
201
|
-
export declare function isSolanaWalletContext(obj: ISolanaAdapter | SolanaWalletContext | undefined | null): obj is SolanaWalletContext;
|
|
202
|
-
/**
|
|
203
|
-
* Check if an object is a ISolanaAdapter
|
|
204
|
-
*/
|
|
205
|
-
export declare function isSolanaAdapter(obj: ISolanaAdapter | SolanaWalletContext | undefined | null): obj is ISolanaAdapter;
|
|
206
75
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -2,16 +2,14 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Solana-specific type definitions for wallet event tracking
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Core types for the Solana integration: cluster mappings, chain ID utilities,
|
|
6
|
+
* and configuration options. Framework-kit store types are in storeTypes.ts.
|
|
7
7
|
*
|
|
8
|
-
* @see https://github.com/
|
|
8
|
+
* @see https://github.com/solana-foundation/framework-kit
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.
|
|
11
|
+
exports.DEFAULT_SOLANA_CHAIN_ID = exports.SOLANA_CLUSTERS_BY_ID = exports.SOLANA_CHAIN_IDS = void 0;
|
|
12
12
|
exports.isSolanaChainId = isSolanaChainId;
|
|
13
|
-
exports.isSolanaWalletContext = isSolanaWalletContext;
|
|
14
|
-
exports.isSolanaAdapter = isSolanaAdapter;
|
|
15
13
|
/**
|
|
16
14
|
* Mapping of Solana clusters to numeric chain IDs for consistency with EVM events
|
|
17
15
|
* These IDs are non-standard but provide a way to identify Solana networks in our analytics
|
|
@@ -46,35 +44,4 @@ function isSolanaChainId(chainId) {
|
|
|
46
44
|
return false;
|
|
47
45
|
return Object.values(exports.SOLANA_CHAIN_IDS).includes(chainId);
|
|
48
46
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Solana wallet ready state
|
|
51
|
-
*/
|
|
52
|
-
var WalletReadyState;
|
|
53
|
-
(function (WalletReadyState) {
|
|
54
|
-
WalletReadyState["Installed"] = "Installed";
|
|
55
|
-
WalletReadyState["NotDetected"] = "NotDetected";
|
|
56
|
-
WalletReadyState["Loadable"] = "Loadable";
|
|
57
|
-
WalletReadyState["Unsupported"] = "Unsupported";
|
|
58
|
-
})(WalletReadyState || (exports.WalletReadyState = WalletReadyState = {}));
|
|
59
|
-
/**
|
|
60
|
-
* Check if an object is a SolanaWalletContext (has wallets array)
|
|
61
|
-
*/
|
|
62
|
-
function isSolanaWalletContext(obj) {
|
|
63
|
-
return (obj !== null &&
|
|
64
|
-
obj !== undefined &&
|
|
65
|
-
typeof obj === "object" &&
|
|
66
|
-
"wallets" in obj &&
|
|
67
|
-
Array.isArray(obj.wallets));
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Check if an object is a ISolanaAdapter
|
|
71
|
-
*/
|
|
72
|
-
function isSolanaAdapter(obj) {
|
|
73
|
-
return (obj !== null &&
|
|
74
|
-
obj !== undefined &&
|
|
75
|
-
typeof obj === "object" &&
|
|
76
|
-
"name" in obj &&
|
|
77
|
-
"connect" in obj &&
|
|
78
|
-
!("wallets" in obj));
|
|
79
|
-
}
|
|
80
47
|
//# sourceMappingURL=types.js.map
|
|
@@ -47,14 +47,22 @@ var StorageManager = /** @class */ (function () {
|
|
|
47
47
|
case "cookieStorage":
|
|
48
48
|
return new cookie_1.default(this.writeKey);
|
|
49
49
|
case "localStorage":
|
|
50
|
-
return new web_1.default(this.writeKey, localStorage);
|
|
51
50
|
case "sessionStorage":
|
|
52
|
-
return new web_1.default(this.writeKey,
|
|
51
|
+
return new web_1.default(this.writeKey, this.getWebStorage(type));
|
|
53
52
|
case "memoryStorage":
|
|
54
53
|
default:
|
|
55
54
|
return new memory_1.default(this.writeKey);
|
|
56
55
|
}
|
|
57
56
|
};
|
|
57
|
+
StorageManager.prototype.getWebStorage = function (type) {
|
|
58
|
+
try {
|
|
59
|
+
var storage = type === "localStorage" ? localStorage : sessionStorage;
|
|
60
|
+
return storage !== null && storage !== void 0 ? storage : null;
|
|
61
|
+
}
|
|
62
|
+
catch (_a) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
58
66
|
return StorageManager;
|
|
59
67
|
}());
|
|
60
68
|
exports.StorageManager = StorageManager;
|
|
@@ -164,6 +164,14 @@ export interface Options {
|
|
|
164
164
|
* @default true
|
|
165
165
|
*/
|
|
166
166
|
autocapture?: boolean | AutocaptureOptions;
|
|
167
|
+
/**
|
|
168
|
+
* EVM provider tracking.
|
|
169
|
+
* Set to `false` to disable all EVM provider detection and tracking
|
|
170
|
+
* (EIP-1193, EIP-6963, window.ethereum). Useful for Solana-only apps
|
|
171
|
+
* that don't need EVM wallet event capture.
|
|
172
|
+
* @default true
|
|
173
|
+
*/
|
|
174
|
+
evm?: boolean;
|
|
167
175
|
/**
|
|
168
176
|
* Wagmi integration configuration
|
|
169
177
|
* When provided, the SDK will hook into Wagmi's event system instead of wrapping EIP-1193 providers
|
|
@@ -173,11 +181,14 @@ export interface Options {
|
|
|
173
181
|
*/
|
|
174
182
|
wagmi?: WagmiOptions;
|
|
175
183
|
/**
|
|
176
|
-
* Solana
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
184
|
+
* Solana integration configuration.
|
|
185
|
+
* Pass `store: client.store` from framework-kit for automatic tracking of
|
|
186
|
+
* wallet connect/disconnect and transaction events.
|
|
187
|
+
*
|
|
188
|
+
* For signMessage/signTransaction, use formo.signature() directly
|
|
189
|
+
* (framework-kit doesn't track these in the store).
|
|
190
|
+
*
|
|
191
|
+
* @see https://github.com/solana-foundation/framework-kit
|
|
181
192
|
*/
|
|
182
193
|
solana?: SolanaOptions;
|
|
183
194
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UUID } from "crypto";
|
|
2
2
|
import { Address, ChainID, Nullable } from "./base";
|
|
3
3
|
import { TEventChannel, TEventType } from "../constants";
|
|
4
|
+
import { CLICK_ID_PARAMS } from "../event/constants";
|
|
4
5
|
export type AnonymousID = UUID;
|
|
5
6
|
export interface ICommonProperties {
|
|
6
7
|
anonymous_id: AnonymousID;
|
|
@@ -21,7 +22,10 @@ export type UTMParameters = {
|
|
|
21
22
|
utm_term: string;
|
|
22
23
|
utm_content: string;
|
|
23
24
|
};
|
|
24
|
-
export type
|
|
25
|
+
export type ClickIdParameters = {
|
|
26
|
+
[K in (typeof CLICK_ID_PARAMS)[number]]: string;
|
|
27
|
+
};
|
|
28
|
+
export type ITrafficSource = UTMParameters & ClickIdParameters & {
|
|
25
29
|
ref: string;
|
|
26
30
|
referrer: string;
|
|
27
31
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "1.
|
|
1
|
+
export declare const version = "1.29.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/cjs/src/version.js
CHANGED
|
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.version = void 0;
|
|
4
4
|
// This file is auto-generated by scripts/update-version.js during npm version
|
|
5
5
|
// Do not edit manually - it will be overwritten
|
|
6
|
-
exports.version = '1.
|
|
6
|
+
exports.version = '1.29.0';
|
|
7
7
|
//# sourceMappingURL=version.js.map
|
|
@@ -45,8 +45,15 @@ export declare class FormoAnalytics implements IFormoAnalytics {
|
|
|
45
45
|
* When true, EIP-1193 provider wrapping is skipped
|
|
46
46
|
*/
|
|
47
47
|
private isWagmiMode;
|
|
48
|
+
/**
|
|
49
|
+
* Flag indicating if EVM provider tracking is disabled.
|
|
50
|
+
* When true, all EIP-1193/EIP-6963 detection and wrapping is skipped.
|
|
51
|
+
*/
|
|
52
|
+
private isEvmDisabled;
|
|
48
53
|
/** Instance-level flag so multiple SDK instances don't interfere. */
|
|
49
54
|
private crossSubdomainCookies;
|
|
55
|
+
/** In-memory URL used to deduplicate SPA pageview events. */
|
|
56
|
+
private _currentUrl;
|
|
50
57
|
config: Config;
|
|
51
58
|
currentChainId?: ChainID;
|
|
52
59
|
currentAddress?: Address;
|
|
@@ -294,10 +301,9 @@ export declare class FormoAnalytics implements IFormoAnalytics {
|
|
|
294
301
|
*
|
|
295
302
|
* @example
|
|
296
303
|
* ```tsx
|
|
297
|
-
* formo.solana.
|
|
298
|
-
* formo.solana.setConnection(connection);
|
|
304
|
+
* formo.solana.setStore(client.store);
|
|
299
305
|
* formo.solana.setCluster("devnet");
|
|
300
|
-
* formo.
|
|
306
|
+
* // For signatures, use formo.signature() directly
|
|
301
307
|
* ```
|
|
302
308
|
*/
|
|
303
309
|
get solana(): SolanaManager;
|
|
@@ -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_HOST, EventType, LOCAL_ANONYMOUS_ID_KEY,
|
|
58
|
+
import { EVENTS_API_HOST, EventType, LOCAL_ANONYMOUS_ID_KEY, SESSION_USER_ID_KEY, CONSENT_OPT_OUT_KEY, } from "./constants";
|
|
59
59
|
import { cookie, initStorageManager } from "./storage";
|
|
60
60
|
import { getIdentityCookieDomain } from "./storage/cookiePolicy";
|
|
61
61
|
import { EventManager } from "./event";
|
|
@@ -114,6 +114,13 @@ var FormoAnalytics = /** @class */ (function () {
|
|
|
114
114
|
* When true, EIP-1193 provider wrapping is skipped
|
|
115
115
|
*/
|
|
116
116
|
this.isWagmiMode = false;
|
|
117
|
+
/**
|
|
118
|
+
* Flag indicating if EVM provider tracking is disabled.
|
|
119
|
+
* When true, all EIP-1193/EIP-6963 detection and wrapping is skipped.
|
|
120
|
+
*/
|
|
121
|
+
this.isEvmDisabled = false;
|
|
122
|
+
/** In-memory URL used to deduplicate SPA pageview events. */
|
|
123
|
+
this._currentUrl = "";
|
|
117
124
|
this.currentUserId = "";
|
|
118
125
|
this.config = {
|
|
119
126
|
writeKey: writeKey,
|
|
@@ -121,6 +128,7 @@ var FormoAnalytics = /** @class */ (function () {
|
|
|
121
128
|
this.options = options;
|
|
122
129
|
// Check if Wagmi mode is enabled
|
|
123
130
|
this.isWagmiMode = !!options.wagmi;
|
|
131
|
+
this.isEvmDisabled = options.evm === false;
|
|
124
132
|
this.crossSubdomainCookies = (_a = options.crossSubdomainCookies) !== null && _a !== void 0 ? _a : true;
|
|
125
133
|
// Normalize so downstream consumers (EventFactory) read the resolved value.
|
|
126
134
|
options.crossSubdomainCookies = this.crossSubdomainCookies;
|
|
@@ -153,8 +161,11 @@ var FormoAnalytics = /** @class */ (function () {
|
|
|
153
161
|
if (this.hasOptedOutTracking()) {
|
|
154
162
|
logger.info("User has previously opted out of tracking");
|
|
155
163
|
}
|
|
156
|
-
// Initialize
|
|
157
|
-
if (this.
|
|
164
|
+
// Initialize EVM provider tracking (unless explicitly disabled)
|
|
165
|
+
if (this.isEvmDisabled) {
|
|
166
|
+
logger.info("FormoAnalytics: EVM provider tracking disabled");
|
|
167
|
+
}
|
|
168
|
+
else if (this.isWagmiMode && options.wagmi) {
|
|
158
169
|
logger.info("FormoAnalytics: Initializing in Wagmi mode");
|
|
159
170
|
this.wagmiHandler = new WagmiEventHandler(this, options.wagmi.config, options.wagmi.queryClient);
|
|
160
171
|
}
|
|
@@ -176,6 +187,7 @@ var FormoAnalytics = /** @class */ (function () {
|
|
|
176
187
|
if (options.solana) {
|
|
177
188
|
this.solanaManager = new SolanaManager(this, options.solana);
|
|
178
189
|
}
|
|
190
|
+
this._currentUrl = window.location.href;
|
|
179
191
|
this.trackPageHit();
|
|
180
192
|
this.trackPageHits();
|
|
181
193
|
}
|
|
@@ -223,22 +235,26 @@ var FormoAnalytics = /** @class */ (function () {
|
|
|
223
235
|
case 0:
|
|
224
236
|
initStorageManager(writeKey);
|
|
225
237
|
analytics = new FormoAnalytics(writeKey, options);
|
|
226
|
-
if (
|
|
238
|
+
if (!analytics.isEvmDisabled) return [3 /*break*/, 1];
|
|
239
|
+
logger.info("FormoAnalytics: Skipping provider detection (EVM disabled)");
|
|
240
|
+
return [3 /*break*/, 5];
|
|
241
|
+
case 1:
|
|
242
|
+
if (!!analytics.isWagmiMode) return [3 /*break*/, 4];
|
|
227
243
|
// Auto-detect wallet provider
|
|
228
244
|
_a = analytics;
|
|
229
245
|
return [4 /*yield*/, analytics.getProviders()];
|
|
230
|
-
case
|
|
246
|
+
case 2:
|
|
231
247
|
// Auto-detect wallet provider
|
|
232
248
|
_a._providers = _b.sent();
|
|
233
249
|
return [4 /*yield*/, analytics.detectWallets(analytics._providers)];
|
|
234
|
-
case
|
|
250
|
+
case 3:
|
|
235
251
|
_b.sent();
|
|
236
252
|
analytics.trackProviders(analytics._providers);
|
|
237
|
-
return [3 /*break*/,
|
|
238
|
-
case
|
|
253
|
+
return [3 /*break*/, 5];
|
|
254
|
+
case 4:
|
|
239
255
|
logger.info("FormoAnalytics: Skipping provider detection (Wagmi mode)");
|
|
240
|
-
_b.label =
|
|
241
|
-
case
|
|
256
|
+
_b.label = 5;
|
|
257
|
+
case 5: return [2 /*return*/, analytics];
|
|
242
258
|
}
|
|
243
259
|
});
|
|
244
260
|
});
|
|
@@ -1424,11 +1440,9 @@ var FormoAnalytics = /** @class */ (function () {
|
|
|
1424
1440
|
};
|
|
1425
1441
|
FormoAnalytics.prototype.onLocationChange = function () {
|
|
1426
1442
|
return __awaiter(this, void 0, void 0, function () {
|
|
1427
|
-
var currentUrl;
|
|
1428
1443
|
return __generator(this, function (_a) {
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
cookie().set(SESSION_CURRENT_URL_KEY, window.location.href);
|
|
1444
|
+
if (this._currentUrl !== window.location.href) {
|
|
1445
|
+
this._currentUrl = window.location.href;
|
|
1432
1446
|
this.trackPageHit();
|
|
1433
1447
|
}
|
|
1434
1448
|
return [2 /*return*/];
|
|
@@ -1767,10 +1781,9 @@ var FormoAnalytics = /** @class */ (function () {
|
|
|
1767
1781
|
*
|
|
1768
1782
|
* @example
|
|
1769
1783
|
* ```tsx
|
|
1770
|
-
* formo.solana.
|
|
1771
|
-
* formo.solana.setConnection(connection);
|
|
1784
|
+
* formo.solana.setStore(client.store);
|
|
1772
1785
|
* formo.solana.setCluster("devnet");
|
|
1773
|
-
* formo.
|
|
1786
|
+
* // For signatures, use formo.signature() directly
|
|
1774
1787
|
* ```
|
|
1775
1788
|
*/
|
|
1776
1789
|
get: function () {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare const SESSION_TRAFFIC_SOURCE_KEY = "traffic-source";
|
|
2
|
-
export declare const SESSION_CURRENT_URL_KEY = "analytics-current-url";
|
|
3
2
|
export declare const SESSION_USER_ID_KEY = "user-id";
|
|
4
3
|
export declare const LOCAL_ANONYMOUS_ID_KEY = "anonymous-id";
|
|
5
4
|
export declare const CONSENT_OPT_OUT_KEY = "opt-out-tracking";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export var SESSION_TRAFFIC_SOURCE_KEY = "traffic-source";
|
|
2
2
|
// SESSION_WALLET_DETECTED_KEY and SESSION_WALLET_IDENTIFIED_KEY
|
|
3
3
|
// are now defined in src/session/index.ts
|
|
4
|
-
export var SESSION_CURRENT_URL_KEY = "analytics-current-url";
|
|
5
4
|
export var SESSION_USER_ID_KEY = "user-id";
|
|
6
5
|
export var LOCAL_ANONYMOUS_ID_KEY = "anonymous-id";
|
|
7
6
|
// Consent management keys
|
|
@@ -17,6 +17,7 @@ declare class EventFactory implements IEventFactory {
|
|
|
17
17
|
private getLanguage;
|
|
18
18
|
private getLibraryVersion;
|
|
19
19
|
private extractUTMParameters;
|
|
20
|
+
private extractClickIdParameters;
|
|
20
21
|
private extractReferralParameter;
|
|
21
22
|
private getTrafficSources;
|
|
22
23
|
private getScreen;
|
|
@@ -54,7 +54,7 @@ import { logger } from "../logger";
|
|
|
54
54
|
import mergeDeepRight from "../ramda/mergeDeepRight";
|
|
55
55
|
import { session } from "../storage";
|
|
56
56
|
import { version } from "../version";
|
|
57
|
-
import { CHANNEL,
|
|
57
|
+
import { CHANNEL, CLICK_ID_PARAMS, PAGE_PROPERTIES_EXCLUDED_FIELDS, VERSION, } from "./constants";
|
|
58
58
|
import { generateAnonymousId } from "./utils";
|
|
59
59
|
import { detectBrowser } from "../browser/browsers";
|
|
60
60
|
var EventFactory = /** @class */ (function () {
|
|
@@ -81,6 +81,15 @@ var EventFactory = /** @class */ (function () {
|
|
|
81
81
|
catch (_a) { }
|
|
82
82
|
return result;
|
|
83
83
|
};
|
|
84
|
+
this.extractClickIdParameters = function (urlObj) {
|
|
85
|
+
var result = {};
|
|
86
|
+
for (var _i = 0, CLICK_ID_PARAMS_1 = CLICK_ID_PARAMS; _i < CLICK_ID_PARAMS_1.length; _i++) {
|
|
87
|
+
var param = CLICK_ID_PARAMS_1[_i];
|
|
88
|
+
var value = urlObj.searchParams.get(param);
|
|
89
|
+
result[param] = value ? value.trim() : "";
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
};
|
|
84
93
|
this.extractReferralParameter = function (urlObj) {
|
|
85
94
|
var _a, _b, _c;
|
|
86
95
|
// Strategy: Check query params first, then check path pattern if configured
|
|
@@ -113,25 +122,23 @@ var EventFactory = /** @class */ (function () {
|
|
|
113
122
|
};
|
|
114
123
|
this.getTrafficSources = function (url) {
|
|
115
124
|
var urlObj = new URL(url);
|
|
116
|
-
var contextTrafficSources = __assign(__assign({}, _this.extractUTMParameters(url)), { ref: _this.extractReferralParameter(urlObj), referrer: document.referrer });
|
|
125
|
+
var contextTrafficSources = __assign(__assign(__assign({}, _this.extractUTMParameters(url)), _this.extractClickIdParameters(urlObj)), { ref: _this.extractReferralParameter(urlObj), referrer: document.referrer });
|
|
117
126
|
var storedTrafficSources = session().get(SESSION_TRAFFIC_SOURCE_KEY) || {};
|
|
118
|
-
var
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
127
|
+
var mergedClickIds = {};
|
|
128
|
+
for (var _i = 0, CLICK_ID_PARAMS_2 = CLICK_ID_PARAMS; _i < CLICK_ID_PARAMS_2.length; _i++) {
|
|
129
|
+
var p = CLICK_ID_PARAMS_2[_i];
|
|
130
|
+
mergedClickIds[p] =
|
|
131
|
+
contextTrafficSources[p] || (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources[p]) || "";
|
|
132
|
+
}
|
|
133
|
+
var finalTrafficSources = __assign({ ref: contextTrafficSources.ref || (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.ref) || "", referrer: contextTrafficSources.referrer || (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.referrer) || "", utm_campaign: contextTrafficSources.utm_campaign ||
|
|
122
134
|
(storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.utm_campaign) ||
|
|
123
|
-
"",
|
|
124
|
-
utm_content: contextTrafficSources.utm_content ||
|
|
135
|
+
"", utm_content: contextTrafficSources.utm_content ||
|
|
125
136
|
(storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.utm_content) ||
|
|
126
|
-
"",
|
|
127
|
-
utm_medium: contextTrafficSources.utm_medium ||
|
|
137
|
+
"", utm_medium: contextTrafficSources.utm_medium ||
|
|
128
138
|
(storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.utm_medium) ||
|
|
129
|
-
"",
|
|
130
|
-
utm_source: contextTrafficSources.utm_source ||
|
|
139
|
+
"", utm_source: contextTrafficSources.utm_source ||
|
|
131
140
|
(storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.utm_source) ||
|
|
132
|
-
"",
|
|
133
|
-
utm_term: contextTrafficSources.utm_term || (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.utm_term) || "",
|
|
134
|
-
};
|
|
141
|
+
"", utm_term: contextTrafficSources.utm_term || (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.utm_term) || "" }, mergedClickIds);
|
|
135
142
|
// Store to session
|
|
136
143
|
var sessionStoredTrafficSources = Object.keys(finalTrafficSources).reduce(function (res, key) {
|
|
137
144
|
var value = finalTrafficSources[key];
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
declare const CHANNEL = "web";
|
|
2
2
|
declare const VERSION = "0";
|
|
3
|
+
/**
|
|
4
|
+
* Paid-attribution click IDs captured from the landing-page URL and persisted
|
|
5
|
+
* across the session alongside UTM parameters. Keep the ClickIdParameters type
|
|
6
|
+
* in src/types/events.ts derived from this array.
|
|
7
|
+
*/
|
|
8
|
+
declare const CLICK_ID_PARAMS: readonly ["gclid", "gad_source", "fbclid", "msclkid", "twclid", "li_fat_id", "rdt_cid", "ttclid"];
|
|
3
9
|
/**
|
|
4
10
|
* Fields that should be excluded from page event properties parsing
|
|
5
11
|
* These are either:
|
|
6
|
-
* - Already captured in event context (UTM params, referral params)
|
|
12
|
+
* - Already captured in event context (UTM params, referral params, click IDs)
|
|
7
13
|
* - Semantic event properties that should not be overridden by URL params
|
|
8
14
|
*/
|
|
9
15
|
declare const PAGE_PROPERTIES_EXCLUDED_FIELDS: Set<string>;
|
|
10
|
-
export { CHANNEL, VERSION, PAGE_PROPERTIES_EXCLUDED_FIELDS };
|
|
16
|
+
export { CHANNEL, VERSION, CLICK_ID_PARAMS, PAGE_PROPERTIES_EXCLUDED_FIELDS };
|
|
11
17
|
//# sourceMappingURL=constants.d.ts.map
|