Skip to content
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

Add an overload to FirebaseCrashlytics.recordException to attach additional custom key value pairs #6528

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

tejasd
Copy link
Contributor

@tejasd tejasd commented Nov 20, 2024

This PR adds a method public void recordException(@NonNull Throwable throwable, Map<String, String> userInfo) as an overload to the existing recordException method in Crashlytics to allow attaching additional custom keys to the specific event. This restores parity w/ the behaviour on iOS.

Details:

  • The key value pairs passed through this method override the global custom keys (if there are any duplicates)

Additionally:

  • Creates a new EventMetadata class to represent sessionId and timestamp attached to non fatal events.

Copy link
Contributor

github-actions bot commented Nov 20, 2024

Javadoc Changes:
--- /home/runner/diff/original/firebase-kotlindoc/android/com/google/firebase/crashlytics/FirebaseCrashlytics.html	2024-11-21 17:15:37.090331321 +0000
+++ /home/runner/diff/modified/firebase-kotlindoc/android/com/google/firebase/crashlytics/FirebaseCrashlytics.html	2024-11-21 17:13:08.626606418 +0000
@@ -79,6 +79,13 @@
           <tr>
             <td><code>void</code></td>
             <td>
+              <div><code><a href="/docs/reference/android/com/google/firebase/crashlytics/FirebaseCrashlytics.html#recordException(java.lang.Throwable,java.util.Map&lt;java.lang.String,java.lang.String&gt;)">recordException</a>(<br>&nbsp;&nbsp;&nbsp;&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/Throwable.html">Throwable</a>&nbsp;throwable,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/kotlin/java/util/Map.html">Map</a>&lt;<a href="https://developer.android.com/reference/kotlin/java/lang/String.html">String</a>,&nbsp;<a href="https://developer.android.com/reference/kotlin/java/lang/String.html">String</a>&gt;&nbsp;userInfo<br>)</code></div>
+              <p>Records a non-fatal report to send to Crashlytics.</p>
+            </td>
+          </tr>
+          <tr>
+            <td><code>void</code></td>
+            <td>
               <div><code><a href="/docs/reference/android/com/google/firebase/crashlytics/FirebaseCrashlytics.html#sendUnsentReports()">sendUnsentReports</a>()</code></div>
               <p>If automatic data collection is disabled, this method queues up all the reports on a device to send to Crashlytics.</p>
             </td>
@@ -333,6 +340,38 @@
                 </td>
               </tr>
             </tbody>
+          </table>
+        </div>
+      </div>
+      <div class="api-item"><a name="recordException(java.lang.Throwable, java.util.Map&lt;java.lang.String,java.lang.String&gt;)"></a><a name="recordException-java.lang.Throwable-java.util.Map&lt;java.lang.String,java.lang.String&gt;-"></a><a name="recordexception"></a>
+        <h3 class="api-name" id="recordException(java.lang.Throwable,java.util.Map&lt;java.lang.String,java.lang.String&gt;)">recordException</h3>
+        <pre class="api-signature no-pretty-print">public&nbsp;void&nbsp;<a href="/docs/reference/android/com/google/firebase/crashlytics/FirebaseCrashlytics.html#recordException(java.lang.Throwable,java.util.Map&lt;java.lang.String,java.lang.String&gt;)">recordException</a>(<br>&nbsp;&nbsp;&nbsp;&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/Throwable.html">Throwable</a>&nbsp;throwable,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/kotlin/java/util/Map.html">Map</a>&lt;<a href="https://developer.android.com/reference/kotlin/java/lang/String.html">String</a>,&nbsp;<a href="https://developer.android.com/reference/kotlin/java/lang/String.html">String</a>&gt;&nbsp;userInfo<br>)</pre>
+        <p>Records a non-fatal report to send to Crashlytics.</p>
+        <div class="devsite-table-wrapper">
+          <table class="responsive">
+            <colgroup>
+              <col width="40%">
+              <col>
+            </colgroup>
+            <thead>
+              <tr>
+                <th colspan="100%">Parameters</th>
+              </tr>
+            </thead>
+            <tbody class="list">
+              <tr>
+                <td><code>@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/kotlin/java/lang/Throwable.html">Throwable</a>&nbsp;throwable</code></td>
+                <td>
+                  <p>a <code><a href="https://developer.android.com/reference/kotlin/java/lang/Throwable.html">Throwable</a></code> to be recorded as a non-fatal event.</p>
+                </td>
+              </tr>
+              <tr>
+                <td><code>@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/kotlin/java/util/Map.html">Map</a>&lt;<a href="https://developer.android.com/reference/kotlin/java/lang/String.html">String</a>,&nbsp;<a href="https://developer.android.com/reference/kotlin/java/lang/String.html">String</a>&gt;&nbsp;userInfo</code></td>
+                <td>
+                  <p>a <code><a href="https://developer.android.com/reference/kotlin/java/util/Map.html">Map</a></code> to add key value pairs to be recorded with the non fatal exception.</p>
+                </td>
+              </tr>
+            </tbody>
           </table>
         </div>
       </div>
