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 14 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-25 22:25:30.381115193 +0000
+++ /home/runner/diff/modified/firebase-kotlindoc/android/com/google/firebase/crashlytics/FirebaseCrashlytics.html	2024-11-25 22:22:59.501695586 +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-25 22:25:30.373115223 +0000
+++ /home/runner/diff/modified/firebase-kotlindoc/kotlin/com/google/firebase/crashlytics/FirebaseCrashlytics.html	2024-11-25 22:22:59.497695601 +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

@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

0 files   - 20  0 suites   - 20   0s ⏱️ -34s
0 tests  - 23  0 ✅  - 23  0 💤 ±0  0 ❌ ±0 
0 runs   - 68  0 ✅  - 68  0 💤 ±0  0 ❌ ±0 

Results for commit dfaf14d. ± Comparison against base commit 04bfe55.

♻️ 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 (04bfe55)Merge (d5e4a5e)Diff
    aar411 kB413 kB+2.49 kB (+0.6%)
    apk (aggressive)698 kB698 kB+52 B (+0.0%)
    apk (release)5.85 MB5.85 MB+2.53 kB (+0.0%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/XsAyl0k7vL.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