-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update environment configuration and Sentry
integration
- Loading branch information
Showing
5 changed files
with
119 additions
and
100 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
window._env_ = { | ||
REACT_APP_ENVIRONMENT: "local", | ||
REACT_APP_VERSION: "local", | ||
}; |
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 |
---|---|---|
|
@@ -26,100 +26,79 @@ import AgreementsList from "./pages/agreements/list"; | |
import SingleAgreementEdit from "./pages/agreements/view-edit"; | ||
import SingleAgreementNew from "./pages/agreements/new"; | ||
import UxDashboard from "./pages/UxDashboard"; | ||
import isStagingEnvironment from "./features/isStagingEnvironment"; | ||
import SentryWrapper from "./features/SentryWrapper"; | ||
|
||
const SentryRoute = Sentry.withSentryRouting(Route); | ||
const history = createBrowserHistory(); | ||
|
||
if (process.env.NODE_ENV !== "test") { | ||
Sentry.init({ | ||
dsn: "https://[email protected]/4506320026664960", | ||
integrations: [ | ||
new Sentry.BrowserTracing({ | ||
routingInstrumentation: Sentry.reactRouterV5Instrumentation(history), | ||
}), | ||
], | ||
environment: _env_.REACT_APP_ENVIRONMENT, | ||
// trace all staging and locale traces and 70% of production traces | ||
tracesSampleRate: isStagingEnvironment() ? 1.0 : 0.7, | ||
// Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled | ||
tracePropagationTargets: [ | ||
"localhost", | ||
/^https:\/\/dev\.tryber\.me\/api/, | ||
/^https:\/\/tryber\.me\/api/, | ||
], | ||
|
||
// Capture Replay for 10% of all sessions, | ||
// plus for 100% of sessions with an error | ||
// do not capture for staging and locale | ||
replaysSessionSampleRate: isStagingEnvironment() ? 0.0 : 0.1, | ||
replaysOnErrorSampleRate: isStagingEnvironment() ? 0.0 : 1.0, | ||
}); | ||
} | ||
|
||
function App() { | ||
return ( | ||
<Provider store={setupStore()}> | ||
<ThemeProvider theme={aqBootstrapTheme}> | ||
<GlobalStyle /> | ||
<SiteWideMessages /> | ||
<BrowserRouter> | ||
<Router history={history}> | ||
<Switch> | ||
<SentryRoute | ||
path={`/backoffice/campaigns/:id/bugs`} | ||
component={BugsList} | ||
/> | ||
<SentryRoute | ||
path={`/backoffice/campaigns/:id/prospect`} | ||
component={Prospect} | ||
/> | ||
<SentryRoute path={`/backoffice/new`} component={Create} /> | ||
<SentryRoute | ||
path="/backoffice/payments" | ||
component={AdminPayments} | ||
/> | ||
<SentryRoute path="/backoffice/jotform" component={Jotform} /> | ||
<SentryRoute | ||
path="/backoffice/campaigns/preselection-forms/new" | ||
component={CampaignPreselection} | ||
/> | ||
<SentryRoute | ||
path="/backoffice/campaigns/preselection-forms/:id" | ||
component={CampaignPreselection} | ||
/> | ||
<SentryRoute | ||
path="/backoffice/campaigns/preselection-forms" | ||
component={CampaignPreselectionList} | ||
/> | ||
<SentryRoute | ||
path="/backoffice/campaigns/:id/selection" | ||
component={SelectionPage} | ||
/> | ||
<SentryRoute | ||
path="/backoffice/campaigns/:id/ux-dashboard" | ||
component={UxDashboard} | ||
/> | ||
<SentryRoute path="/backoffice/campaigns" component={Campaigns} /> | ||
<SentryRoute | ||
path="/backoffice/agreements/new" | ||
component={SingleAgreementNew} | ||
/> | ||
<SentryRoute | ||
path="/backoffice/agreements/:id" | ||
component={SingleAgreementEdit} | ||
/> | ||
<SentryRoute | ||
path="/backoffice/agreements" | ||
component={AgreementsList} | ||
/> | ||
<SentryRoute path={`/backoffice/:id`} component={Update} /> | ||
<SentryRoute path={`/backoffice`} component={List} /> | ||
</Switch> | ||
</Router> | ||
</BrowserRouter> | ||
</ThemeProvider> | ||
</Provider> | ||
<SentryWrapper history={history}> | ||
<Provider store={setupStore()}> | ||
<ThemeProvider theme={aqBootstrapTheme}> | ||
<GlobalStyle /> | ||
<SiteWideMessages /> | ||
<BrowserRouter> | ||
<Router history={history}> | ||
<Switch> | ||
<SentryRoute | ||
path={`/backoffice/campaigns/:id/bugs`} | ||
component={BugsList} | ||
/> | ||
<SentryRoute | ||
path={`/backoffice/campaigns/:id/prospect`} | ||
component={Prospect} | ||
/> | ||
<SentryRoute path={`/backoffice/new`} component={Create} /> | ||
<SentryRoute | ||
path="/backoffice/payments" | ||
component={AdminPayments} | ||
/> | ||
<SentryRoute path="/backoffice/jotform" component={Jotform} /> | ||
<SentryRoute | ||
path="/backoffice/campaigns/preselection-forms/new" | ||
component={CampaignPreselection} | ||
/> | ||
<SentryRoute | ||
path="/backoffice/campaigns/preselection-forms/:id" | ||
component={CampaignPreselection} | ||
/> | ||
<SentryRoute | ||
path="/backoffice/campaigns/preselection-forms" | ||
component={CampaignPreselectionList} | ||
/> | ||
<SentryRoute | ||
path="/backoffice/campaigns/:id/selection" | ||
component={SelectionPage} | ||
/> | ||
<SentryRoute | ||
path="/backoffice/campaigns/:id/ux-dashboard" | ||
component={UxDashboard} | ||
/> | ||
<SentryRoute | ||
path="/backoffice/campaigns" | ||
component={Campaigns} | ||
/> | ||
<SentryRoute | ||
path="/backoffice/agreements/new" | ||
component={SingleAgreementNew} | ||
/> | ||
<SentryRoute | ||
path="/backoffice/agreements/:id" | ||
component={SingleAgreementEdit} | ||
/> | ||
<SentryRoute | ||
path="/backoffice/agreements" | ||
component={AgreementsList} | ||
/> | ||
<SentryRoute path={`/backoffice/:id`} component={Update} /> | ||
<SentryRoute path={`/backoffice`} component={List} /> | ||
</Switch> | ||
</Router> | ||
</BrowserRouter> | ||
</ThemeProvider> | ||
</Provider> | ||
</SentryWrapper> | ||
); | ||
} | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,39 @@ | ||
import { useGetUsersMeQuery } from "src/services/tryberApi"; | ||
import * as Sentry from "@sentry/react"; | ||
import isStagingEnvironment from "./isStagingEnvironment"; | ||
import { RouterHistory } from "@sentry/react/types/reactrouter"; | ||
|
||
const SentryWrapper = ({ children }: { children: React.ReactNode }) => { | ||
const { data: user } = useGetUsersMeQuery({}); | ||
|
||
Sentry.setUser({ | ||
role: user?.role ?? "unknown", | ||
wp_user_id: user?.wp_user_id ?? 0, | ||
tester_id: user?.id ?? 0, | ||
}); | ||
const SentryWrapper = ({ | ||
children, | ||
history, | ||
}: { | ||
children: React.ReactNode; | ||
history: RouterHistory; | ||
}) => { | ||
if (process.env.NODE_ENV !== "test") { | ||
Sentry.init({ | ||
dsn: "https://[email protected]/4506337899511808", | ||
integrations: [ | ||
new Sentry.BrowserTracing({ | ||
routingInstrumentation: Sentry.reactRouterV5Instrumentation(history), | ||
}), | ||
], | ||
environment: _env_.REACT_APP_ENVIRONMENT, | ||
// trace all staging and locale traces and 70% of production traces | ||
tracesSampleRate: isStagingEnvironment() ? 1.0 : 0.7, | ||
// Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled | ||
tracePropagationTargets: [ | ||
"localhost", | ||
/^https:\/\/dev\.tryber\.me\/api/, | ||
/^https:\/\/tryber\.me\/api/, | ||
], | ||
release: _env_.REACT_APP_VERSION, | ||
// Capture Replay for 10% of all sessions, | ||
// plus for 100% of sessions with an error | ||
// do not capture for staging and locale | ||
replaysSessionSampleRate: isStagingEnvironment() ? 0.0 : 0.1, | ||
replaysOnErrorSampleRate: isStagingEnvironment() ? 0.0 : 1.0, | ||
}); | ||
} | ||
|
||
return <>{children}</>; | ||
}; | ||
|
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 |
---|---|---|
|
@@ -14,5 +14,6 @@ declare global { | |
|
||
var _env_: { | ||
REACT_APP_ENVIRONMENT: string; | ||
REACT_APP_VERSION: string; | ||
}; | ||
} |