Skip to content

Commit

Permalink
Merge pull request #4005 from owid/bugsnag-init
Browse files Browse the repository at this point in the history
🔨 correctly initialize bugsnag in SiteBaker v2
  • Loading branch information
ikesau authored Oct 9, 2024
2 parents 2599ed9 + 6d314b4 commit d21f869
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions baker/SiteBaker.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from "fs-extra"
import path from "path"
import Bugsnag from "@bugsnag/js"
import { glob } from "glob"
import { keyBy, without, uniq, mapValues, pick, chunk } from "lodash"
import ProgressBar from "progress"
Expand All @@ -10,6 +11,7 @@ import {
GDOCS_DETAILS_ON_DEMAND_ID,
BAKED_GRAPHER_URL,
FEATURE_FLAGS,
BUGSNAG_NODE_API_KEY,
} from "../settings/serverSettings.js"

import {
Expand Down Expand Up @@ -209,6 +211,13 @@ export class SiteBaker {
}
)
this.explorerAdminServer = new ExplorerAdminServer(GIT_CMS_DIR)
if (BUGSNAG_NODE_API_KEY) {
Bugsnag.start({
apiKey: BUGSNAG_NODE_API_KEY,
context: "site-baker",
autoTrackSessions: false,
})
}
}

private async bakeEmbeds(knex: db.KnexReadonlyTransaction) {
Expand Down Expand Up @@ -631,17 +640,13 @@ export class SiteBaker {
}

await publishedGdoc.validate(knex)
if (
publishedGdoc.errors.filter(
(e) => e.type === OwidGdocErrorMessageType.Error
).length
) {
for (const errorOrWarning of publishedGdoc.errors) {
const announcement =
errorOrWarning.type === OwidGdocErrorMessageType.Error
? `Error baking "${publishedGdoc.slug}"`
: `Warning baking "${publishedGdoc.slug}"`
await logErrorAndMaybeSendToBugsnag(
`Error(s) baking "${
publishedGdoc.slug
}" :\n ${publishedGdoc.errors
.map((error) => error.message)
.join("\n ")}`
`${announcement}: ${errorOrWarning.message}`
)
}
try {
Expand Down

0 comments on commit d21f869

Please sign in to comment.