Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.rudderstack.sdk.kotlin.android
import android.app.Application
import com.rudderstack.sdk.kotlin.core.Configuration
import com.rudderstack.sdk.kotlin.core.internals.policies.FlushPolicy
import com.rudderstack.sdk.kotlin.android.models.reset.ResetOptions as AndroidResetOptions

internal const val DEFAULT_SESSION_TIMEOUT_IN_MILLIS = 300_000L

Expand Down Expand Up @@ -37,6 +38,7 @@ internal const val DEFAULT_SESSION_TIMEOUT_IN_MILLIS = 300_000L
* @param controlPlaneUrl The URL of the control plane, used for remote configuration management. Defaults to `DEFAULT_CONTROL_PLANE_URL`.
* @param flushPolicies A list of flush policies defining when and how events should be sent to the backend. Defaults to `DEFAULT_FLUSH_POLICIES`.
* @param gzipEnabled Flag to enable or disable GZIP compression for network requests. Defaults to `DEFAULT_GZIP_STATUS`.
* @param defaultResetOptions The default value for the [AndroidResetOptions] to be passed to the `reset` API call. Defaults to [DEFAULT_RESET_OPTIONS].
*
* ## Example
* ```kotlin
Expand All @@ -63,7 +65,8 @@ data class Configuration @JvmOverloads constructor(
override val dataPlaneUrl: String,
override val controlPlaneUrl: String = DEFAULT_CONTROL_PLANE_URL,
override val flushPolicies: List<FlushPolicy> = DEFAULT_FLUSH_POLICIES,
override val gzipEnabled: Boolean = DEFAULT_GZIP_STATUS
override val gzipEnabled: Boolean = DEFAULT_GZIP_STATUS,
override val defaultResetOptions: AndroidResetOptions = DEFAULT_RESET_OPTIONS
) : Configuration(
writeKey = writeKey,
dataPlaneUrl = dataPlaneUrl,
Expand All @@ -76,6 +79,7 @@ data class Configuration @JvmOverloads constructor(
internal const val DEFAULT_TRACK_DEEP_LINKS = true
internal const val DEFAULT_TRACK_ACTIVITIES = false
internal const val DEFAULT_COLLECT_DEVICE_ID = true
internal val DEFAULT_RESET_OPTIONS = AndroidResetOptions()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import com.rudderstack.sdk.kotlin.android.Configuration.Companion.DEFAULT_TRACK_
import com.rudderstack.sdk.kotlin.android.DEFAULT_SESSION_TIMEOUT_IN_MILLIS
import com.rudderstack.sdk.kotlin.android.SessionConfiguration
import com.rudderstack.sdk.kotlin.android.SessionConfiguration.Companion.DEFAULT_AUTOMATIC_SESSION_TRACKING
import com.rudderstack.sdk.kotlin.core.internals.models.reset.ResetOptions
import com.rudderstack.sdk.kotlin.core.internals.policies.FlushPolicy
import com.rudderstack.sdk.kotlin.core.javacompat.ConfigurationBuilder
import kotlin.apply

/**
* Builder class for creating Configuration instances.
Expand Down Expand Up @@ -88,6 +90,13 @@ class ConfigurationBuilder(
super.setGzipEnabled(enabled)
}

/**
* Sets the default reset options for reset API calls.
*/
override fun setDefaultResetOptions(options: ResetOptions) = apply {
super.setDefaultResetOptions(options)
}

/**
* Builds the Configuration instance with the configured properties.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ open class Analytics protected constructor(
* - `traits`: Controls whether to clear user traits
* If not provided, defaults to resetting all user data.
*/
open fun reset(options: ResetOptions = ResetOptions()) {
open fun reset(options: ResetOptions = configuration.defaultResetOptions) {
if (!isAnalyticsActive()) return

userIdentityState.dispatch(ResetUserIdentityAction(options.entries))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.rudderstack.sdk.kotlin.core
import com.rudderstack.sdk.kotlin.core.Configuration.Companion.DEFAULT_CONTROL_PLANE_URL
import com.rudderstack.sdk.kotlin.core.Configuration.Companion.DEFAULT_FLUSH_POLICIES
import com.rudderstack.sdk.kotlin.core.Configuration.Companion.DEFAULT_GZIP_STATUS
import com.rudderstack.sdk.kotlin.core.internals.models.reset.ResetOptions
import com.rudderstack.sdk.kotlin.core.internals.policies.CountFlushPolicy
import com.rudderstack.sdk.kotlin.core.internals.policies.FlushPolicy
import com.rudderstack.sdk.kotlin.core.internals.policies.FrequencyFlushPolicy
Expand All @@ -18,13 +19,15 @@ import org.jetbrains.annotations.VisibleForTesting
* @property controlPlaneUrl The URL of the control plane for fetching configuration settings. Defaults to [DEFAULT_CONTROL_PLANE_URL].
* @property gzipEnabled A flag indicating whether GZIP compression is enabled for network requests. Defaults to [DEFAULT_GZIP_STATUS].
* @property flushPolicies A list of flush policies that determine when to flush events to the data plane. Defaults to [DEFAULT_FLUSH_POLICIES].
* @property defaultResetOptions The default value for the [ResetOptions] to be passed to the `reset` API call. Defaults to [DEFAULT_RESET_OPTIONS].
*/
open class Configuration @JvmOverloads constructor(
open val writeKey: String,
open val dataPlaneUrl: String,
open val controlPlaneUrl: String = DEFAULT_CONTROL_PLANE_URL,
open val gzipEnabled: Boolean = DEFAULT_GZIP_STATUS,
open val flushPolicies: List<FlushPolicy> = DEFAULT_FLUSH_POLICIES,
open val defaultResetOptions: ResetOptions = DEFAULT_RESET_OPTIONS
) {

companion object {
Expand All @@ -46,6 +49,11 @@ open class Configuration @JvmOverloads constructor(
*/
val DEFAULT_FLUSH_POLICIES: List<FlushPolicy>
get() = provideDefaultFlushPolicies()

/**
* The default value for `defaultResetOptions` which define the default `ResetOptions` passed to the `reset` API calls in the SDK.
*/
val DEFAULT_RESET_OPTIONS: ResetOptions = ResetOptions()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import com.rudderstack.sdk.kotlin.core.Configuration
import com.rudderstack.sdk.kotlin.core.Configuration.Companion.DEFAULT_CONTROL_PLANE_URL
import com.rudderstack.sdk.kotlin.core.Configuration.Companion.DEFAULT_FLUSH_POLICIES
import com.rudderstack.sdk.kotlin.core.Configuration.Companion.DEFAULT_GZIP_STATUS
import com.rudderstack.sdk.kotlin.core.Configuration.Companion.DEFAULT_RESET_OPTIONS
import com.rudderstack.sdk.kotlin.core.internals.models.reset.ResetOptions
import com.rudderstack.sdk.kotlin.core.internals.policies.FlushPolicy

/**
Expand All @@ -19,6 +21,7 @@ open class ConfigurationBuilder(
private var controlPlaneUrl: String = DEFAULT_CONTROL_PLANE_URL
private var gzipEnabled: Boolean = DEFAULT_GZIP_STATUS
private var flushPolicies: List<FlushPolicy> = DEFAULT_FLUSH_POLICIES
private var defaultResetOptions: ResetOptions = DEFAULT_RESET_OPTIONS

/**
* Sets the control plane URL.
Expand All @@ -41,6 +44,13 @@ open class ConfigurationBuilder(
gzipEnabled = enabled
}

/**
* Sets the default reset options for reset API calls.
*/
open fun setDefaultResetOptions(options: ResetOptions) = apply {
defaultResetOptions = options
}

/**
* Builds the Configuration instance with the configured properties.
*/
Expand Down
Loading