Skip to content

Commit

Permalink
some cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
everdimension committed Mar 11, 2024
1 parent 4f096aa commit 5d41241
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 35 deletions.
4 changes: 0 additions & 4 deletions src/background/Wallet/Wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -939,10 +939,6 @@ export class Wallet {
const safeTx = removeSignature(transactionResponse);
emitter.emit('transactionSent', {
transaction: safeTx,
// initiator,
// feeValueCommon,
// addressAction,
// quote,
...transactionContextParams,
});
return safeTx;
Expand Down
14 changes: 3 additions & 11 deletions src/background/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,13 @@ export const emitter = createNanoEvents<{
chainsUpdated: () => void;
chainChanged: (chain: Chain) => void;
transactionSent: (
data: {
transaction: TransactionResponse;
} & TransactionContextParams
data: { transaction: TransactionResponse } & TransactionContextParams
) => void;
typedDataSigned: (
data: {
typedData: TypedData;
address: string;
} & MessageContextParams
data: { typedData: TypedData; address: string } & MessageContextParams
) => void;
messageSigned: (
data: {
message: string;
address: string;
} & MessageContextParams
data: { message: string; address: string } & MessageContextParams
) => void;
userActivity: () => void;
connectToSiteEvent: (info: { origin: string }) => void;
Expand Down
19 changes: 8 additions & 11 deletions src/shared/analytics/analytics.background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ function queryWalletProvider(account: Account, address: string) {
function trackAppEvents({ account }: { account: Account }) {
const getProvider = (address: string) =>
getProviderForMetabase(queryWalletProvider(account, address));
const getUserId = () => account.getUser()?.id;

const createParams: typeof createBaseParams = (params) => {
const getUserId = () => account.getUser()?.id;
return createBaseParams({ ...params, userId: getUserId() });
};
emitter.on('dappConnection', ({ origin, address }) => {
Expand Down Expand Up @@ -105,23 +105,21 @@ function trackAppEvents({ account }: { account: Account }) {
screen_name: origin === initiator ? 'Transaction Request' : pathname,
wallet_address: transaction.from,
wallet_provider: getProvider(transaction.from),
/* @deprecated*/
/* @deprecated */
context: initiatorName,
/* @deprecated*/
/* @deprecated */
type: 'Sign',
clientScope: clientScope ?? initiatorName,
client_scope: clientScope ?? initiatorName,
action_type: addressActionAnalytics?.action_type ?? 'Execute',
dapp_domain: globalThis.location.origin === origin ? null : origin,
dapp_domain: isInternalOrigin ? null : origin,
chain,
gas: transaction.gasLimit.toString(),
hash: transaction.hash,
asset_amount_sent: [], // TODO
gas_price: null, // TODO
network_fee: null, // TODO
network_fee_value: feeValueCommon,
contract_type: quote?.contract_metadata
? quote.contract_metadata.name
: null,
contract_type: quote?.contract_metadata?.name ?? null,
...addressActionAnalytics,
});
sendToMetabase('signed_transaction', params);
Expand Down Expand Up @@ -173,13 +171,12 @@ function trackAppEvents({ account }: { account: Account }) {
type: eventToMethod[type] ?? 'unexpected type',
/* @deprecated */
context: initiatorName,
client_scope: initiatorName,
client_scope: clientScope ?? initiatorName,
action_type: eventToActionType[type] ?? 'unexpected type',
wallet_address: address,
address,
wallet_provider: getProvider(address),

dapp_domain: globalThis.location.origin === origin ? null : origin,
dapp_domain: isInternalOrigin ? null : origin,
});
sendToMetabase('signed_message', params);
const mixpanelParams = omit(params, [
Expand Down
2 changes: 1 addition & 1 deletion src/shared/analytics/mixpanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { invariant } from '../invariant';
import { Loglevel, logTable } from '../logger';
import { getBaseMixpanelParams } from './shared/mixpanel-data-helpers';

// TODO: move to src/env/config.ts
const mixPanelTokenDev = 'a30959c6848ddba6ee5cb8feda61922f';
const mixPanelTokenProd = '1713511ace475d2c78689b3d66558b62';
const mixPanelToken =
Expand Down Expand Up @@ -115,6 +116,5 @@ export async function mixPanelTrack(
) {
const baseParams = await getBaseMixpanelParams(account);
const params = { ...baseParams, ...values };
logTable(Loglevel.info, params);
mixpanelApi.track(event, params);
}
2 changes: 0 additions & 2 deletions src/shared/analytics/shared/mixpanel-data-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ export async function getBaseMixpanelParams(account: Account) {
);
const userId = getUserId();

// // TODO: Filter out "watched" addresses once this feature is introduced
// const ownedAddresses = addresses;
const portfolioStats =
ownedAddresses && ownedAddresses.length
? await getPortfolioStats(ownedAddresses)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export const SignTransactionButton = React.forwardRef(
return walletPort.request('sendSignedTransaction', {
serialized: signedTx,
...params,
// chain: params.chain.toString(),
});
} else {
return await walletPort.request('signAndSendTransaction', [
Expand Down
5 changes: 0 additions & 5 deletions src/ui/pages/SendTransaction/SendTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,6 @@ function TransactionDefaultView({
incomingTxWithGasAndFee || incomingTransaction
);
const feeValueCommon = feeValueCommonRef.current || null;
// NOTE:
// clientScope can also be read from searchParams if we pass it.
// For example, if we redirect to SendTransaction view from our own UI
// TODO: Pass it when completing the "Mint Zerion DNA" flow
// const clientScope = 'External Dapp';
return signerSenderRef.current.sendTransaction({
transaction: tx,
chain: chain.toString(),
Expand Down

0 comments on commit 5d41241

Please sign in to comment.