Skip to content

Add SessionGenerator to generate the Session ID #4747

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

Merged
merged 7 commits into from
Mar 7, 2023

Conversation

samedson
Copy link
Contributor

@samedson samedson commented Mar 6, 2023

Adds a SessionGenerator that rotates the Session ID and index.

#no-changelog

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Mar 6, 2023

Coverage Report 1

Affected Products

  • firebase-sessions

    Overall coverage changed from ? (0358ae9) to 0.00% (a149ea4) by ?.

    FilenameBase (0358ae9)Merge (a149ea4)Diff
    FirebaseSessions.kt?0.00%?
    FirebaseSessionsRegistrar.kt?0.00%?
    SessionGenerator.kt?0.00%?
    SessionInitiator.kt?0.00%?
    WallClock.kt?0.00%?

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/SckakBEBgI.html

@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2023

Unit Test Results

  4 files    4 suites   0s ⏱️
  8 tests   8 ✔️ 0 💤 0
16 runs  16 ✔️ 0 💤 0

Results for commit d2b1452.

♻️ This comment has been updated with latest results.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Mar 6, 2023

Size Report 1

Affected Products

  • base

    TypeBase (0358ae9)Merge (a149ea4)Diff
    apk (aggressive)?8.39 kB? (?)
    apk (release)?8.65 kB? (?)
  • firebase-annotations

    TypeBase (0358ae9)Merge (a149ea4)Diff
    apk (aggressive)?8.39 kB? (?)
    apk (release)?9.46 kB? (?)
  • firebase-common

    TypeBase (0358ae9)Merge (a149ea4)Diff
    aar?75.3 kB? (?)
    apk (aggressive)?111 kB? (?)
    apk (release)?1.26 MB? (?)
  • firebase-common-ktx

    TypeBase (0358ae9)Merge (a149ea4)Diff
    aar?13.2 kB? (?)
    apk (aggressive)?123 kB? (?)
    apk (release)?1.64 MB? (?)
  • firebase-components

    TypeBase (0358ae9)Merge (a149ea4)Diff
    aar?44.9 kB? (?)
    apk (aggressive)?23.1 kB? (?)
    apk (release)?596 kB? (?)
  • firebase-sessions

    TypeBase (0358ae9)Merge (a149ea4)Diff
    aar?16.6 kB? (?)
    apk (aggressive)?135 kB? (?)
    apk (release)?1.65 MB? (?)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/kSZgoDu5XO.html

@samedson samedson changed the title Add SessionGenerator Add SessionGenerator to generate the Session ID Mar 6, 2023
@firebase firebase deleted a comment from google-oss-bot Mar 6, 2023
@samedson samedson requested review from mrober and visumickey March 6, 2023 19:08
SessionInfo(
sessionId = "",
firstSessionId = "",
collectEvents = collectEvents,
Copy link
Contributor

Choose a reason for hiding this comment

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

Does SessionInfo need the collectEvents state?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah we'll use this later in the SDK. This class is almost identical to the iOS one.

*
* @hide
*/
internal data class SessionInfo(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this fine to have a separate class defined inside another class? I see a need for this sessionInfo to be accessible outside of this context - should we move this to something more open for other classes to use?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

internal is like swift - it's internal to the compilation unit, so other classes in the SDK can use it.


class SessionGeneratorTest {
fun isValidSessionId(sessionId: String): Boolean {
if (sessionId.length != 32) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a valid assumption? Why a specific need to be exactly 32 characters? I would rather recommend validating alpha numeric value of the sessionID.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this is a valid assumption of UUIDs - we have this in the iOS SDK too

internal class SessionGenerator(collectEvents: Boolean) {
private var firstSessionId = ""
private var sessionIndex: Int = -1
private var collectEvents = collectEvents
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we plan to have a dynamic toggle of collectEvents state? Eg: SessionGenerator starts with the collectEvents state to be false and somewhere between turns to be true. Is this a usecase we want to support?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not anymore - we decided that the collectEvents state is consistent for the run of the app

@samedson samedson merged commit 14fc4a8 into firebase-sessions Mar 7, 2023
@samedson samedson deleted the session-generator branch March 7, 2023 15:47
@firebase firebase locked and limited conversation to collaborators Apr 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants