Skip to content

Commit fc671fb

Browse files
committed
Fix tree shaking
1 parent bcb59cb commit fc671fb

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

src/background/main.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import browser from "webextension-polyfill";
2-
import * as Sentry from "@sentry/browser";
2+
import {
3+
init as sentryInit,
4+
browserTracingIntegration,
5+
startSpan,
6+
} from "@sentry/browser";
37

48
import { MessageType } from "src/types";
59
import { Codecov } from "src/service";
@@ -11,12 +15,12 @@ import {
1115
async function main(): Promise<void> {
1216
browser.runtime.onMessage.addListener(handleMessages);
1317

14-
Sentry.init({
18+
sentryInit({
1519
// @ts-ignore SENTRY_DSN is populated by Webpack at build time
1620
dsn: SENTRY_DSN,
1721

1822
integrations: [
19-
Sentry.browserTracingIntegration({
23+
browserTracingIntegration({
2024
// disable automatic span creation
2125
instrumentNavigation: false,
2226
instrumentPageLoad: false,
@@ -33,7 +37,7 @@ async function handleMessages(message: {
3337
referrer?: string;
3438
}) {
3539
const codecov = new Codecov();
36-
return Sentry.startSpan({ name: message.type }, async () => {
40+
return startSpan({ name: message.type }, async () => {
3741
switch (message.type) {
3842
case MessageType.FETCH_COMMIT_REPORT:
3943
return codecov.fetchCommitReport(message.payload, message.referrer!);

src/content/common/sentry.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
11
import {
2+
breadcrumbsIntegration,
3+
browserApiErrorsIntegration,
24
BrowserClient,
35
defaultStackParser,
4-
getDefaultIntegrations,
6+
globalHandlersIntegration,
57
makeFetchTransport,
8+
dedupeIntegration,
69
Scope,
7-
} from '@sentry/browser';
10+
} from "@sentry/browser";
811

912
// Sentry config
10-
// Browser extensions must initialize Sentry a bit differently to avoid
13+
// Browser extensions must initialize Sentry a bit differently to avoid
1114
// conflicts between Sentry instances should the site the extension is running
1215
// on also use Sentry. Read more here:
1316
// https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/
1417

15-
const sentryIntegrations = getDefaultIntegrations({}).filter(defaultIntegration => {
16-
return !['BrowserApiErrors', 'TryCatch', 'Breadcrumbs', 'GlobalHandlers'].includes(
17-
defaultIntegration.name
18-
);
19-
});
20-
2118
const sentryClient = new BrowserClient({
2219
// @ts-ignore SENTRY_DSN is populated by Webpack at build time
2320
dsn: SENTRY_DSN,
2421
transport: makeFetchTransport,
2522
stackParser: defaultStackParser,
26-
integrations: sentryIntegrations,
23+
integrations: [
24+
breadcrumbsIntegration,
25+
browserApiErrorsIntegration,
26+
globalHandlersIntegration,
27+
dedupeIntegration,
28+
],
2729
});
2830

2931
const Sentry = new Scope();
3032
Sentry.setClient(sentryClient);
3133
sentryClient.init();
3234

33-
export default Sentry
35+
export default Sentry;

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"compilerOptions": {
33
"strict": true,
4-
"module": "commonjs",
4+
"module": "es6",
55
"target": "es6",
66
"esModuleInterop": true,
77
"sourceMap": false,
@@ -15,6 +15,7 @@
1515
"outDir": "dist/js",
1616
"noEmitOnError": true,
1717
"jsx": "react",
18-
"typeRoots": ["node_modules/@types"]
18+
"typeRoots": ["node_modules/@types"],
19+
"moduleResolution": "node"
1920
}
2021
}

0 commit comments

Comments
 (0)