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

Improve AEI capture code quality #1694

Merged
merged 1 commit into from
Nov 21, 2024
Merged

Improve AEI capture code quality #1694

merged 1 commit into from
Nov 21, 2024

Conversation

fractalwrench
Copy link
Contributor

Goal

Improves the code quality of the AEI capture. I've attempted this by removing obsolete code constructs, renaming functions, moving to a more functional paradigm as opposed to mutating state, and by splitting up the data capture from the code that reads a trace file.

Testing

Relied on existing test coverage added in #1693

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

Attention: Patch coverage is 90.19608% with 5 lines in your changes missing coverage. Please review.

Project coverage is 84.32%. Comparing base (e855169) to head (b830c76).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...sdk/internal/capture/aei/ApplicationExitInfoExt.kt 86.66% 0 Missing and 4 partials ⚠️
...embracesdk/internal/injection/FeatureModuleImpl.kt 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1694      +/-   ##
==========================================
- Coverage   84.33%   84.32%   -0.01%     
==========================================
  Files         458      459       +1     
  Lines       10683    10646      -37     
  Branches     1604     1597       -7     
==========================================
- Hits         9009     8977      -32     
+ Misses        945      941       -4     
+ Partials      729      728       -1     
Files with missing lines Coverage Δ
...acesdk/internal/prefs/EmbracePreferencesService.kt 93.85% <100.00%> (ø)
...bracesdk/internal/capture/aei/AeiDataSourceImpl.kt 100.00% <100.00%> (+10.63%) ⬆️
...oid/embracesdk/internal/capture/aei/TraceResult.kt 100.00% <100.00%> (ø)
...embracesdk/internal/injection/FeatureModuleImpl.kt 99.19% <66.66%> (-0.81%) ⬇️
...sdk/internal/capture/aei/ApplicationExitInfoExt.kt 86.66% <86.66%> (ø)
---- 🚨 Try these New Features:

Base automatically changed from aei-tests to main November 21, 2024 13:12
@@ -191,11 +191,11 @@ internal class EmbraceInternalInterfaceTest {
assertAction = {
val session = getSingleSessionEnvelope()
val tapBreadcrumb = session.findSessionSpan().findEventOfType(EmbType.Ux.Tap)
tapBreadcrumb.attributes?.assertMatches {
"view.name" to "button"
"tap.coords" to "10,99"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did this change? Because some test fixtures changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

View taps no longer capture coordinates by default: https://github.com/embrace-io/embrace-android-sdk/blob/main/UPGRADING.md#upgrading-from-6x-to-7x

#1691 meant the change in behavior wasn't caught in the test. This change will disappear from the PR after a rebase


// number of results to be returned; a value of 0 means to ignore this parameter and return
// all matching records with a maximum of 16 entries
private fun processAeiRecords() {
val maxNum = appExitInfoBehavior.appExitInfoMaxNum()
Copy link
Collaborator

@bidetofevil bidetofevil Nov 21, 2024

Choose a reason for hiding this comment

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

Given that we will be dealing with all exists now rather than just those with blobs, is the limit we are setting still reasonable? Or will you tackle that when we actually implement that feature?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That will be tackled when we implement the feature. I haven't made any functional changes as part of this refactor.

Copy link
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

}
private fun getUnsentRecords(records: List<ApplicationExitInfo>): List<ApplicationExitInfo> {
val deliveredIds = preferencesService.deliveredAeiIds
preferencesService.deliveredAeiIds = records.map { it.getAeiId() }.toSet()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a mechanism to cap the growth of this list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@bidetofevil bidetofevil left a comment

Choose a reason for hiding this comment

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

LGTM. One comment about capping the growth of deliveredAeiIds but good to go for merging.

@fractalwrench fractalwrench merged commit d8b820c into main Nov 21, 2024
7 checks passed
@fractalwrench fractalwrench deleted the aei-refactor branch November 21, 2024 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants