Clean up context, use it, pass metadata through to Bitdrift
This commit is contained in:
@@ -14,7 +14,12 @@ const logFunctions = {
|
|||||||
[LogLevel.Error]: bdError,
|
[LogLevel.Error]: bdError,
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export const bitdriftTransport: Transport = (level, _context, message) => {
|
export const bitdriftTransport: Transport = (
|
||||||
|
level,
|
||||||
|
context,
|
||||||
|
message,
|
||||||
|
metadata,
|
||||||
|
) => {
|
||||||
const log = logFunctions[level]
|
const log = logFunctions[level]
|
||||||
log('' + message)
|
log(`(${context}) ${message}`, metadata)
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-10
@@ -9,7 +9,8 @@ export enum LogContext {
|
|||||||
Default = 'logger',
|
Default = 'logger',
|
||||||
Session = 'session',
|
Session = 'session',
|
||||||
Notifications = 'notifications',
|
Notifications = 'notifications',
|
||||||
Convo = 'convo',
|
ConversationAgent = 'conversation-agent',
|
||||||
|
DMsAgent = 'dms-agent',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum LogLevel {
|
export enum LogLevel {
|
||||||
@@ -56,19 +57,23 @@ export type Metadata = {
|
|||||||
* @see https://github.com/getsentry/sentry-javascript/blob/903addf9a1a1534a6cb2ba3143654b918a86f6dd/packages/types/src/misc.ts#L65
|
* @see https://github.com/getsentry/sentry-javascript/blob/903addf9a1a1534a6cb2ba3143654b918a86f6dd/packages/types/src/misc.ts#L65
|
||||||
*/
|
*/
|
||||||
tags?: {
|
tags?: {
|
||||||
[key: string]:
|
[key: string]: number | string | boolean | null | undefined
|
||||||
| number
|
|
||||||
| string
|
|
||||||
| boolean
|
|
||||||
| bigint
|
|
||||||
| symbol
|
|
||||||
| null
|
|
||||||
| undefined
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Any additional data, passed through to Sentry as `extra` param on
|
* Any additional data, passed through to Sentry as `extra` param on
|
||||||
* exceptions, or the `data` param on breadcrumbs.
|
* exceptions, or the `data` param on breadcrumbs.
|
||||||
*/
|
*/
|
||||||
[key: string]: unknown
|
[key: string]: Serializable
|
||||||
} & Parameters<typeof Sentry.captureException>[1]
|
} & Parameters<typeof Sentry.captureException>[1]
|
||||||
|
|
||||||
|
export type Serializable =
|
||||||
|
| string
|
||||||
|
| number
|
||||||
|
| boolean
|
||||||
|
| null
|
||||||
|
| undefined
|
||||||
|
| Serializable[]
|
||||||
|
| {
|
||||||
|
[key: string]: Serializable
|
||||||
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import {MessagesEventBus} from '#/state/messages/events/agent'
|
|||||||
import {MessagesEventBusError} from '#/state/messages/events/types'
|
import {MessagesEventBusError} from '#/state/messages/events/types'
|
||||||
import {DM_SERVICE_HEADERS} from '#/state/queries/messages/const'
|
import {DM_SERVICE_HEADERS} from '#/state/queries/messages/const'
|
||||||
|
|
||||||
const logger = Logger.create(Logger.Context.Convo)
|
const logger = Logger.create(Logger.Context.ConversationAgent)
|
||||||
|
|
||||||
export function isConvoItemMessage(
|
export function isConvoItemMessage(
|
||||||
item: ConvoItem,
|
item: ConvoItem,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import {
|
|||||||
import {DM_SERVICE_HEADERS} from '#/state/queries/messages/const'
|
import {DM_SERVICE_HEADERS} from '#/state/queries/messages/const'
|
||||||
|
|
||||||
const LOGGER_CONTEXT = 'MessagesEventBus'
|
const LOGGER_CONTEXT = 'MessagesEventBus'
|
||||||
const logger = Logger.create(Logger.Context.Convo)
|
const logger = Logger.create(Logger.Context.DMsAgent)
|
||||||
|
|
||||||
export class MessagesEventBus {
|
export class MessagesEventBus {
|
||||||
private id: string
|
private id: string
|
||||||
|
|||||||
Reference in New Issue
Block a user