0xtrails 0.1.2 → 0.1.4
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/address.d.ts.map +1 -1
- package/dist/analytics.d.ts +86 -1
- package/dist/analytics.d.ts.map +1 -1
- package/dist/apiClient.d.ts +1 -1
- package/dist/apiClient.d.ts.map +1 -1
- package/dist/{ccip-BmFTEOaB.js → ccip-dLSEJjCf.js} +55 -55
- package/dist/cctpqueue.d.ts +1 -1
- package/dist/cctpqueue.d.ts.map +1 -1
- package/dist/chains.d.ts +9 -3
- package/dist/chains.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/decoders.d.ts +58 -0
- package/dist/decoders.d.ts.map +1 -0
- package/dist/ens.d.ts +13 -0
- package/dist/ens.d.ts.map +1 -0
- package/dist/error.d.ts +9 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/{index-BPsVj7zK.js → index-BXbaLmtt.js} +28779 -25738
- package/dist/index.js +2 -2
- package/dist/intents.d.ts +4 -4
- package/dist/intents.d.ts.map +1 -1
- package/dist/lifi.d.ts +4 -0
- package/dist/lifi.d.ts.map +1 -0
- package/dist/metaTxns.d.ts +1 -1
- package/dist/metaTxns.d.ts.map +1 -1
- package/dist/mode.d.ts +1 -1
- package/dist/mode.d.ts.map +1 -1
- package/dist/preconditions.d.ts +1 -1
- package/dist/preconditions.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +32 -24
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/prices.d.ts +3 -1
- package/dist/prices.d.ts.map +1 -1
- package/dist/proxyCaller.d.ts +0 -1
- package/dist/proxyCaller.d.ts.map +1 -1
- package/dist/relaySdk.d.ts.map +1 -1
- package/dist/relayer.d.ts.map +1 -1
- package/dist/tokenBalances.d.ts +1 -1
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/tokens.d.ts +2 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/trails.d.ts +4 -4
- package/dist/trails.d.ts.map +1 -1
- package/dist/transactions.d.ts +4 -0
- package/dist/transactions.d.ts.map +1 -1
- package/dist/utils.d.ts +6 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/wallets.d.ts +247 -5
- package/dist/wallets.d.ts.map +1 -1
- package/dist/widget/components/ChainFilterDropdown.d.ts +2 -0
- package/dist/widget/components/ChainFilterDropdown.d.ts.map +1 -1
- package/dist/widget/components/ConnectWallet.d.ts +1 -0
- package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
- package/dist/widget/components/DebugScreensDropdown.d.ts.map +1 -1
- package/dist/widget/components/ErrorDisplay.d.ts +9 -0
- package/dist/widget/components/ErrorDisplay.d.ts.map +1 -0
- package/dist/widget/components/FundSendForm.d.ts +2 -2
- package/dist/widget/components/FundSendForm.d.ts.map +1 -1
- package/dist/widget/components/OriginTransferInformation.d.ts +10 -0
- package/dist/widget/components/OriginTransferInformation.d.ts.map +1 -0
- package/dist/widget/components/PaySendForm.d.ts +2 -2
- package/dist/widget/components/PaySendForm.d.ts.map +1 -1
- package/dist/widget/components/QrCode.d.ts +1 -1
- package/dist/widget/components/QrCode.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receipt.d.ts.map +1 -1
- package/dist/widget/components/Receive.d.ts +12 -0
- package/dist/widget/components/Receive.d.ts.map +1 -0
- package/dist/widget/components/RefundAddressInput.d.ts +13 -0
- package/dist/widget/components/RefundAddressInput.d.ts.map +1 -0
- package/dist/widget/components/Swap.d.ts +47 -0
- package/dist/widget/components/Swap.d.ts.map +1 -0
- package/dist/widget/components/SwapDisplay.d.ts +9 -0
- package/dist/widget/components/SwapDisplay.d.ts.map +1 -0
- package/dist/widget/components/TokenList.d.ts +0 -2
- package/dist/widget/components/TokenList.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts +26 -0
- package/dist/widget/components/TokenSelector.d.ts.map +1 -0
- package/dist/widget/components/TransferPendingVertical.d.ts +2 -0
- package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
- package/dist/widget/components/WalletConnect.d.ts.map +1 -1
- package/dist/widget/components/WalletConnectionPending.d.ts +12 -0
- package/dist/widget/components/WalletConnectionPending.d.ts.map +1 -0
- package/dist/widget/components/WalletList.d.ts.map +1 -1
- package/dist/widget/components/YellowWarningAnimation.d.ts +2 -0
- package/dist/widget/components/YellowWarningAnimation.d.ts.map +1 -0
- package/dist/widget/hooks/useAmountUsd.d.ts +1 -3
- package/dist/widget/hooks/useAmountUsd.d.ts.map +1 -1
- package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
- package/dist/widget/hooks/useDebugScreens.d.ts +22 -0
- package/dist/widget/hooks/useDebugScreens.d.ts.map +1 -0
- package/dist/widget/hooks/useSendForm.d.ts +12 -6
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts +2 -3
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/index.js +1 -1
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +19 -15
- package/src/aave.ts +13 -13
- package/src/address.ts +3 -0
- package/src/analytics.ts +192 -8
- package/src/apiClient.ts +1 -1
- package/src/cctpqueue.ts +1 -1
- package/src/chains.ts +45 -7
- package/src/constants.ts +7 -4
- package/src/decoders.ts +310 -0
- package/src/ens.ts +32 -0
- package/src/error.ts +101 -1
- package/src/intents.ts +10 -2
- package/src/lifi.ts +58 -0
- package/src/metaTxns.ts +1 -1
- package/src/mode.ts +1 -1
- package/src/morpho.ts +3 -3
- package/src/pools.ts +18 -18
- package/src/preconditions.ts +1 -1
- package/src/prepareSend.ts +463 -113
- package/src/prices.ts +26 -1
- package/src/proxyCaller.ts +2 -14
- package/src/relaySdk.ts +1 -0
- package/src/relayer.ts +8 -0
- package/src/tokenBalances.ts +24 -17
- package/src/tokens.ts +147 -22
- package/src/trails.ts +4 -4
- package/src/transactions.ts +35 -17
- package/src/utils.ts +28 -0
- package/src/wallets.ts +275 -35
- package/src/widget/compiled.css +2 -2
- package/src/widget/components/ChainFilterDropdown.tsx +42 -33
- package/src/widget/components/ChainImage.tsx +1 -1
- package/src/widget/components/ConnectWallet.tsx +92 -128
- package/src/widget/components/DebugScreensDropdown.tsx +6 -0
- package/src/widget/components/ErrorDisplay.tsx +150 -0
- package/src/widget/components/FundSendForm.tsx +78 -11
- package/src/widget/components/OriginTransferInformation.tsx +59 -0
- package/src/widget/components/PaySendForm.tsx +80 -13
- package/src/widget/components/QRCodeDeposit.tsx +6 -6
- package/src/widget/components/QrCode.tsx +278 -17
- package/src/widget/components/QuoteDetails.tsx +93 -25
- package/src/widget/components/Receipt.tsx +296 -103
- package/src/widget/components/Receive.tsx +146 -0
- package/src/widget/components/RecentTokens.tsx +1 -1
- package/src/widget/components/RefundAddressInput.tsx +149 -0
- package/src/widget/components/Swap.tsx +769 -0
- package/src/widget/components/SwapDisplay.tsx +68 -0
- package/src/widget/components/TokenList.tsx +27 -363
- package/src/widget/components/TokenSelector.tsx +405 -0
- package/src/widget/components/TransferPendingVertical.tsx +162 -112
- package/src/widget/components/WalletConnect.tsx +9 -7
- package/src/widget/components/WalletConnectionPending.tsx +157 -0
- package/src/widget/components/WalletList.tsx +6 -5
- package/src/widget/components/YellowWarningAnimation.tsx +146 -0
- package/src/widget/hooks/useAmountUsd.ts +3 -8
- package/src/widget/hooks/useCheckout.ts +3 -2
- package/src/widget/hooks/useDebugScreens.ts +583 -0
- package/src/widget/hooks/useSendForm.ts +111 -35
- package/src/widget/hooks/useTokenList.ts +155 -122
- package/src/widget/widget.tsx +503 -523
package/src/analytics.ts
CHANGED
|
@@ -4,6 +4,60 @@ import { DATABEAT_KEY, DATABEAT_SERVER } from "./constants.js"
|
|
|
4
4
|
import { getQueryParam } from "./queryParams.js"
|
|
5
5
|
import { getSequenceProjectAccessKey } from "./config.js"
|
|
6
6
|
|
|
7
|
+
let checkoutIdSingleton: string | null = null
|
|
8
|
+
|
|
9
|
+
export function hasCheckoutId() {
|
|
10
|
+
return checkoutIdSingleton !== null
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function resetCheckoutId() {
|
|
14
|
+
checkoutIdSingleton = null
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
localStorage.removeItem("checkoutId")
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.error("Error removing checkout id:", error)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function getCheckoutId(newCheckoutId: boolean = false) {
|
|
24
|
+
if (newCheckoutId) {
|
|
25
|
+
generateCheckoutIdAndSet()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (checkoutIdSingleton) {
|
|
29
|
+
return checkoutIdSingleton
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
checkoutIdSingleton = localStorage.getItem("checkoutId")
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error("Error getting checkout id:", error)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return checkoutIdSingleton
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function generateCheckoutIdAndSet() {
|
|
42
|
+
resetCheckoutId()
|
|
43
|
+
|
|
44
|
+
checkoutIdSingleton = generateCheckoutId()
|
|
45
|
+
try {
|
|
46
|
+
localStorage.setItem("checkoutId", checkoutIdSingleton)
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error("Error setting checkout id:", error)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function generateCheckoutId() {
|
|
53
|
+
try {
|
|
54
|
+
return crypto.randomUUID()
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error("Error generating checkout id:", error)
|
|
57
|
+
return Date.now().toString()
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
7
61
|
// Pseudonymize sensitive data like transaction hashes and addresses
|
|
8
62
|
export function pseudonymize(value: string): string {
|
|
9
63
|
if (!value) return value
|
|
@@ -131,6 +185,7 @@ abstract class BaseAnalytics {
|
|
|
131
185
|
event: EventType.WIDGET_SCREEN,
|
|
132
186
|
props: {
|
|
133
187
|
...this.getCommonProps(),
|
|
188
|
+
checkoutId: getCheckoutId(),
|
|
134
189
|
...data,
|
|
135
190
|
...(data.userAddress && {
|
|
136
191
|
userAddress: pseudonymize(data.userAddress),
|
|
@@ -147,12 +202,17 @@ abstract class BaseAnalytics {
|
|
|
147
202
|
originTokenAddress?: string
|
|
148
203
|
destinationTokenAddress?: string
|
|
149
204
|
destinationTokenAmount?: string
|
|
205
|
+
mode?: string
|
|
206
|
+
fundMethod?: string
|
|
150
207
|
[key: string]: any
|
|
151
208
|
}) {
|
|
209
|
+
resetCheckoutId()
|
|
210
|
+
|
|
152
211
|
this.track({
|
|
153
212
|
event: EventType.PAYMENT_STARTED,
|
|
154
213
|
props: {
|
|
155
214
|
...this.getCommonProps(),
|
|
215
|
+
checkoutId: getCheckoutId(true),
|
|
156
216
|
...data,
|
|
157
217
|
...(data.userAddress && {
|
|
158
218
|
userAddress: pseudonymize(data.userAddress),
|
|
@@ -170,12 +230,15 @@ abstract class BaseAnalytics {
|
|
|
170
230
|
trackPaymentCompleted(data: {
|
|
171
231
|
userAddress?: string
|
|
172
232
|
intentAddress?: string
|
|
233
|
+
mode?: string
|
|
234
|
+
fundMethod?: string
|
|
173
235
|
[key: string]: any
|
|
174
236
|
}) {
|
|
175
237
|
this.track({
|
|
176
238
|
event: EventType.PAYMENT_COMPLETED,
|
|
177
239
|
props: {
|
|
178
240
|
...this.getCommonProps(),
|
|
241
|
+
checkoutId: getCheckoutId(),
|
|
179
242
|
...data,
|
|
180
243
|
originChainId: data.originChainId?.toString(),
|
|
181
244
|
destinationChainId: data.destinationChainId?.toString(),
|
|
@@ -187,18 +250,22 @@ abstract class BaseAnalytics {
|
|
|
187
250
|
}),
|
|
188
251
|
},
|
|
189
252
|
})
|
|
253
|
+
resetCheckoutId()
|
|
190
254
|
}
|
|
191
255
|
|
|
192
256
|
trackPaymentError(data: {
|
|
193
257
|
error: string
|
|
194
258
|
userAddress?: string
|
|
195
259
|
intentAddress?: string
|
|
260
|
+
mode?: string
|
|
261
|
+
fundMethod?: string
|
|
196
262
|
[key: string]: any
|
|
197
263
|
}) {
|
|
198
264
|
this.track({
|
|
199
265
|
event: EventType.PAYMENT_ERROR,
|
|
200
266
|
props: {
|
|
201
267
|
...this.getCommonProps(),
|
|
268
|
+
checkoutId: getCheckoutId(),
|
|
202
269
|
...data,
|
|
203
270
|
...(data.userAddress && {
|
|
204
271
|
userAddress: pseudonymize(data.userAddress),
|
|
@@ -245,12 +312,17 @@ abstract class BaseAnalytics {
|
|
|
245
312
|
originTokenAddress?: string
|
|
246
313
|
destinationTokenAddress?: string
|
|
247
314
|
userAddress?: string
|
|
315
|
+
mode?: string
|
|
316
|
+
fundMethod?: string
|
|
317
|
+
originTokenSymbol?: string
|
|
318
|
+
destinationTokenSymbol?: string
|
|
248
319
|
[key: string]: any
|
|
249
320
|
}) {
|
|
250
321
|
this.track({
|
|
251
322
|
event: EventType.INTENT_QUOTE_REQUESTED,
|
|
252
323
|
props: {
|
|
253
324
|
...this.getCommonProps(),
|
|
325
|
+
checkoutId: getCheckoutId(),
|
|
254
326
|
originChainId: data.originChainId?.toString(),
|
|
255
327
|
destinationChainId: data.destinationChainId?.toString(),
|
|
256
328
|
originTokenAddress: data.originTokenAddress,
|
|
@@ -258,6 +330,8 @@ abstract class BaseAnalytics {
|
|
|
258
330
|
...(data.userAddress && {
|
|
259
331
|
userAddress: pseudonymize(data.userAddress),
|
|
260
332
|
}),
|
|
333
|
+
originTokenSymbol: data.originTokenSymbol,
|
|
334
|
+
destinationTokenSymbol: data.destinationTokenSymbol,
|
|
261
335
|
},
|
|
262
336
|
})
|
|
263
337
|
}
|
|
@@ -277,6 +351,11 @@ abstract class BaseAnalytics {
|
|
|
277
351
|
feeToken?: string
|
|
278
352
|
userAddress?: string
|
|
279
353
|
intentAddress?: string
|
|
354
|
+
mode?: string
|
|
355
|
+
fundMethod?: string
|
|
356
|
+
feeTokenSymbol?: string
|
|
357
|
+
originTokenSymbol?: string
|
|
358
|
+
destinationTokenSymbol?: string
|
|
280
359
|
[key: string]: any
|
|
281
360
|
}) {
|
|
282
361
|
this.track({
|
|
@@ -284,6 +363,7 @@ abstract class BaseAnalytics {
|
|
|
284
363
|
props: {
|
|
285
364
|
...this.getCommonProps(),
|
|
286
365
|
quoteId: pseudonymize(data.quoteId),
|
|
366
|
+
checkoutId: getCheckoutId(),
|
|
287
367
|
totalFeeUSD: data.totalFeeUSD?.toString(),
|
|
288
368
|
trailsFixedFeeUSD: data.trailsFixedFeeUSD?.toString(),
|
|
289
369
|
crossChainFeeTotalUSD: data.crossChainFeeTotalUSD?.toString(),
|
|
@@ -303,6 +383,9 @@ abstract class BaseAnalytics {
|
|
|
303
383
|
...(data.intentAddress && {
|
|
304
384
|
intentAddress: pseudonymize(data.intentAddress),
|
|
305
385
|
}),
|
|
386
|
+
feeTokenSymbol: data.feeTokenSymbol,
|
|
387
|
+
originTokenSymbol: data.originTokenSymbol,
|
|
388
|
+
destinationTokenSymbol: data.destinationTokenSymbol,
|
|
306
389
|
},
|
|
307
390
|
})
|
|
308
391
|
}
|
|
@@ -314,18 +397,25 @@ abstract class BaseAnalytics {
|
|
|
314
397
|
destinationChainId?: number
|
|
315
398
|
originTokenAddress?: string
|
|
316
399
|
destinationTokenAddress?: string
|
|
400
|
+
mode?: string
|
|
401
|
+
fundMethod?: string
|
|
402
|
+
originTokenSymbol?: string
|
|
403
|
+
destinationTokenSymbol?: string
|
|
317
404
|
[key: string]: any
|
|
318
405
|
}) {
|
|
319
406
|
this.track({
|
|
320
407
|
event: EventType.INTENT_QUOTE_ERROR,
|
|
321
408
|
props: {
|
|
322
409
|
...this.getCommonProps(),
|
|
410
|
+
checkoutId: getCheckoutId(),
|
|
323
411
|
...data,
|
|
324
412
|
...(data.userAddress && {
|
|
325
413
|
userAddress: pseudonymize(data.userAddress),
|
|
326
414
|
}),
|
|
327
415
|
originChainId: data.originChainId?.toString(),
|
|
328
416
|
destinationChainId: data.destinationChainId?.toString(),
|
|
417
|
+
originTokenSymbol: data.originTokenSymbol,
|
|
418
|
+
destinationTokenSymbol: data.destinationTokenSymbol,
|
|
329
419
|
},
|
|
330
420
|
})
|
|
331
421
|
}
|
|
@@ -333,12 +423,15 @@ abstract class BaseAnalytics {
|
|
|
333
423
|
trackIntentCommitStarted(data: {
|
|
334
424
|
intentAddress: string
|
|
335
425
|
userAddress?: string
|
|
426
|
+
originTokenSymbol?: string
|
|
427
|
+
destinationTokenSymbol?: string
|
|
336
428
|
[key: string]: any
|
|
337
429
|
}) {
|
|
338
430
|
this.track({
|
|
339
431
|
event: EventType.INTENT_COMMIT_STARTED,
|
|
340
432
|
props: {
|
|
341
433
|
...this.getCommonProps(),
|
|
434
|
+
checkoutId: getCheckoutId(),
|
|
342
435
|
...data,
|
|
343
436
|
originChainId: data.originChainId?.toString(),
|
|
344
437
|
destinationChainId: data.destinationChainId?.toString(),
|
|
@@ -346,6 +439,8 @@ abstract class BaseAnalytics {
|
|
|
346
439
|
...(data.userAddress && {
|
|
347
440
|
userAddress: pseudonymize(data.userAddress),
|
|
348
441
|
}),
|
|
442
|
+
originTokenSymbol: data.originTokenSymbol,
|
|
443
|
+
destinationTokenSymbol: data.destinationTokenSymbol,
|
|
349
444
|
},
|
|
350
445
|
})
|
|
351
446
|
}
|
|
@@ -353,12 +448,15 @@ abstract class BaseAnalytics {
|
|
|
353
448
|
trackIntentCommitCompleted(data: {
|
|
354
449
|
intentAddress: string
|
|
355
450
|
userAddress?: string
|
|
451
|
+
originTokenSymbol?: string
|
|
452
|
+
destinationTokenSymbol?: string
|
|
356
453
|
[key: string]: any
|
|
357
454
|
}) {
|
|
358
455
|
this.track({
|
|
359
456
|
event: EventType.INTENT_COMMIT_COMPLETED,
|
|
360
457
|
props: {
|
|
361
458
|
...this.getCommonProps(),
|
|
459
|
+
checkoutId: getCheckoutId(),
|
|
362
460
|
...data,
|
|
363
461
|
originChainId: data.originChainId?.toString(),
|
|
364
462
|
destinationChainId: data.destinationChainId?.toString(),
|
|
@@ -366,6 +464,8 @@ abstract class BaseAnalytics {
|
|
|
366
464
|
...(data.userAddress && {
|
|
367
465
|
userAddress: pseudonymize(data.userAddress),
|
|
368
466
|
}),
|
|
467
|
+
originTokenSymbol: data.originTokenSymbol,
|
|
468
|
+
destinationTokenSymbol: data.destinationTokenSymbol,
|
|
369
469
|
},
|
|
370
470
|
})
|
|
371
471
|
}
|
|
@@ -376,12 +476,17 @@ abstract class BaseAnalytics {
|
|
|
376
476
|
intentAddress?: string
|
|
377
477
|
originChainId?: number
|
|
378
478
|
destinationChainId?: number
|
|
479
|
+
mode?: string
|
|
480
|
+
fundMethod?: string
|
|
481
|
+
originTokenSymbol?: string
|
|
482
|
+
destinationTokenSymbol?: string
|
|
379
483
|
[key: string]: any
|
|
380
484
|
}) {
|
|
381
485
|
this.track({
|
|
382
486
|
event: EventType.INTENT_COMMIT_ERROR,
|
|
383
487
|
props: {
|
|
384
488
|
...this.getCommonProps(),
|
|
489
|
+
checkoutId: getCheckoutId(),
|
|
385
490
|
...data,
|
|
386
491
|
...(data.userAddress && {
|
|
387
492
|
userAddress: pseudonymize(data.userAddress),
|
|
@@ -391,6 +496,8 @@ abstract class BaseAnalytics {
|
|
|
391
496
|
}),
|
|
392
497
|
originChainId: data.originChainId?.toString(),
|
|
393
498
|
destinationChainId: data.destinationChainId?.toString(),
|
|
499
|
+
originTokenSymbol: data.originTokenSymbol,
|
|
500
|
+
destinationTokenSymbol: data.destinationTokenSymbol,
|
|
394
501
|
},
|
|
395
502
|
})
|
|
396
503
|
}
|
|
@@ -401,12 +508,15 @@ abstract class BaseAnalytics {
|
|
|
401
508
|
chainId: number
|
|
402
509
|
userAddress?: string
|
|
403
510
|
intentAddress?: string
|
|
511
|
+
mode?: string
|
|
512
|
+
fundMethod?: string
|
|
404
513
|
[key: string]: any
|
|
405
514
|
}) {
|
|
406
515
|
this.track({
|
|
407
516
|
event: EventType.TRANSACTION_STARTED,
|
|
408
517
|
props: {
|
|
409
518
|
...this.getCommonProps(),
|
|
519
|
+
checkoutId: getCheckoutId(),
|
|
410
520
|
...data,
|
|
411
521
|
...(data.userAddress && {
|
|
412
522
|
userAddress: pseudonymize(data.userAddress),
|
|
@@ -423,14 +533,16 @@ abstract class BaseAnalytics {
|
|
|
423
533
|
transactionHash: string
|
|
424
534
|
userAddress?: string
|
|
425
535
|
intentAddress?: string
|
|
536
|
+
mode?: string
|
|
537
|
+
fundMethod?: string
|
|
426
538
|
[key: string]: any
|
|
427
539
|
}) {
|
|
428
540
|
this.track({
|
|
429
541
|
event: EventType.TRANSACTION_SIGNED,
|
|
430
542
|
props: {
|
|
431
543
|
...this.getCommonProps(),
|
|
544
|
+
checkoutId: getCheckoutId(),
|
|
432
545
|
...data,
|
|
433
|
-
transactionHash: pseudonymize(data.transactionHash),
|
|
434
546
|
...(data.userAddress && {
|
|
435
547
|
userAddress: pseudonymize(data.userAddress),
|
|
436
548
|
}),
|
|
@@ -446,12 +558,15 @@ abstract class BaseAnalytics {
|
|
|
446
558
|
chainId: number
|
|
447
559
|
userAddress?: string
|
|
448
560
|
intentAddress?: string
|
|
561
|
+
mode?: string
|
|
562
|
+
fundMethod?: string
|
|
449
563
|
[key: string]: any
|
|
450
564
|
}) {
|
|
451
565
|
this.track({
|
|
452
566
|
event: EventType.TRANSACTION_SUBMITTED,
|
|
453
567
|
props: {
|
|
454
568
|
...this.getCommonProps(),
|
|
569
|
+
checkoutId: getCheckoutId(),
|
|
455
570
|
...data,
|
|
456
571
|
transactionHash: pseudonymize(data.transactionHash),
|
|
457
572
|
...(data.userAddress && {
|
|
@@ -470,12 +585,15 @@ abstract class BaseAnalytics {
|
|
|
470
585
|
blockNumber?: number
|
|
471
586
|
userAddress?: string
|
|
472
587
|
intentAddress?: string
|
|
588
|
+
mode?: string
|
|
589
|
+
fundMethod?: string
|
|
473
590
|
[key: string]: any
|
|
474
591
|
}) {
|
|
475
592
|
this.track({
|
|
476
593
|
event: EventType.TRANSACTION_CONFIRMED,
|
|
477
594
|
props: {
|
|
478
595
|
...this.getCommonProps(),
|
|
596
|
+
checkoutId: getCheckoutId(),
|
|
479
597
|
...data,
|
|
480
598
|
chainId: data.chainId?.toString(),
|
|
481
599
|
transactionHash: pseudonymize(data.transactionHash),
|
|
@@ -495,14 +613,16 @@ abstract class BaseAnalytics {
|
|
|
495
613
|
error: string
|
|
496
614
|
userAddress?: string
|
|
497
615
|
intentAddress?: string
|
|
616
|
+
mode?: string
|
|
617
|
+
fundMethod?: string
|
|
498
618
|
[key: string]: any
|
|
499
619
|
}) {
|
|
500
620
|
this.track({
|
|
501
621
|
event: EventType.TRANSACTION_ERROR,
|
|
502
622
|
props: {
|
|
503
623
|
...this.getCommonProps(),
|
|
624
|
+
checkoutId: getCheckoutId(),
|
|
504
625
|
...data,
|
|
505
|
-
transactionHash: pseudonymize(data.transactionHash),
|
|
506
626
|
...(data.userAddress && {
|
|
507
627
|
userAddress: pseudonymize(data.userAddress),
|
|
508
628
|
}),
|
|
@@ -518,12 +638,15 @@ abstract class BaseAnalytics {
|
|
|
518
638
|
walletAddress?: string
|
|
519
639
|
contractAddress?: string
|
|
520
640
|
chainId?: number
|
|
641
|
+
mode?: string
|
|
642
|
+
fundMethod?: string
|
|
521
643
|
[key: string]: any
|
|
522
644
|
}) {
|
|
523
645
|
this.track({
|
|
524
646
|
event: EventType.RELAYER_CALL_STARTED,
|
|
525
647
|
props: {
|
|
526
648
|
...this.getCommonProps(),
|
|
649
|
+
checkoutId: getCheckoutId(),
|
|
527
650
|
...data,
|
|
528
651
|
...(data.walletAddress && {
|
|
529
652
|
walletAddress: pseudonymize(data.walletAddress),
|
|
@@ -540,12 +663,15 @@ abstract class BaseAnalytics {
|
|
|
540
663
|
walletAddress?: string
|
|
541
664
|
contractAddress?: string
|
|
542
665
|
chainId?: number
|
|
666
|
+
mode?: string
|
|
667
|
+
fundMethod?: string
|
|
543
668
|
[key: string]: any
|
|
544
669
|
}) {
|
|
545
670
|
this.track({
|
|
546
671
|
event: EventType.RELAYER_CALL_COMPLETED,
|
|
547
672
|
props: {
|
|
548
673
|
...this.getCommonProps(),
|
|
674
|
+
checkoutId: getCheckoutId(),
|
|
549
675
|
...data,
|
|
550
676
|
...(data.walletAddress && {
|
|
551
677
|
walletAddress: pseudonymize(data.walletAddress),
|
|
@@ -563,12 +689,15 @@ abstract class BaseAnalytics {
|
|
|
563
689
|
walletAddress?: string
|
|
564
690
|
contractAddress?: string
|
|
565
691
|
chainId?: number
|
|
692
|
+
mode?: string
|
|
693
|
+
fundMethod?: string
|
|
566
694
|
[key: string]: any
|
|
567
695
|
}) {
|
|
568
696
|
this.track({
|
|
569
697
|
event: EventType.RELAYER_CALL_ERROR,
|
|
570
698
|
props: {
|
|
571
699
|
...this.getCommonProps(),
|
|
700
|
+
checkoutId: getCheckoutId(),
|
|
572
701
|
...data,
|
|
573
702
|
...(data.walletAddress && {
|
|
574
703
|
walletAddress: pseudonymize(data.walletAddress),
|
|
@@ -623,6 +752,10 @@ class Analytics extends BaseAnalytics {
|
|
|
623
752
|
console.log("[trails-sdk] Analytics track:", event)
|
|
624
753
|
}
|
|
625
754
|
}
|
|
755
|
+
|
|
756
|
+
getSessionId() {
|
|
757
|
+
return this.databeat.getSessionId()
|
|
758
|
+
}
|
|
626
759
|
}
|
|
627
760
|
|
|
628
761
|
class MockAnalytics extends BaseAnalytics {
|
|
@@ -633,8 +766,7 @@ class MockAnalytics extends BaseAnalytics {
|
|
|
633
766
|
this.loggingEnabled = loggingEnabled
|
|
634
767
|
}
|
|
635
768
|
|
|
636
|
-
identifyUser(
|
|
637
|
-
console.log("[trails-sdk] MockAnalytics identifyUser:", address)
|
|
769
|
+
identifyUser(_data: { address: string }) {
|
|
638
770
|
return this
|
|
639
771
|
}
|
|
640
772
|
|
|
@@ -664,27 +796,40 @@ class MockAnalytics extends BaseAnalytics {
|
|
|
664
796
|
console.log("[trails-sdk] MockAnalytics track:", event)
|
|
665
797
|
}
|
|
666
798
|
}
|
|
799
|
+
|
|
800
|
+
getSessionId() {
|
|
801
|
+
return `0x${Math.random().toString(16).slice(2, 10)}`
|
|
802
|
+
}
|
|
667
803
|
}
|
|
668
804
|
|
|
669
|
-
let singleton: Analytics | null = null
|
|
805
|
+
let singleton: Analytics | MockAnalytics | null = null
|
|
670
806
|
|
|
671
807
|
export const getAnalytics = () => {
|
|
672
|
-
|
|
808
|
+
if (singleton) {
|
|
809
|
+
return singleton
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
const debugLocalMode = getQueryParam("analyticsDebugLocal") === "true"
|
|
813
|
+
const debugProdMode = getQueryParam("analyticsDebugProd") === "true"
|
|
673
814
|
let isLocalhost = true
|
|
674
815
|
if (typeof window !== "undefined") {
|
|
675
816
|
isLocalhost =
|
|
676
817
|
window.location.hostname === "localhost" ||
|
|
677
818
|
window.location.hostname === "127.0.0.1"
|
|
678
819
|
}
|
|
679
|
-
const enableMockAnalytics =
|
|
820
|
+
const enableMockAnalytics =
|
|
821
|
+
(!DATABEAT_KEY || debugLocalMode || isLocalhost) && !debugProdMode
|
|
680
822
|
if (enableMockAnalytics) {
|
|
681
|
-
|
|
823
|
+
singleton = new MockAnalytics({ loggingEnabled: true }) // return a dummy analytics object
|
|
682
824
|
}
|
|
683
825
|
if (!singleton) {
|
|
684
826
|
singleton = new Analytics(DATABEAT_SERVER, {
|
|
685
827
|
jwt: DATABEAT_KEY,
|
|
686
828
|
})
|
|
687
829
|
}
|
|
830
|
+
|
|
831
|
+
console.log("[trails-sdk] Analytics sessionId:", singleton.getSessionId())
|
|
832
|
+
|
|
688
833
|
return singleton
|
|
689
834
|
}
|
|
690
835
|
|
|
@@ -723,6 +868,8 @@ export const trackPaymentStarted = (data: {
|
|
|
723
868
|
originTokenAddress?: string
|
|
724
869
|
destinationTokenAddress?: string
|
|
725
870
|
destinationTokenAmount?: string
|
|
871
|
+
mode?: string
|
|
872
|
+
fundMethod?: string
|
|
726
873
|
[key: string]: any
|
|
727
874
|
}) => {
|
|
728
875
|
const analytics = getAnalytics()
|
|
@@ -732,6 +879,8 @@ export const trackPaymentStarted = (data: {
|
|
|
732
879
|
export const trackPaymentCompleted = (data: {
|
|
733
880
|
userAddress?: string
|
|
734
881
|
intentAddress?: string
|
|
882
|
+
mode?: string
|
|
883
|
+
fundMethod?: string
|
|
735
884
|
[key: string]: any
|
|
736
885
|
}) => {
|
|
737
886
|
const analytics = getAnalytics()
|
|
@@ -742,6 +891,8 @@ export const trackPaymentError = (data: {
|
|
|
742
891
|
error: string
|
|
743
892
|
userAddress?: string
|
|
744
893
|
intentAddress?: string
|
|
894
|
+
mode?: string
|
|
895
|
+
fundMethod?: string
|
|
745
896
|
[key: string]: any
|
|
746
897
|
}) => {
|
|
747
898
|
const analytics = getAnalytics()
|
|
@@ -772,6 +923,8 @@ export const trackIntentQuoteRequested = (data: {
|
|
|
772
923
|
destinationChainId: number
|
|
773
924
|
tokenAddress?: string
|
|
774
925
|
userAddress?: string
|
|
926
|
+
mode?: string
|
|
927
|
+
fundMethod?: string
|
|
775
928
|
[key: string]: any
|
|
776
929
|
}) => {
|
|
777
930
|
const analytics = getAnalytics()
|
|
@@ -793,6 +946,8 @@ export const trackIntentQuoteReceived = (data: {
|
|
|
793
946
|
feeToken?: string
|
|
794
947
|
userAddress?: string
|
|
795
948
|
intentAddress?: string
|
|
949
|
+
mode?: string
|
|
950
|
+
fundMethod?: string
|
|
796
951
|
[key: string]: any
|
|
797
952
|
}) => {
|
|
798
953
|
const analytics = getAnalytics()
|
|
@@ -806,6 +961,8 @@ export const trackIntentQuoteError = (data: {
|
|
|
806
961
|
destinationChainId?: number
|
|
807
962
|
originTokenAddress?: string
|
|
808
963
|
destinationTokenAddress?: string
|
|
964
|
+
mode?: string
|
|
965
|
+
fundMethod?: string
|
|
809
966
|
[key: string]: any
|
|
810
967
|
}) => {
|
|
811
968
|
const analytics = getAnalytics()
|
|
@@ -817,6 +974,8 @@ export const trackIntentCommitStarted = (data: {
|
|
|
817
974
|
userAddress?: string
|
|
818
975
|
originChainId?: number
|
|
819
976
|
destinationChainId?: number
|
|
977
|
+
mode?: string
|
|
978
|
+
fundMethod?: string
|
|
820
979
|
[key: string]: any
|
|
821
980
|
}) => {
|
|
822
981
|
const analytics = getAnalytics()
|
|
@@ -828,6 +987,8 @@ export const trackIntentCommitCompleted = (data: {
|
|
|
828
987
|
userAddress?: string
|
|
829
988
|
originChainId?: number
|
|
830
989
|
destinationChainId?: number
|
|
990
|
+
mode?: string
|
|
991
|
+
fundMethod?: string
|
|
831
992
|
[key: string]: any
|
|
832
993
|
}) => {
|
|
833
994
|
const analytics = getAnalytics()
|
|
@@ -840,6 +1001,8 @@ export const trackIntentCommitError = (data: {
|
|
|
840
1001
|
intentAddress?: string
|
|
841
1002
|
originChainId?: number
|
|
842
1003
|
destinationChainId?: number
|
|
1004
|
+
mode?: string
|
|
1005
|
+
fundMethod?: string
|
|
843
1006
|
[key: string]: any
|
|
844
1007
|
}) => {
|
|
845
1008
|
const analytics = getAnalytics()
|
|
@@ -852,6 +1015,8 @@ export const trackTransactionStarted = (data: {
|
|
|
852
1015
|
chainId: number
|
|
853
1016
|
userAddress?: string
|
|
854
1017
|
intentAddress?: string
|
|
1018
|
+
mode?: string
|
|
1019
|
+
fundMethod?: string
|
|
855
1020
|
[key: string]: any
|
|
856
1021
|
}) => {
|
|
857
1022
|
const analytics = getAnalytics()
|
|
@@ -862,6 +1027,8 @@ export const trackTransactionSigned = (data: {
|
|
|
862
1027
|
transactionHash: string
|
|
863
1028
|
userAddress?: string
|
|
864
1029
|
intentAddress?: string
|
|
1030
|
+
mode?: string
|
|
1031
|
+
fundMethod?: string
|
|
865
1032
|
[key: string]: any
|
|
866
1033
|
}) => {
|
|
867
1034
|
const analytics = getAnalytics()
|
|
@@ -873,6 +1040,8 @@ export const trackTransactionSubmitted = (data: {
|
|
|
873
1040
|
chainId: number
|
|
874
1041
|
userAddress?: string
|
|
875
1042
|
intentAddress?: string
|
|
1043
|
+
mode?: string
|
|
1044
|
+
fundMethod?: string
|
|
876
1045
|
[key: string]: any
|
|
877
1046
|
}) => {
|
|
878
1047
|
const analytics = getAnalytics()
|
|
@@ -884,6 +1053,8 @@ export const trackTransactionConfirmed = (data: {
|
|
|
884
1053
|
blockNumber?: number
|
|
885
1054
|
userAddress?: string
|
|
886
1055
|
intentAddress?: string
|
|
1056
|
+
mode?: string
|
|
1057
|
+
fundMethod?: string
|
|
887
1058
|
[key: string]: any
|
|
888
1059
|
}) => {
|
|
889
1060
|
const analytics = getAnalytics()
|
|
@@ -895,6 +1066,8 @@ export const trackTransactionError = (data: {
|
|
|
895
1066
|
error: string
|
|
896
1067
|
userAddress?: string
|
|
897
1068
|
intentAddress?: string
|
|
1069
|
+
mode?: string
|
|
1070
|
+
fundMethod?: string
|
|
898
1071
|
[key: string]: any
|
|
899
1072
|
}) => {
|
|
900
1073
|
const analytics = getAnalytics()
|
|
@@ -906,6 +1079,8 @@ export const trackRelayerCallStarted = (data: {
|
|
|
906
1079
|
walletAddress?: string
|
|
907
1080
|
contractAddress?: string
|
|
908
1081
|
chainId?: number
|
|
1082
|
+
mode?: string
|
|
1083
|
+
fundMethod?: string
|
|
909
1084
|
[key: string]: any
|
|
910
1085
|
}) => {
|
|
911
1086
|
const analytics = getAnalytics()
|
|
@@ -916,6 +1091,8 @@ export const trackRelayerCallCompleted = (data: {
|
|
|
916
1091
|
walletAddress?: string
|
|
917
1092
|
contractAddress?: string
|
|
918
1093
|
chainId?: number
|
|
1094
|
+
mode?: string
|
|
1095
|
+
fundMethod?: string
|
|
919
1096
|
[key: string]: any
|
|
920
1097
|
}) => {
|
|
921
1098
|
const analytics = getAnalytics()
|
|
@@ -927,8 +1104,15 @@ export const trackRelayerCallError = (data: {
|
|
|
927
1104
|
walletAddress?: string
|
|
928
1105
|
contractAddress?: string
|
|
929
1106
|
chainId?: number
|
|
1107
|
+
mode?: string
|
|
1108
|
+
fundMethod?: string
|
|
930
1109
|
[key: string]: any
|
|
931
1110
|
}) => {
|
|
932
1111
|
const analytics = getAnalytics()
|
|
933
1112
|
analytics.trackRelayerCallError(data)
|
|
934
1113
|
}
|
|
1114
|
+
|
|
1115
|
+
export function getSessionId() {
|
|
1116
|
+
const analytics = getAnalytics()
|
|
1117
|
+
return analytics.getSessionId()
|
|
1118
|
+
}
|
package/src/apiClient.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useConfig } from "@0xsequence/hooks"
|
|
2
|
-
import { SequenceAPIClient } from "@0xsequence/api"
|
|
2
|
+
import { SequenceAPIClient } from "@0xsequence/trails-api"
|
|
3
3
|
import { useMemo } from "react"
|
|
4
4
|
import { getSequenceApiUrl, getSequenceProjectAccessKey } from "./config.js"
|
|
5
5
|
|
package/src/cctpqueue.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getSequenceApiUrl, getSequenceProjectAccessKey } from "./config.js"
|
|
2
|
-
import type { SequenceAPIClient } from "@0xsequence/api"
|
|
2
|
+
import type { SequenceAPIClient } from "@0xsequence/trails-api"
|
|
3
3
|
|
|
4
4
|
// Narrow API client to one that supports queueing CCTP transfers without using 'any'
|
|
5
5
|
type CctpQueueCapable = {
|