Skip to content

Commit 2a8f57a

Browse files
authored
Merge pull request #1108 from DataDog/sbarrio/release-v3.0.0
[RELEASE] React Native SDK v3.0.0
2 parents ceddd4c + 1e21f7d commit 2a8f57a

253 files changed

Lines changed: 15358 additions & 7141 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,26 @@ use_frameworks!
142142
Now you can go back to your `App.js/tsx` and use `@datadog/mobile-react-native` from there
143143
Example code:
144144
```
145-
import { DdSdkReactNative, DdSdkReactNativeConfiguration } from '@datadog/mobile-react-native';
145+
import { DdSdkReactNative, CoreConfiguration, TrackingConsent } from '@datadog/mobile-react-native';
146146
147147
const App: () => React$Node = () => {
148-
const config = new DdSdkReactNativeConfiguration(
148+
const config = new CoreConfiguration(
149149
"<CLIENT_TOKEN>",
150150
"<ENVIRONMENT_NAME>",
151-
"<RUM_APPLICATION_ID>",
152-
true, // track User interactions (e.g.: Tap on buttons)
153-
true, // track XHR Resources
154-
true // track Errors
151+
TrackingConsent.GRANTED,
152+
{
153+
rumConfiguration: {
154+
applicationId: APPLICATION_ID,
155+
trackInteractions: true,
156+
trackResources: true,
157+
trackFrustrations: true,
158+
trackErrors: true,
159+
},
160+
logsConfiguration: {},
161+
traceConfiguration: {}
162+
}
155163
)
164+
156165
DdSdkReactNative.initialize(config);
157166
...
158167
```

