Skip to content

Commit

Permalink
RUM-4098: Align datastore api with iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanmos committed May 26, 2024
1 parent 43eef1c commit 921ee19
Show file tree
Hide file tree
Showing 16 changed files with 485 additions and 328 deletions.
19 changes: 13 additions & 6 deletions dd-sdk-android-core/api/apiSurface
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ interface com.datadog.android.api.feature.FeatureContextUpdateReceiver
interface com.datadog.android.api.feature.FeatureEventReceiver
fun onReceive(Any)
interface com.datadog.android.api.feature.FeatureScope
var dataStore: com.datadog.android.core.internal.persistence.datastore.DataStoreHandler
var dataStore: com.datadog.android.core.persistence.datastore.DataStoreHandler
fun withWriteContext(Boolean = false, (com.datadog.android.api.context.DatadogContext, com.datadog.android.api.storage.EventBatchWriter) -> Unit)
fun sendEvent(Any)
fun <T: Feature> unwrap(): T
Expand Down Expand Up @@ -243,11 +243,6 @@ interface com.datadog.android.core.internal.net.FirstPartyHostHeaderTypeResolver
fun isEmpty(): Boolean
interface com.datadog.android.core.internal.persistence.Deserializer<P: Any, R: Any>
fun deserialize(P): R?
interface com.datadog.android.core.internal.persistence.datastore.DataStoreHandler
fun <T: Any> write(String, String, com.datadog.android.core.persistence.Serializer<T>, T)
fun <T: Any> read(String, String, com.datadog.android.core.internal.persistence.Deserializer<String, T>, Int): T?
companion object
const val CURRENT_DATASTORE_VERSION: Int
fun java.io.File.canReadSafe(com.datadog.android.api.InternalLogger): Boolean
fun java.io.File.existsSafe(com.datadog.android.api.InternalLogger): Boolean
fun java.io.File.readTextSafe(java.nio.charset.Charset = Charsets.UTF_8, com.datadog.android.api.InternalLogger): String?
Expand Down Expand Up @@ -292,6 +287,18 @@ interface com.datadog.android.core.persistence.Serializer<T: Any>
fun serialize(T): String?
companion object
fun <T: Any> Serializer<T>.serializeToByteArray(T, com.datadog.android.api.InternalLogger): ByteArray?
interface com.datadog.android.core.persistence.datastore.DataStoreCallback
fun <T: Any> onSuccess(DataStoreContent<T>)
fun onFailure()
fun onNoData()
data class com.datadog.android.core.persistence.datastore.DataStoreContent<T: Any>
constructor(Long, Int, T?)
interface com.datadog.android.core.persistence.datastore.DataStoreHandler
fun <T: Any> setValue(String, T, com.datadog.android.core.persistence.Serializer<T>, Int = 0)
fun <T: Any> value(String, com.datadog.android.core.internal.persistence.Deserializer<String, T>, Int = 0, DataStoreCallback)
fun removeValue(String)
companion object
const val CURRENT_DATASTORE_VERSION: Int
class com.datadog.android.core.sampling.RateBasedSampler : Sampler
constructor(() -> Float)
constructor(Float)
Expand Down
53 changes: 40 additions & 13 deletions dd-sdk-android-core/api/dd-sdk-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@ public abstract interface class com/datadog/android/api/feature/FeatureEventRece
}

public abstract interface class com/datadog/android/api/feature/FeatureScope {
public abstract fun getDataStore ()Lcom/datadog/android/core/internal/persistence/datastore/DataStoreHandler;
public abstract fun getDataStore ()Lcom/datadog/android/core/persistence/datastore/DataStoreHandler;
public abstract fun sendEvent (Ljava/lang/Object;)V
public abstract fun setDataStore (Lcom/datadog/android/core/internal/persistence/datastore/DataStoreHandler;)V
public abstract fun setDataStore (Lcom/datadog/android/core/persistence/datastore/DataStoreHandler;)V
public abstract fun unwrap ()Lcom/datadog/android/api/feature/Feature;
public abstract fun withWriteContext (ZLkotlin/jvm/functions/Function2;)V
}
Expand Down Expand Up @@ -671,17 +671,6 @@ public abstract interface class com/datadog/android/core/internal/persistence/De
public abstract fun deserialize (Ljava/lang/Object;)Ljava/lang/Object;
}

