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

Merged
merged 50 commits into from
Dec 5, 2024

Conversation

tejasd
Copy link
Contributor

@tejasd tejasd commented Nov 20, 2024

This PR adds a method public void recordException(@NonNull Throwable throwable, CustomKeysAndValues keysAndValues) as an overload to the existing recordException method in Crashlytics to allow attaching additional custom keys to the specific event.

Details:

  • The total number of custom key/value pairs are still restricted to 64
  • App level custom keys take precedence over event specific custom keys for the 64 key/value pair limit
  • The values of event keys override the value of global custom keys if they're identical

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-12-05 20:39:24.625934594 +0000
+++ /home/runner/diff/modified/firebase-kotlindoc/android/com/google/firebase/crashlytics/FirebaseCrashlytics.html	2024-12-05 20:36:53.610282592 +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,com.google.firebase.crashlytics.CustomKeysAndValues)">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="/docs/reference/android/com/google/firebase/crashlytics/CustomKeysAndValues.html">CustomKeysAndValues</a>&nbsp;keysAndValues<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,40 @@
                 </td>
               </tr>
             </tbody>
+          </table>
+        </div>
+      </div>
+      <div class="api-item"><a name="recordException(java.lang.Throwable, com.google.firebase.crashlytics.CustomKeysAndValues)"></a><a name="recordException-java.lang.Throwable-com.google.firebase.crashlytics.CustomKeysAndValues-"></a><a name="recordexception"></a>
+        <h3 class="api-name" id="recordException(java.lang.Throwable,com.google.firebase.crashlytics.CustomKeysAndValues)">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,com.google.firebase.crashlytics.CustomKeysAndValues)">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="/docs/reference/android/com/google/firebase/crashlytics/CustomKeysAndValues.html">CustomKeysAndValues</a>&nbsp;keysAndValues<br>)</pre>
+        <p>Records a non-fatal report to send to Crashlytics. </p>
+        <p>Combined with app level custom keys, the event is restricted to a maximum of 64 key/value pairs. New keys beyond that limit are ignored. Keys or values that exceed 1024 characters are truncated. </p>
+        <p>The values of event keys override the values of app level custom keys if they're identical.</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="/docs/reference/android/com/google/firebase/crashlytics/CustomKeysAndValues.html">CustomKeysAndValues</a>&nbsp;keysAndValues</code></td>
+                <td>
+                  <p>A dictionary of keys and the values to associate with the non fatal exception, in addition to the app level custom keys.</p>
+                </td>
+              </tr>
+            </tbody>
           </table>
         </div>
       </div>
--- /home/runner/diff/original/firebase-kotlindoc/kotlin/com/google/firebase/crashlytics/FirebaseCrashlytics.html	2024-12-05 20:39:24.613934621 +0000
+++ /home/runner/diff/modified/firebase-kotlindoc/kotlin/com/google/firebase/crashlytics/FirebaseCrashlytics.html	2024-12-05 20:36:53.594282619 +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,com.google.firebase.crashlytics.CustomKeysAndValues)">recordException</a>(throwable:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html">Throwable</a>,&nbsp;keysAndValues:&nbsp;<a href="/docs/reference/kotlin/com/google/firebase/crashlytics/CustomKeysAndValues.html">CustomKeysAndValues</a>)</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,40 @@
                 </td>
               </tr>
             </tbody>
+          </table>
+        </div>
+      </div>
+      <div class="api-item"><a name="recordException(java.lang.Throwable, com.google.firebase.crashlytics.CustomKeysAndValues)"></a><a name="recordException-java.lang.Throwable-com.google.firebase.crashlytics.CustomKeysAndValues-"></a><a name="recordexception"></a>
+        <h3 class="api-name" id="recordException(java.lang.Throwable,com.google.firebase.crashlytics.CustomKeysAndValues)">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,com.google.firebase.crashlytics.CustomKeysAndValues)">recordException</a>(throwable:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html">Throwable</a>,&nbsp;keysAndValues:&nbsp;<a href="/docs/reference/kotlin/com/google/firebase/crashlytics/CustomKeysAndValues.html">CustomKeysAndValues</a>):&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>
+        <p>Combined with app level custom keys, the event is restricted to a maximum of 64 key/value pairs. New keys beyond that limit are ignored. Keys or values that exceed 1024 characters are truncated. </p>
+        <p>The values of event keys override the values of app level custom keys if they're identical.</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>keysAndValues:&nbsp;<a href="/docs/reference/kotlin/com/google/firebase/crashlytics/CustomKeysAndValues.html">CustomKeysAndValues</a></code></td>
+                <td>
+                  <p>A dictionary of keys and the values to associate with the non fatal exception, in addition to the app level custom keys.</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.56% (37f8134) to 11.53% (5bc04fe) by -0.03%.

    FilenameBase (37f8134)Merge (5bc04fe)Diff
    CrashlyticsController.java18.57%18.52%-0.05%
    EventMetadata.kt?0.00%?
    SessionReportingCoordinator.java42.20%42.13%-0.06%
    UserMetadata.java22.33%19.17%-3.16%

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/2JDGdf7rUM.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   -   140   8 suites   - 140   20s ⏱️ - 2m 41s
22 tests  - 1 041  22 ✅  - 1 041  0 💤 ±0  0 ❌ ±0 
44 runs   - 2 090  44 ✅  - 2 090  0 💤 ±0  0 ❌ ±0 

Results for commit 79417ac. ± Comparison against base commit 37f8134.

This pull request removes 1041 tests.
com.google.firebase.perf.FirebasePerfRegistrarTest ‑ testGetComponents
com.google.firebase.perf.FirebasePerformanceTest ‑ firebasePerformanceInitialization_providesRcProvider_remoteConfigManagerIsSet
com.google.firebase.perf.FirebasePerformanceTest ‑ initFirebasePerformance_injectsMetadataIntoConfigResolver
com.google.firebase.perf.FirebasePerformanceTest ‑ initializeFirebasePerformance_emptyMetadataAndCache_metadataAndContextInjected
com.google.firebase.perf.FirebasePerformanceTest ‑ setDataCollectionDefaultEnabled_whenForceDisabledThenCleared_respectsGlobalFlag
com.google.firebase.perf.FirebasePerformanceTest ‑ setDataCollectionDefaultEnabled_whenForceDisabledThenCleared_respectsManifestTrue
com.google.firebase.perf.FirebasePerformanceTest ‑ setDataCollectionDefaultEnabled_whenForceEnabledThenCleared_respectsGlobalFlag
com.google.firebase.perf.FirebasePerformanceTest ‑ setDataCollectionDefaultEnabled_whenForceEnabledThenCleared_respectsManifestFalse
com.google.firebase.perf.FirebasePerformanceTest ‑ testAddingMoreThanMaxLocalAttributes
com.google.firebase.perf.FirebasePerformanceTest ‑ testBothManifestsAgree
…

♻️ 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 (37f8134)Merge (5bc04fe)Diff
    aar412 kB415 kB+2.99 kB (+0.7%)
    apk (aggressive)698 kB699 kB+392 B (+0.1%)
    apk (release)5.85 MB5.85 MB+2.83 kB (+0.0%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/mM1o0BsVSp.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
@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,com.google.firebase.crashlytics.CustomKeysAndValues) [AddedMethod]
error: Removed method com.google.firebase.crashlytics.FirebaseCrashlytics.recordException(Throwable,java.util.Map<java.lang.String,java.lang.String>) [RemovedMethod]

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,com.google.firebase.crashlytics.CustomKeysAndValues) [AddedMethod]
error: Removed method com.google.firebase.crashlytics.FirebaseCrashlytics.recordException(Throwable,java.util.Map<java.lang.String,java.lang.String>) [RemovedMethod]

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

@mrober mrober left a comment

Choose a reason for hiding this comment

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

LGTM just a few small nits!

@tejasd tejasd merged commit 71ceb1b into main Dec 5, 2024
42 checks passed
@tejasd tejasd deleted the td/record-exception branch December 5, 2024 20:53
@firebase firebase locked and limited conversation to collaborators Jan 5, 2025
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