How datadog/dd-sdk-reactnative works
Project Type and Purpose
• This is a monorepo for an open-source React Native SDK maintained by Datadog.
• It contains multiple platform-specific and JS/TS packages (core monitoring, codepush, Apollo Client integration, navigation instrumentation, session replay, WebView instrumentation, internal testing tools).
• It uses Yarn Plug’n’Play (v3+), Lerna for package orchestration, and includes example apps demonstrating usage.
File Structure Analysis
• Top-level:
– package.json, lerna.json, .yarnrc.yml, Yarn Plug’n’Play files, Makefile, CI configs (.github/workflows, .gitlab-ci.yml).
– docs/, CONTRIBUTING.md, LICENSE, troubleshooting, version-update scripts.
– example-apps: example/ and example-new-architecture/ showing React Native apps consuming the SDK.
• packages/: each subfolder is an independently versioned package with:
– a JS/TS layer (src/, __tests__),
– native Android code (android/src/newarch & oldarch),
– native iOS code (ios/Sources & Tests),
– package.json, CI/test configs.
• Build & release: custom Gradle scripts, CocoaPods podspecs, Babel configs, TypeScript configs for each package.
Core Components
a. Monorepo Orchestrator
– Yarn v3 Plug’n’Play & Lerna
– CI/CD pipelines (GitHub Actions, GitLab CI)
1. core
2. codepush
3. internal-testing-tools
4. react-native-apollo-client
5. react-native-navigation
6. react-native-session-replay
7. react-native-webview
8. react-navigation
c. Example Applications
– example (classic RN app)
– example-new-architecture (TurboModules / New Architecture RN app)
d. Native Layers within each package
– Android (Kotlin modules: newarch vs oldarch)
– iOS (Swift/Obj-C sources, Podspecs)
e. JS/TS Bridge Layer
– React Native NativeModules proxies in TypeScript
– Instrumentation (DD-Rum, DD-Logs, DD-Trace event mappers)
Interactions & Data Flows
• Developer invokes Yarn/Lerna → installs all packages → links native modules into RN project.
• Example apps import NPM modules → JS/TS layer calls NativeModules → bridges into Android/iOS SDK wrappers → forwards data to Datadog backend.
• CI job: runs tests per package (jest, unit tests for Android & iOS) → builds artifacts → publishes to npm/CocoaPods/Maven.
Architectural Patterns & Principles
• Monorepo modularity: each concern is isolated as a package.
• Layered architecture per package:
– Presentation/JS layer (TypeScript)
– Bridge layer (React Native NativeModules)
– Native SDK wrapper layer (Kotlin / Swift + instrumentation)
• Platform abstraction: newarch vs oldarch modules for Android, versioned code for multiple RN versions.
• Strong test coverage: unit tests in JS, Android, iOS.
Essential Elements to Capture
• Monorepo root & tooling (Yarn Plug’n’Play, Lerna, CI).
• Core package and integration packages with both JS and native sub-layers.
• Example apps as consumers.
• Bridge interaction path: JS → NativeModules → Android/iOS wrappers.
• Testing pipelines attached to each module.