Skip to content

Commit

Permalink
🎉 add @bugsnag/browser-performance and GIT_REVISION to bugsnag initia…
Browse files Browse the repository at this point in the history
…lization
  • Loading branch information
ikesau committed Aug 20, 2024
1 parent a2b5b74 commit 7b75fdf
Show file tree
Hide file tree
Showing 5 changed files with 468 additions and 20 deletions.
6 changes: 6 additions & 0 deletions ops/buildkite/build-code
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ update_env() {
else
sed -i "s|^BAKED_SITE_DIR=.*$|BAKED_SITE_DIR=/home/owid/live-data/bakedSite|" owid-grapher/.env
fi
# set GIT_REVISION based on current hash, used for Bugsnag
if ! grep -q "^GIT_REVISION=" owid-grapher/.env; then
echo "GIT_REVISION=$(git rev-parse HEAD)" >> owid-grapher/.env
else
sed -i "s|^GIT_REVISION=.*$|GIT_REVISION=$(git rev-parse HEAD)|" owid-grapher/.env
fi
# redirect assets
if ! grep -q "^BAKED_GRAPHER_EXPORTS_BASE_URL=" owid-grapher/.env; then
echo "BAKED_GRAPHER_EXPORTS_BASE_URL=https://assets.ourworldindata.org/grapher/exports" >> owid-grapher/.env
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@algolia/autocomplete-plugin-recent-searches": "^1.17.2",
"@algolia/autocomplete-theme-classic": "^1.17.2",
"@aws-sdk/client-s3": "^3.626.0",
"@bugsnag/browser-performance": "^2.4.1",
"@bugsnag/core": "^7.19.0",
"@bugsnag/js": "^7.20.0",
"@bugsnag/plugin-express": "^7.19.0",
Expand Down
2 changes: 1 addition & 1 deletion settings/clientSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { parseIntOrUndefined } from "@ourworldindata/utils"

export const ENV: "development" | "production" =
process.env.ENV === "production" ? "production" : "development"

export const GIT_REVISION = process.env.GIT_REVISION ?? "unknown"
export const BUGSNAG_API_KEY: string | undefined = process.env.BUGSNAG_API_KEY
export const ADMIN_SERVER_PORT: number =
parseIntOrUndefined(process.env.ADMIN_SERVER_PORT) ?? 3030
Expand Down
8 changes: 8 additions & 0 deletions site/owid.entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ import {
ENV,
BUGSNAG_API_KEY,
ADMIN_BASE_URL,
GIT_REVISION,
} from "../settings/clientSettings.js"
import { Grapher, CookieKey } from "@ourworldindata/grapher"
import { MultiEmbedderSingleton } from "../site/multiembedder/MultiEmbedder.js"
import { CoreTable } from "@ourworldindata/core-table"
import { SiteAnalytics } from "./SiteAnalytics.js"
import Bugsnag, { BrowserConfig } from "@bugsnag/js"
import BugsnagPluginReact from "@bugsnag/plugin-react"
import BugsnagPerformance from "@bugsnag/browser-performance"
import { runMonkeyPatchForGoogleTranslate } from "./hacks.js"
import { runSiteFooterScripts } from "./runSiteFooterScripts.js"
import {
Expand Down Expand Up @@ -74,11 +76,17 @@ if (BUGSNAG_API_KEY) {

Bugsnag.start({
apiKey: BUGSNAG_API_KEY,
appVersion: GIT_REVISION,
plugins: [new BugsnagPluginReact()],
autoTrackSessions: false,
collectUserIp: false,
...bugsnagUserInformation,
})
BugsnagPerformance.start({
apiKey: BUGSNAG_API_KEY,
appVersion: GIT_REVISION,
...bugsnagUserInformation,
})
} catch (error) {
console.error("Failed to initialize Bugsnag")
}
Expand Down
Loading

0 comments on commit 7b75fdf

Please sign in to comment.