Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes corvus in favor of sentry and analytics client #3891

Merged
merged 6 commits into from Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove personal path on etcher
Change-type: minor
  • Loading branch information
otaviojacobi committed Jan 12, 2023
commit 2b728d3c521b76177a2c019b4891627272f35aac
31 changes: 30 additions & 1 deletion lib/gui/app/modules/analytics.ts
Expand Up @@ -21,6 +21,35 @@ import * as settings from '../models/settings';
import { store } from '../models/store';
import * as packageJSON from '../../../../package.json';

const clearUserPath = (filename: string): string => {
const generatedFile = filename.split('generated').reverse()[0];
return `generated${generatedFile}`;
};

export const anonymizeData = (
event: SentryRenderer.Event,
): SentryRenderer.Event => {
event.exception?.values?.forEach((exception) => {
exception.stacktrace?.frames?.forEach((frame) => {
if (frame.filename) {
frame.filename = clearUserPath(frame.filename);
}
});
});

event.breadcrumbs?.forEach((breadcrumb) => {
if (breadcrumb.data?.url) {
breadcrumb.data.url = clearUserPath(breadcrumb.data.url);
}
});

if (event.request?.url) {
event.request.url = clearUserPath(event.request.url);
}

return event;
};

let analyticsClient: Client;
/**
* @summary Init analytics configurations
Expand All @@ -29,7 +58,7 @@ export const initAnalytics = _.once(() => {
const dsn =
settings.getSync('analyticsSentryToken') ||
_.get(packageJSON, ['analytics', 'sentry', 'token']);
SentryRenderer.init({ dsn });
SentryRenderer.init({ dsn, beforeSend: anonymizeData });

const projectName =
settings.getSync('analyticsAmplitudeToken') ||
Expand Down
3 changes: 2 additions & 1 deletion lib/gui/etcher.ts
Expand Up @@ -32,6 +32,7 @@ import { buildWindowMenu } from './menu';
import * as i18n from 'i18next';
import * as SentryMain from '@sentry/electron/main';
import * as packageJSON from '../../package.json';
import { anonymizeData } from './app/modules/analytics';

const customProtocol = 'etcher';
const scheme = `${customProtocol}://`;
Expand Down Expand Up @@ -109,7 +110,7 @@ const initSentryMain = _.once(() => {
settings.getSync('analyticsSentryToken') ||
_.get(packageJSON, ['analytics', 'sentry', 'token']);

SentryMain.init({ dsn });
SentryMain.init({ dsn, beforeSend: anonymizeData });
});

const sourceSelectorReady = new Promise((resolve) => {
Expand Down