MIGRATION.md

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
# Migration Guide
2+
3+
This document outlines breaking changes and migration steps between major versions of the project.
4+
5+
## Migration from 2.x to 3.0
6+
7+
This section describes the main changes introduced in SDK `3.0` compared to `2.x`.
8+
9+
### Core SDK Initialization changes
10+
11+
The configuration object used to initialize the SDK has seen some changes in its structure.
12+
Feature configuration is now split into feature-specific properties: rumConfiguration, logsConfiguration, traceConfiguration.
13+
14+
Then, RUM, Logs and Trace can be independently configured via their optional configuration objects that are each represented by a property inside the core configuration object.
15+
16+
**NOTE: clientToken, environment and trackingConsent are mandatory for the Core SDK initialization.
17+
ApplicationID is mandatory for RUM to work.**
18+
19+
For instance, to configure the SDK and enable RUM, Logs and Trace you'd do the following:
20+
21+
```
22+
const config = new CoreConfiguration(
23+
CLIENT_TOKEN,
24+
ENVIRONMENT,
25+
TrackingConsent.GRANTED,
26+
{
27+
rumConfiguration: {
28+
applicationId: APPLICATION_ID,
29+
trackInteractions: true,
30+
trackResources: true,
31+
trackFrustrations: true,
32+
sessionSampleRate: 100,
33+
telemetrySampleRate: 100
34+
}
35+
},
36+
logsConfiguration: {
37+
logEventMapper: (logEvent) => {
38+
logEvent.message = `[CUSTOM] ${logEvent.message}`;
39+
return logEvent;
40+
}
41+
},
42+
traceConfiguration: {}
43+
);
44+
45+
...
46+
47+
await DdSdkReactNative.initialize(config);
48+
```
49+
50+
Or if using the DatadogProvider wrapper:
51+
52+
```
53+
const configuration = new DatadogProviderConfiguration(
54+
CLIENT_TOKEN,
55+
ENVIRONMENT,
56+
TrackingConsent.GRANTED,
57+
{
58+
batchSize: BatchSize.SMALL,
59+
uploadFrequency: UploadFrequency.FREQUENT,
60+
batchProcessingLevel: BatchProcessingLevel.MEDIUM,
61+
additionalConfiguration: {
62+
customProperty: "sdk-example-app"
63+
},
64+
rumConfiguration: {
65+
applicationId: APPLICATION_ID,
66+
trackInteractions: true,
67+
trackResources: true,
68+
trackErrors: true,
69+
sessionSampleRate: 100,
70+
nativeCrashReportEnabled: true
71+
},
72+
logsConfiguration: {
73+
logEventMapper: (logEvent) => {
74+
logEvent.message = `[CUSTOM] ${logEvent.message}`;
75+
return logEvent;
76+
}
77+
},
78+
traceConfiguration: {}
79+
}
80+
);
81+
82+
...
83+
84+
<DatadogProvider configuration={configuration} onInitialization={onDatadogInitialization}>
85+
```
86+
87+
**NOTE: Unlike v2.x, which would always enable all feature modules when initializing the SDK, v3 won't initialize nor enable a feature module if there's no configuration for it.**
88+
89+
### Property renames and relocations
90+
91+
| Property | New Location | Changes |
92+
| :--- | :--- | :--- |
93+
| `sampleRate` | *Removed* | Deprecated property removed. |
94+
| `sessionSamplingRate` | `RumConfiguration` | Moved and renamed to `sessionSampleRate` |
95+
| `resourceTracingSamplingRate` | `RumConfiguration` | Moved and renamed to `resourceTraceSampleRate`. |
96+
| `proxyConfig` | `CoreConfiguration` | Renamed to `proxyConfiguration`. |
97+
| `serviceName` | `CoreConfiguration` | Renamed to `service`. |
98+
| `customEndpoints` | *Split* | Split into `customEndpoint` within `RumConfiguration`, `LogsConfiguration`, and `TraceConfiguration` |
99+
| *New Property* | `CoreConfiguration` | `attributeEncoders` added. |
100+
| *New Property* | `RumConfiguration` | `trackMemoryWarnings` added. |
101+
| `nativeCrashReportEnabled` | `RumConfiguration` | Moved. |
102+
| `nativeViewTracking` | `RumConfiguration` | Moved. |
103+
| `nativeInteractionTracking` | `RumConfiguration` | Moved. |
104+
| `firstPartyHosts` | `RumConfiguration` | Moved. |
105+
| `telemetrySampleRate` | `RumConfiguration` | Moved. |
106+
| `nativeLongTaskThresholdMs` | `RumConfiguration` | Moved. |
107+
| `longTaskThresholdMs` | `RumConfiguration` | Moved. |
108+
| `vitalsUpdateFrequency` | `RumConfiguration` | Moved. |
109+
| `trackFrustrations` | `RumConfiguration` | Moved. |
110+
| `trackBackgroundEvents` | `RumConfiguration` | Moved. |
111+
| `bundleLogsWithRum` | `LogsConfiguration` | Moved. |
112+
| `bundleLogsWithTraces` | `LogsConfiguration` | Moved. |
113+
| `trackNonFatalAnrs` | `RumConfiguration` | Moved. |
114+
| `appHangThreshold` | `RumConfiguration` | Moved. |
115+
| `initialResourceThreshold` | `RumConfiguration` | Moved. |
116+
| `trackWatchdogTerminations` | `RumConfiguration` | Moved. |
117+
| `actionNameAttribute` | `RumConfiguration` | Moved. |
118+
| `logEventMapper` | `LogsConfiguration` | Moved. |
119+
| `errorEventMapper` | `RumConfiguration` | Moved. |
120+
| `resourceEventMapper` | `RumConfiguration` | Moved. |
121+
| `actionEventMapper` | `RumConfiguration` | Moved. |`TraceConfiguration`. |
122+
| `useAccessibilityLabel` | `RumConfiguration` | Moved. |
123+
| `trackInteractions` | `RumConfiguration` | Moved. |
124+
| `trackResources` | `RumConfiguration` | Moved. |
125+
| `trackErrors` | `RumConfiguration` | Moved. |
126+
127+
### FileBasedConfiguration changes
128+
129+
FileBasedConfiguration now requires a path to a configuration JSON file instead of trying to find a default `datadog-configuration.json` at the app's root level like it did on v2.
130+
131+
### Changes to SessionReplay configuration
132+
defaultPrivacyLevel has been removed in favor of granular options: imagePrivacyLevel, touchPrivacyLevel and textAndInputPrivacyLevel.
133+
134+
### Fatal Errors are no longer reported as logs
135+
136+
Fatal Errors are no longer automatically reported as Logs. Fatal crashes will still be captured, but are no longer duplicated in Logs by default.
137+
138+
### Context / Attribute encoding
139+
Context / attributes encoding is now safe and deterministic
140+
All attributes passed to Datadog SDK APIs are automatically sanitized and encoded:
141+
Unsupported values (functions, symbols, non-finite numbers, etc.) are dropped with a warning to prevent crashes and undefined behavior
142+
Common types (Date, Error, Map) are properly serialized
143+
Nested objects are flattened using dot notation (a.b.c = value) to match native SDK expectations
144+
Root-level primitives and arrays are wrapped under a context key for schema consistency
145+
Custom encoders can be registered via the attributeEncoders configuration option for domain-specific types
146+
147+
### Android mindSdkVersion bumped to 23
148+
Android's minSdkVersion has been bumped to 23.
149+
150+
### Resource Traces sampling aligned with RUM Sessions
151+
Resource traces are now consistently sampled based on the active RUM session.
152+
You may notice changes in the percentage of reported resources.
153+
154+
### JS Refresh rate normalization changes
155+
JS refresh rate is now normalized to a 0–60 FPS range.
156+
157+
### RUM Session sampling changes
158+
v3 modifies the logic to determine whether a trace should be sampled or not, by using the RUM Session ID first, before using the Trace sampling if no session can be found.
159+
160+
Consistent trace sampling based on RUM Session ID allows RUM clients and the backend to come to a the same decision about sampling without relying on randomness for each trace.
161+
162+
### Removed APIs
163+
164+
| API | Status |
165+
| :--- | :--- |
166+
| setUser | Removed in favor of setUserInfo. To completely remove userInfo please use the newly added clearUserInfo |
167+
| setAttributes| Removed in favor of addAttributes |
168+
169+
### Attributes API
170+
The attribute API has been expanded allowing for addition and removal of single or batches of attributes in bulk.This can be performed with the new granular APIs: addAttributes, removeAttributes, addAttribute and removeAttribute.
171+
172+
### New APIs
173+
174+
#### ViewAttributes
175+
176+
RUM View-level attributes are now automatically propagated to all related child events, including resources, user actions, errors, and long tasks. This ensures consistent metadata across events, making it easier to filter and correlate data on Datadog dashboards.
177+
178+
To manage View level attributes more effectively, new APIs were added:
179+
180+
```
181+
addViewAttribute = (key: string, value: unknown)
182+
removeViewAttribute = (key: string)
183+
addViewAttributes = (attributes: Attributes)
184+
removeViewAttributes = (keys: string[])
185+
```
186+
187+
#### AccountInfo
188+
The AccountInfo API from the native Datadog SDKs has been exposed to React Native as well:
189+
190+
```
191+
setAccountInfo = async (accountInfo: {
192+
id: string;
193+
name?: string;
194+
extraInfo?: Record<string, unknown>;
195+
})
196+
197+
clearAccountInfo = async ()
198+
199+
addAccountExtraInfo = async (extraAccountInfo: Record<string, unknown>)
200+
```
201+
202+
#### Feature Operations
203+
204+
```
205+
startFeatureOperation(
206+
name: string,
207+
operationKey: string | null,
208+
attributes: object
209+
): Promise<void>
210+
211+
succeedFeatureOperation(
212+
name: string,
213+
operationKey: string | null,
214+
attributes: object
215+
): Promise<void>
216+
217+
failFeatureOperation(
218+
name: string,
219+
operationKey: string | null,
220+
reason: FeatureOperationFailure,
221+
attributes: object
222+
): Promise<void>
223+
```
224+
225+
### New Navigation Tracking Options
226+
227+
v3 modifies the automatic navigation tracking modules for React Navigation and React Native Navigation and exposes a new NavigationTrackingOptions parameter through the startTracking/startTrackingViews function.
228+
229+
This `options` object allows to customize the view tracking logic via 3 new optional predicate functions:
230+
231+
- ViewNamePredicate - a custom naming predicates that decide the display name of views tracked by RUM.
232+
- ViewTrackingPredicate - a custom predicate that decides if a view needs to be tracked by RUM or not.
233+
- ParamsTrackingPredicate - a custom predicate that decides which navigation parameters (if any) need to be tracked alongside the view on RUM.
234+
235+
All of these are optional, and when not set the default behavior will be used for each one of them. The default behaviours are as follows:
236+
237+
- ViewNamePredicate - directly forwards the view given name to RUM.
238+
- ViewTrackingPredicate - tracks all views on RUM.
239+
- ParamsTrackingPredicate - does not forward any parameters to RUM.

NATIVE_SDK_VERSIONS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
| React Native | iOS Bridge / iOS SDK | Android Bridge / Android SDK |
22
|-------------|---------------------|-----------------------------|
3+
| 3.0.0 | 3.4.0 | 3.4.0 |
34
| 2.14.1 | 2.30.2 | 2.26.2 |
45
| 2.14.0 | 2.30.2 | 2.26.2 |
56
| 2.13.2 | 2.30.2 | 2.26.2 |

benchmarks/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,5 @@ dependencies {
129129

130130
// Benchmark tools from dd-sdk-android are used for vitals recording
131131
// Remember to bump thid alongside the main dd-sdk-android dependencies
132-
implementation("com.datadoghq:dd-sdk-android-benchmark-internal:2.25.0")
132+
implementation("com.datadoghq:dd-sdk-android-benchmark-internal:3.4.0")
133133
}

0 commit comments

Comments
 (0)