Skip to content

Conversation

@jrothfeder
Copy link
Contributor

No description provided.

@jrothfeder jrothfeder changed the title Session storage Wire datastore in to FirebaseLifecycleService Oct 13, 2023
*/
internal class SessionLifecycleService : Service() {
internal class SessionLifecycleService(
private var datastore: SessionDatastore = SessionDatastore(Firebase.app.applicationContext))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is Firebase.app guaranteed to exist when this is constructed?

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 think so. Isn't it created first?

updateSessionStorage(null, timeMs)
}

private fun updateSessionStorage(sessionId: String?, timeMs: Long) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You could say sessionId: String = null here instead of the manual overloading with and without sessionId.

// Send the value from the datastore before the first foregrounding it exists
val sessionData = currentSessionFromDatastore.get()
if (sessionData != null) {
sessionData.sessionId?.let { sendSessionToClient(client, it) }
Copy link
Contributor

Choose a reason for hiding this comment

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

sessionData?.sessionId?.let will remove the if null check.

* The callback class that will be used to receive updated session events from the
* [SessionLifecycleService].
*/
// TODO(rothbutter) should we use the main looper or is there one available in this SDK?
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine for now. I'll make the firebase common ones easy to access.

}
}
lastMsgTimeMs = msg.getWhen()
updateSessionStorage(lastMsgTimeMs) // TODO(rothbutter) don't think we need this, eh?
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure. If we don't, that will be much better. I am a bit worried about using a timestamp like this, because clocks can change with daylight savings and leap seconds and whatever. In the WallClock object there is elapsedRealtime which is a monotonic increasing clock so won't go backwards no matter what happens on the calendar. Otherwise an hour forward might make everything a new session.

@jrothfeder jrothfeder merged commit 83d407e into sessions-nine Oct 16, 2023
@jrothfeder jrothfeder deleted the session-storage branch October 16, 2023 17:17
@google-oss-bot
Copy link
Contributor

1 Warning
⚠️ Did you forget to add a changelog entry? (Add the 'no-changelog' label to the PR to silence this warning.)

Generated by 🚫 Danger

@google-oss-bot
Copy link
Contributor

Coverage Report 1

Affected Products

  • firebase-sessions

    Overall coverage changed from ? (716b65c) to 59.25% (46a9e0a) by ?.

    26 individual files with coverage change

    FilenameBase (716b65c)Merge (46a9e0a)Diff
    ApplicationInfo.kt?100.00%?
    AutoSessionEventEncoder.java?100.00%?
    Comparisons.kt?0.00%?
    Emitters.kt?0.00%?
    EventGDTLogger.kt?75.00%?
    FirebaseSessions.kt?0.00%?
    FirebaseSessionsDependencies.kt?91.30%?
    FirebaseSessionsRegistrar.kt?74.07%?
    LocalOverrideSettings.kt?100.00%?
    RemoteSettings.kt?88.06%?
    RemoteSettingsFetcher.kt?65.85%?
    SafeCollector.common.kt?0.00%?
    SessionDatastore.kt?0.00%?
    SessionEvent.kt?100.00%?
    SessionEvents.kt?97.78%?
    SessionFirelogPublisher.kt?66.67%?
    SessionGenerator.kt?84.00%?
    SessionInitiateListener.kt?0.00%?
    SessionInitiator.kt?74.19%?
    SessionLifecycleClient.kt?0.00%?
    SessionLifecycleService.kt?0.00%?
    SessionsSettings.kt?58.49%?
    SessionSubscriber.kt?75.00%?
    SettingsCache.kt?94.83%?
    SettingsProvider.kt?50.00%?
    TimeProvider.kt?0.00%?

Test Logs

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

@google-oss-bot
Copy link
Contributor

Size Report 1

Affected Products

  • base

    TypeBase (716b65c)Merge (46a9e0a)Diff
    apk (aggressive)?8.39 kB? (?)
    apk (release)?8.66 kB? (?)
  • firebase-installations

    TypeBase (716b65c)Merge (46a9e0a)Diff
    aar?58.8 kB? (?)
    apk (aggressive)?127 kB? (?)
    apk (release)?1.67 MB? (?)
  • firebase-installations-interop

    TypeBase (716b65c)Merge (46a9e0a)Diff
    aar?8.17 kB? (?)
    apk (aggressive)?65.2 kB? (?)
    apk (release)?652 kB? (?)
  • firebase-sessions

    TypeBase (716b65c)Merge (46a9e0a)Diff
    aar?145 kB? (?)
    apk (aggressive)?370 kB? (?)
    apk (release)?2.08 MB? (?)

Test Logs

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

@firebase firebase locked and limited conversation to collaborators Nov 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants