-
Notifications
You must be signed in to change notification settings - Fork 625
Fix encoding for Session Events #4870
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
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
package com.google.firebase.sessions | ||
|
||
import android.util.Log | ||
import com.google.android.datatransport.* | ||
import com.google.android.datatransport.TransportFactory | ||
import com.google.firebase.inject.Provider | ||
|
@@ -53,11 +54,14 @@ internal class EventGDTLogger(private val transportFactoryProvider: Provider<Tra | |
} | ||
|
||
private fun encode(value: SessionEvent): ByteArray { | ||
return SessionEvents.SESSION_EVENT_ENCODER.encode(value).toByteArray() | ||
val jsonEvent = SessionEvents.SESSION_EVENT_ENCODER.encode(value) | ||
Log.d(TAG, "Encoded Session Start event $jsonEvent") | ||
return jsonEvent.toByteArray() | ||
} | ||
|
||
companion object { | ||
// TODO What do we put for the AQS Log Source | ||
private const val TAG = "EventGDTLogger" | ||
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. How would the log message look with this TAG? Would it contain 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. It looks like: We've been doing it like this so I'll update this file and others |
||
|
||
private const val AQS_LOG_SOURCE = "FIREBASE_APPQUALITY_SESSION" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,41 @@ internal data class SessionInfo( | |
/** What order this Session came in this run of the app. For the first Session this will be 0. */ | ||
val sessionIndex: Int, | ||
|
||
/** Tracks when the event was initiated */ | ||
var eventTimestampUs: Long, | ||
|
||
/** Data collection status of the dependent product SDKs. */ | ||
var dataCollectionStatus: DataCollectionStatus = DataCollectionStatus(), | ||
|
||
/** Identifies a unique device+app installation: go/firebase-installations */ | ||
var firebaseInstallationId: String = "", | ||
) | ||
|
||
/** Contains the data collection state for all dependent SDKs and sampling info */ | ||
internal data class DataCollectionStatus( | ||
val performance: DataCollectionState = DataCollectionState.COLLECTION_ENABLED, | ||
val crashlytics: DataCollectionState = DataCollectionState.COLLECTION_ENABLED, | ||
Comment on lines
+74
to
+75
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. Is the default 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. Yeah I'm putting it like this so it looks right in our data but we'll need to change this when we integrate with the product SDKs |
||
val sessionSamplingRate: Double = 1.0, | ||
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. Interesting to have sessionSamplingRate inside the 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. This is how it is in our proto - |
||
) | ||
|
||
/** Enum denoting different data collection states. */ | ||
internal enum class DataCollectionState(override val number: Int) : NumberedEnum { | ||
COLLECTION_UNKNOWN(0), | ||
|
||
// This product SDK is not present in this version of the app. | ||
COLLECTION_SDK_NOT_INSTALLED(1), | ||
|
||
// The product SDK is present and collecting all product-level events. | ||
COLLECTION_ENABLED(2), | ||
|
||
// The product SDK is present but data collection for it has been locally | ||
// disabled. | ||
COLLECTION_DISABLED(3), | ||
|
||
// The product SDK is present but data collection has been remotely disabled. | ||
COLLECTION_DISABLED_REMOTE(4), | ||
|
||
// Indicates that the product SDK is present, but session data is being | ||
// collected, but the product-level events are not being uploaded. | ||
COLLECTION_SAMPLED(5), | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,8 @@ class SessionEventTest { | |
val sessionEvent = | ||
SessionEvents.startSession( | ||
FakeFirebaseApp.fakeFirebaseApp(), | ||
TestSessionEventData.TEST_SESSION_DETAILS | ||
TestSessionEventData.TEST_SESSION_DETAILS, | ||
TestSessionEventData.TEST_SESSION_TIMESTAMP_US, | ||
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. Any reason why the event timestamp is configurable? Can we leave it as a constant? 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.
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 think this is fine for now, but we need a proper time solution at some point. We can't just use go/javatime because it requires Android API level 26+. Maybe we can add another function in |
||
) | ||
|
||
assertThat(sessionEvent).isEqualTo(TestSessionEventData.EXPECTED_DEFAULT_SESSION_EVENT) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious if you want to leave this as
Debug
orVerbose
?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm down for Verbose - I wasn't sure when we use debug vs verbose