--- /home/runner/diff/original/firebase-kotlindoc/kotlin/com/google/firebase/crashlytics/FirebaseCrashlytics.html	2024-11-21 17:15:37.090331321 +0000
+++ /home/runner/diff/modified/firebase-kotlindoc/kotlin/com/google/firebase/crashlytics/FirebaseCrashlytics.html	2024-11-21 17:13:08.610606448 +0000
@@ -79,6 +79,13 @@
           <tr>
             <td><code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td>
             <td>
+              <div><code><a href="/docs/reference/kotlin/com/google/firebase/crashlytics/FirebaseCrashlytics.html#recordException(java.lang.Throwable,java.util.Map&lt;java.lang.String,java.lang.String&gt;)">recordException</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;throwable:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html">Throwable</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;userInfo:&nbsp;(<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html">Mutable</a>)<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html">Map</a>&lt;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html">String</a>!,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html">String</a>!&gt;<br>)</code></div>
+              <p>Records a non-fatal report to send to Crashlytics.</p>
+            </td>
+          </tr>
+          <tr>
+            <td><code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></code></td>
+            <td>
               <div><code><a href="/docs/reference/kotlin/com/google/firebase/crashlytics/FirebaseCrashlytics.html#sendUnsentReports()">sendUnsentReports</a>()</code></div>
               <p>If automatic data collection is disabled, this method queues up all the reports on a device to send to Crashlytics.</p>
             </td>
@@ -333,6 +340,38 @@
                 </td>
               </tr>
             </tbody>
