-
-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathindex.ts
More file actions
36 lines (30 loc) · 1.01 KB
/
index.ts
File metadata and controls
36 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { getSendMetricsSetting } from '../../stores/settings/app'
import * as Sentry from '@sentry/react-native'
import LoggingContext from './enums'
export { default as LoggingContext } from './enums'
export const captureError = (error: unknown, context: LoggingContext, message?: string) => {
console.error(`Captured Error [${context}]:`, message ?? '', error)
const sendMetrics = getSendMetricsSetting()
if (sendMetrics) {
Sentry.captureException(error, {
contexts: {
logging: { context, message },
},
})
}
}
export const captureWarning = (context: LoggingContext, message: string, error?: unknown) => {
console.warn(`Captured Warning [${context}]:`, message, error ?? '')
const sendMetrics = getSendMetricsSetting()
if (sendMetrics) {
Sentry.captureMessage(message, {
level: 'warning',
contexts: {
logging: { context, error: error ? String(error) : undefined },
},
})
}
}
export const captureInfo = (context: LoggingContext, message: string) => {
console.info(`[${context}]:`, message)
}