Skip to content

Commit

Permalink
update events
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-schrammel committed Dec 20, 2024
1 parent fbf52f8 commit 657329d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/analytics/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,11 @@ export type EventProperties = {
dappName: string;
dappUrl: string;
};
[event.wcRequestFailed]: { reason: string };
[event.wcRequestFailed]: {
type: 'session_proposal' | 'session_request' | 'read only wallet' | 'method not supported' | 'invalid namespaces' | 'dapp browser';
reason: string;
method?: string;
};

[event.nftOffersOpenedOffersSheet]: {
entryPoint: string;
Expand Down
5 changes: 4 additions & 1 deletion src/screens/NoNeedWCSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ const WalletConnectRedirectSheet = () => {
const { params } = useRoute();

useEffect(() => {
analyticsV2.track(analyticsV2.event.wcRequestFailed, { reason: 'rainbow dapp browser' });
analyticsV2.track(analyticsV2.event.wcRequestFailed, {
type: 'dapp browser',
reason: 'tried to connect with WalletConnect in the dapp browser',
});
}, []);

const handleOnPress = useCallback(() => {
Expand Down
20 changes: 15 additions & 5 deletions src/walletConnect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ export async function onSessionProposal(proposal: WalletKitTypes.SessionProposal
reason: 'INVALID_SESSION_SETTLE_REQUEST',
});

analyticsV2.track(analyticsV2.event.wcRequestFailed, { reason: `invalid namespaces: ${namespaces}` });
analyticsV2.track(analyticsV2.event.wcRequestFailed, { type: `invalid namespaces`, reason: namespaces.error.message });

showErrorSheet({
title: lang.t(T.errors.generic_title),
Expand Down Expand Up @@ -651,7 +651,10 @@ export async function onSessionRequest(event: SignClientTypes.EventArguments['se
message,
});

analyticsV2.track(analyticsV2.event.wcRequestFailed, { reason: 'invalid signing request' });
analyticsV2.track(analyticsV2.event.wcRequestFailed, {
type: 'session_request',
reason: 'session_request exited, signing request had no address and/or messsage',
});

await client.respondSessionRequest({
topic,
Expand Down Expand Up @@ -683,7 +686,10 @@ export async function onSessionRequest(event: SignClientTypes.EventArguments['se

const errorMessageBody = isReadOnly ? lang.t(T.errors.read_only_wallet_on_signing_method) : lang.t(T.errors.generic_error);

analyticsV2.track(analyticsV2.event.wcRequestFailed, { reason: 'read only wallet' });
analyticsV2.track(analyticsV2.event.wcRequestFailed, {
type: 'read only wallet',
reason: 'session_request exited, selectedWallet was falsy or read only',
});

await client.respondSessionRequest({
topic,
Expand All @@ -708,7 +714,7 @@ export async function onSessionRequest(event: SignClientTypes.EventArguments['se
if (!session) {
logger.error(new RainbowError(`[walletConnect]: session_request topic was not found`));

analyticsV2.track(analyticsV2.event.wcRequestFailed, { reason: 'session not found' });
analyticsV2.track(analyticsV2.event.wcRequestFailed, { type: 'session_request', reason: 'session_request topic was not found' });

await client.respondSessionRequest({
topic,
Expand Down Expand Up @@ -775,7 +781,11 @@ export async function onSessionRequest(event: SignClientTypes.EventArguments['se
method,
});

analyticsV2.track(analyticsV2.event.wcRequestFailed, { reason: `method not supported: ${method}` });
analyticsV2.track(analyticsV2.event.wcRequestFailed, {
type: `method not supported`,
reason: 'received unsupported session_request RPC method',
method: method,
});

try {
await client.respondSessionRequest({
Expand Down

0 comments on commit 657329d

Please sign in to comment.