Colocate bitdrift in logger, use logger for transport (#7868)

* Colocate bitdrift in logger, use logger for transport

(cherry picked from commit cdd6941fd7)

* Fix mocks, format

(cherry picked from commit 9de88660c6)

* Ok I guess mocks dir doesn't work

(cherry picked from commit 9f37e52011)
This commit is contained in:
Eric Bailey
2025-02-28 12:46:27 -06:00
committed by GitHub
parent 7c36ea1158
commit 36a7a8d8c6
9 changed files with 15 additions and 23 deletions
+1
View File
@@ -0,0 +1 @@
export {debug, error, info, warn} from '@bitdrift/react-native'
+4
View File
@@ -0,0 +1,4 @@
export function debug() {}
export function error() {}
export function info() {}
export function warn() {}
+28
View File
@@ -0,0 +1,28 @@
import {init, SessionStrategy} from '@bitdrift/react-native'
import {Statsig} from 'statsig-react-native-expo'
import {initPromise} from '#/lib/statsig/statsig'
const BITDRIFT_API_KEY = process.env.BITDRIFT_API_KEY
initPromise.then(() => {
let isEnabled = false
let isNetworkEnabled = false
try {
if (Statsig.checkGate('enable_bitdrift_v2')) {
isEnabled = true
}
if (Statsig.checkGate('enable_bitdrift_v2_networking')) {
isNetworkEnabled = true
}
} catch (e) {
// Statsig may complain about it being called too early.
}
if (isEnabled && BITDRIFT_API_KEY) {
init(BITDRIFT_API_KEY, SessionStrategy.Activity, {
url: 'https://api-bsky.bitdrift.io',
// Only effects iOS, Android instrumentation is set via Gradle Plugin
enableNetworkInstrumentation: isNetworkEnabled,
})
}
})