-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/sdkv2' into feature/session-replay-vo
- Loading branch information
Showing
24 changed files
with
2,748 additions
and
399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
dd-sdk-android/src/main/kotlin/com/datadog/android/v2/api/Request.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2016-Present Datadog, Inc. | ||
*/ | ||
|
||
package com.datadog.android.v2.api | ||
|
||
/** | ||
* Request object holding the data to be sent. | ||
* | ||
* @property id Unique identifier of the request. | ||
* @property description Description of the request (ex. "RUM request", "Logs request", etc.). | ||
* @property url URL to call. | ||
* @property headers Request headers. Note that User Agent header will be ignored. | ||
* @property body Request payload. | ||
* @property contentType Content type of the request, if needed. | ||
*/ | ||
data class Request( | ||
val id: String, | ||
val description: String, | ||
val url: String, | ||
val headers: Map<String, String>, | ||
// won't generate custom equals/hashcode, because ID field is enough to identify the request | ||
// and we don't want to have array content comparison | ||
@Suppress("ArrayInDataClass") val body: ByteArray, | ||
val contentType: String? = null | ||
) |
28 changes: 28 additions & 0 deletions
28
dd-sdk-android/src/main/kotlin/com/datadog/android/v2/api/RequestFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2016-Present Datadog, Inc. | ||
*/ | ||
|
||
package com.datadog.android.v2.api | ||
|
||
import com.datadog.android.v2.api.context.DatadogContext | ||
|
||
/** | ||
* Factory used to build requests from the batches stored. | ||
*/ | ||
fun interface RequestFactory { | ||
|
||
// TODO RUMM-2298 Support 1:many relationship between batch and requests | ||
/** | ||
* Creates a request for the given batch. | ||
* @param context Datadog SDK context. | ||
* @param batchData Raw data of the batch. | ||
* @param batchMetadata Raw metadata of the batch. | ||
*/ | ||
fun create( | ||
context: DatadogContext, | ||
batchData: List<ByteArray>, | ||
batchMetadata: ByteArray? | ||
): Request | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
dd-sdk-android/src/main/kotlin/com/datadog/android/v2/core/DatadogFeature.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2016-Present Datadog, Inc. | ||
*/ | ||
|
||
package com.datadog.android.v2.core | ||
|
||
import com.datadog.android.v2.api.FeatureScope | ||
import com.datadog.android.v2.core.internal.net.DataUploader | ||
import com.datadog.android.v2.core.internal.storage.Storage | ||
|
||
internal abstract class DatadogFeature( | ||
val storage: Storage, | ||
val uploader: DataUploader | ||
) : FeatureScope |
13 changes: 13 additions & 0 deletions
13
dd-sdk-android/src/main/kotlin/com/datadog/android/v2/core/internal/ContextProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2016-Present Datadog, Inc. | ||
*/ | ||
|
||
package com.datadog.android.v2.core.internal | ||
|
||
import com.datadog.android.v2.api.context.DatadogContext | ||
|
||
internal interface ContextProvider { | ||
val context: DatadogContext? | ||
} |
13 changes: 13 additions & 0 deletions
13
dd-sdk-android/src/main/kotlin/com/datadog/android/v2/core/internal/NoOpContextProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2016-Present Datadog, Inc. | ||
*/ | ||
|
||
package com.datadog.android.v2.core.internal | ||
|
||
import com.datadog.android.v2.api.context.DatadogContext | ||
|
||
internal class NoOpContextProvider : ContextProvider { | ||
override val context: DatadogContext? = null | ||
} |
44 changes: 44 additions & 0 deletions
44
...k-android/src/main/kotlin/com/datadog/android/v2/core/internal/data/upload/DataFlusher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2016-Present Datadog, Inc. | ||
*/ | ||
|
||
package com.datadog.android.v2.core.internal.data.upload | ||
|
||
import androidx.annotation.WorkerThread | ||
import com.datadog.android.core.internal.persistence.file.FileMover | ||
import com.datadog.android.core.internal.persistence.file.FileOrchestrator | ||
import com.datadog.android.core.internal.persistence.file.FileReader | ||
import com.datadog.android.core.internal.persistence.file.batch.BatchFileReader | ||
import com.datadog.android.core.internal.persistence.file.existsSafe | ||
import com.datadog.android.v2.core.internal.ContextProvider | ||
import com.datadog.android.v2.core.internal.net.DataUploader | ||
|
||
// TODO RUMM-0000 Should replace com.datadog.android.core.internal.net.DataFlusher once | ||
// features are configured as V2 | ||
internal class DataFlusher( | ||
internal val contextProvider: ContextProvider, | ||
internal val fileOrchestrator: FileOrchestrator, | ||
internal val fileReader: BatchFileReader, | ||
internal val metadataFileReader: FileReader, | ||
internal val fileMover: FileMover | ||
) : Flusher { | ||
|
||
@WorkerThread | ||
override fun flush(uploader: DataUploader) { | ||
val context = contextProvider.context ?: return | ||
|
||
val toUploadFiles = fileOrchestrator.getFlushableFiles() | ||
toUploadFiles.forEach { | ||
val batch = fileReader.readData(it) | ||
val metaFile = fileOrchestrator.getMetadataFile(it) | ||
val meta = if (metaFile != null) metadataFileReader.readData(metaFile) else null | ||
uploader.upload(context, batch, meta) | ||
fileMover.delete(it) | ||
if (metaFile?.existsSafe() == true) { | ||
fileMover.delete(metaFile) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.