Skip to content

Commit

Permalink
Merge branch 'main' into feat/add-notifications-actions-selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathansoufer authored Jul 18, 2024
2 parents a4befbe + 96d6399 commit 55032d0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 19 deletions.
38 changes: 21 additions & 17 deletions app/components/UI/AccountApproval/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,26 +108,30 @@ class AccountApproval extends PureComponent {
};

getAnalyticsParams = () => {
const { currentPageInformation, chainId, selectedAddress, accountsLength } =
this.props;
let urlHostName = 'N/A';

try {
const {
currentPageInformation,
chainId,
selectedAddress,
accountsLength,
} = this.props;
const url = new URL(currentPageInformation?.url);
return {
account_type: getAddressAccountType(selectedAddress),
dapp_host_name: url?.host,
chain_id: getDecimalChainId(chainId),
number_of_accounts: accountsLength,
number_of_accounts_connected: 1,
source: 'SDK / WalletConnect',
...currentPageInformation?.analytics,
};
if (currentPageInformation?.url) {
const url = new URL(currentPageInformation.url);
urlHostName = url.host;
}
} catch (error) {
return {};
console.error('URL conversion error:', error);
}

return {
account_type: selectedAddress
? getAddressAccountType(selectedAddress)
: null,
dapp_host_name: urlHostName,
chain_id: chainId ? getDecimalChainId(chainId) : null,
number_of_accounts: accountsLength,
number_of_accounts_connected: 1,
source: 'SDK / WalletConnect',
...currentPageInformation?.analytics,
};
};

componentDidMount = () => {
Expand Down
13 changes: 11 additions & 2 deletions app/components/UI/AccountApproval/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jest.mock('../../../core/Engine', () => ({
state: {
keyrings: [
{
accounts: ['0xC4955C0d639D99699Bfd7Ec54d9FaFEe40e4D272'],
accounts: ['0xC4966c0D659D99699BFD7EB54D8fafEE40e4a756'],
},
],
},
Expand All @@ -30,7 +30,16 @@ const mockInitialState = {
engine: {
backgroundState: {
...backgroundState,
AccountsController: MOCK_ACCOUNTS_CONTROLLER_STATE,
AccountsController: {
...MOCK_ACCOUNTS_CONTROLLER_STATE,
accounts: {
'0xC4966c0D659D99699BFD7EB54D8fafEE40e4a756': {
balance: '0x0',
name: 'Account 1',
address: '0xC4966c0D659D99699BFD7EB54D8fafEE40e4a756',
},
},
},
},
},
};
Expand Down

0 comments on commit 55032d0

Please sign in to comment.