configure the bitdrift Capture SDK (#6979)

* configure bitdrift Capture SDK

* remove console log

* use the new url

* add patch to fix devtool interaction

* update patches

* fix patch

* add BITDRIFT_API_KEY to .env.example
This commit is contained in:
Snow Pettersen
2024-12-11 20:28:15 -08:00
committed by GitHub
parent c8745a9ab0
commit 20ac42a5a3
10 changed files with 64 additions and 0 deletions
+1
View File
@@ -1,5 +1,6 @@
import 'react-native-url-polyfill/auto'
import '#/lib/sentry' // must be near top
import '#/lib/bitdrift' // must be near top
import '#/view/icons'
import React, {useEffect, useState} from 'react'
+7
View File
@@ -0,0 +1,7 @@
import {init} from '@bitdrift/react-native'
const BITDRIFT_API_KEY = process.env.BITDRIFT_API_KEY
if (BITDRIFT_API_KEY) {
init(BITDRIFT_API_KEY, {url: 'https://api-bsky.bitdrift.io'})
}
+24
View File
@@ -1,3 +1,9 @@
import {
debug as bdDebug,
error as bdError,
info as bdInfo,
warn as bdWarn,
} from '@bitdrift/react-native'
import format from 'date-fns/format'
import {nanoid} from 'nanoid/non-secure'
@@ -131,6 +137,20 @@ export const consoleTransport: Transport = (
}
}
export const bitdriftTransport: Transport = (level, message) => {
const log = (
{
[LogLevel.Debug]: bdDebug,
[LogLevel.Info]: bdInfo,
[LogLevel.Log]: bdInfo,
[LogLevel.Warn]: bdWarn,
[LogLevel.Error]: bdError,
} as const
)[level]
log(message.toString())
}
export const sentryTransport: Transport = (
level,
message,
@@ -328,6 +348,10 @@ export class Logger {
*/
export const logger = new Logger()
if (!env.IS_TEST) {
logger.addTransport(bitdriftTransport)
}
if (env.IS_DEV && !env.IS_TEST) {
logger.addTransport(consoleTransport)