Reserve context prop on metadata and include in transports
This commit is contained in:
@@ -22,5 +22,9 @@ export const bitdriftTransport: Transport = (
|
||||
metadata,
|
||||
) => {
|
||||
const log = logFunctions[level]
|
||||
log(`(${context}) ${message}`, prepareMetadata(metadata))
|
||||
log(message.toString(), {
|
||||
// match Sentry payload
|
||||
context,
|
||||
...prepareMetadata(metadata),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -10,7 +10,17 @@ export const sentryTransport: Transport = (
|
||||
{type, tags, ...metadata},
|
||||
timestamp,
|
||||
) => {
|
||||
const meta = prepareMetadata(metadata)
|
||||
const meta = {
|
||||
// match Bitdrift payload
|
||||
context,
|
||||
...prepareMetadata(metadata),
|
||||
}
|
||||
let _tags = tags || {}
|
||||
_tags = {
|
||||
// use `category` to match breadcrumbs
|
||||
category: context,
|
||||
...tags,
|
||||
}
|
||||
|
||||
/**
|
||||
* If a string, report a breadcrumb
|
||||
@@ -46,9 +56,9 @@ export const sentryTransport: Transport = (
|
||||
*/
|
||||
if (level === 'error' || level === 'warn' || level === 'log') {
|
||||
// Defer non-critical messages so they're sent in a batch
|
||||
queueMessageForSentry(`(${context}) message`, {
|
||||
queueMessageForSentry(message, {
|
||||
level: severity,
|
||||
tags,
|
||||
tags: _tags,
|
||||
extra: meta,
|
||||
})
|
||||
}
|
||||
@@ -57,7 +67,7 @@ export const sentryTransport: Transport = (
|
||||
* It's otherwise an Error and should be reported with captureException
|
||||
*/
|
||||
Sentry.captureException(message, {
|
||||
tags,
|
||||
tags: _tags,
|
||||
extra: meta,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -32,6 +32,11 @@ export type Transport = (
|
||||
* `captureException` parameter, `CaptureContext`.
|
||||
*/
|
||||
export type Metadata = {
|
||||
/**
|
||||
* Reserved for appending `LogContext` to logging payloads
|
||||
*/
|
||||
context?: undefined
|
||||
|
||||
/**
|
||||
* Applied as Sentry breadcrumb types. Defaults to `default`.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user