Skip to content

Commit

Permalink
feat(sentry): log tracking and prod mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Aug 30, 2022
1 parent b575487 commit e423fc0
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 14 deletions.
64 changes: 50 additions & 14 deletions packages/better-write-app/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,55 @@ useRegisterSW({
},
})

Sentry.init({
app,
dsn: env.getSentryDsn(),
integrations: [
new BrowserTracing({
routingInstrumentation: Sentry.vueRouterInstrumentation(router),
tracingOrigins: ['localhost', env.getProdUrl(), /^\//],
}),
],
logErrors: true,
tracesSampleRate: env.isDev() ? 0.0 : 0.25,
trackComponents: true,
hooks: ['activate', 'mount', 'update', 'destroy', 'create'],
})
// @ts-ignore
const { t } = i18n.global

if (!env.isDev()) {
Sentry.init({
app,
dsn: env.getSentryDsn(),
integrations: [
new BrowserTracing({
routingInstrumentation: Sentry.vueRouterInstrumentation(router),
tracingOrigins: [env.getProdUrl(), /^\//],
}),
],
beforeSend(event, _) {
if (event.exception) {
Sentry.showReportDialog({
eventId: event.event_id,
// @ts-ignore
title: t('plugin.sentry.errorWidget.title'),
// @ts-ignore
subtitle: t('plugin.sentry.errorWidget.subtitle'),
// @ts-ignore
subtitle2: t('plugin.sentry.errorWidget.subtitle2'),
// @ts-ignore
labelName: t('plugin.sentry.errorWidget.labelName'),
// @ts-ignore
labelEmail: t('plugin.sentry.errorWidget.labelEmail'),
// @ts-ignore
labelComments: t('plugin.sentry.errorWidget.labelComments'),
// @ts-ignore
labelClose: t('plugin.sentry.errorWidget.labelClose'),
// @ts-ignore
labelSubmit: t('plugin.sentry.errorWidget.labelSubmit'),
// @ts-ignore
errorGeneric: t('plugin.sentry.errorWidget.errorGeneric'),
// @ts-ignore
errorFormEntry: t('plugin.sentry.errorWidget.errorFormEntry'),
// @ts-ignore
successMessage: t('plugin.sentry.errorWidget.successMessage'),
})
}

return event
},
logErrors: true,
tracesSampleRate: 0.5,
trackComponents: true,
hooks: ['activate', 'mount', 'update', 'destroy', 'create'],
})
}

router.isReady().then(() => app.mount('#app'))
2 changes: 2 additions & 0 deletions packages/better-write-languages/src/en-US/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import dashboard from './dashboard'
import questions from './questions'
import plans from './plans'
import logger from './plugin/logger'
import sentry from './plugin/sentry'

export default {
editor,
Expand All @@ -21,6 +22,7 @@ export default {
questions,
plugin: {
logger,
sentry,
},
generics: {
input: {
Expand Down
18 changes: 18 additions & 0 deletions packages/better-write-languages/src/en-US/plugin/sentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default {
errorWidget: {
title: 'It looks like we’re having issues.',
subtitle: 'Our team has been notified.',
subtitle2:
'If you’d like to help, tell us what happened below. – not visible on small screen resolutions',
labelName: 'Name',
labelEmail: 'Email',
labelComments: 'What happened?',
labelClose: 'Close',
labelSubmit: 'Submit',
errorGeneric:
'An unknown error occurred while submitting your report. Please try again.',
errorFormEntry:
'Some fields were invalid. Please correct the errors and try again.',
successMessage: 'Your feedback has been sent. Thank you!',
},
}
2 changes: 2 additions & 0 deletions packages/better-write-languages/src/pt-BR/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import dashboard from './dashboard'
import questions from './questions'
import plans from './plans'
import logger from './plugin/logger'
import sentry from './plugin/sentry'

export default {
editor,
Expand All @@ -21,6 +22,7 @@ export default {
questions,
plugin: {
logger,
sentry,
},
generics: {
input: {
Expand Down
17 changes: 17 additions & 0 deletions packages/better-write-languages/src/pt-BR/plugin/sentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default {
errorWidget: {
title: 'Parece que estamos com problemas.',
subtitle: 'Nossa equipe foi avisada.',
subtitle2: 'Se você quiser ajudar, conte-nos o que aconteceu abaixo.',
labelName: 'Nome',
labelEmail: 'Email',
labelComments: 'O que aconteceu?',
labelClose: 'Fechar',
labelSubmit: 'Enviar',
errorGeneric:
'Ocorreu um erro desconhecido ao enviar seu relatório. Por favor, tente novamente.',
errorFormEntry:
'Alguns campos eram inválidos. Corrija os erros e tente novamente.',
successMessage: 'Seu feedback foi enviado. Obrigada!',
},
}

0 comments on commit e423fc0

Please sign in to comment.