Skip to content

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

Merged
merged 15 commits into from
May 16, 2023

Conversation

mrober
Copy link
Contributor

@mrober mrober commented May 8, 2023

Add register api to FirebaseSessions so products can integrate with Sessions.

# Conflicts:
#	firebase-sessions/src/main/kotlin/com/google/firebase/sessions/FirebaseSessionsRegistrar.kt
#	firebase-sessions/src/test/kotlin/com/google/firebase/sessions/SessionCoordinatorTest.kt
@mrober mrober requested review from visumickey and samedson May 8, 2023 18:37
@google-oss-bot
Copy link
Contributor

google-oss-bot commented May 8, 2023

Coverage Report 1

Affected Products

  • firebase-sessions

    Overall coverage changed from ? (97675ee) to 68.74% (d8fdd9e) by ?.

    18 individual files with coverage change

    FilenameBase (97675ee)Merge (d8fdd9e)Diff
    ApplicationInfo.kt?100.00%?
    EventGDTLogger.kt?75.00%?
    FirebaseSessions.kt?0.00%?
    FirebaseSessionsDependencies.kt?91.30%?
    FirebaseSessionsRegistrar.kt?0.00%?
    LocalOverrideSettings.kt?88.46%?
    RemoteSettings.kt?86.25%?
    RemoteSettingsFetcher.kt?3.03%?
    SessionCoordinator.kt?75.00%?
    SessionEvent.kt?100.00%?
    SessionEvents.kt?98.73%?
    SessionGenerator.kt?20.00%?
    SessionInitiator.kt?66.67%?
    SessionsSettings.kt?90.00%?
    SessionSubscriber.kt?75.00%?
    SettingsCache.kt?94.12%?
    SettingsProvider.kt?0.00%?
    Time.kt?0.00%?

Test Logs

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

@github-actions
Copy link
Contributor

github-actions bot commented May 8, 2023

Unit Test Results

24 files  24 suites   36s ⏱️
42 tests 42 ✔️ 0 💤 0
84 runs  84 ✔️ 0 💤 0

Results for commit dd9ed1b.

♻️ This comment has been updated with latest results.

@google-oss-bot
Copy link
Contributor

The public api surface has changed for the subproject firebase-sessions:
error: Added method com.google.firebase.sessions.FirebaseSessions.register(com.google.firebase.sessions.api.SessionSubscriber) [AddedMethod]

Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented May 8, 2023

Size Report 1

Affected Products

  • base

    TypeBase (97675ee)Merge (d8fdd9e)Diff
    apk (aggressive)?8.39 kB? (?)
    apk (release)?8.65 kB? (?)
  • firebase-datatransport

    TypeBase (97675ee)Merge (d8fdd9e)Diff
    aar?4.94 kB? (?)
    apk (aggressive)?161 kB? (?)
    apk (release)?1.35 MB? (?)
  • firebase-sessions

    TypeBase (97675ee)Merge (d8fdd9e)Diff
    aar?107 kB? (?)

Test Logs

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

@github-actions
Copy link
Contributor

github-actions bot commented May 8, 2023

Javadoc Changes:
--- /Users/runner/diff/original/firebase-kotlindoc/android/com/google/firebase/sessions/FirebaseSessions.html	2023-05-12 19:09:09.000000000 +0000
+++ /Users/runner/diff/modified/firebase-kotlindoc/android/com/google/firebase/sessions/FirebaseSessions.html	2023-05-12 19:04:02.000000000 +0000
@@ -72,9 +72,10 @@
             </td>
           </tr>
           <tr>
-            <td><code>final @<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/kotlin/java/lang/String.html">String</a></code></td>
+            <td><code>final void</code></td>
             <td>
-              <div><code>@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/Discouraged.html">Discouraged</a>(message&nbsp;=&nbsp;&quot;This will be replaced with a real API.&quot;)<br><a href="/docs/reference/android/com/google/firebase/sessions/FirebaseSessions.html#greeting()">greeting</a>()</code></div>
+              <div><code><a href="/docs/reference/android/com/google/firebase/sessions/FirebaseSessions.html#register(com.google.firebase.sessions.api.SessionSubscriber)">register</a>(@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> <a href="/docs/reference/android/com/google/firebase/sessions/api/SessionSubscriber.html">SessionSubscriber</a>&nbsp;subscriber)</code></div>
+              <p>Register the <code><a href="/docs/reference/android/com/google/firebase/sessions/FirebaseSessions.html#register(com.google.firebase.sessions.api.SessionSubscriber)">subscriber</a></code>.</p>
             </td>
           </tr>
         </tbody>
