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

Commit

Permalink
Merge branch 'main' of github.com:evergreen-ci/spruce into EVG-20048
Browse files Browse the repository at this point in the history
  • Loading branch information
SupaJoon committed Oct 30, 2023
2 parents c8d17f9 + b6b5f85 commit ad6d4c0
Show file tree
Hide file tree
Showing 31 changed files with 475 additions and 633 deletions.
2 changes: 0 additions & 2 deletions .evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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} \
Expand Down Expand Up @@ -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} \
Expand Down
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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}};
Expand Down
14 changes: 5 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spruce",
"version": "3.0.158",
"version": "3.0.162",
"private": true,
"scripts": {
"bootstrap-logkeeper": "./scripts/bootstrap-logkeeper.sh",
Expand All @@ -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",
Expand All @@ -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": {
Expand All @@ -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",
Expand All @@ -69,7 +66,7 @@
"@leafygreen-ui/code": "14.0.1",
"@leafygreen-ui/combobox": "5.0.7",
"@leafygreen-ui/confirmation-modal": "5.0.6",
"@leafygreen-ui/emotion": "4.0.3",
"@leafygreen-ui/emotion": "4.0.7",
"@leafygreen-ui/expandable-card": "3.0.5",
"@leafygreen-ui/guide-cue": "3.0.0",
"@leafygreen-ui/icon": "11.12.1",
Expand Down Expand Up @@ -112,7 +109,7 @@
"deep-object-diff": "1.1.9",
"env-cmd": "10.1.0",
"graphql": "16.8.1",
"html-react-parser": "4.2.1",
"html-react-parser": "4.2.9",
"js-cookie": "3.0.5",
"linkify-html": "4.1.1",
"linkifyjs": "4.1.0",
Expand All @@ -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",
Expand Down Expand Up @@ -183,7 +179,7 @@
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jest": "27.2.1",
"eslint-plugin-jsdoc": "^46.2.6",
"eslint-plugin-jsx-a11y": "6.6.0",
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-react": "7.30.1",
"eslint-plugin-react-hooks": "4.6.0",
Expand Down
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
Expand Up @@ -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,
Expand Down
21 changes: 14 additions & 7 deletions src/analytics/task/useTaskAnalytics.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useQuery } from "@apollo/client";
import { useParams, useLocation } from "react-router-dom";
import { useParams } from "react-router-dom";
import { useAnalyticsRoot } from "analytics/useAnalyticsRoot";
import {
SaveSubscriptionForUserMutationVariables,
Expand All @@ -9,11 +9,9 @@ import {
TestSortCategory,
} from "gql/generated/types";
import { TASK } from "gql/queries";
import { useQueryParam } from "hooks/useQueryParam";
import { CommitType } from "pages/task/actionButtons/previousCommits/types";
import { RequiredQueryParams, LogTypes } from "types/task";
import { queryString } from "utils";

const { parseQueryString } = queryString;

type LogViewer = "raw" | "html" | "parsley" | "lobster";
type Action =
Expand Down Expand Up @@ -61,16 +59,23 @@ type Action =
| { name: "Click Display Task Link" }
| { name: "Click Project Link" }
| { name: "Click See History Button" }
| {
name: "Click Task File Link";
parsleyAvailable: boolean;
fileName: string;
}
| {
name: "Click Task File Parsley Link";
fileName: string;
}
| { name: "Click Trace Link" }
| { name: "Click Trace Metrics Link" }
| { name: "Submit Previous Commit Selector"; type: CommitType };

export const useTaskAnalytics = () => {
const { id } = useParams<{ id: string }>();
const location = useLocation();

const parsed = parseQueryString(location.search);
const execution = Number(parsed[RequiredQueryParams.Execution]);
const [execution] = useQueryParam(RequiredQueryParams.Execution, 0);
const { data: eventData } = useQuery<TaskQuery, TaskQueryVariables>(TASK, {
variables: { taskId: id, execution },
fetchPolicy: "cache-first",
Expand All @@ -79,6 +84,7 @@ export const useTaskAnalytics = () => {
const {
failedTestCount,
latestExecution,
project: { identifier } = { identifier: null },
status: taskStatus,
} = eventData?.task || {};
const isLatestExecution = latestExecution === execution;
Expand All @@ -89,5 +95,6 @@ export const useTaskAnalytics = () => {
isLatestExecution: isLatestExecution.toString(),
taskId: id,
failedTestCount,
projectIdentifier: identifier,
});
};
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";
Expand All @@ -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 = () => (
Expand All @@ -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");

Expand All @@ -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";

Expand Down Expand Up @@ -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>;
};
Loading

0 comments on commit ad6d4c0

Please sign in to comment.