Skip to content

Commit 9cab974

Browse files
committed
feat(sdk): include chainId in all events
1 parent 2579525 commit 9cab974

File tree

9 files changed

+22
-2
lines changed

9 files changed

+22
-2
lines changed

.changeset/slimy-pots-camp.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Adds chain ID to tracked analytics

packages/thirdweb/src/analytics/track/connect.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ export async function trackConnect(args: {
1010
ecosystem?: Ecosystem;
1111
walletType: string;
1212
walletAddress: string;
13+
chainId?: number;
1314
}) {
14-
const { client, ecosystem, walletType, walletAddress } = args;
15+
const { client, ecosystem, walletType, walletAddress, chainId } = args;
1516
return track({
1617
client,
1718
ecosystem,
@@ -20,6 +21,7 @@ export async function trackConnect(args: {
2021
action: "connect",
2122
walletType,
2223
walletAddress,
24+
chainId,
2325
},
2426
});
2527
}

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ export function SwapConfirmationScreen(props: {
279279
fromAmount: props.quote.swapDetails.fromAmountWei,
280280
toToken: props.quote.swapDetails.toToken.tokenAddress,
281281
toAmount: props.quote.swapDetails.toAmountWei,
282-
chainId: props.quote.swapDetails.toToken.chainId,
282+
chainId: props.quote.swapDetails.fromToken.chainId,
283283
dstChainId: props.quote.swapDetails.toToken.chainId,
284284
});
285285

packages/thirdweb/src/react/web/ui/TransactionButton/TransactionModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export function TransactionModal(props: ModalProps) {
4242
client: props.client,
4343
walletAddress: account.address,
4444
walletType: wallet.id,
45+
dstChainId: props.tx.chain.id,
4546
event: "open_pay_transaction_modal",
4647
});
4748
},

packages/thirdweb/src/wallets/coinbase/coinbase-wallet.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export function coinbaseWalletSDK(args: {
8181
client: options.client,
8282
walletType: COINBASE,
8383
walletAddress: account.address,
84+
chainId: chain.id,
8485
});
8586
// return account
8687
return account;
@@ -100,6 +101,7 @@ export function coinbaseWalletSDK(args: {
100101
client: options.client,
101102
walletType: COINBASE,
102103
walletAddress: account.address,
104+
chainId: chain.id,
103105
});
104106
// return account
105107
return account;

packages/thirdweb/src/wallets/create-wallet.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ export function createWallet<const ID extends WalletId>(
250250
client: options.client,
251251
walletType: id,
252252
walletAddress: account.address,
253+
chainId: chain.id,
253254
});
254255
// return account
255256
return account;
@@ -281,6 +282,7 @@ export function createWallet<const ID extends WalletId>(
281282
client: options.client,
282283
walletType: id,
283284
walletAddress: account.address,
285+
chainId: chain.id,
284286
});
285287
// return account
286288
return account;
@@ -314,6 +316,7 @@ export function createWallet<const ID extends WalletId>(
314316
client: wcOptions.client,
315317
walletType: id,
316318
walletAddress: account.address,
319+
chainId: chain.id,
317320
});
318321
return account;
319322
}
@@ -359,6 +362,7 @@ export function createWallet<const ID extends WalletId>(
359362
client: options.client,
360363
walletType: id,
361364
walletAddress: account.address,
365+
chainId: chain.id,
362366
});
363367
// return account
364368
return account;

packages/thirdweb/src/wallets/in-app/core/wallet/in-app-core.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export function createInAppWallet(args: {
106106
ecosystem,
107107
walletType: walletId,
108108
walletAddress: account.address,
109+
chainId: chain.id,
109110
});
110111
// return only the account
111112
return account;
@@ -153,6 +154,7 @@ export function createInAppWallet(args: {
153154
ecosystem,
154155
walletType: walletId,
155156
walletAddress: account.address,
157+
chainId: chain.id,
156158
});
157159
// return only the account
158160
return account;

packages/thirdweb/src/wallets/native/create-wallet.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ export function createWallet<const ID extends WalletId>(
169169
client: options.client,
170170
walletType: id,
171171
walletAddress: account.address,
172+
chainId: chain.id,
172173
});
173174
// return account
174175
return account;
@@ -202,6 +203,7 @@ export function createWallet<const ID extends WalletId>(
202203
client: wcOptions.client,
203204
walletType: id,
204205
walletAddress: account.address,
206+
chainId: chain.id,
205207
});
206208
return account;
207209
}

packages/thirdweb/src/wallets/smart/smart-wallet.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export function smartWallet(
167167
client: options.client,
168168
walletType: "smart",
169169
walletAddress: account.address,
170+
chainId: chain.id,
170171
});
171172
// return account
172173
return account;
@@ -187,6 +188,7 @@ export function smartWallet(
187188
client: options.client,
188189
walletType: "smart",
189190
walletAddress: account.address,
191+
chainId: chain.id,
190192
});
191193
// return account
192194
emitter.emit("accountChanged", account);

0 commit comments

Comments
 (0)