Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QA Update DataDog SDK and change initialization #2193

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/core-mobile/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ dependencies {
} else {
implementation jscFlavor
}

}

task deleteDuplicateDependencies(type: Delete) {
Expand Down
44 changes: 26 additions & 18 deletions packages/core-mobile/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,38 @@ import { navigationRef } from 'utils/Navigation'
import SentryService from 'services/sentry/SentryService'
import DataDogService from 'services/datadog/DataDogService'
import Logger from 'utils/Logger'
import { DatadogProvider } from '@datadog/mobile-react-native'
import { getDatadogConfig } from 'services/datadog/DataDogConfig'
import { SessionReplay } from '@datadog/mobile-react-native-session-replay'

function App(): JSX.Element {
const context = useApplicationContext()
const [backgroundStyle] = useState(context.appBackgroundStyle)

SessionReplay.enable()
console.log(getDatadogConfig())

return (
<SafeAreaView style={backgroundStyle}>
<KeyboardAvoidingView
enabled={context.keyboardAvoidingViewEnabled}
style={{ flex: 1 }}
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}>
<NavigationContainer
theme={context.navContainerTheme}
ref={navigationRef}
onReady={() => {
SentryService.routingInstrumentation.registerNavigationContainer(
navigationRef
)
DataDogService.init(navigationRef).catch(Logger.error)
}}>
<RootScreenStack />
</NavigationContainer>
</KeyboardAvoidingView>
</SafeAreaView>
<DatadogProvider configuration={getDatadogConfig()}>
<SafeAreaView style={backgroundStyle}>
<KeyboardAvoidingView
enabled={context.keyboardAvoidingViewEnabled}
style={{ flex: 1 }}
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}>
<NavigationContainer
theme={context.navContainerTheme}
ref={navigationRef}
onReady={() => {
SentryService.routingInstrumentation.registerNavigationContainer(
navigationRef
)
DataDogService.init(navigationRef).catch(Logger.error)
}}>
<RootScreenStack />
</NavigationContainer>
</KeyboardAvoidingView>
</SafeAreaView>
</DatadogProvider>
)
}

Expand Down
47 changes: 26 additions & 21 deletions packages/core-mobile/app/services/datadog/DataDogConfig.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
import {
DdSdkReactNativeConfiguration,
TrackingConsent
TrackingConsent,
DatadogProviderConfiguration,
SdkVerbosity,
InitializationMode,
BatchSize
} from '@datadog/mobile-react-native'
import Config from 'react-native-config'
import DeviceInfo from 'react-native-device-info'

let DataDogConfig: DdSdkReactNativeConfiguration | null = null
import {
APPLICATION_ID,
CLIENT_TOKEN,
ENVIRONMENT,
SITE
} from './ddCredentials'

