Skip to content

Commit

Permalink
chore: add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandreferris committed Jul 22, 2024
1 parent 0c68003 commit 35144c8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,38 @@ package com.wire.kalium.logic.data.analytics

sealed interface AnalyticsIdentifierResult {

/**
* To be used when there is no user logged in or analytics settings is disabled.
*/
data object Disabled : AnalyticsIdentifierResult

/**
* Wrapper: To be used when there is a user logged in and analytics settings is enabled.
*/
sealed interface Enabled : AnalyticsIdentifierResult {
val identifier: String
}

/**
* To be used when user first login to device, generating a new identifier and sending over to other clients.
*/
data class NonExistingIdentifier(
override val identifier: String
) : Enabled

/**
* To be used when user already has a tracking identifier, meaning no migration will be done.
*/
data class ExistingIdentifier(
override val identifier: String
) : Enabled

/**
* To be used when user is already logged in and receive a new tracking identifier from another client,
* it needs to set received tracking identifier as current identifier with migration.
* (migrate old identifier events to new identifier)
*/
data class MigrationIdentifier(
override val identifier: String
) : Enabled

data object None : AnalyticsIdentifierResult
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,19 @@ import kotlinx.datetime.Clock

interface AnalyticsIdentifierManager {

/**
* When doing a migration of tracking identifier (receive new identifier -> migrate new identifier),
* we should then after migration is complete, delete the previous tracking identifier.
*
* Previous tracking identifier is kept because in case migration or network failure, we still have both values
* to do the correct migration of tracking identifiers.
*/
suspend fun onMigrationComplete()

/**
* When user first login, we generate a new tracking identifier, when this tracking identifier is set,
* we need to send a message to the other clients of the user, to ensure they also use this newly generated identifier.
*/
suspend fun propagateTrackingIdentifier(identifier: String)
}

Expand Down

0 comments on commit 35144c8

Please sign in to comment.