@formo/analytics 1.28.5 → 1.28.6
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 +7 -3
- package/dist/cjs/src/FormoAnalytics.js +24 -12
- 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/version.d.ts +1 -1
- package/dist/cjs/src/version.js +1 -1
- package/dist/esm/src/FormoAnalytics.d.ts +7 -3
- package/dist/esm/src/FormoAnalytics.js +24 -12
- 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/version.d.ts +1 -1
- package/dist/esm/src/version.js +1 -1
- package/dist/index.umd.min.js +1 -1
- package/package.json +3 -3
- 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,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "1.28.
|
|
1
|
+
export declare const version = "1.28.6";
|
|
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.28.
|
|
6
|
+
exports.version = '1.28.6';
|
|
7
7
|
//# sourceMappingURL=version.js.map
|
|
@@ -45,6 +45,11 @@ 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;
|
|
50
55
|
config: Config;
|
|
@@ -294,10 +299,9 @@ export declare class FormoAnalytics implements IFormoAnalytics {
|
|
|
294
299
|
*
|
|
295
300
|
* @example
|
|
296
301
|
* ```tsx
|
|
297
|
-
* formo.solana.
|
|
298
|
-
* formo.solana.setConnection(connection);
|
|
302
|
+
* formo.solana.setStore(client.store);
|
|
299
303
|
* formo.solana.setCluster("devnet");
|
|
300
|
-
* formo.
|
|
304
|
+
* // For signatures, use formo.signature() directly
|
|
301
305
|
* ```
|
|
302
306
|
*/
|
|
303
307
|
get solana(): SolanaManager;
|
|
@@ -114,6 +114,11 @@ 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;
|
|
117
122
|
this.currentUserId = "";
|
|
118
123
|
this.config = {
|
|
119
124
|
writeKey: writeKey,
|
|
@@ -121,6 +126,7 @@ var FormoAnalytics = /** @class */ (function () {
|
|
|
121
126
|
this.options = options;
|
|
122
127
|
// Check if Wagmi mode is enabled
|
|
123
128
|
this.isWagmiMode = !!options.wagmi;
|
|
129
|
+
this.isEvmDisabled = options.evm === false;
|
|
124
130
|
this.crossSubdomainCookies = (_a = options.crossSubdomainCookies) !== null && _a !== void 0 ? _a : true;
|
|
125
131
|
// Normalize so downstream consumers (EventFactory) read the resolved value.
|
|
126
132
|
options.crossSubdomainCookies = this.crossSubdomainCookies;
|
|
@@ -153,8 +159,11 @@ var FormoAnalytics = /** @class */ (function () {
|
|
|
153
159
|
if (this.hasOptedOutTracking()) {
|
|
154
160
|
logger.info("User has previously opted out of tracking");
|
|
155
161
|
}
|
|
156
|
-
// Initialize
|
|
157
|
-
if (this.
|
|
162
|
+
// Initialize EVM provider tracking (unless explicitly disabled)
|
|
163
|
+
if (this.isEvmDisabled) {
|
|
164
|
+
logger.info("FormoAnalytics: EVM provider tracking disabled");
|
|
165
|
+
}
|
|
166
|
+
else if (this.isWagmiMode && options.wagmi) {
|
|
158
167
|
logger.info("FormoAnalytics: Initializing in Wagmi mode");
|
|
159
168
|
this.wagmiHandler = new WagmiEventHandler(this, options.wagmi.config, options.wagmi.queryClient);
|
|
160
169
|
}
|
|
@@ -223,22 +232,26 @@ var FormoAnalytics = /** @class */ (function () {
|
|
|
223
232
|
case 0:
|
|
224
233
|
initStorageManager(writeKey);
|
|
225
234
|
analytics = new FormoAnalytics(writeKey, options);
|
|
226
|
-
if (
|
|
235
|
+
if (!analytics.isEvmDisabled) return [3 /*break*/, 1];
|
|
236
|
+
logger.info("FormoAnalytics: Skipping provider detection (EVM disabled)");
|
|
237
|
+
return [3 /*break*/, 5];
|
|
238
|
+
case 1:
|
|
239
|
+
if (!!analytics.isWagmiMode) return [3 /*break*/, 4];
|
|
227
240
|
// Auto-detect wallet provider
|
|
228
241
|
_a = analytics;
|
|
229
242
|
return [4 /*yield*/, analytics.getProviders()];
|
|
230
|
-
case
|
|
243
|
+
case 2:
|
|
231
244
|
// Auto-detect wallet provider
|
|
232
245
|
_a._providers = _b.sent();
|
|
233
246
|
return [4 /*yield*/, analytics.detectWallets(analytics._providers)];
|
|
234
|
-
case
|
|
247
|
+
case 3:
|
|
235
248
|
_b.sent();
|
|
236
249
|
analytics.trackProviders(analytics._providers);
|
|
237
|
-
return [3 /*break*/,
|
|
238
|
-
case
|
|
250
|
+
return [3 /*break*/, 5];
|
|
251
|
+
case 4:
|
|
239
252
|
logger.info("FormoAnalytics: Skipping provider detection (Wagmi mode)");
|
|
240
|
-
_b.label =
|
|
241
|
-
case
|
|
253
|
+
_b.label = 5;
|
|
254
|
+
case 5: return [2 /*return*/, analytics];
|
|
242
255
|
}
|
|
243
256
|
});
|
|
244
257
|
});
|
|
@@ -1767,10 +1780,9 @@ var FormoAnalytics = /** @class */ (function () {
|
|
|
1767
1780
|
*
|
|
1768
1781
|
* @example
|
|
1769
1782
|
* ```tsx
|
|
1770
|
-
* formo.solana.
|
|
1771
|
-
* formo.solana.setConnection(connection);
|
|
1783
|
+
* formo.solana.setStore(client.store);
|
|
1772
1784
|
* formo.solana.setCluster("devnet");
|
|
1773
|
-
* formo.
|
|
1785
|
+
* // For signatures, use formo.signature() directly
|
|
1774
1786
|
* ```
|
|
1775
1787
|
*/
|
|
1776
1788
|
get: function () {
|
package/dist/esm/src/index.d.ts
CHANGED
|
@@ -4,5 +4,7 @@ export * from "./types";
|
|
|
4
4
|
export { parsePrivyProperties } from "./privy";
|
|
5
5
|
export type { PrivyUser, PrivyLinkedAccount, PrivyAccountType, PrivyProfileProperties, PrivyWalletInfo } from "./privy";
|
|
6
6
|
export { SolanaManager } from "./solana";
|
|
7
|
-
export
|
|
7
|
+
export { SOLANA_CHAIN_IDS, DEFAULT_SOLANA_CHAIN_ID, isSolanaChainId } from "./solana";
|
|
8
|
+
export type { SolanaOptions, SolanaCluster, } from "./solana";
|
|
9
|
+
export type { SolanaClientStore, SolanaClientState, } from "./solana";
|
|
8
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/src/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./types";
|
|
|
5
5
|
export { parsePrivyProperties } from "./privy";
|
|
6
6
|
// Solana integration exports
|
|
7
7
|
export { SolanaManager } from "./solana";
|
|
8
|
+
export { SOLANA_CHAIN_IDS, DEFAULT_SOLANA_CHAIN_ID, isSolanaChainId } from "./solana";
|
|
8
9
|
if (typeof window !== "undefined")
|
|
9
10
|
window.formofy = formofy;
|
|
10
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,24 +1,49 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SolanaManager
|
|
3
3
|
*
|
|
4
|
-
* Manages the lifecycle of the
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Manages the lifecycle of the Solana store integration.
|
|
5
|
+
* Subscribes to framework-kit's zustand store for automatic event capture
|
|
6
|
+
* of wallet connect/disconnect and transaction lifecycle events.
|
|
7
|
+
*
|
|
8
|
+
* For signMessage/signTransaction tracking (not captured by the store),
|
|
9
|
+
* use formo.signature() directly with the address and chainId.
|
|
10
|
+
*
|
|
11
|
+
* For manual event tracking without the store, use the core API directly:
|
|
12
|
+
* formo.transaction(), formo.signature(), formo.connect(), formo.disconnect().
|
|
7
13
|
*/
|
|
8
14
|
import { FormoAnalytics } from "../FormoAnalytics";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
15
|
+
import { SolanaCluster, SolanaOptions } from "./types";
|
|
16
|
+
import { SolanaClientStore } from "./storeTypes";
|
|
11
17
|
export declare class SolanaManager {
|
|
12
18
|
private formo;
|
|
13
|
-
private
|
|
14
|
-
private pendingConnection?;
|
|
19
|
+
private storeHandler?;
|
|
15
20
|
private pendingCluster?;
|
|
16
21
|
constructor(formo: FormoAnalytics, options?: SolanaOptions);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Set the framework-kit zustand store for automatic event tracking.
|
|
24
|
+
* This enables autocapture mode — connect/disconnect and transaction events
|
|
25
|
+
* are tracked automatically by subscribing to store state changes.
|
|
26
|
+
*
|
|
27
|
+
* @param store - The framework-kit client store (client.store)
|
|
28
|
+
* @param options - Optional configuration
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* import { createClient } from '@solana-foundation/framework-kit';
|
|
33
|
+
*
|
|
34
|
+
* const client = createClient({ endpoint: '...', walletConnectors: autoDiscover() });
|
|
35
|
+
* formo.solana.setStore(client.store);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
setStore(store: SolanaClientStore, options?: {
|
|
39
|
+
cluster?: SolanaCluster;
|
|
40
|
+
}): void;
|
|
41
|
+
/**
|
|
42
|
+
* Update the cluster/network. Only needed if the store endpoint doesn't
|
|
43
|
+
* contain a recognizable cluster name (e.g. custom RPC URLs).
|
|
44
|
+
* In most cases, the cluster is auto-detected from the store's endpoint.
|
|
45
|
+
*/
|
|
20
46
|
setCluster(cluster: SolanaCluster): void;
|
|
21
|
-
syncWalletState(): void;
|
|
22
47
|
cleanup(): void;
|
|
23
48
|
}
|
|
24
49
|
//# sourceMappingURL=SolanaManager.d.ts.map
|
|
@@ -1,75 +1,73 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SolanaManager
|
|
3
3
|
*
|
|
4
|
-
* Manages the lifecycle of the
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Manages the lifecycle of the Solana store integration.
|
|
5
|
+
* Subscribes to framework-kit's zustand store for automatic event capture
|
|
6
|
+
* of wallet connect/disconnect and transaction lifecycle events.
|
|
7
|
+
*
|
|
8
|
+
* For signMessage/signTransaction tracking (not captured by the store),
|
|
9
|
+
* use formo.signature() directly with the address and chainId.
|
|
10
|
+
*
|
|
11
|
+
* For manual event tracking without the store, use the core API directly:
|
|
12
|
+
* formo.transaction(), formo.signature(), formo.connect(), formo.disconnect().
|
|
7
13
|
*/
|
|
8
14
|
import { logger } from "../logger";
|
|
9
|
-
import {
|
|
15
|
+
import { SolanaStoreHandler } from "./SolanaStoreHandler";
|
|
10
16
|
var SolanaManager = /** @class */ (function () {
|
|
11
17
|
function SolanaManager(formo, options) {
|
|
12
18
|
this.formo = formo;
|
|
13
|
-
if (options === null || options === void 0 ? void 0 : options.
|
|
14
|
-
logger.info("SolanaManager: Initializing Solana
|
|
15
|
-
this.
|
|
16
|
-
wallet: options.wallet,
|
|
17
|
-
connection: options.connection,
|
|
19
|
+
if (options === null || options === void 0 ? void 0 : options.store) {
|
|
20
|
+
logger.info("SolanaManager: Initializing store-based Solana tracking");
|
|
21
|
+
this.storeHandler = new SolanaStoreHandler(formo, options.store, {
|
|
18
22
|
cluster: options.cluster,
|
|
19
23
|
});
|
|
20
24
|
}
|
|
21
|
-
else if (options) {
|
|
22
|
-
// Store pending
|
|
23
|
-
this.pendingConnection = options.connection;
|
|
25
|
+
else if (options === null || options === void 0 ? void 0 : options.cluster) {
|
|
26
|
+
// Store pending cluster for when setStore is called later
|
|
24
27
|
this.pendingCluster = options.cluster;
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (this.handler) {
|
|
51
|
-
this.handler.setConnection(connection);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
this.pendingConnection = connection !== null && connection !== void 0 ? connection : undefined;
|
|
55
|
-
}
|
|
30
|
+
/**
|
|
31
|
+
* Set the framework-kit zustand store for automatic event tracking.
|
|
32
|
+
* This enables autocapture mode — connect/disconnect and transaction events
|
|
33
|
+
* are tracked automatically by subscribing to store state changes.
|
|
34
|
+
*
|
|
35
|
+
* @param store - The framework-kit client store (client.store)
|
|
36
|
+
* @param options - Optional configuration
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* import { createClient } from '@solana-foundation/framework-kit';
|
|
41
|
+
*
|
|
42
|
+
* const client = createClient({ endpoint: '...', walletConnectors: autoDiscover() });
|
|
43
|
+
* formo.solana.setStore(client.store);
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
SolanaManager.prototype.setStore = function (store, options) {
|
|
47
|
+
var _a;
|
|
48
|
+
(_a = this.storeHandler) === null || _a === void 0 ? void 0 : _a.cleanup();
|
|
49
|
+
this.storeHandler = new SolanaStoreHandler(this.formo, store, {
|
|
50
|
+
cluster: (options === null || options === void 0 ? void 0 : options.cluster) || this.pendingCluster,
|
|
51
|
+
});
|
|
52
|
+
this.pendingCluster = undefined;
|
|
56
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* Update the cluster/network. Only needed if the store endpoint doesn't
|
|
56
|
+
* contain a recognizable cluster name (e.g. custom RPC URLs).
|
|
57
|
+
* In most cases, the cluster is auto-detected from the store's endpoint.
|
|
58
|
+
*/
|
|
57
59
|
SolanaManager.prototype.setCluster = function (cluster) {
|
|
58
|
-
if (this.
|
|
59
|
-
this.
|
|
60
|
+
if (this.storeHandler) {
|
|
61
|
+
this.storeHandler.setCluster(cluster);
|
|
60
62
|
}
|
|
61
63
|
else {
|
|
62
64
|
this.pendingCluster = cluster;
|
|
63
65
|
}
|
|
64
66
|
};
|
|
65
|
-
SolanaManager.prototype.syncWalletState = function () {
|
|
66
|
-
var _a;
|
|
67
|
-
(_a = this.handler) === null || _a === void 0 ? void 0 : _a.syncWalletState();
|
|
68
|
-
};
|
|
69
67
|
SolanaManager.prototype.cleanup = function () {
|
|
70
68
|
var _a;
|
|
71
|
-
(_a = this.
|
|
72
|
-
this.
|
|
69
|
+
(_a = this.storeHandler) === null || _a === void 0 ? void 0 : _a.cleanup();
|
|
70
|
+
this.storeHandler = undefined;
|
|
73
71
|
};
|
|
74
72
|
return SolanaManager;
|
|
75
73
|
}());
|