if (
Config.DD_CLIENT_TOKEN &&
Config.ENVIRONMENT &&
Config.DD_APPLICATION_ID &&
Config.DD_SITE &&
process.env.CI
) {
DataDogConfig = new DdSdkReactNativeConfiguration(
Config.DD_CLIENT_TOKEN,
Config.ENVIRONMENT,
Config.DD_APPLICATION_ID,
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export function getDatadogConfig() {
const DataDogConfig = new DatadogProviderConfiguration(
CLIENT_TOKEN,
ENVIRONMENT,
APPLICATION_ID,
true,
true,
true,
TrackingConsent.GRANTED
TrackingConsent.GRANTED,
true
)

DataDogConfig.site = Config.DD_SITE
DataDogConfig.nativeCrashReportEnabled = true
DataDogConfig.nativeViewTracking = true
DataDogConfig.sessionSamplingRate = 100
DataDogConfig.nativeViewTracking = true
DataDogConfig.resourceTracingSamplingRate = 100
DataDogConfig.site = SITE
DataDogConfig.version = DeviceInfo.getBuildNumber()
}
DataDogConfig.verbosity = SdkVerbosity.DEBUG
DataDogConfig.initializationMode = InitializationMode.ASYNC
DataDogConfig.batchSize = BatchSize.SMALL

export default DataDogConfig
return DataDogConfig
}
4 changes: 4 additions & 0 deletions packages/core-mobile/app/services/datadog/ddCredentials.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const APPLICATION_ID = `${process.env.DD_APP_KEY}`
export const CLIENT_TOKEN = `${process.env.DD_API_KEY}`
export const ENVIRONMENT = `production`
export const SITE = `US1`
3 changes: 2 additions & 1 deletion packages/core-mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"@coinbase/cbpay-js": "2.2.1",
"@cubist-labs/cubesigner-sdk": "0.3.29",
"@cubist-labs/cubesigner-sdk-ethers-v6": "0.3.29",
"@datadog/mobile-react-native": "2.4.3",
"@datadog/mobile-react-native": "^2.6.1",
"@datadog/mobile-react-native-session-replay": "^2.6.1",
"@datadog/mobile-react-navigation": "2.4.3",
"@date-fns/utc": "2.1.0",
"@ethereumjs/common": "4.4.0",
Expand Down
27 changes: 20 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ __metadata:
"@coinbase/cbpay-js": 2.2.1
"@cubist-labs/cubesigner-sdk": 0.3.29
"@cubist-labs/cubesigner-sdk-ethers-v6": 0.3.29
"@datadog/mobile-react-native": 2.4.3
"@datadog/mobile-react-native": ^2.6.1
"@datadog/mobile-react-native-session-replay": ^2.6.1
"@datadog/mobile-react-navigation": 2.4.3
"@date-fns/utc": 2.1.0
"@dlenroc/testrail": 1.9.1
Expand Down Expand Up @@ -4418,13 +4419,25 @@ __metadata:
languageName: node
linkType: hard

"@datadog/mobile-react-native@npm:2.4.3":
version: 2.4.3
resolution: "@datadog/mobile-react-native@npm:2.4.3"
"@datadog/mobile-react-native-session-replay@npm:^2.6.1":
version: 2.6.1
resolution: "@datadog/mobile-react-native-session-replay@npm:2.6.1"
peerDependencies:
react: ">=16.13.1"
react-native: ">=0.63.4 <1.0"
checksum: d3dc37582ef56df3d48fc7a230ef5422e399843986d2ed57c190ccb93cc6c9548b75fdaa5ecf3195b17bed29fe5fc4fd0f803c4e86a73bed471d4930e760474b
languageName: node
linkType: hard

"@datadog/mobile-react-native@npm:^2.6.1":
version: 2.6.1
resolution: "@datadog/mobile-react-native@npm:2.6.1"
dependencies:
big-integer: ^1.6.52
peerDependencies:
react: ">=16.13.1"
react-native: ">=0.63.4 <1.0"
checksum: c1baa070ce4ebc88c6e0e5237704a7cf16df343cf735cbe04494b32b9de9bdacdb93d0c218cad8bc074f29709d54a356b5bdd09573c9343c242f7093698bd100
checksum: c62383f2191e85cf99820730911282c1d08e3a1a0f6258a3f41dd9ee9828d3ca7b6d504407bcf058ed2065548b99c8ddff4fc63754dc8c26e5cbe43188a5e4d8
languageName: node
linkType: hard

Expand Down Expand Up @@ -13574,7 +13587,7 @@ __metadata:
languageName: node
linkType: hard

"big-integer@npm:1.6.x":
"big-integer@npm:1.6.x, big-integer@npm:^1.6.52":
version: 1.6.52
resolution: "big-integer@npm:1.6.52"
checksum: 6e86885787a20fed96521958ae9086960e4e4b5e74d04f3ef7513d4d0ad631a9f3bde2730fc8aaa4b00419fc865f6ec573e5320234531ef37505da7da192c40b
Expand Down Expand Up @@ -26645,7 +26658,7 @@ react-native-webview@ava-labs/react-native-webview:
peerDependencies:
react: "*"
react-native: "*"
checksum: d396f3dea807077e8789e1d463c87024e1633481d3dff53c0650c82a08d8b7d699db97ceab4e8d2c9de85c3d5378d192c968487254c62edadff77e82a9b8c929
checksum: 6cff7c4794fb7ae57c535938762daadaacf6140901fd4c2c575275aaeaee6586ee40e190b3a243498b67e2d766ad1c2da737d30aa0f15e29bf6f4e04b8fcec0c
languageName: node
linkType: hard

Expand Down