Skip to content

Commit fcf95ba

Browse files
Merge pull request #92 from codecov/revert-91-spalmurray/sentry-tracing
Revert "Add sentry tracing to network requests"
2 parents 0f5bc4e + 9c0194e commit fcf95ba

File tree

4 files changed

+55
-77
lines changed

4 files changed

+55
-77
lines changed

src/background/main.ts

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,8 @@ import {
66
registerContentScript,
77
unregisterContentScriptIfExists,
88
} from "./dynamic_content_scripts";
9-
import * as Sentry from "@sentry/browser";
109

1110
async function main(): Promise<void> {
12-
Sentry.init({
13-
// @ts-ignore SENTRY_DSN is populated by Webpack at build time
14-
dsn: SENTRY_DSN,
15-
16-
integrations: [
17-
Sentry.browserTracingIntegration({
18-
// disable automatic span creation
19-
instrumentNavigation: false,
20-
instrumentPageLoad: false,
21-
}),
22-
],
23-
24-
tracesSampleRate: 1.0,
25-
});
2611
browser.runtime.onMessage.addListener(handleMessages);
2712
}
2813

@@ -31,24 +16,22 @@ async function handleMessages(message: {
3116
payload: any;
3217
referrer?: string;
3318
}) {
34-
Sentry.startSpan({ name: message.type }, async () => {
35-
switch (message.type) {
36-
case MessageType.FETCH_COMMIT_REPORT:
37-
return Codecov.fetchCommitReport(message.payload, message.referrer!);
38-
case MessageType.FETCH_PR_COMPARISON:
39-
return Codecov.fetchPRComparison(message.payload, message.referrer!);
40-
case MessageType.FETCH_FLAGS_LIST:
41-
return Codecov.listFlags(message.payload, message.referrer!);
42-
case MessageType.FETCH_COMPONENTS_LIST:
43-
return Codecov.listComponents(message.payload, message.referrer!);
44-
case MessageType.CHECK_AUTH:
45-
return Codecov.checkAuth(message.payload);
46-
case MessageType.REGISTER_CONTENT_SCRIPTS:
47-
return registerContentScript(message.payload);
48-
case MessageType.UNREGISTER_CONTENT_SCRIPTS:
49-
return unregisterContentScriptIfExists(message.payload);
50-
}
51-
});
19+
switch (message.type) {
20+
case MessageType.FETCH_COMMIT_REPORT:
21+
return Codecov.fetchCommitReport(message.payload, message.referrer!);
22+
case MessageType.FETCH_PR_COMPARISON:
23+
return Codecov.fetchPRComparison(message.payload, message.referrer!);
24+
case MessageType.FETCH_FLAGS_LIST:
25+
return Codecov.listFlags(message.payload, message.referrer!);
26+
case MessageType.FETCH_COMPONENTS_LIST:
27+
return Codecov.listComponents(message.payload, message.referrer!);
28+
case MessageType.CHECK_AUTH:
29+
return Codecov.checkAuth(message.payload);
30+
case MessageType.REGISTER_CONTENT_SCRIPTS:
31+
return registerContentScript(message.payload);
32+
case MessageType.UNREGISTER_CONTENT_SCRIPTS:
33+
return unregisterContentScriptIfExists(message.payload);
34+
}
5235
}
5336

5437
main().catch(console.log);

src/content/common/sentry.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,19 @@ import {
44
getDefaultIntegrations,
55
makeFetchTransport,
66
Scope,
7-
} from "@sentry/browser";
7+
} from '@sentry/browser';
88

99
// Sentry config
10-
// Browser extensions must initialize Sentry a bit differently to avoid
10+
// Browser extensions must initialize Sentry a bit differently to avoid
1111
// conflicts between Sentry instances should the site the extension is running
1212
// on also use Sentry. Read more here:
1313
// https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/
1414

15-
const sentryIntegrations = getDefaultIntegrations({}).filter(
16-
(defaultIntegration) => {
17-
return ![
18-
"BrowserApiErrors",
19-
"TryCatch",
20-
"Breadcrumbs",
21-
"GlobalHandlers",
22-
].includes(defaultIntegration.name);
23-
}
24-
);
15+
const sentryIntegrations = getDefaultIntegrations({}).filter(defaultIntegration => {
16+
return !['BrowserApiErrors', 'TryCatch', 'Breadcrumbs', 'GlobalHandlers'].includes(
17+
defaultIntegration.name
18+
);
19+
});
2520

