Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update events #86

Merged
merged 5 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -34,6 +34,8 @@ import android.content.Intent
import android.net.Uri
import android.os.Bundle
import com.schibsted.account.webflows.client.Client
import com.schibsted.account.webflows.tracking.SchibstedAccountTracker
import com.schibsted.account.webflows.tracking.SchibstedAccountTrackingEvent
import com.schibsted.account.webflows.util.Either.Left
import timber.log.Timber

Expand Down Expand Up @@ -177,6 +179,7 @@ class AuthorizationManagementActivity : Activity() {

private fun handleAuthorizationCanceled() {
Timber.d("Authorization flow canceled by user")
SchibstedAccountTracker.track(SchibstedAccountTrackingEvent.UserLoginCanceled)
AuthResultLiveData.get().update(Left(NotAuthed.CancelledByUser))
cancelIntent?.send()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import com.schibsted.account.webflows.persistence.StorageError
import com.schibsted.account.webflows.token.TokenError
import com.schibsted.account.webflows.token.TokenHandler
import com.schibsted.account.webflows.token.UserTokens
import com.schibsted.account.webflows.tracking.SchibstedAccountTracker
import com.schibsted.account.webflows.tracking.SchibstedAccountTrackingEvent
import com.schibsted.account.webflows.user.StoredUserSession
import com.schibsted.account.webflows.user.User
import com.schibsted.account.webflows.util.Either
Expand Down Expand Up @@ -180,10 +182,12 @@ class Client {
storedUserSession
.onSuccess { session ->
sessionStorage.save(session)
SchibstedAccountTracker.track(SchibstedAccountTrackingEvent.UserLoginSuccessful)
callback(Right(User(this, session.userTokens)))
}
.onFailure { err ->
Timber.d("Token error response: $err")
SchibstedAccountTracker.track(SchibstedAccountTrackingEvent.UserLoginFailed)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would consider pushing exception or some kind of "reason" to event

val oauthError = err.toOauthError()
if (oauthError != null) {
callback(Left(LoginError.TokenErrorResponse(oauthError)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import android.content.UriMatcher
import android.database.Cursor
import android.database.sqlite.SQLiteException
import android.net.Uri
import com.schibsted.account.webflows.tracking.SchibstedAccountTracker
import com.schibsted.account.webflows.tracking.SchibstedAccountTrackingEvent

internal class LoginPromptContentProvider : ContentProvider() {

Expand Down Expand Up @@ -55,6 +57,7 @@ internal class LoginPromptContentProvider : ContentProvider() {
if (rowId != null) {
val uri: Uri = ContentUris.withAppendedId(contentURI, rowId)
context!!.contentResolver.notifyChange(uri, null)
SchibstedAccountTracker.track(SchibstedAccountTrackingEvent.LoginPromptContentProviderInsert)
return uri
}
throw SQLiteException("Failed to add a record into $uri")
Expand All @@ -70,6 +73,7 @@ internal class LoginPromptContentProvider : ContentProvider() {
uri: Uri, selection: String?, selectionArgs: Array<String>?
): Int {
val rowsAffected = db?.clearSessionsForPackage(selectionArgs?.first() as String);
SchibstedAccountTracker.track(SchibstedAccountTrackingEvent.LoginPromptContentProviderDelete)
return rowsAffected ?: 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.schibsted.account.webflows.R
import com.schibsted.account.webflows.databinding.LoginPromptBinding
import com.schibsted.account.webflows.tracking.SchibstedAccountTracker
import com.schibsted.account.webflows.tracking.SchibstedAccountTrackingEvent
import com.schibsted.account.webflows.tracking.SchibstedAccountTrackingEvent.*
import com.schibsted.account.webflows.util.Util
import kotlinx.coroutines.launch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package com.schibsted.account.webflows.persistence

import android.content.Context
import android.content.ContentResolver
import android.content.ContentValues
import android.content.SharedPreferences
import android.net.Uri
import androidx.security.crypto.EncryptedSharedPreferences
import androidx.security.crypto.MasterKey
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.google.gson.JsonSyntaxException
import com.schibsted.account.webflows.loginPrompt.LoginPromptContentProvider
import com.schibsted.account.webflows.loginPrompt.SessionInfoManager
import com.schibsted.account.webflows.user.StoredUserSession
import com.schibsted.account.webflows.util.Either
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ sealed class SchibstedAccountTrackingEvent {
object LoginPromptClickToLogin : SchibstedAccountTrackingEvent()
object LoginPromptClickToContinueWithoutLogin : SchibstedAccountTrackingEvent()
object LoginPromptClickOutside : SchibstedAccountTrackingEvent()
object LoginPromptContentProviderInsert : SchibstedAccountTrackingEvent()
object LoginPromptContentProviderDelete : SchibstedAccountTrackingEvent()

object UserLoginSuccessful : SchibstedAccountTrackingEvent()
object UserLoginFailed : SchibstedAccountTrackingEvent()
object UserLoginCanceled : SchibstedAccountTrackingEvent()
}
Loading