@@ -93,9 +94,10 @@
         <h3 class="api-name" id="getInstance(com.google.firebase.FirebaseApp)">getInstance</h3>
         <pre class="api-signature no-pretty-print">public&nbsp;static&nbsp;final&nbsp;@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> <a href="/docs/reference/android/com/google/firebase/sessions/FirebaseSessions.html">FirebaseSessions</a>&nbsp;<a href="/docs/reference/android/com/google/firebase/sessions/FirebaseSessions.Companion.html#getInstance(com.google.firebase.FirebaseApp)">getInstance</a>(@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> <a href="/docs/reference/android/com/google/firebase/FirebaseApp.html">FirebaseApp</a>&nbsp;app)</pre>
       </div>
-      <div class="api-item"><a name="greeting--"></a><a name="greeting"></a>
-        <h3 class="api-name" id="greeting()">greeting</h3>
-        <pre class="api-signature no-pretty-print">@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/Discouraged.html">Discouraged</a>(message&nbsp;=&nbsp;&quot;This will be replaced with a real API.&quot;)<br>public&nbsp;final&nbsp;@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/kotlin/java/lang/String.html">String</a>&nbsp;<a href="/docs/reference/android/com/google/firebase/sessions/FirebaseSessions.html#greeting()">greeting</a>()</pre>
+      <div class="api-item"><a name="register-com.google.firebase.sessions.api.SessionSubscriber-"></a><a name="register"></a>
+        <h3 class="api-name" id="register(com.google.firebase.sessions.api.SessionSubscriber)">register</h3>
+        <pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;void&nbsp;<a href="/docs/reference/android/com/google/firebase/sessions/FirebaseSessions.html#register(com.google.firebase.sessions.api.SessionSubscriber)">register</a>(@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> <a href="/docs/reference/android/com/google/firebase/sessions/api/SessionSubscriber.html">SessionSubscriber</a>&nbsp;subscriber)</pre>
+        <p>Register the <code><a href="/docs/reference/android/com/google/firebase/sessions/FirebaseSessions.html#register(com.google.firebase.sessions.api.SessionSubscriber)">subscriber</a></code>. This must be called for every dependency.</p>
       </div>
     </div>
   </body>
--- /Users/runner/diff/original/firebase-kotlindoc/android/com/google/firebase/sessions/api/SessionSubscriber.Name.html	2023-05-12 19:09:09.000000000 +0000
+++ /Users/runner/diff/modified/firebase-kotlindoc/android/com/google/firebase/sessions/api/SessionSubscriber.Name.html	2023-05-12 19:04:02.000000000 +0000
@@ -48,6 +48,10 @@
             <td></td>
           </tr>
           <tr>
+            <td><code><a href="/docs/reference/android/com/google/firebase/sessions/api/SessionSubscriber.Name.html#MATT_SAYS_HI">MATT_SAYS_HI</a></code></td>
+            <td></td>
+          </tr>
+          <tr>
             <td><code><a href="/docs/reference/android/com/google/firebase/sessions/api/SessionSubscriber.Name.html#PERFORMANCE">PERFORMANCE</a></code></td>
             <td></td>
           </tr>
@@ -90,6 +94,10 @@
         <pre class="api-signature no-pretty-print"><a href="/docs/reference/android/com/google/firebase/sessions/api/SessionSubscriber.Name.html">SessionSubscriber.Name</a>&nbsp;<a href="/docs/reference/android/com/google/firebase/sessions/api/SessionSubscriber.Name.html#CRASHLYTICS">SessionSubscriber.Name.CRASHLYTICS</a></pre>
       </div>
       <div class="api-item">
+        <h3 class="api-name" id="MATT_SAYS_HI">MATT_SAYS_HI</h3>
+        <pre class="api-signature no-pretty-print"><a href="/docs/reference/android/com/google/firebase/sessions/api/SessionSubscriber.Name.html">SessionSubscriber.Name</a>&nbsp;<a href="/docs/reference/android/com/google/firebase/sessions/api/SessionSubscriber.Name.html#MATT_SAYS_HI">SessionSubscriber.Name.MATT_SAYS_HI</a></pre>
+      </div>
+      <div class="api-item">
         <h3 class="api-name" id="PERFORMANCE">PERFORMANCE</h3>
         <pre class="api-signature no-pretty-print"><a href="/docs/reference/android/com/google/firebase/sessions/api/SessionSubscriber.Name.html">SessionSubscriber.Name</a>&nbsp;<a href="/docs/reference/android/com/google/firebase/sessions/api/SessionSubscriber.Name.html#PERFORMANCE">SessionSubscriber.Name.PERFORMANCE</a></pre>
       </div>
--- /Users/runner/diff/original/firebase-kotlindoc/kotlin/com/google/firebase/sessions/FirebaseSessions.html	2023-05-12 19:09:09.000000000 +0000
+++ /Users/runner/diff/modified/firebase-kotlindoc/kotlin/com/google/firebase/sessions/FirebaseSessions.html	2023-05-12 19:04:02.000000000 +0000
@@ -67,9 +67,10 @@
         </thead>
         <tbody class="list">
           <tr>
-            <td><code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html">String</a></code></td>
+            <td><code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td>
             <td>
-              <div><code>@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/Discouraged.html">Discouraged</a>(message&nbsp;=&nbsp;&quot;This will be replaced with a real API.&quot;)<br><a href="/docs/reference/kotlin/com/google/firebase/sessions/FirebaseSessions.html#greeting()">greeting</a>()</code></div>
+              <div><code><a href="/docs/reference/kotlin/com/google/firebase/sessions/FirebaseSessions.html#register(com.google.firebase.sessions.api.SessionSubscriber)">register</a>(subscriber:&nbsp;<a href="/docs/reference/kotlin/com/google/firebase/sessions/api/SessionSubscriber.html">SessionSubscriber</a>)</code></div>
+              <p>Register the <code><a href="/docs/reference/kotlin/com/google/firebase/sessions/FirebaseSessions.html#register(com.google.firebase.sessions.api.SessionSubscriber)">subscriber</a></code>.</p>
             </td>
           </tr>
         </tbody>
@@ -91,9 +92,10 @@
     </div>
     <div class="list">
       <h2>Public functions</h2>
-      <div class="api-item"><a name="greeting--"></a><a name="greeting"></a>
-        <h3 class="api-name" id="greeting()">greeting</h3>
-        <pre class="api-signature no-pretty-print">@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/Discouraged.html">Discouraged</a>(message&nbsp;=&nbsp;&quot;This will be replaced with a real API.&quot;)<br>fun&nbsp;<a href="/docs/reference/kotlin/com/google/firebase/sessions/FirebaseSessions.html#greeting()">greeting</a>():&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html">String</a></pre>
+      <div class="api-item"><a name="register-com.google.firebase.sessions.api.SessionSubscriber-"></a><a name="register"></a>
+        <h3 class="api-name" id="register(com.google.firebase.sessions.api.SessionSubscriber)">register</h3>
+        <pre class="api-signature no-pretty-print">fun&nbsp;<a href="/docs/reference/kotlin/com/google/firebase/sessions/FirebaseSessions.html#register(com.google.firebase.sessions.api.SessionSubscriber)">register</a>(subscriber:&nbsp;<a href="/docs/reference/kotlin/com/google/firebase/sessions/api/SessionSubscriber.html">SessionSubscriber</a>):&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></pre>
+        <p>Register the <code><a href="/docs/reference/kotlin/com/google/firebase/sessions/FirebaseSessions.html#register(com.google.firebase.sessions.api.SessionSubscriber)">subscriber</a></code>. This must be called for every dependency.</p>
       </div>
     </div>
   </body>
--- /Users/runner/diff/original/firebase-kotlindoc/kotlin/com/google/firebase/sessions/api/SessionSubscriber.Name.html	2023-05-12 19:09:09.000000000 +0000
+++ /Users/runner/diff/modified/firebase-kotlindoc/kotlin/com/google/firebase/sessions/api/SessionSubscriber.Name.html	2023-05-12 19:04:02.000000000 +0000
@@ -48,6 +48,10 @@
             <td></td>
           </tr>
           <tr>
+            <td><code><a href="/docs/reference/kotlin/com/google/firebase/sessions/api/SessionSubscriber.Name.html#MATT_SAYS_HI">MATT_SAYS_HI</a></code></td>
+            <td></td>
+          </tr>
+          <tr>
             <td><code><a href="/docs/reference/kotlin/com/google/firebase/sessions/api/SessionSubscriber.Name.html#PERFORMANCE">PERFORMANCE</a></code></td>
             <td></td>
           </tr>