public abstract interface class com/datadog/android/core/internal/persistence/datastore/DataStoreHandler {
public static final field CURRENT_DATASTORE_VERSION I
public static final field Companion Lcom/datadog/android/core/internal/persistence/datastore/DataStoreHandler$Companion;
public abstract fun read (Ljava/lang/String;Ljava/lang/String;Lcom/datadog/android/core/internal/persistence/Deserializer;I)Ljava/lang/Object;
public abstract fun write (Ljava/lang/String;Ljava/lang/String;Lcom/datadog/android/core/persistence/Serializer;Ljava/lang/Object;)V
}

public final class com/datadog/android/core/internal/persistence/datastore/DataStoreHandler$Companion {
public static final field CURRENT_DATASTORE_VERSION I
}

public final class com/datadog/android/core/internal/persistence/file/FileExtKt {
public static final fun canReadSafe (Ljava/io/File;Lcom/datadog/android/api/InternalLogger;)Z
public static final fun existsSafe (Ljava/io/File;Lcom/datadog/android/api/InternalLogger;)Z
Expand Down Expand Up @@ -794,6 +783,44 @@ public final class com/datadog/android/core/persistence/SerializerKt {
public static final fun serializeToByteArray (Lcom/datadog/android/core/persistence/Serializer;Ljava/lang/Object;Lcom/datadog/android/api/InternalLogger;)[B
}

public abstract interface class com/datadog/android/core/persistence/datastore/DataStoreCallback {
public abstract fun onFailure ()V
public abstract fun onNoData ()V
public abstract fun onSuccess (Lcom/datadog/android/core/persistence/datastore/DataStoreContent;)V
}

public final class com/datadog/android/core/persistence/datastore/DataStoreContent {
public fun <init> (JILjava/lang/Object;)V
public final fun component1 ()J
public final fun component2 ()I
public final fun component3 ()Ljava/lang/Object;
public final fun copy (JILjava/lang/Object;)Lcom/datadog/android/core/persistence/datastore/DataStoreContent;
public static synthetic fun copy$default (Lcom/datadog/android/core/persistence/datastore/DataStoreContent;JILjava/lang/Object;ILjava/lang/Object;)Lcom/datadog/android/core/persistence/datastore/DataStoreContent;
public fun equals (Ljava/lang/Object;)Z
public final fun getData ()Ljava/lang/Object;
public final fun getLastUpdateDate ()J
public final fun getVersionCode ()I
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public abstract interface class com/datadog/android/core/persistence/datastore/DataStoreHandler {
public static final field CURRENT_DATASTORE_VERSION I
public static final field Companion Lcom/datadog/android/core/persistence/datastore/DataStoreHandler$Companion;
public abstract fun removeValue (Ljava/lang/String;)V
public abstract fun setValue (Ljava/lang/String;Ljava/lang/Object;Lcom/datadog/android/core/persistence/Serializer;I)V
public abstract fun value (Ljava/lang/String;Lcom/datadog/android/core/internal/persistence/Deserializer;ILcom/datadog/android/core/persistence/datastore/DataStoreCallback;)V
}

public final class com/datadog/android/core/persistence/datastore/DataStoreHandler$Companion {
public static final field CURRENT_DATASTORE_VERSION I
}

public final class com/datadog/android/core/persistence/datastore/DataStoreHandler$DefaultImpls {
public static synthetic fun setValue$default (Lcom/datadog/android/core/persistence/datastore/DataStoreHandler;Ljava/lang/String;Ljava/lang/Object;Lcom/datadog/android/core/persistence/Serializer;IILjava/lang/Object;)V
public static synthetic fun value$default (Lcom/datadog/android/core/persistence/datastore/DataStoreHandler;Ljava/lang/String;Lcom/datadog/android/core/internal/persistence/Deserializer;ILcom/datadog/android/core/persistence/datastore/DataStoreCallback;ILjava/lang/Object;)V
}

public final class com/datadog/android/core/sampling/RateBasedSampler : com/datadog/android/core/sampling/Sampler {
public static final field SAMPLE_ALL_RATE F
public fun <init> (D)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package com.datadog.android.api.feature

import com.datadog.android.api.context.DatadogContext
import com.datadog.android.api.storage.EventBatchWriter
import com.datadog.android.core.internal.persistence.datastore.DataStoreHandler
import com.datadog.android.core.persistence.datastore.DataStoreHandler

/**
* Represents a Datadog feature.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import com.datadog.android.core.internal.net.info.NetworkInfoDeserializer
import com.datadog.android.core.internal.net.info.NetworkInfoProvider
import com.datadog.android.core.internal.net.info.NoOpNetworkInfoProvider
import com.datadog.android.core.internal.persistence.JsonObjectDeserializer
import com.datadog.android.core.internal.persistence.datastore.DataStoreHandler
import com.datadog.android.core.internal.persistence.datastore.NoOpDataStoreHandler
import com.datadog.android.core.internal.persistence.file.FileMover
import com.datadog.android.core.internal.persistence.file.FilePersistenceConfig
Expand Down Expand Up @@ -75,6 +74,7 @@ import com.datadog.android.core.internal.user.UserInfoDeserializer
import com.datadog.android.core.internal.utils.submitSafe
import com.datadog.android.core.internal.utils.unboundInternalLogger
import com.datadog.android.core.persistence.PersistenceStrategy
import com.datadog.android.core.persistence.datastore.DataStoreHandler
import com.datadog.android.core.thread.FlushableExecutorService
import com.datadog.android.ndk.internal.DatadogNdkCrashHandler
import com.datadog.android.ndk.internal.NdkCrashHandler
Expand Down Expand Up @@ -198,7 +198,7 @@ internal class CoreFeature(
if (initialized.get()) {
return
}

readConfigurationSettings(configuration.coreConfig)
readApplicationInformation(appContext, configuration)
resolveProcessInfo(appContext)
Expand Down Expand Up @@ -711,8 +711,8 @@ internal class CoreFeature(
internal const val BUILD_ID_FILE_NAME = "datadog.buildId"
internal const val BUILD_ID_IS_MISSING_INFO_MESSAGE =
"Build ID is not found in the application" +
" assets. If you are using obfuscation, please use Datadog Gradle Plugin 1.13.0" +
" or above to be able to de-obfuscate stacktraces."
" assets. If you are using obfuscation, please use Datadog Gradle Plugin 1.13.0" +
" or above to be able to de-obfuscate stacktraces."
internal const val BUILD_ID_READ_ERROR =
"Failed to read Build ID information, de-obfuscation may not work properly."

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ import com.datadog.android.core.internal.persistence.AbstractStorage
import com.datadog.android.core.internal.persistence.ConsentAwareStorage
import com.datadog.android.core.internal.persistence.NoOpStorage
import com.datadog.android.core.internal.persistence.Storage
import com.datadog.android.core.internal.persistence.datastore.DataStoreFileHandler
import com.datadog.android.core.internal.persistence.datastore.DataStoreFileHelper
import com.datadog.android.core.internal.persistence.datastore.DataStoreHandler
import com.datadog.android.core.internal.persistence.datastore.FileDataStoreHandler
import com.datadog.android.core.internal.persistence.datastore.NoOpDataStoreHandler
import com.datadog.android.core.internal.persistence.file.FileMover
import com.datadog.android.core.internal.persistence.file.FileOrchestrator
Expand All @@ -45,8 +44,9 @@ import com.datadog.android.core.internal.persistence.file.FileReaderWriter
import com.datadog.android.core.internal.persistence.file.NoOpFileOrchestrator
import com.datadog.android.core.internal.persistence.file.advanced.FeatureFileOrchestrator
import com.datadog.android.core.internal.persistence.file.batch.BatchFileReaderWriter
import com.datadog.android.core.internal.persistence.tlvformat.FileTLVBlockReader
import com.datadog.android.core.internal.persistence.tlvformat.TLVBlockFileReader
import com.datadog.android.core.persistence.PersistenceStrategy
import com.datadog.android.core.persistence.datastore.DataStoreHandler
import com.datadog.android.privacy.TrackingConsentProviderCallback
import com.datadog.android.security.Encryption
import java.util.Collections
Expand Down Expand Up @@ -362,11 +362,13 @@ internal class SdkFeature(
encryption
)

dataStore = FileDataStoreHandler(
dataStore = DataStoreFileHandler(
executorService = coreFeature.persistenceExecutorService,
storageDir = coreFeature.storageDir,
featureName = wrappedFeature.name,
internalLogger = internalLogger,
fileReaderWriter = fileReaderWriter,
fileTLVBlockReader = FileTLVBlockReader(
tlvBlockFileReader = TLVBlockFileReader(
internalLogger = internalLogger,
fileReaderWriter = fileReaderWriter
),
Expand Down

This file was deleted.

Loading

0 comments on commit 921ee19

Please sign in to comment.