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:
@@ -1,5 +1,6 @@
|
|||||||
# Copy this to `.env` and `.env.test` files
|
# Copy this to `.env` and `.env.test` files
|
||||||
|
|
||||||
|
BITDRIFT_API_KEY=
|
||||||
SENTRY_AUTH_TOKEN=
|
SENTRY_AUTH_TOKEN=
|
||||||
EXPO_PUBLIC_ENV=development
|
EXPO_PUBLIC_ENV=development
|
||||||
EXPO_PUBLIC_LOG_LEVEL=debug
|
EXPO_PUBLIC_LOG_LEVEL=debug
|
||||||
|
|||||||
@@ -222,6 +222,7 @@ module.exports = function (config) {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
'react-native-compressor',
|
'react-native-compressor',
|
||||||
|
'@bitdrift/react-native',
|
||||||
'./plugins/starterPackAppClipExtension/withStarterPackAppClip.js',
|
'./plugins/starterPackAppClipExtension/withStarterPackAppClip.js',
|
||||||
'./plugins/withAndroidManifestPlugin.js',
|
'./plugins/withAndroidManifestPlugin.js',
|
||||||
'./plugins/withAndroidManifestFCMIconPlugin.js',
|
'./plugins/withAndroidManifestFCMIconPlugin.js',
|
||||||
|
|||||||
@@ -87,6 +87,12 @@ However, if you're a part of the Bluesky team and want to enable Sentry, fill in
|
|||||||
|
|
||||||
If you change `SENTRY_AUTH_TOKEN`, you need to do `yarn prebuild` before running `yarn ios` or `yarn android` again.
|
If you change `SENTRY_AUTH_TOKEN`, you need to do `yarn prebuild` before running `yarn ios` or `yarn android` again.
|
||||||
|
|
||||||
|
### Adding bitdrift
|
||||||
|
|
||||||
|
Adding bitdirft is NOT required. You can keep `BITDRIFT_API_KEY=` in `.env` which will avoid initializing bitdrift during startup.
|
||||||
|
|
||||||
|
However, if you're a part of the Bluesky team and want to enable bitdrift, fill in `BITDRIFT_API_KEY` in your `.env` to enable bitdrift.
|
||||||
|
|
||||||
### Adding and Updating Locales
|
### Adding and Updating Locales
|
||||||
|
|
||||||
- `yarn intl:build` -> you will also need to run this anytime `./src/locale/{locale}/messages.po` change
|
- `yarn intl:build` -> you will also need to run this anytime `./src/locale/{locale}/messages.po` change
|
||||||
|
|||||||
@@ -55,6 +55,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@atproto/api": "^0.13.18",
|
"@atproto/api": "^0.13.18",
|
||||||
|
"@bitdrift/react-native": "0.4.0",
|
||||||
"@braintree/sanitize-url": "^6.0.2",
|
"@braintree/sanitize-url": "^6.0.2",
|
||||||
"@discord/bottom-sheet": "bluesky-social/react-native-bottom-sheet",
|
"@discord/bottom-sheet": "bluesky-social/react-native-bottom-sheet",
|
||||||
"@emoji-mart/react": "^1.1.1",
|
"@emoji-mart/react": "^1.1.1",
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
## expo-modules-core Patch
|
||||||
|
|
||||||
|
This patch fixes an issue where bitdrift's API stream gets blocked by the Expo interceptor used to power the devtools
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
diff --git a/node_modules/expo-modules-core/android/src/main/java/expo/modules/kotlin/devtools/ExpoNetworkInspectOkHttpInterceptors.kt b/node_modules/expo-modules-core/android/src/main/java/expo/modules/kotlin/devtools/ExpoNetworkInspectOkHttpInterceptors.kt
|
||||||
|
index 47c4d15..afe138d 100644
|
||||||
|
--- a/node_modules/expo-modules-core/android/src/main/java/expo/modules/kotlin/devtools/ExpoNetworkInspectOkHttpInterceptors.kt
|
||||||
|
+++ b/node_modules/expo-modules-core/android/src/main/java/expo/modules/kotlin/devtools/ExpoNetworkInspectOkHttpInterceptors.kt
|
||||||
|
@@ -125,6 +125,10 @@ internal fun peekResponseBody(
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun shouldParseBody(response: Response): Boolean {
|
||||||
|
+ if (response.request.url.encodedPath == "/bitdrift_public.protobuf.client.v1.ApiService/Mux") {
|
||||||
|
+ return false
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
// Check for Content-Type
|
||||||
|
val skipContentTypes = listOf(
|
||||||
|
"text/event-stream", // Server Sent Events
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'react-native-url-polyfill/auto'
|
import 'react-native-url-polyfill/auto'
|
||||||
import '#/lib/sentry' // must be near top
|
import '#/lib/sentry' // must be near top
|
||||||
|
import '#/lib/bitdrift' // must be near top
|
||||||
import '#/view/icons'
|
import '#/view/icons'
|
||||||
|
|
||||||
import React, {useEffect, useState} from 'react'
|
import React, {useEffect, useState} from 'react'
|
||||||
|
|||||||
@@ -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'})
|
||||||
|
}
|
||||||
@@ -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 format from 'date-fns/format'
|
||||||
import {nanoid} from 'nanoid/non-secure'
|
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 = (
|
export const sentryTransport: Transport = (
|
||||||
level,
|
level,
|
||||||
message,
|
message,
|
||||||
@@ -328,6 +348,10 @@ export class Logger {
|
|||||||
*/
|
*/
|
||||||
export const logger = new Logger()
|
export const logger = new Logger()
|
||||||
|
|
||||||
|
if (!env.IS_TEST) {
|
||||||
|
logger.addTransport(bitdriftTransport)
|
||||||
|
}
|
||||||
|
|
||||||
if (env.IS_DEV && !env.IS_TEST) {
|
if (env.IS_DEV && !env.IS_TEST) {
|
||||||
logger.addTransport(consoleTransport)
|
logger.addTransport(consoleTransport)
|
||||||
|
|
||||||
|
|||||||
@@ -3377,6 +3377,11 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||||
|
|
||||||
|
"@bitdrift/react-native@0.4.0":
|
||||||
|
version "0.4.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@bitdrift/react-native/-/react-native-0.4.0.tgz#e6484343ef04824aa924df2a757bd9620b2106c1"
|
||||||
|
integrity sha512-KuYzWEkoGwjjP0ZurjHwV+zfRZjQXxbXa3zhijWv0iqzMI/7kbrBd9lm+wNQo8OrkqFVDlebCb8AGPc0jMZw7A==
|
||||||
|
|
||||||
"@braintree/sanitize-url@^6.0.2":
|
"@braintree/sanitize-url@^6.0.2":
|
||||||
version "6.0.4"
|
version "6.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/@braintree/sanitize-url/-/sanitize-url-6.0.4.tgz#923ca57e173c6b232bbbb07347b1be982f03e783"
|
resolved "https://registry.yarnpkg.com/@braintree/sanitize-url/-/sanitize-url-6.0.4.tgz#923ca57e173c6b232bbbb07347b1be982f03e783"
|
||||||
|
|||||||
Reference in New Issue
Block a user