Skip to content

Commit

Permalink
fix: restore form; add throw error button
Browse files Browse the repository at this point in the history
  • Loading branch information
mplewis committed Nov 20, 2024
1 parent f7c43ee commit f9bf536
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
10 changes: 10 additions & 0 deletions web/src/layouts/BaseLayout/BaseLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ const BaseLayout = ({ children }: BaseLayoutProps) => {
<>
<div className="is-max-desktop container px-4 pb-4">
<Navbar />
<div>
<button
onClick={() => {
throw new Error('Test error, please ignore')
}}
className="button is-danger"
>
Throw error
</button>
</div>
<Announcement msg={currentAnnouncement} />
{children}
<Footer />
Expand Down
51 changes: 25 additions & 26 deletions web/src/lib/sentry.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
import * as Sentry from '@sentry/react'

let dsn = ''
let environment = 'development'
function main() {
const SENTRY_DSN =
process.env.SENTRY_DSN ||
// HACK: Redwood+Netlify doesn't seem to be obeying our `includeEnvironmentVariables` setting
process.env.REDWOOD_ENV_SENTRY_DSN

// HACK: I think this helps the build rewrite find the env var
const SENTRY_DSN = process.env.SENTRY_DSN || process.env.REDWOOD_ENV_SENTRY_DSN
if (!SENTRY_DSN) {
console.error(
'Missing SENTRY_DSN environment variable. Sentry is disabled for now.'
)
return
}

console.log({ SENTRY_DSN, env: process.env })
const dsn = SENTRY_DSN
const environment = process.env.NODE_ENV

if (typeof process === 'undefined' || !SENTRY_DSN) {
console.error(
'Missing SENTRY_DSN environment variable. Did you forget to add it to ' +
'your redwood.toml file in `includeEnvironmentVariables`?'
)
console.info(`Copy this into your redwood.toml file:`)
console.info(`
includeEnvironmentVariables = [
"SENTRY_DSN"
]
Sentry.init({
dsn,
environment,
integrations: [new Sentry.BrowserTracing()],
tracesSampleRate: 1.0,
})

`)
console.error('Sentry is disabled for now')
} else {
dsn = SENTRY_DSN
environment = process.env.NODE_ENV
console.log('Sentry initialized', {
dsn,
environment,
processEnv: process.env,
})
}

Sentry.init({
dsn,
environment,
integrations: [new Sentry.BrowserTracing()],
tracesSampleRate: 1.0,
})
main()

export default Sentry
5 changes: 1 addition & 4 deletions web/src/pages/NewEventPage/NewEventPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ const NewEventPage = () => {
<Form
className="mt-3"
formMethods={formMethods}
onSubmit={(input: FormValues) => {
throw new Error('Test error, please ignore')
return { variables: { input } }
}}
onSubmit={(input: FormValues) => create({ variables: { input } })}
>
<FormField name="ownerEmail" text="Email Address*">
<Typ x="labelDetails">
Expand Down

0 comments on commit f9bf536

Please sign in to comment.