2621
const sentryClient = new BrowserClient({
2722
// @ts-ignore SENTRY_DSN is populated by Webpack at build time
@@ -35,4 +30,4 @@ const Sentry = new Scope();
3530
Sentry.setClient(sentryClient);
3631
sentryClient.init();
3732

38-
export default Sentry;
33+
export default Sentry

src/content/github/file/main.tsx

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {
3535
} from "../common/fetchers";
3636
import { print } from "src/utils";
3737
import { isFileUrl } from "../common/utils";
38-
import Sentry from "../../common/sentry";
38+
import Sentry from '../../common/sentry';
3939

4040
const globals: {
4141
coverageReport?: FileCoverageReport;
@@ -47,7 +47,7 @@ const globals: {
4747
prompt?: HTMLElement;
4848
} = {};
4949

50-
init();
50+
init()
5151

5252
function init(): Promise<void> {
5353
// this event discovered by "reverse-engineering GitHub"
@@ -73,10 +73,10 @@ async function main(): Promise<void> {
7373

7474
globals.coverageButton = createCoverageButton();
7575

76-
process(metadata);
76+
process(metadata)
7777
} catch (e) {
78-
Sentry.captureException(e);
79-
throw e;
78+
Sentry.captureException(e)
79+
throw e
8080
}
8181
}
8282

@@ -111,16 +111,17 @@ async function process(metadata: FileMetadata): Promise<void> {
111111
previousElement: globals.coverageButton!,
112112
selectedOptions: selectedFlags,
113113
onClick: handleFlagClick,
114-
}).then(({ button, list }) => {
115-
globals.flagsButton = button;
116-
globals.flagsDrop = new Drop({
117-
target: button,
118-
content: list,
119-
classes: "drop-theme-arrows codecov-z1 codecov-bg-white",
120-
position: "bottom right",
121-
openOn: "click",
122-
});
123-
});
114+
})
115+
.then(({ button, list }) => {
116+
globals.flagsButton = button;
117+
globals.flagsDrop = new Drop({
118+
target: button,
119+
content: list,
120+
classes: "drop-theme-arrows codecov-z1 codecov-bg-white",
121+
position: "bottom right",
122+
openOn: "click",
123+
});
124+
})
124125
}
125126

126127
const components = await getComponents(metadata);
@@ -150,16 +151,17 @@ async function process(metadata: FileMetadata): Promise<void> {
150151
previousElement: globals.coverageButton!,
151152
onClick: handleComponentClick,
152153
selectedOptions: selectedComponents,
153-
}).then(({ button, list }) => {
154-
globals.componentsButton = button;
155-
globals.componentsDrop = new Drop({
156-
target: button,
157-
content: list,
158-
classes: "drop-theme-arrows codecov-z1 codecov-bg-white",
159-
position: "bottom right",
160-
openOn: "click",
161-
});
162-
});
154+
})
155+
.then(({ button, list }) => {
156+
globals.componentsButton = button;
157+
globals.componentsDrop = new Drop({
158+
target: button,
159+
content: list,
160+
classes: "drop-theme-arrows codecov-z1 codecov-bg-white",
161+
position: "bottom right",
162+
openOn: "click",
163+
});
164+
})
163165
}
164166

165167
let coverageReportResponses: Array<FileCoverageReportResponse>;
@@ -239,9 +241,7 @@ async function promptPastReport(metadata: FileMetadata): Promise<void> {
239241
const matches = regexp.exec(response.commit_file_url);
240242
const commit = matches?.groups?.commit;
241243
if (!commit) {
242-
throw new Error(
243-
"Could not parse commit hash from response for past coverage report"
244-
);
244+
throw new Error("Could not parse commit hash from response for past coverage report")
245245
}
246246
const link = document.URL.replace(
247247
`blob/${metadata.branch}`,
@@ -260,7 +260,7 @@ function createPrompt(child: any) {
260260
const ref = document.querySelector('[data-testid="latest-commit"]')
261261
?.parentElement?.parentElement;
262262
if (!ref) {
263-
throw new Error("Could not find reference element to render prompt");
263+
throw new Error("Could not find reference element to render prompt")
264264
}
265265
const prompt = <div className="codecov-mb2 codecov-mx1">{child}</div>;
266266
return ref.insertAdjacentElement("afterend", prompt) as HTMLElement;

webpack/webpack.common.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module.exports = {
5050
browser: "webextensions-polyfill",
5151
}),
5252
new DefinePlugin({
53-
SENTRY_DSN: JSON.stringify(process.env.SENTRY_DSN),
54-
}),
53+
SENTRY_DSN: process.env.SENTRY_DSN
54+
})
5555
],
5656
};

0 commit comments

Comments
 (0)