Skip to content

Commit 5fe313c

Browse files
authored
Merge pull request #1547 from DataDog/nogorodnikov/prepare-2.0.0-beta2
Prepare release `2.0.0-beta2`
2 parents c92a870 + 65f83b2 commit 5fe313c

File tree

38 files changed

+1014
-86
lines changed

38 files changed

+1014
-86
lines changed

CHANGELOG.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1+
# 2.0.0-beta2 / 2023-07-17
2+
3+
This is a beta release of SDK v2. Compared to SDK v1 it contains breaking changes related to the SDK setup and APIs. See the [migration guide](https://github.com/DataDog/dd-sdk-android/blob/8d1f9abb101039abcd44ffed2823655c33e5129f/MIGRATION.MD) for details.
4+
5+
Changes in comparison with `2.0.0-beta1`:
6+
7+
* [IMPROVEMENT] Global: Provide the `uploadFrequency` per feature. See [#1533](https://github.com/DataDog/dd-sdk-android/pull/1533)
8+
* [IMPROVEMENT] RUM: Update documentation of `ViewEventMapper`. See [#1537](https://github.com/DataDog/dd-sdk-android/pull/1537)
9+
* [IMPROVEMENT] RUM: Support `navHost` hosted by `FragmentContainerView` for `NavigationViewTrackingStrategy`. See [#1538](https://github.com/DataDog/dd-sdk-android/pull/1538)
10+
* [IMPROVEMENT] Session Replay: Always listen and react to RUM session state. See [#1539](https://github.com/DataDog/dd-sdk-android/pull/1539)
11+
* [IMPROVEMENT] Session Replay: Remove explicit dependency on RUM module from Session Replay. See [#1541](https://github.com/DataDog/dd-sdk-android/pull/1541)
12+
* [IMPROVEMENT] Update Compose Navigation version to 2.6.0. See [#1542](https://github.com/DataDog/dd-sdk-android/pull/1542)
13+
* [IMPROVEMENT] Don't reexport `OkHttp` from `Glide`. See [#1543](https://github.com/DataDog/dd-sdk-android/pull/1543)
14+
15+
# 1.19.3 / 2023-07-11
16+
17+
* [IMPROVEMENT] RUM: Introduce known file cache and cleanup throttling in `BatchFileOrchestrator` in order to reduce the number of syscalls. See [#1506](https://github.com/DataDog/dd-sdk-android/pull/1506)
18+
119
# 2.0.0-beta1 / 2023-07-07
220

3-
This is the first release of SDK v2. It contains breaking changes related to the SDK setup and APIs. See the [migration guide](https://github.com/DataDog/dd-sdk-android/blob/d6877966391bfe979eda18a5c7cb0bb04ef52659/MIGRATION.MD) for details.
21+
This is the first release of SDK v2. It contains breaking changes related to the SDK setup and APIs. See the [migration guide](https://github.com/DataDog/dd-sdk-android/blob/026fc30f5c28226b244a0f6884841cbcac9c864b/MIGRATION.MD) for details.
422

523
Functional changes in comparison with `1.19.2`:
624

MIGRATION.MD

Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
# Migration from 1.x to 2.0
2+
3+
The main changes introduced in SDK 2.0 compared to 1.x are:
4+
5+
1. All relevant products (RUM, Trace, Logs, etc.) are now extracted into different modules. That allows you to integrate only what is needed into your application.
6+
7+
Whereas all products in version 1.x were contained in the single artifact `com.datadoghq:dd-sdk-android:x.x.x`, you now need to adopt the following artifacts:
8+
9+
* RUM: `com.datadoghq:dd-sdk-android-rum:x.x.x`
10+
* Logs: `com.datadoghq:dd-sdk-android-logs:x.x.x`
11+
* Trace: `com.datadoghq:dd-sdk-android-trace:x.x.x`
12+
* WebView Tracking: `com.datadoghq:dd-sdk-android-webview:x.x.x`
13+
* OkHttp instrumentation: `com.datadoghq:dd-sdk-android-okhttp:x.x.x`
14+
15+
**Note**: If you utilize NDK Crash Reporting and WebView Tracking, you also need to add RUM and/or Logs artifacts to be able to report events to RUM and/or Logs respectively.
16+
17+
Reference to the `com.datadoghq:dd-sdk-android` artifact should be removed from your Gradle buildscript, this artifact doesn't exist anymore.
18+
19+
**Note**: The Maven coordinates of all the other artifacts stay the same.
20+
21+
2. Support for multiple SDK instances (see below).
22+
3. Unification of the API layout, as well as naming between iOS and Android SDKs with other Datadog products. Datadog SDK v2 is not binary compatible with Datadog SDK v1.
23+
4. Support of Android API 19 (KitKat) was dropped. The minimum SDK supported is now API 21 (Lollipop).
24+
5. Kotlin 1.7 is required in order to integrate the SDK. SDK itself is compiled with Kotlin 1.8, so compiler of Kotlin 1.6 and below cannot read SDK classes metadata.
25+
26+
If you have an error like the following:
27+
28+
```
29+
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
30+
Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk8-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20)
31+
```
32+
33+
you need to add the following rules to your buildscript (more details [here](https://stackoverflow.com/a/75298544)):
34+
35+
```kotlin
36+
dependencies {
37+
constraints {
38+
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.10") {
39+
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
40+
}
41+
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10") {
42+
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
43+
}
44+
}
45+
}
46+
```
47+
48+
You can always refer to this [sample application](https://github.com/DataDog/dd-sdk-android/blob/9c2d460b6b66161efb1252039a82784792958042/sample/kotlin/src/main/kotlin/com/datadog/android/sample/SampleApplication.kt) for an example on how to setup the SDK.
49+
50+
## SDK configuration changes
51+
52+
Better SDK granularity is achieved with the extraction of different products into independent modules. This changes the way SDK is configured.
53+
54+
`com.datadog.android.core.configuration.Configuration.Builder` class has the following changes:
55+
56+
* Client token, env name, variant name (default value is empty string), service name (default value is application ID taken from the manifest) should be provided in the constructor.
57+
* `com.datadog.android.core.configuration.Credentials` class which was containing parameters mentioned above is removed.
58+
* `logsEnabled`, `tracesEnabled`, `rumEnabled` are removed from the constructor in favour of the individual products configuration (see below).
59+
* `crashReportsEnabled` constructor argument is removed. You can enable/disable JVM crash reporting by using `Configuration.Builder.setCrashReportsEnabled` method, by default JVM crash reporting is enabled.
60+
* RUM, Logs, Trace products configuration methods are removed from `Configuration.Builder` in favour of the individual products configuration (see below).
61+
62+
`Datadog.initialize` method has `Credentials` class removed from the list of the arguments.
63+
64+
`com.datadog.android.plugin` package and all related classes/methods are removed.
65+
66+
### Logs product changes
67+
68+
All the classes related to the Logs product are now strictly contained in the `com.datadog.android.log` package.
69+
70+
To use Logs product, import the following artifact:
71+
72+
```kotlin
73+
implementation("com.datadoghq:dd-sdk-android-logs:x.x.x")
74+
```
75+
76+
You can enable the Logs product with the following snippet:
77+
78+
```kotlin
79+
val logsConfig = LogsConfiguration.Builder()
80+
...
81+
.build()
82+
83+
Logs.enable(logsConfig)
84+
85+
val logger = Logger.Builder()
86+
...
87+
.build()
88+
```
89+
90+
API changes:
91+
92+
|`1.x`|`2.0`|
93+
|---|---|
94+
|`com.datadog.android.core.configuration.Configuration.Builder.setLogEventMapper`|`com.datadog.android.log.LogsConfiguration.Builder.setEventMapper`|
95+
|`com.datadog.android.core.configuration.Configuration.Builder.useCustomLogsEndpoint`|`com.datadog.android.log.LogsConfiguration.Builder.useCustomEndpoint`|
96+
|`com.datadog.android.log.Logger.Builder.setLoggerName`|`com.datadog.android.log.Logger.Builder.setName`|
97+
|`com.datadog.android.log.Logger.Builder.setSampleRate`|`com.datadog.android.log.Logger.Builder.setRemoteSampleRate`|
98+
|`com.datadog.android.log.Logger.Builder.setDatadogLogsEnabled`|This method has been removed. Use `com.datadog.android.log.Logger.Builder.setRemoteSampleRate(0f)` instead to disable sending logs to Datadog.|
99+
|`com.datadog.android.log.Logger.Builder.setServiceName`|`com.datadog.android.log.Logger.Builder.setService`|
100+
|`com.datadog.android.log.Logger.Builder.setDatadogLogsMinPriority`|`com.datadog.android.log.Logger.Builder.setRemoteLogThreshold`|
101+
102+
### Trace product changes
103+
104+
All the classes related to the Trace product are now strictly contained in the `com.datadog.android.trace` package (this means that all classes residing in `com.datadog.android.tracing` before have moved).
105+
106+
To use the Trace product, import the following artifact:
107+
108+
```kotlin
109+
implementation("com.datadoghq:dd-sdk-android-trace:x.x.x")
110+
```
111+
112+
Enable the Trace product with the following snippet:
113+
114+
```kotlin
115+
val traceConfig = TraceConfiguration.Builder()
116+
...
117+
.build()
118+
119+
Trace.enable(traceConfig)
120+
121+
val tracer = AndroidTracer.Builder()
122+
...
123+
.build()
124+
125+
GlobalTracer.registerIfAbsent(tracer)
126+
```
127+
128+
API changes:
129+
130+
|`1.x`|`2.0`|
131+
|---|---|
132+
|`com.datadog.android.core.configuration.Configuration.Builder.setSpanEventMapper`|`com.datadog.android.trace.TraceConfiguration.Builder.setEventMapper`|
133+
|`com.datadog.android.core.configuration.Configuration.Builder.useCustomTracesEndpoint`|`com.datadog.android.trace.TraceConfiguration.Builder.useCustomEndpoint`|
134+
|`com.datadog.android.tracing.AndroidTracer.Builder.setSamplingRate`|`com.datadog.android.trace.AndroidTracer.Builder.setSampleRate`|
135+
|`com.datadog.android.tracing.AndroidTracer.Builder.setServiceName`|`com.datadog.android.trace.AndroidTracer.Builder.setService`|
136+
137+
### RUM product changes
138+
139+
All classes related to the RUM product are now strictly contained in the `com.datadog.android.rum` package.
140+
141+
To use the RUM product, import the following artifact:
142+
143+
```kotlin
144+
implementation("com.datadoghq:dd-sdk-android-rum:x.x.x")
145+
```
146+
147+
The RUM product can be enabled with the following snippet:
148+
149+
```kotlin
150+
val rumConfig = RumConfiguration.Builder(rumApplicationId)
151+
...
152+
.build()
153+
154+
Rum.enable(rumConfig)
155+
```
156+
157+
API changes:
158+
159+
|`1.x`|`2.0`|
160+
|---|---|
161+
|`com.datadog.android.core.configuration.Configuration.Builder.setRumViewEventMapper`|`com.datadog.android.rum.RumConfiguration.Builder.setViewEventMapper`|
162+
|`com.datadog.android.core.configuration.Configuration.Builder.setRumResourceEventMapper`|`com.datadog.android.rum.RumConfiguration.Builder.setResourceEventMapper`|
163+
|`com.datadog.android.core.configuration.Configuration.Builder.setRumActionEventMapper`|`com.datadog.android.rum.RumConfiguration.Builder.setActionEventMapper`|
164+
|`com.datadog.android.core.configuration.Configuration.Builder.setRumErrorEventMapper`|`com.datadog.android.rum.RumConfiguration.Builder.setErrorEventMapper`|
165+
|`com.datadog.android.core.configuration.Configuration.Builder.setRumLongTaskEventMapper`|`com.datadog.android.rum.RumConfiguration.Builder.setLongTaskEventMapper`|
166+
|`com.datadog.android.core.configuration.Configuration.Builder.useCustomRumEndpoint`|`com.datadog.android.rum.RumConfiguration.Builder.useCustomEndpoint`|
167+
|`com.datadog.android.event.ViewEventMapper`|`com.datadog.android.rum.event.ViewEventMapper`|
168+
|`com.datadog.android.core.configuration.VitalsUpdateFrequency`|`com.datadog.android.rum.configuration.VitalsUpdateFrequency`|
169+
|`com.datadog.android.core.configuration.Configuration.Builder.trackInteractions`|`com.datadog.android.rum.RumConfiguration.Builder.trackUserInteractions`|
170+
|`com.datadog.android.core.configuration.Configuration.Builder.disableInteractionTracking`|`com.datadog.android.rum.RumConfiguration.Builder.disableUserInteractionTracking`|
171+
|`com.datadog.android.core.configuration.Configuration.Builder.sampleRumSessions`|`com.datadog.android.rum.RumConfiguration.Builder.setSessionSampleRate`|
172+
|`com.datadog.android.core.configuration.Configuration.Builder.sampleTelemetry`|`com.datadog.android.rum.RumConfiguration.Builder.setTelemetrySampleRate`|
173+
|`com.datadog.android.rum.RumMonitor.Builder`|This class has been removed. The RUM monitor is created and registered during the `Rum.enable` call.|
174+
|`com.datadog.android.rum.RumMonitor.Builder.sampleRumSessions`|`com.datadog.android.rum.RumConfiguration.Builder.setSessionSampleRate`|
175+
|`com.datadog.android.rum.RumMonitor.Builder.setSessionListener`|`com.datadog.android.rum.RumConfiguration.Builder.setSessionListener`|
176+
|`com.datadog.android.rum.RumMonitor.addUserAction`|`com.datadog.android.rum.RumMonitor.addAction`|
177+
|`com.datadog.android.rum.RumMonitor.startUserAction`|`com.datadog.android.rum.RumMonitor.startAction`|
178+
|`com.datadog.android.rum.RumMonitor.stopUserAction`|`com.datadog.android.rum.RumMonitor.stopAction`|
179+
|`com.datadog.android.rum.GlobalRum.registerIfAbsent`|This method has been removed. The RUM monitor is created and registered during the `Rum.enable` call.|
180+
|`com.datadog.android.rum.GlobalRum`|`com.datadog.android.rum.GlobalRumMonitor`|
181+
|`com.datadog.android.rum.GlobalRum.addAttribute`|`com.datadog.android.rum.RumMonitor.addAttribute`|
182+
|`com.datadog.android.rum.GlobalRum.removeAttribute`|`com.datadog.android.rum.RumMonitor.removeAttribute`|
183+
184+
### NDK Crash Reporting changes
185+
186+
The artifact name stays the same as before: `com.datadoghq:dd-sdk-android-ndk:x.x.x`
187+
188+
NDK Crash Reporting can be enabled using the following snippet:
189+
190+
```kotlin
191+
NdkCrashReports.enable()
192+
```
193+
194+
This configuration replaces the `com.datadog.android.core.configuration.Configuration.Builder.addPlugin` call used before.
195+
196+
**Note**: You should have RUM and/or Logs products enabled in order to receive NDK crash reports in RUM and/or Logs.
197+
198+
### WebView Tracking changes
199+
200+
The artifact name stays the same as before: `com.datadoghq:dd-sdk-android-webview:x.x.x`
201+
202+
You can enable WebView Tracking with the following snippet:
203+
204+
```kotlin
205+
WebViewTracking.enable(webView, allowedHosts)
206+
```
207+
208+
**Note**: You should have RUM and/or Logs products enabled in order to receive events coming from WebView in RUM and/or Logs.
209+
210+
API changes:
211+
212+
|`1.x`|`2.0`|
213+
|---|---|
214+
|`com.datadog.android.webview.DatadogEventBridge`|This method became an `internal` class. Use `WebViewTracking` instead.|
215+
|`com.datadog.android.rum.webview.RumWebChromeClient`|This class was removed. Use `WebViewTracking` instead.|
216+
|`com.datadog.android.rum.webview.RumWebViewClient`|This class was removed. Use `WebViewTracking` instead.|
217+
218+
### OkHttp Tracking changes
219+
220+
In order to be able to use OkHttp Tracking you need to import the following artifact:
221+
222+
```kotlin
223+
implementation("com.datadoghq:dd-sdk-android-okhttp:x.x.x")
224+
```
225+
226+
OkHttp instrumentation now supports the case when Datadog SDK is initialized after the OkHttp client, allowing you to create `com.datadog.android.okhttp.DatadogEventListener`, `com.datadog.android.okhttp.DatadogInterceptor`, and `com.datadog.android.okhttp.trace.TracingInterceptor` before Datadog SDK. OkHttp instrumentation starts reporting events to Datadog once Datadog SDK is initialized.
227+
228+
Also, both `com.datadog.android.okhttp.DatadogInterceptor` and `com.datadog.android.okhttp.trace.TracingInterceptor` improve the integration with remote configuration, allowing you to control sampling dynamically.
229+
In order to do that, you need to provide your own implementation of the `com.datadog.android.core.sampling.Sampler` interface in the `com.datadog.android.okhttp.DatadogInterceptor`/`com.datadog.android.okhttp.trace.TracingInterceptor` constructor. It is queried for each request to make the sampling decision.
230+
231+
## Using a Secondary Instance of the SDK
232+
233+
Previously, the Datadog SDK implemented a singleton and only one SDK instance could exist in the application process. This created obstacles for use-cases like the usage of the SDK by 3rd party libraries.
234+
235+
With version 2.0 we addressed this limitation:
236+
237+
* It is now possible to initialize multiple instances of the SDK by associating them with a name.
238+
* Many methods of the SDK can optionally take an SDK instance as an argument. If not provided, the call is associated with the default (nameless) SDK instance.
239+
240+
Here is an example illustrating how to initialize a secondary core instance and enable products:
241+
242+
```kotlin
243+
val namedSdkInstance = Datadog.initialize("myInstance", context, configuration, trackingConsent)
244+
val userInfo = UserInfo(...)
245+
Datadog.setUserInfo(userInfo, sdkCore = namedSdkInstance)
246+
247+
Logs.enable(logsConfig, namedSdkInstance)
248+
val logger = Logger.Builder(namedSdkInstance)
249+
...
250+
.build()
251+
252+
Trace.enable(traceConfig, namedSdkInstance)
253+
val tracer = AndroidTracer.Builder(namedSdkInstance)
254+
...
255+
.build()
256+
257+
Rum.enable(rumConfig, namedSdkInstance)
258+
GlobalRumMonitor.get(namedSdkInstance)
259+
260+
NdkCrashReports.enable(namedSdkInstance)
261+
262+
WebViewTracking.enable(webView, allowedHosts, namedSdkInstance)
263+
```
264+
265+
**Note**: The SDK instance name should have the same value between application runs. Storage paths for SDK events are associated with it.
266+
267+
You can retrieve the named SDK instance by calling `Datadog.getInstance(<name>)` and use the `Datadog.isInitialized(<name>)` method to check if the particular SDK instance is initialized.

buildSrc/src/main/kotlin/com/datadog/gradle/config/AndroidConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object AndroidConfig {
1717
const val MIN_SDK = 21
1818
const val BUILD_TOOLS_VERSION = "33.0.2"
1919

20-
val VERSION = Version(2, 0, 0, Version.Type.Beta(1))
20+
val VERSION = Version(2, 0, 0, Version.Type.Beta(2))
2121
}
2222

2323
// TODO RUMM-3263 Switch to Java 17 bytecode

dd-sdk-android-core/api/apiSurface

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ interface com.datadog.android.api.storage.EventBatchWriter
131131
fun currentMetadata(): ByteArray?
132132
fun write(ByteArray, ByteArray?): Boolean
133133
data class com.datadog.android.api.storage.FeatureStorageConfiguration
134-
constructor(Long, Int, Long, Long)
134+
constructor(Long, Int, Long, Long, com.datadog.android.core.configuration.UploadFrequency?, com.datadog.android.core.configuration.BatchSize?)
135135
companion object
136136
val DEFAULT: FeatureStorageConfiguration
137137
interface com.datadog.android.core.InternalSdkCore : com.datadog.android.api.feature.FeatureSdkCore

dd-sdk-android-core/api/dd-sdk-android-core.api

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,18 +394,22 @@ public abstract interface class com/datadog/android/api/storage/EventBatchWriter
394394

395395
public final class com/datadog/android/api/storage/FeatureStorageConfiguration {
396396
public static final field Companion Lcom/datadog/android/api/storage/FeatureStorageConfiguration$Companion;
397-
public fun <init> (JIJJ)V
397+
public fun <init> (JIJJLcom/datadog/android/core/configuration/UploadFrequency;Lcom/datadog/android/core/configuration/BatchSize;)V
398398
public final fun component1 ()J
399399
public final fun component2 ()I
400400
public final fun component3 ()J
401401
public final fun component4 ()J
402-
public final fun copy (JIJJ)Lcom/datadog/android/api/storage/FeatureStorageConfiguration;
403-
public static synthetic fun copy$default (Lcom/datadog/android/api/storage/FeatureStorageConfiguration;JIJJILjava/lang/Object;)Lcom/datadog/android/api/storage/FeatureStorageConfiguration;
402+
public final fun component5 ()Lcom/datadog/android/core/configuration/UploadFrequency;
403+
public final fun component6 ()Lcom/datadog/android/core/configuration/BatchSize;
404+
public final fun copy (JIJJLcom/datadog/android/core/configuration/UploadFrequency;Lcom/datadog/android/core/configuration/BatchSize;)Lcom/datadog/android/api/storage/FeatureStorageConfiguration;
405+
public static synthetic fun copy$default (Lcom/datadog/android/api/storage/FeatureStorageConfiguration;JIJJLcom/datadog/android/core/configuration/UploadFrequency;Lcom/datadog/android/core/configuration/BatchSize;ILjava/lang/Object;)Lcom/datadog/android/api/storage/FeatureStorageConfiguration;
404406
public fun equals (Ljava/lang/Object;)Z
407+
public final fun getBatchSize ()Lcom/datadog/android/core/configuration/BatchSize;
405408
public final fun getMaxBatchSize ()J
406409
public final fun getMaxItemSize ()J
407410
public final fun getMaxItemsPerBatch ()I
408411
public final fun getOldBatchThreshold ()J
412+
public final fun getUploadFrequency ()Lcom/datadog/android/core/configuration/UploadFrequency;
409413
public fun hashCode ()I
410414
public fun toString ()Ljava/lang/String;
411415
}

0 commit comments

Comments
 (0)