Skip to content

Commit

Permalink
feat(suite-native): redact graph errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vytick committed Dec 13, 2024
1 parent b2c18de commit a784199
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion suite-native/graph/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,31 @@ const useWatchTimeframeChangeForAnalytics = (
}, [timeframeHours, symbol, isFirstRender]);
};

const redactAfterSubstring = (string: string, substring: string) => {
const index = string.indexOf(substring);

if (index !== -1) {
return string.slice(0, index + substring.length) + ' redacted';
}

return string;
};

const redact = (string: string) => {
const redactAfterSubstringArray = [
'Account not found:',
'Unable to fetch fiat rates for defined timestamps. ',
];
let msg = string;
redactAfterSubstringArray.map(substring => {
msg = redactAfterSubstring(msg, substring);
});

return msg;
};

const checkAndReportGraphError = (error: string | null) => {
if (error) captureException(error);
if (error) captureException(redact(error));
};

export const useGraphForSingleAccount = ({
Expand Down

0 comments on commit a784199

Please sign in to comment.