@@ -5,10 +5,12 @@ import com.getcode.crypt.DerivedKey
55import com.getcode.ed25519.Ed25519.KeyPair
66import com.getcode.generator.OrganizerGenerator
77import com.getcode.model.ID
8+ import com.getcode.model.description
89import com.getcode.model.uuid
910import com.getcode.services.manager.MnemonicManager
1011import com.getcode.solana.organizer.Organizer
1112import com.getcode.utils.FormatUtils
13+ import com.mixpanel.android.mpmetrics.MixpanelAPI
1214import kotlinx.coroutines.flow.MutableStateFlow
1315import kotlinx.coroutines.flow.StateFlow
1416import kotlinx.coroutines.flow.asStateFlow
@@ -31,6 +33,7 @@ sealed interface AuthState {
3133class UserManager @Inject constructor(
3234 private val mnemonicManager : MnemonicManager ,
3335 private val organizerGenerator : OrganizerGenerator ,
36+ private val mixpanelAPI : MixpanelAPI ,
3437) {
3538 private val _state : MutableStateFlow <State > = MutableStateFlow (State ())
3639 val state: StateFlow <State >
@@ -130,18 +133,23 @@ class UserManager @Inject constructor(
130133 }
131134
132135 private fun associate () {
133- if (Bugsnag .isStarted() && ! BuildConfig .DEBUG ) {
134- Bugsnag .setUser(userId?.uuid?.toString(), null , displayName)
135- userFlags?.let { flags ->
136- Bugsnag .addMetadata(
137- /* section = */ " userflags" ,
138- /* value = */ mapOf (
139- " isStaff" to flags.isStaff,
140- " isRegistered" to flags.isRegistered,
141- " createCost" to FormatUtils .formatWholeRoundDown(flags.createCost.toKinValueDouble())
136+ if (! BuildConfig .DEBUG ) {
137+ val distinctId = userId?.uuid?.toString()
138+ if (Bugsnag .isStarted()) {
139+ Bugsnag .setUser(distinctId, null , displayName)
140+ userFlags?.let { flags ->
141+ Bugsnag .addMetadata(
142+ /* section = */ " userflags" ,
143+ /* value = */ mapOf (
144+ " isStaff" to flags.isStaff,
145+ " isRegistered" to flags.isRegistered,
146+ " createCost" to FormatUtils .formatWholeRoundDown(flags.createCost.toKinValueDouble())
147+ )
142148 )
143- )
149+ }
144150 }
151+
152+ mixpanelAPI.identify(distinctId)
145153 }
146154 }
147155
0 commit comments