Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

EVG-21011: Remove BugSnag #2107

Merged
merged 5 commits into from
Oct 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .evergreen.yml
Original file line number Diff line number Diff line change
@@ -391,7 +391,6 @@ functions:
working_dir: spruce
script: |
echo "Generating .env-cmdrc.json"
REACT_APP_BUGSNAG_API_KEY=${REACT_APP_BUGSNAG_API_KEY} \
REACT_APP_SENTRY_AUTH_TOKEN=${REACT_APP_SENTRY_AUTH_TOKEN} \
REACT_APP_SENTRY_DSN=${REACT_APP_SENTRY_DSN} \
REACT_APP_NEW_RELIC_ACCOUNT_ID=${REACT_APP_NEW_RELIC_ACCOUNT_ID} \
@@ -420,7 +419,6 @@ functions:
shell: bash
script: |
${PREPARE_SHELL}
REACT_APP_BUGSNAG_API_KEY=${REACT_APP_BUGSNAG_API_KEY} \
BUCKET=${bucket} \
AWS_ACCESS_KEY_ID=${aws_key} \
AWS_SECRET_ACCESS_KEY=${aws_secret} \
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -4,7 +4,8 @@
<head>
<meta charset="utf-8" />
<meta name="theme-color" content="#000000" />
<meta name="ui-version" content="%GIT_SHA%">
<meta name="git-hash" content="%GIT_SHA%" />
<meta name="package-version" content="%APP_VERSION%" />
<script type="text/javascript">
if ("%REACT_APP_RELEASE_STAGE%" === "production" || "%REACT_APP_RELEASE_STAGE%" === "beta") {
;window.NREUM||(NREUM={});NREUM.init={privacy:{cookies_enabled:true}};
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
"build:local": "env-cmd -e local -r .env-cmdrc.local.json yarn build",
"build:prod": "env-cmd -e production yarn build",
"build:staging": "env-cmd -e staging yarn build",
"build": "GIT_SHA=`git rev-parse HEAD` vite build",
"build": "GIT_SHA=`git rev-parse HEAD` APP_VERSION=$npm_package_version vite build",
"check-types": "tsc -p tsconfig.json --noEmit",
"clean": "rm -rf node_modules && rm -rf build && yarn install",
"codegen": "graphql-codegen --config codegen.ts",
@@ -35,7 +35,6 @@
"storybook": "storybook dev -p 6006",
"test:watch": "node scripts/test.js --verbose",
"test": "node scripts/test.js --watchAll=false",
"upload-source-maps": "env-cmd -e production node ./scripts/deploy/upload-bugsnag-sourcemaps",
"postversion": "scripts/push-version.sh"
},
"browserslist": {
@@ -55,8 +54,6 @@
},
"dependencies": {
"@apollo/client": "3.8.4",
"@bugsnag/js": "7.20.2",
"@bugsnag/plugin-react": "7.18.0",
"@emotion/css": "11.11.2",
"@emotion/react": "11.11.1",
"@emotion/styled": "11.11.0",
@@ -133,7 +130,6 @@
"@babel/plugin-proposal-private-property-in-object": "^7.17.12",
"@babel/preset-react": "^7.12.13",
"@babel/preset-typescript": "7.21.5",
"@bugsnag/source-maps": "^2.3.0",
"@emotion/babel-plugin": "11.11.0",
"@emotion/eslint-plugin": "11.11.0",
"@emotion/jest": "11.11.0",
18 changes: 0 additions & 18 deletions scripts/deploy/app-version.sh

This file was deleted.

6 changes: 0 additions & 6 deletions scripts/deploy/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
#!/bin/sh

# This script runs the aws cli command to deploy the app to s3
# It also uploads source maps to bugsnag

# Try this step and throw an error if it fails
echo "Deploying to S3"
aws s3 sync build/ s3://"${BUCKET}"/ --acl public-read --follow-symlinks --delete --exclude .env-cmdrc.json
echo "Deployed to S3"

# If the above step succeeds, run this step
echo "Uploading source maps to Bugsnag"
./scripts/deploy/app-version.sh && node ./scripts/deploy/upload-bugsnag-sourcemaps.js
echo "Source maps uploaded to Bugsnag"
9 changes: 0 additions & 9 deletions scripts/deploy/upload-bugsnag-sourcemaps.js

This file was deleted.

1 change: 0 additions & 1 deletion scripts/setup-credentials.js
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ const production = {
REACT_APP_PARSLEY_URL: "https://parsley.mongodb.com",
REACT_APP_SPRUCE_URL: "https://spruce.mongodb.com",
REACT_APP_RELEASE_STAGE: "production",
REACT_APP_BUGSNAG_API_KEY: process.env.REACT_APP_BUGSNAG_API_KEY,
REACT_APP_SENTRY_AUTH_TOKEN: process.env.REACT_APP_SENTRY_AUTH_TOKEN,
REACT_APP_SENTRY_DSN: process.env.REACT_APP_SENTRY_DSN,
REACT_APP_NEW_RELIC_ACCOUNT_ID: process.env.REACT_APP_NEW_RELIC_ACCOUNT_ID,
65 changes: 0 additions & 65 deletions src/components/ErrorHandling/Bugsnag.tsx

This file was deleted.

6 changes: 3 additions & 3 deletions src/components/ErrorHandling/ErrorBoundary.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Bugsnag from "@bugsnag/js";
import * as Sentry from "@sentry/react";
import { render, screen } from "test_utils";
import { mockEnvironmentVariables } from "test_utils/utils";
@@ -9,13 +8,14 @@ const { cleanup } = mockEnvironmentVariables();
describe("default error boundary", () => {
beforeEach(() => {
jest.spyOn(console, "error").mockImplementation(() => {});
jest.spyOn(Bugsnag, "notify");
jest.spyOn(Sentry, "captureException");
});

afterEach(() => {
cleanup();
jest.restoreAllMocks();
});

it("should render the passed in component", () => {
const TestComponent = () => <div>Hello</div>;
const TestErrorBoundary = () => (
@@ -26,6 +26,7 @@ describe("default error boundary", () => {
render(<TestErrorBoundary />);
expect(screen.getByText("Hello")).toBeInTheDocument();
});

it("should display the fallback when an error occurs", () => {
const err = new Error("Test error");

@@ -45,7 +46,6 @@ describe("default error boundary", () => {
componentStack: expect.any(String),
}),
});
expect(Bugsnag.notify).not.toHaveBeenCalled();
expect(Sentry.captureException).not.toHaveBeenCalled();
});
});
20 changes: 2 additions & 18 deletions src/components/ErrorHandling/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Component } from "react";
import Bugsnag from "@bugsnag/js";
import { ErrorBoundary as BugsnagErrorBoundary } from "./Bugsnag";
import ErrorFallback from "./ErrorFallback";
import { ErrorBoundary as SentryErrorBoundary, isInitialized } from "./Sentry";

@@ -41,24 +39,10 @@ class DefaultErrorBoundary extends Component<
export const ErrorBoundary: React.FC<{ children: React.ReactNode }> = ({
children,
}) => {
const useBugsnag = Bugsnag.isStarted();
const useSentry = isInitialized();

if (!useBugsnag && !useSentry) {
return <DefaultErrorBoundary>{children}</DefaultErrorBoundary>;
}

let errorBoundary = children;

if (useSentry) {
errorBoundary = <SentryErrorBoundary>{errorBoundary}</SentryErrorBoundary>;
return <SentryErrorBoundary>{children}</SentryErrorBoundary>;
}

if (useBugsnag) {
errorBoundary = (
<BugsnagErrorBoundary>{errorBoundary}</BugsnagErrorBoundary>
);
}

return <>{errorBoundary}</>; // eslint-disable-line react/jsx-no-useless-fragment
return <DefaultErrorBoundary>{children}</DefaultErrorBoundary>;
};
39 changes: 0 additions & 39 deletions src/components/ErrorHandling/initialize.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Bugsnag from "@bugsnag/js";
import BugsnagPluginReact from "@bugsnag/plugin-react";
import * as Sentry from "@sentry/react";
import { mockEnvironmentVariables } from "test_utils/utils";
import { initializeErrorHandling } from ".";
@@ -8,8 +6,6 @@ const { cleanup, mockEnv } = mockEnvironmentVariables();

describe("should initialize error handlers according to release stage", () => {
beforeEach(() => {
jest.spyOn(Bugsnag, "start").mockImplementation(jest.fn());
jest.spyOn(Bugsnag, "isStarted").mockImplementation(jest.fn(() => false));
jest.spyOn(Sentry, "init").mockImplementation(jest.fn());
jest
.spyOn(Sentry, "Replay")
@@ -27,25 +23,16 @@ describe("should initialize error handlers according to release stage", () => {
mockEnv("REACT_APP_RELEASE_STAGE", "production");
initializeErrorHandling();

expect(Bugsnag.start).not.toHaveBeenCalled();
expect(Sentry.init).not.toHaveBeenCalled();
});

it("production", () => {
mockEnv("NODE_ENV", "production");
mockEnv("REACT_APP_VERSION", "1.0.0");
mockEnv("REACT_APP_RELEASE_STAGE", "production");
mockEnv("REACT_APP_BUGSNAG_API_KEY", "i-am-a-fake-key");
mockEnv("REACT_APP_SENTRY_DSN", "fake-sentry-key");
initializeErrorHandling();

expect(Bugsnag.start).toHaveBeenCalledWith({
apiKey: "i-am-a-fake-key",
appVersion: "1.0.0",
releaseStage: "production",
plugins: [new BugsnagPluginReact()],
});

expect(Sentry.init).toHaveBeenCalledWith({
dsn: "fake-sentry-key",
debug: false,
@@ -61,17 +48,9 @@ describe("should initialize error handlers according to release stage", () => {
mockEnv("REACT_APP_RELEASE_STAGE", "beta");
mockEnv("NODE_ENV", "production");
mockEnv("REACT_APP_VERSION", "1.0.0");
mockEnv("REACT_APP_BUGSNAG_API_KEY", "i-am-a-fake-key");
mockEnv("REACT_APP_SENTRY_DSN", "fake-sentry-key");
initializeErrorHandling();

expect(Bugsnag.start).toHaveBeenCalledWith({
apiKey: "i-am-a-fake-key",
appVersion: "1.0.0",
releaseStage: "beta",
plugins: [new BugsnagPluginReact()],
});

expect(Sentry.init).toHaveBeenCalledWith({
dsn: "fake-sentry-key",
debug: true,
@@ -87,17 +66,9 @@ describe("should initialize error handlers according to release stage", () => {
mockEnv("NODE_ENV", "production");
mockEnv("REACT_APP_VERSION", "1.0.0");
mockEnv("REACT_APP_RELEASE_STAGE", "staging");
mockEnv("REACT_APP_BUGSNAG_API_KEY", "i-am-a-fake-key");
mockEnv("REACT_APP_SENTRY_DSN", "fake-sentry-key");
initializeErrorHandling();

expect(Bugsnag.start).toHaveBeenCalledWith({
apiKey: "i-am-a-fake-key",
appVersion: "1.0.0",
releaseStage: "staging",
plugins: [new BugsnagPluginReact()],
});

expect(Sentry.init).toHaveBeenCalledWith({
dsn: "fake-sentry-key",
debug: true,
@@ -112,8 +83,6 @@ describe("should initialize error handlers according to release stage", () => {

describe("should not initialize if the client is already running", () => {
beforeEach(() => {
jest.spyOn(Bugsnag, "start").mockImplementation(jest.fn());
jest.spyOn(Bugsnag, "isStarted").mockImplementation(jest.fn(() => false));
jest.spyOn(Sentry, "init").mockImplementation(jest.fn());
mockEnv("NODE_ENV", "production");
});
@@ -123,19 +92,11 @@ describe("should not initialize if the client is already running", () => {
cleanup();
});

it("does not initialize Bugsnag twice", () => {
jest.spyOn(Bugsnag, "isStarted").mockImplementation(jest.fn(() => true));
initializeErrorHandling();
expect(Bugsnag.start).not.toHaveBeenCalled();
expect(Sentry.init).toHaveBeenCalledTimes(1);
});

it("does not initialize Sentry twice", () => {
const mockClient = { getClient: jest.fn(() => true) };
// @ts-expect-error - Type error occurs because the entire return value of getCurrentHub is not mocked
jest.spyOn(Sentry, "getCurrentHub").mockReturnValue(mockClient);
initializeErrorHandling();
expect(Bugsnag.start).toHaveBeenCalledTimes(1);
expect(Sentry.init).not.toHaveBeenCalled();
});
});
6 changes: 0 additions & 6 deletions src/components/ErrorHandling/initialize.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import Bugsnag from "@bugsnag/js";
import { environmentVariables } from "utils";
import { initializeBugsnag } from "./Bugsnag";
import { initializeSentry, isInitialized } from "./Sentry";

const { isProductionBuild } = environmentVariables;
@@ -10,10 +8,6 @@ export const initializeErrorHandling = () => {
return;
}

if (!Bugsnag.isStarted()) {
initializeBugsnag();
}

if (!isInitialized()) {
initializeSentry();
}
6 changes: 3 additions & 3 deletions src/components/HistoryTable/HistoryTable.tsx
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { useEffect, useMemo, useRef } from "react";
import throttle from "lodash.throttle";
import { Virtuoso, VirtuosoHandle } from "react-virtuoso";
import { useDimensions } from "hooks/useDimensions";
import { leaveBreadcrumb } from "utils/errorReporting";
import { leaveBreadcrumb, SentryBreadcrumb } from "utils/errorReporting";
import { types } from ".";
import { useHistoryTable } from "./HistoryTableContext";
import EndOfHistoryRow from "./HistoryTableRow/EndOfHistoryRow";
@@ -55,7 +55,7 @@ const HistoryTable: React.FC<HistoryTableProps> = ({
{
selectedCommit,
},
"process"
SentryBreadcrumb.UI
);
listRef.current.scrollToIndex(selectedCommit.rowIndex);
}
@@ -71,7 +71,7 @@ const HistoryTable: React.FC<HistoryTableProps> = ({
selectedCommit,
processedCommitCount,
},
"process"
SentryBreadcrumb.UI
);
loadMoreItems();
}
Loading