Skip to content

Commit cfa0e76

Browse files
MatissJanisclaude
andcommitted
Fix Bugsnag missing API key error, modernize husky, and upgrade to Yarn 4
- Skip Bugsnag initialization when no API key is set (fixes dev crash) - Update husky config to modern v9+ format (fixes deprecation warning) - Migrate from Yarn 1 to Yarn 4 with node-modules linker - Update CI workflows to use --immutable instead of --frozen-lockfile Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 95339ab commit cfa0e76

11 files changed

Lines changed: 5939 additions & 3112 deletions

File tree

.github/workflows/deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
REACT_APP_STATIC_API_ENDPOINT: ${{ secrets.REACT_APP_STATIC_API_ENDPOINT }}
2222
REACT_APP_BROKALYS_API_KEY: ${{ secrets.REACT_APP_BROKALYS_API_KEY }}
2323
run: |
24-
yarn install --frozen-lockfile
24+
yarn install --immutable
2525
yarn build
2626
- name: Deploy 🚀
2727
uses: JamesIves/github-pages-deploy-action@releases/v4

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
steps:
99
- uses: actions/checkout@v4
1010
- name: Install
11-
run: yarn install --frozen-lockfile
11+
run: yarn install --immutable
1212
- name: Test
1313
run: yarn test
1414
- name: Build 🔧

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
# dependencies
44
/node_modules
55
/.pnp
6-
.pnp.js
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/sdks
12+
!.yarn/versions
713

814
# testing
915
/coverage

.husky/pre-commit

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
41
yarn lint-staged

.yarn/releases/yarn-4.13.0.cjs

Lines changed: 940 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
nodeLinker: node-modules
2+
yarnPath: .yarn/releases/yarn-4.13.0.cjs

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"preview": "vite preview",
6969
"test": "vitest run",
7070
"test:watch": "vitest",
71-
"prepare": "husky install"
71+
"prepare": "husky"
7272
},
7373
"resolutions": {
7474
"@types/react": "^18.3.28",
@@ -86,5 +86,6 @@
8686
"cz-emoji": {
8787
"symbol": true
8888
}
89-
}
89+
},
90+
"packageManager": "yarn@4.13.0"
9091
}

src/bugsnag.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import Bugsnag from '@bugsnag/js';
22
import BugsnagPluginReact from '@bugsnag/plugin-react';
33

4-
Bugsnag.start({
5-
releaseStage: import.meta.env.MODE,
6-
enabledReleaseStages: ['production'],
7-
apiKey: import.meta.env.VITE_BUGSNAG_KEY!,
8-
plugins: [new BugsnagPluginReact()],
9-
collectUserIp: false,
10-
});
4+
const apiKey = import.meta.env.VITE_BUGSNAG_KEY;
5+
6+
if (apiKey) {
7+
Bugsnag.start({
8+
releaseStage: import.meta.env.MODE,
9+
enabledReleaseStages: ['production'],
10+
apiKey,
11+
plugins: [new BugsnagPluginReact()],
12+
collectUserIp: false,
13+
});
14+
}
1115

1216
export default Bugsnag;
17+
export const isBugsnagEnabled = !!apiKey;

src/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import { ReactRouter6Adapter } from 'use-query-params/adapters/react-router-6';
99

1010
import App from './App';
1111
import client from './apollo-client';
12-
import Bugsnag from './bugsnag';
12+
import Bugsnag, { isBugsnagEnabled } from './bugsnag';
1313
import { MapContext } from './hooks/use-map-context';
1414
import './index.css';
1515

16-
const ErrorBoundary = Bugsnag.getPlugin('react')!.createErrorBoundary(React);
16+
const ErrorBoundary = isBugsnagEnabled
17+
? Bugsnag.getPlugin('react')!.createErrorBoundary(React)
18+
: React.Fragment;
1719

1820
const container = document.getElementById('root') as HTMLElement;
1921
const root = createRoot(container);

src/pages/Home/Home.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
22
import { ErrorBoundary } from 'react-error-boundary';
33
import { Header, Message, Statistic } from 'semantic-ui-react';
44

5-
import Bugsnag from 'src/bugsnag';
5+
import Bugsnag, { isBugsnagEnabled } from 'src/bugsnag';
66
import getRegionData from 'src/common/get-region-data';
77
import FilterToolbar from 'src/components/FilterToolbar';
88
import PropertyPriceChart from 'src/components/PropertyPriceChart';
@@ -43,7 +43,9 @@ export default function Home() {
4343
Failed loading the data. Please try again later.
4444
</Message>
4545
}
46-
onError={(error) => Bugsnag.notify(error as Error)}
46+
onError={(error) =>
47+
isBugsnagEnabled && Bugsnag.notify(error as Error)
48+
}
4749
>
4850
<Statistic.Group size="small" className={styles.statistics}>
4951
<MeanPrice />

0 commit comments

Comments
 (0)