@lavarage/telemetry 1.0.1 → 1.1.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/README.md +21 -6
- package/dist/index.d.ts +6 -1
- package/dist/index.js +75 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,7 +22,9 @@ const telemetry = new LavarageTelemetry({
|
|
|
22
22
|
telemetry.interceptFetch();
|
|
23
23
|
|
|
24
24
|
// Connect wallet (triggers login event)
|
|
25
|
-
|
|
25
|
+
// Wallet platform is automatically detected (MetaMask, Phantom, etc.)
|
|
26
|
+
// or you can specify it manually:
|
|
27
|
+
telemetry.setWallet('YourWalletAddress123...', 'MetaMask');
|
|
26
28
|
|
|
27
29
|
// Track trading pair views
|
|
28
30
|
telemetry.trackPairView('SOL/USDC', { source: 'homepage' });
|
|
@@ -206,12 +208,25 @@ All telemetry operations are wrapped in try-catch blocks. Telemetry errors will
|
|
|
206
208
|
|
|
207
209
|
### Methods
|
|
208
210
|
|
|
209
|
-
#### `setWallet(walletAddress: string)`
|
|
211
|
+
#### `setWallet(walletAddress: string, walletPlatform?: string)`
|
|
212
|
+
|
|
213
|
+
Set the current wallet address and trigger a login event. The wallet platform (e.g., 'MetaMask', 'Phantom', 'WalletConnect') is automatically detected from the browser environment, but you can also specify it manually.
|
|
210
214
|
|
|
211
|
-
|
|
215
|
+
**Supported auto-detected platforms:**
|
|
216
|
+
- MetaMask
|
|
217
|
+
- Coinbase Wallet
|
|
218
|
+
- Trust Wallet
|
|
219
|
+
- WalletConnect
|
|
220
|
+
- Phantom (Solana)
|
|
221
|
+
- Solflare (Solana)
|
|
222
|
+
- Generic Ethereum/Solana providers
|
|
212
223
|
|
|
213
224
|
```typescript
|
|
225
|
+
// Auto-detect wallet platform
|
|
214
226
|
telemetry.setWallet('YourWalletAddress123...');
|
|
227
|
+
|
|
228
|
+
// Or specify manually
|
|
229
|
+
telemetry.setWallet('YourWalletAddress123...', 'MetaMask');
|
|
215
230
|
```
|
|
216
231
|
|
|
217
232
|
#### `interceptFetch()`
|
|
@@ -425,12 +440,12 @@ await telemetry.sendLog(
|
|
|
425
440
|
);
|
|
426
441
|
```
|
|
427
442
|
|
|
428
|
-
#### `setWallet(walletAddress: string)`
|
|
443
|
+
#### `setWallet(walletAddress: string, walletPlatform?: string)`
|
|
429
444
|
|
|
430
|
-
Set the default wallet address for subsequent events. This is optional for backend use since you can specify the wallet in each log call.
|
|
445
|
+
Set the default wallet address for subsequent events. This is optional for backend use since you can specify the wallet in each log call. You can also optionally specify the wallet platform.
|
|
431
446
|
|
|
432
447
|
```typescript
|
|
433
|
-
telemetry.setWallet('WalletAddress123...');
|
|
448
|
+
telemetry.setWallet('WalletAddress123...', 'MetaMask');
|
|
434
449
|
// Now all events will use this wallet by default
|
|
435
450
|
telemetry.logWalletEvent(
|
|
436
451
|
null, // Will use the wallet set above
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ export declare class LavarageTelemetry {
|
|
|
17
17
|
constructor(config: TelemetryConfig);
|
|
18
18
|
private generateSessionId;
|
|
19
19
|
private generateRequestId;
|
|
20
|
+
/**
|
|
21
|
+
* Detect wallet platform/provider from browser environment
|
|
22
|
+
* Checks for common wallet providers like MetaMask, Phantom, WalletConnect, etc.
|
|
23
|
+
*/
|
|
24
|
+
private detectWalletPlatform;
|
|
20
25
|
private normalizeHostFilter;
|
|
21
26
|
private shouldCaptureHost;
|
|
22
27
|
private matchesHost;
|
|
@@ -29,7 +34,7 @@ export declare class LavarageTelemetry {
|
|
|
29
34
|
private flush;
|
|
30
35
|
private initializeCapture;
|
|
31
36
|
private trackError;
|
|
32
|
-
setWallet(walletAddress: string): void;
|
|
37
|
+
setWallet(walletAddress: string, walletPlatform?: string): void;
|
|
33
38
|
interceptFetch(): void;
|
|
34
39
|
interceptAxios(axiosInstance: any): void;
|
|
35
40
|
trackPairView(pair: string, metadata?: object): void;
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,77 @@ class LavarageTelemetry {
|
|
|
33
33
|
generateRequestId() {
|
|
34
34
|
return `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Detect wallet platform/provider from browser environment
|
|
38
|
+
* Checks for common wallet providers like MetaMask, Phantom, WalletConnect, etc.
|
|
39
|
+
*/
|
|
40
|
+
detectWalletPlatform() {
|
|
41
|
+
if (typeof window === 'undefined') {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const win = window;
|
|
46
|
+
// Check for Ethereum wallets
|
|
47
|
+
if (win.ethereum) {
|
|
48
|
+
// MetaMask
|
|
49
|
+
if (win.ethereum.isMetaMask) {
|
|
50
|
+
return 'MetaMask';
|
|
51
|
+
}
|
|
52
|
+
// Coinbase Wallet
|
|
53
|
+
if (win.ethereum.isCoinbaseWallet) {
|
|
54
|
+
return 'Coinbase Wallet';
|
|
55
|
+
}
|
|
56
|
+
// Trust Wallet
|
|
57
|
+
if (win.ethereum.isTrust) {
|
|
58
|
+
return 'Trust Wallet';
|
|
59
|
+
}
|
|
60
|
+
// WalletConnect
|
|
61
|
+
if (win.ethereum.isWalletConnect) {
|
|
62
|
+
return 'WalletConnect';
|
|
63
|
+
}
|
|
64
|
+
// Generic Ethereum provider
|
|
65
|
+
if (win.ethereum.providers && Array.isArray(win.ethereum.providers)) {
|
|
66
|
+
// Multiple providers detected, try to identify
|
|
67
|
+
for (const provider of win.ethereum.providers) {
|
|
68
|
+
if (provider.isMetaMask)
|
|
69
|
+
return 'MetaMask';
|
|
70
|
+
if (provider.isCoinbaseWallet)
|
|
71
|
+
return 'Coinbase Wallet';
|
|
72
|
+
if (provider.isTrust)
|
|
73
|
+
return 'Trust Wallet';
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Check provider name/version
|
|
77
|
+
if (win.ethereum.providerName) {
|
|
78
|
+
return win.ethereum.providerName;
|
|
79
|
+
}
|
|
80
|
+
// Default to generic Ethereum
|
|
81
|
+
return 'Ethereum';
|
|
82
|
+
}
|
|
83
|
+
// Check for Solana wallets
|
|
84
|
+
if (win.solana) {
|
|
85
|
+
// Phantom
|
|
86
|
+
if (win.solana.isPhantom) {
|
|
87
|
+
return 'Phantom';
|
|
88
|
+
}
|
|
89
|
+
// Solflare
|
|
90
|
+
if (win.solana.isSolflare) {
|
|
91
|
+
return 'Solflare';
|
|
92
|
+
}
|
|
93
|
+
// Generic Solana
|
|
94
|
+
return 'Solana';
|
|
95
|
+
}
|
|
96
|
+
// Check for other wallet providers
|
|
97
|
+
if (win.web3) {
|
|
98
|
+
return 'Web3';
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
// Silently fail detection
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
36
107
|
normalizeHostFilter(input) {
|
|
37
108
|
if (!input) {
|
|
38
109
|
return { mode: 'all' };
|
|
@@ -325,9 +396,11 @@ class LavarageTelemetry {
|
|
|
325
396
|
url: typeof window !== 'undefined' ? window.location.href : '',
|
|
326
397
|
});
|
|
327
398
|
}
|
|
328
|
-
setWallet(walletAddress) {
|
|
399
|
+
setWallet(walletAddress, walletPlatform) {
|
|
329
400
|
try {
|
|
330
401
|
this.wallet = walletAddress;
|
|
402
|
+
// Detect wallet platform if not provided
|
|
403
|
+
const detectedPlatform = walletPlatform || this.detectWalletPlatform();
|
|
331
404
|
// Track login event
|
|
332
405
|
this.enqueue({
|
|
333
406
|
type: 'login',
|
|
@@ -336,6 +409,7 @@ class LavarageTelemetry {
|
|
|
336
409
|
timestamp: Date.now(),
|
|
337
410
|
sessionId: this.sessionId,
|
|
338
411
|
userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : '',
|
|
412
|
+
walletPlatform: detectedPlatform || null,
|
|
339
413
|
});
|
|
340
414
|
}
|
|
341
415
|
catch (error) {
|