-
Notifications
You must be signed in to change notification settings - Fork 625
Add register api to FirebaseSessions so products can integrate #4989
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
Changes from all commits
f43248d
24ab502
8e23f15
3c68e11
0e65b88
6cea252
6b7fbeb
67da22e
7b20ffd
584ccf8
bf47172
9e67118
de68b51
83c7359
dd9ed1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,6 @@ package com.google.firebase.sessions | |
|
||
import android.util.Log | ||
import com.google.firebase.installations.FirebaseInstallationsApi | ||
import kotlin.coroutines.CoroutineContext | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.launch | ||
import kotlinx.coroutines.tasks.await | ||
|
||
/** | ||
|
@@ -31,30 +28,26 @@ import kotlinx.coroutines.tasks.await | |
*/ | ||
internal class SessionCoordinator( | ||
private val firebaseInstallations: FirebaseInstallationsApi, | ||
context: CoroutineContext, | ||
private val eventGDTLogger: EventGDTLoggerInterface, | ||
) { | ||
private val scope = CoroutineScope(context) | ||
|
||
fun attemptLoggingSessionEvent(sessionEvent: SessionEvent) = | ||
scope.launch { | ||
sessionEvent.sessionData.firebaseInstallationId = | ||
try { | ||
firebaseInstallations.id.await() | ||
} catch (ex: Exception) { | ||
Log.e(TAG, "Error getting Firebase Installation ID: ${ex}. Using an empty ID") | ||
// Use an empty fid if there is any failure. | ||
"" | ||
} | ||
|
||
suspend fun attemptLoggingSessionEvent(sessionEvent: SessionEvent) { | ||
sessionEvent.sessionData.firebaseInstallationId = | ||
try { | ||
eventGDTLogger.log(sessionEvent) | ||
|
||
Log.i(TAG, "Successfully logged Session Start event: ${sessionEvent.sessionData.sessionId}") | ||
} catch (e: RuntimeException) { | ||
Log.e(TAG, "Error logging Session Start event to DataTransport: ", e) | ||
firebaseInstallations.id.await() | ||
} catch (ex: Exception) { | ||
Log.e(TAG, "Error getting Firebase Installation ID: ${ex}. Using an empty ID") | ||
// Use an empty fid if there is any failure. | ||
"" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to allow dispatching events with empty There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure. @samedson and I talked and thought this was better, we even updated iOS to do the same firebase/firebase-ios-sdk#11161 I am ok with dropping the event instead but we'll need to revert that iOS change to keep it consistent. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you remember the rationale as to why it is fine to dispatch an event with empty FID? Because, backend is going to drop it anyways since this event would be accounted as invalid. |
||
} | ||
|
||
try { | ||
eventGDTLogger.log(sessionEvent) | ||
|
||
Log.i(TAG, "Successfully logged Session Start event: ${sessionEvent.sessionData.sessionId}") | ||
} catch (ex: RuntimeException) { | ||
Log.e(TAG, "Error logging Session Start event to DataTransport: ", ex) | ||
} | ||
} | ||
|
||
companion object { | ||
private const val TAG = "SessionCoordinator" | ||
|
Uh oh!
There was an error while loading. Please reload this page.