+          </table>
+        </div>
+      </div>
+      <div class="api-item"><a name="recordException(java.lang.Throwable, java.util.Map&lt;java.lang.String,java.lang.String&gt;)"></a><a name="recordException-java.lang.Throwable-java.util.Map&lt;java.lang.String,java.lang.String&gt;-"></a><a name="recordexception"></a>
+        <h3 class="api-name" id="recordException(java.lang.Throwable,java.util.Map&lt;java.lang.String,java.lang.String&gt;)">recordException</h3>
+        <pre class="api-signature no-pretty-print">fun&nbsp;<a href="/docs/reference/kotlin/com/google/firebase/crashlytics/FirebaseCrashlytics.html#recordException(java.lang.Throwable,java.util.Map&lt;java.lang.String,java.lang.String&gt;)">recordException</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;throwable:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html">Throwable</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;userInfo:&nbsp;(<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html">Mutable</a>)<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html">Map</a>&lt;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html">String</a>!,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html">String</a>!&gt;<br>):&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></pre>
+        <p>Records a non-fatal report to send to Crashlytics.</p>
+        <div class="devsite-table-wrapper">
+          <table class="responsive">
+            <colgroup>
+              <col width="40%">
+              <col>
+            </colgroup>
+            <thead>
+              <tr>
+                <th colspan="100%">Parameters</th>
+              </tr>
+            </thead>
+            <tbody class="list">
+              <tr>
+                <td><code>throwable:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html">Throwable</a></code></td>
+                <td>
+                  <p>a <code><a href="https://developer.android.com/reference/kotlin/java/lang/Throwable.html">Throwable</a></code> to be recorded as a non-fatal event.</p>
+                </td>
+              </tr>
+              <tr>
+                <td><code>userInfo:&nbsp;(<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html">Mutable</a>)<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html">Map</a>&lt;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html">String</a>!,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html">String</a>!&gt;</code></td>
+                <td>
+                  <p>a <code><a href="https://developer.android.com/reference/kotlin/java/util/Map.html">Map</a></code> to add key value pairs to be recorded with the non fatal exception.</p>
+                </td>
+              </tr>
+            </tbody>
           </table>
         </div>
       </div>

Copy link
Contributor

Vertex AI Mock Responses Check ⚠️

A newer major version of the mock responses for Vertex AI unit tests is available. update_responses.sh should be updated to clone the latest version of the responses: v5.2

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Nov 20, 2024

Coverage Report 1

Affected Products

  • firebase-crashlytics

    Overall coverage changed from 11.59% (6a03d4c) to 11.63% (b66b8ff) by +0.04%.

    FilenameBase (6a03d4c)Merge (b66b8ff)Diff
    CrashlyticsController.java18.57%18.52%-0.05%
    EventMetadata.kt?0.00%?
    SessionReportingCoordinator.java42.20%43.09%+0.90%

Test Logs

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

@google-oss-bot
Copy link
Contributor

The public api surface has changed for the subproject firebase-crashlytics:
error: Added method com.google.firebase.crashlytics.FirebaseCrashlytics.recordException(Throwable,java.util.Map<java.lang.String,java.lang.String>) [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.

Copy link
Contributor

github-actions bot commented Nov 20, 2024

Test Results

 8 files   -  1 028   8 suites   - 1 028   25s ⏱️ - 36m 12s
22 tests  -  5 851  22 ✅  -  5 829  0 💤  - 22  0 ❌ ±0 
44 runs   - 11 787  44 ✅  - 11 743  0 💤  - 44  0 ❌ ±0 

Results for commit 1b5f09e. ± Comparison against base commit 6a03d4c.

This pull request removes 5851 tests.
com.google.android.datatransport.cct.CctBackendFactoryTest ‑ create_returnCCTBackend_WhenBackendNameIsCCT
com.google.android.datatransport.cct.CctDestinationTest ‑ cctDestination_shouldOnlySupportProtoAndJson
com.google.android.datatransport.cct.CctDestinationTest ‑ cctDestination_shouldSupportProtoAndJson
com.google.android.datatransport.cct.CctTransportBackendTest ‑ decorate_whenOffline_shouldProperlyPopulateNetworkInfo
com.google.android.datatransport.cct.CctTransportBackendTest ‑ decorate_whenOnline_shouldProperlyPopulateNetworkInfo
com.google.android.datatransport.cct.CctTransportBackendTest ‑ schedule_shouldAddCookieOnPseudonymousIds
com.google.android.datatransport.cct.CctTransportBackendTest ‑ schedule_shouldDropCookieOnMixedPseudonymousIds
com.google.android.datatransport.cct.CctTransportBackendTest ‑ send_CompressedResponseIsUncompressed
com.google.android.datatransport.cct.CctTransportBackendTest ‑ send_whenBackendRedirectsMoreThan5Times_shouldOnlyRedirect4Times
com.google.android.datatransport.cct.CctTransportBackendTest ‑ send_whenBackendRedirects_shouldCorrectlyFollowTheRedirectViaPost
…

♻️ This comment has been updated with latest results.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Nov 20, 2024

Size Report 1

Affected Products

  • firebase-crashlytics

    TypeBase (6a03d4c)Merge (b66b8ff)Diff
    aar411 kB413 kB+2.40 kB (+0.6%)
    apk (aggressive)698 kB698 kB+52 B (+0.0%)
    apk (release)5.85 MB5.85 MB+2.38 kB (+0.0%)

Test Logs

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

@google-oss-bot
Copy link
Contributor

The public api surface has changed for the subproject firebase-crashlytics:
error: Added method com.google.firebase.crashlytics.FirebaseCrashlytics.recordException(Throwable,java.util.Map<java.lang.String,java.lang.String>) [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.

1 similar comment
@google-oss-bot
Copy link
Contributor

The public api surface has changed for the subproject firebase-crashlytics:
error: Added method com.google.firebase.crashlytics.FirebaseCrashlytics.recordException(Throwable,java.util.Map<java.lang.String,java.lang.String>) [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.

@tejasd tejasd changed the title Initial implementation of recording a custom key value pair in recordExcpetion. Add an overload to FirebaseCrashlytics.recordException to attach additional custom key value pairs Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants