Use ol_spell_check_language tag for error reporting (#21126)

GitOrigin-RevId: 11580f8dca22b0d4858dc5db36827b69a3637371
This commit is contained in:
Alf Eaton 2024-10-16 11:54:35 +01:00 committed by Copybot
parent 17b66e495f
commit a238b8eee4
4 changed files with 11 additions and 4 deletions

View file

@ -127,7 +127,7 @@ export class SpellChecker {
debugConsole.error(result.error) debugConsole.error(result.error)
captureException( captureException(
new Error('Error running spellcheck for word'), new Error('Error running spellcheck for word'),
{ language: this.language } { tags: { ol_spell_check_language: this.language } }
) )
} else { } else {
processResult(result.misspellings) processResult(result.misspellings)

View file

@ -66,7 +66,7 @@ export const SpellingSuggestions: FC<{
}) })
.catch(error => { .catch(error => {
captureException(error, { captureException(error, {
language: spellCheckLanguage, tags: { ol_spell_check_language: spellCheckLanguage },
}) })
debugConsole.error(error) debugConsole.error(error)
}) })

View file

@ -161,7 +161,7 @@ export class HunspellManager {
this.loaded = true this.loaded = true
} else if (rest.loadingFailed) { } else if (rest.loadingFailed) {
captureException(new Error('Spell check loading failed'), { captureException(new Error('Spell check loading failed'), {
language: this.language, tags: { ol_spell_check_language: this.language },
}) })
this.loadingFailed = true this.loadingFailed = true
this.pendingMessages.length = 0 this.pendingMessages.length = 0

View file

@ -101,7 +101,14 @@ function nullReporter() {
}) })
} }
export function captureException(err: Error, options?: Record<string, any>) { // https://develop.sentry.dev/sdk/data-model/event-payloads/contexts/
// https://docs.sentry.io/platforms/javascript/enriching-events/context/#passing-context-directly
type Options = {
tags?: Record<string, any>
extra?: Record<string, any>
}
export function captureException(err: Error, options?: Options) {
options = options || {} options = options || {}
const extra = Object.assign(OError.getFullInfo(err), options.extra || {}) const extra = Object.assign(OError.getFullInfo(err), options.extra || {})
const fullStack = OError.getFullStack(err) const fullStack = OError.getFullStack(err)