This repository has been archived by the owner on Sep 6, 2024. It is now read-only.
forked from facebook/create-react-app
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Refactor sentry implementation in skeleton
- Loading branch information
1 parent
d2e048b
commit f9edbff
Showing
21 changed files
with
96 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 7 additions & 3 deletions
10
packages/cra-template-typescript/template/src/config/config.development.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
const appName = process.env.REACT_APP_NAME; | ||
|
||
const config = { | ||
api: { | ||
base: `https://api-${appName}-development.ack.ee/api`, | ||
base: `https://api-YOU_APP_NAME-development.ack.ee/api`, | ||
}, | ||
sentry: { | ||
// TODO: add PUBLIC 'dsn' of your project here: | ||
dsn: '', | ||
}, | ||
devTools: true, | ||
}; | ||
|
||
export type ConfigDevelopment = typeof config; | ||
|
||
export default config; |
7 changes: 6 additions & 1 deletion
7
packages/cra-template-typescript/template/src/config/config.production.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
const config = { | ||
api: { | ||
base: 'https://skeleton', | ||
base: '', | ||
}, | ||
sentry: { | ||
dsn: '', | ||
}, | ||
devTools: false, | ||
}; | ||
|
||
export type ConfigProduction = typeof config; | ||
|
||
export default config; |
7 changes: 6 additions & 1 deletion
7
packages/cra-template-typescript/template/src/config/config.stage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
const config = { | ||
api: { | ||
base: 'https://skeleton', | ||
base: '', | ||
}, | ||
sentry: { | ||
dsn: '', | ||
}, | ||
devTools: false, | ||
}; | ||
|
||
export type ConfigStage = typeof config; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/cra-template-typescript/template/src/config/sentry/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { init, createReduxEnhancer, reactRouterV5Instrumentation } from '@sentry/react'; | ||
import type { BrowserOptions } from '@sentry/react'; | ||
import { Integrations } from '@sentry/tracing'; | ||
|
||
import config from 'config/config'; | ||
import { currentEnv, isEnvProduction, isServerEnv } from 'constants/index'; | ||
import { history } from 'modules/core/modules/router/config'; | ||
|
||
declare global { | ||
interface Window { | ||
requestIdleCallback: (cb: IdleRequestCallback, options?: IdleRequestOptions) => number; | ||
} | ||
} | ||
|
||
if (config.sentry.enable) { | ||
const options: BrowserOptions = { | ||
dsn: config.sentry.dsn, | ||
debug: false, | ||
integrations: [ | ||
new Integrations.BrowserTracing({ | ||
routingInstrumentation: reactRouterV5Instrumentation(history), | ||
}), | ||
], | ||
environment: currentEnv, | ||
release: `${process.env.REACT_APP_NAME}@${process.env.REACT_APP_VERSION}`, | ||
denyUrls: [ | ||
// Chrome extensions | ||
/extensions\//i, | ||
/^chrome:\/\//i, | ||
], | ||
normalizeDepth: 5, | ||
tracesSampleRate: isEnvProduction ? 0.25 : 1.0, | ||
}; | ||
|
||
const initSentry = () => init(options); | ||
|
||
if (isServerEnv && 'requestIdleCallback' in window) { | ||
window.requestIdleCallback(initSentry); | ||
} else { | ||
setTimeout(initSentry, 0); | ||
} | ||
} | ||
|
||
export const sentryReduxEnhancer = createReduxEnhancer(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
packages/cra-template-typescript/template/src/constants/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
export { default as env } from './env'; | ||
export * from './env'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletions
5
packages/cra-template-typescript/template/src/modules/core/config/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
import * as Consts from "constants/index"; | ||
import * as Consts from 'constants/index'; | ||
|
||
export const plugins = { | ||
// Learn more about service workers: http://bit.ly/CRA-PWA | ||
serviceWorker: !Consts.isServerEnv && false, | ||
|
||
// Enable Sentry only in prouduction environment | ||
sentry: Consts.isEnvProduction, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 4 additions & 6 deletions
10
packages/cra-template-typescript/template/src/modules/core/modules/redux/services/reducer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
import { combineReducers } from "redux"; | ||
import { combineReducers } from 'redux'; | ||
|
||
import { reducer as translateReducer } from "modules/core/modules/localization"; | ||
import { connectRouterWithHistory } from "modules/core/modules/router"; | ||
import { reducer as sentryReducer } from "modules/core/modules/sentry"; | ||
import { reducer as translateReducer } from 'modules/core/modules/localization'; | ||
import { connectRouterWithHistory } from 'modules/core/modules/router'; | ||
|
||
import reducers from "services/reducers"; | ||
import reducers from 'services/reducers'; | ||
|
||
export default combineReducers({ | ||
...reducers, | ||
translate: translateReducer, | ||
router: connectRouterWithHistory, | ||
sentry: sentryReducer, | ||
}); |
9 changes: 4 additions & 5 deletions
9
packages/cra-template-typescript/template/src/modules/core/modules/redux/services/saga.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import * as sagaEffects from "redux-saga/effects"; | ||
import * as sagaEffects from 'redux-saga/effects'; | ||
|
||
import { saga as sentrySaga } from "modules/core/modules/sentry"; | ||
import { saga as localizationSaga } from "modules/core/modules/localization"; | ||
import { saga as localizationSaga } from 'modules/core/modules/localization'; | ||
|
||
import saga from "services/sagas"; | ||
import saga from 'services/sagas'; | ||
|
||
const { all } = sagaEffects; | ||
|
||
export default function* rootSaga() { | ||
yield all([sentrySaga(), localizationSaga(), saga()]); | ||
yield all([localizationSaga(), saga()]); | ||
} |
46 changes: 0 additions & 46 deletions
46
packages/cra-template-typescript/template/src/modules/core/modules/sentry/config/index.ts
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
packages/cra-template-typescript/template/src/modules/core/modules/sentry/index.ts
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
...ra-template-typescript/template/src/modules/core/modules/sentry/services/actions/index.ts
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
...a-template-typescript/template/src/modules/core/modules/sentry/services/reducers/index.ts
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
.../cra-template-typescript/template/src/modules/core/modules/sentry/services/sagas/index.ts
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
...-template-typescript/template/src/modules/core/modules/sentry/services/selectors/index.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.