@@ -90,6 +94,10 @@
         <pre class="api-signature no-pretty-print">val&nbsp;<a href="/docs/reference/kotlin/com/google/firebase/sessions/api/SessionSubscriber.Name.html#CRASHLYTICS">SessionSubscriber.Name.CRASHLYTICS</a>:&nbsp;<a href="/docs/reference/kotlin/com/google/firebase/sessions/api/SessionSubscriber.Name.html">SessionSubscriber.Name</a></pre>
       </div>
       <div class="api-item">
+        <h3 class="api-name" id="MATT_SAYS_HI">MATT_SAYS_HI</h3>
+        <pre class="api-signature no-pretty-print">val&nbsp;<a href="/docs/reference/kotlin/com/google/firebase/sessions/api/SessionSubscriber.Name.html#MATT_SAYS_HI">SessionSubscriber.Name.MATT_SAYS_HI</a>:&nbsp;<a href="/docs/reference/kotlin/com/google/firebase/sessions/api/SessionSubscriber.Name.html">SessionSubscriber.Name</a></pre>
+      </div>
+      <div class="api-item">
         <h3 class="api-name" id="PERFORMANCE">PERFORMANCE</h3>
         <pre class="api-signature no-pretty-print">val&nbsp;<a href="/docs/reference/kotlin/com/google/firebase/sessions/api/SessionSubscriber.Name.html#PERFORMANCE">SessionSubscriber.Name.PERFORMANCE</a>:&nbsp;<a href="/docs/reference/kotlin/com/google/firebase/sessions/api/SessionSubscriber.Name.html">SessionSubscriber.Name</a></pre>
       </div>

@google-oss-bot
Copy link
Contributor

google-oss-bot commented May 8, 2023

Startup Time Report 1

Note: Layout is sometimes suboptimal due to limited formatting support on GitHub. Please check this report on GCS.

Startup time comparison between the CI merge commit (a9d0fef) and the base commit (6c066f3) are not available.

No macrobenchmark data found for the base commit (6c066f3). Analysis for the CI merge commit (a9d0fef) can be found at:

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

@@ -17,3 +17,51 @@ package com.google.firebase.sessions {

}

package com.google.firebase.sessions.api {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a curiosity question on the purpose of api.txt. All of these are private/internal APIs - why document them here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was auto-generated by ./gradlew :firebase-sessions:generateApiTxtFile but it seems fine if I delete all these internal apis.

Copy link
Contributor

Choose a reason for hiding this comment

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

What are the legit APIs that should find a place here? Secondly, how do we control what does inside this file? We can do this as a separate validation task before we go out for launch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally I would like this to not expose any public API since it's for internal products only. But we need at least this to be public for Firebase to work with it.

} 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.
""
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 want to allow dispatching events with empty fids? Can we stop from such events to go through? Empty FID could lead to invalid data ingested.

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 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

mrober added 3 commits May 12, 2023 10:11
# Conflicts:
#	firebase-sessions/src/main/kotlin/com/google/firebase/sessions/api/SessionSubscriber.kt
@mrober mrober changed the base branch from firebase-sessions to sessions-deps May 12, 2023 14:44
@mrober mrober changed the base branch from sessions-deps to firebase-sessions May 12, 2023 14:45
@mrober mrober changed the base branch from firebase-sessions to sessions-deps May 12, 2023 14:50
Copy link
Contributor

@visumickey visumickey left a comment

Choose a reason for hiding this comment

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

All changes look good to me except for the empty FID scenario. Once that is clarified, this is good to get merged.

@@ -17,3 +17,51 @@ package com.google.firebase.sessions {

}

package com.google.firebase.sessions.api {
Copy link
Contributor

Choose a reason for hiding this comment

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

What are the legit APIs that should find a place here? Secondly, how do we control what does inside this file? We can do this as a separate validation task before we go out for launch.

} 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.
""
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Base automatically changed from sessions-deps to firebase-sessions May 12, 2023 18:55
# Conflicts:
#	firebase-sessions/src/main/kotlin/com/google/firebase/sessions/api/SessionSubscriber.kt
Copy link
Contributor

@samedson samedson left a comment

Choose a reason for hiding this comment

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

This looks great 👍

@mrober mrober merged commit 259fa0c into firebase-sessions May 16, 2023
@mrober mrober deleted the sessions-products branch May 16, 2023 19:32
@firebase firebase locked and limited conversation to collaborators Jun 16, 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