forked from bluesky-social/social-app
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix web build * Fix circular deps * Hoist log functions
- Loading branch information
Showing
4 changed files
with
105 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { | ||
debug as bdDebug, | ||
error as bdError, | ||
info as bdInfo, | ||
warn as bdWarn, | ||
} from '@bitdrift/react-native' | ||
|
||
import {LogLevel, Transport} from './types' | ||
|
||
export function createBitdriftTransport(): Transport { | ||
const logFunctions = { | ||
[LogLevel.Debug]: bdDebug, | ||
[LogLevel.Info]: bdInfo, | ||
[LogLevel.Log]: bdInfo, | ||
[LogLevel.Warn]: bdWarn, | ||
[LogLevel.Error]: bdError, | ||
} as const | ||
|
||
return (level, message) => { | ||
const log = logFunctions[level] | ||
log(message.toString()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {Transport} from './index' | ||
|
||
export function createBitdriftTransport(): Transport { | ||
return (_level, _message) => { | ||
// noop | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import type {Sentry} from '#/logger/sentry' | ||
|
||
export enum LogLevel { | ||
Debug = 'debug', | ||
Info = 'info', | ||
Log = 'log', | ||
Warn = 'warn', | ||
Error = 'error', | ||
} | ||
|
||
export type Transport = ( | ||
level: LogLevel, | ||
message: string | Error, | ||
metadata: Metadata, | ||
timestamp: number, | ||
) => void | ||
|
||
/** | ||
* A union of some of Sentry's breadcrumb properties as well as Sentry's | ||
* `captureException` parameter, `CaptureContext`. | ||
*/ | ||
export type Metadata = { | ||
/** | ||
* Applied as Sentry breadcrumb types. Defaults to `default`. | ||
* | ||
* @see https://develop.sentry.dev/sdk/event-payloads/breadcrumbs/#breadcrumb-types | ||
*/ | ||
type?: | ||
| 'default' | ||
| 'debug' | ||
| 'error' | ||
| 'navigation' | ||
| 'http' | ||
| 'info' | ||
| 'query' | ||
| 'transaction' | ||
| 'ui' | ||
| 'user' | ||
|
||
/** | ||
* Passed through to `Sentry.captureException` | ||
* | ||
* @see https://github.com/getsentry/sentry-javascript/blob/903addf9a1a1534a6cb2ba3143654b918a86f6dd/packages/types/src/misc.ts#L65 | ||
*/ | ||
tags?: { | ||
[key: string]: | ||
| number | ||
| string | ||
| boolean | ||
| bigint | ||
| symbol | ||
| null | ||
| undefined | ||
} | ||
|
||
/** | ||
* Any additional data, passed through to Sentry as `extra` param on | ||
* exceptions, or the `data` param on breadcrumbs. | ||
*/ | ||
[key: string]: unknown | ||
} & Parameters<typeof Sentry.captureException>[1] | ||
|
||
export type ConsoleTransportEntry = { | ||
id: string | ||
timestamp: number | ||
level: LogLevel | ||
message: string | Error | ||
metadata: Metadata | ||
} |