Skip to content

Introduce _RumInternalProxy.setRumSessionTypeOverride#2776

Merged
aleksandr-gringauz merged 1 commit into
developfrom
aleksandr-gringauz/force-user-session-type
Jul 7, 2025
Merged

Introduce _RumInternalProxy.setRumSessionTypeOverride#2776
aleksandr-gringauz merged 1 commit into
developfrom
aleksandr-gringauz/force-user-session-type

Conversation

@aleksandr-gringauz

@aleksandr-gringauz aleksandr-gringauz commented Jul 3, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

We want to be able to force sessionType=user for sessions that happen in synthetic tests.

Introducing internal api _RumInternalProxy.setRumSessionType that sets sessionType that will be propagated to all RUM events regardless of whether we have a synthetic test or not.

The pr is big, but most of the changes are related to using named arguments in various places. For example this constructor has a lot of arguments of primitive types (bool, long), one can easily make mistake in order of the items. Also some of them have default values and if I create a new argument in this constructor and place it in the end, I have to provide the values for previous arguments manually.

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@aleksandr-gringauz
aleksandr-gringauz force-pushed the aleksandr-gringauz/force-user-session-type branch 2 times, most recently from 33c11be to 3b18911 Compare July 4, 2025 07:38
} else {
ActionEvent.ActionEventSessionType.SYNTHETICS

val sessionType = when {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If we have rumSessionType use it. If we are inside a synthetic test, use sessionType=SYNTHETICS, otherwise sessionType=USER

@aleksandr-gringauz
aleksandr-gringauz marked this pull request as ready for review July 4, 2025 08:00
@aleksandr-gringauz
aleksandr-gringauz requested review from a team as code owners July 4, 2025 08:00
@codecov-commenter

codecov-commenter commented Jul 4, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.09524% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.83%. Comparing base (edd95ec) to head (04acd57).
⚠️ Report is 1914 commits behind head on develop.

Files with missing lines Patch % Lines
.../android/rum/internal/domain/scope/RumViewScope.kt 91.49% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2776      +/-   ##
===========================================
- Coverage    69.97%   69.83%   -0.14%     
===========================================
  Files          824      826       +2     
  Lines        30881    30930      +49     
  Branches      5195     5207      +12     
===========================================
- Hits         21606    21597       -9     
- Misses        7828     7858      +30     
- Partials      1447     1475      +28     
Files with missing lines Coverage Δ
...rum/src/main/kotlin/com/datadog/android/rum/Rum.kt 88.33% <100.00%> (+0.20%) ⬆️
...kotlin/com/datadog/android/rum/RumConfiguration.kt 97.37% <100.00%> (+0.07%) ⬆️
...n/kotlin/com/datadog/android/rum/RumSessionType.kt 100.00% <100.00%> (ø)
...otlin/com/datadog/android/rum/_RumInternalProxy.kt 72.22% <100.00%> (+1.63%) ⬆️
...lin/com/datadog/android/rum/internal/RumFeature.kt 92.92% <100.00%> (+0.33%) ⬆️
.../datadog/android/rum/internal/RumSessionTypeExt.kt 100.00% <100.00%> (ø)
...ndroid/rum/internal/domain/scope/RumActionScope.kt 97.40% <100.00%> (+0.04%) ⬆️
...d/rum/internal/domain/scope/RumApplicationScope.kt 94.34% <100.00%> (+0.16%) ⬆️
...roid/rum/internal/domain/scope/RumResourceScope.kt 94.70% <100.00%> (-0.94%) ⬇️
...droid/rum/internal/domain/scope/RumSessionScope.kt 95.97% <100.00%> (+0.03%) ⬆️
... and 3 more

... and 33 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aleksandr-gringauz
aleksandr-gringauz force-pushed the aleksandr-gringauz/force-user-session-type branch 3 times, most recently from ef249ff to fa65f79 Compare July 4, 2025 12:32
0xnm
0xnm previously approved these changes Jul 7, 2025

@0xnm 0xnm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good 👍

since we have many lines changed here, it would be nice to have one more review.

val additionalConfig: Map<String, Any>,
val trackAnonymousUser: Boolean
val trackAnonymousUser: Boolean,
val rumSessionType: RumSessionType?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm wondering if we should call this something like rumSessionTypeOverride, because we will have set it up from the intent attributes and this value is just what overrides the normal flow. Or maybe add some comment.

Although in the symmetric PR for iOS SDK suffix Override is used only in configuration https://github.com/DataDog/dd-sdk-ios/pull/2383/files.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm wondering if we should call this something like rumSessionTypeOverride

done

Or maybe add some comment.

I added a comment here

Although in the symmetric PR for iOS SDK suffix Override is used only in configuration

Looks like on iOS the situation is slightly different, they are able to determine final rumSessionType in one place and propagate the value to all rum events link. So it is not "override", it is the final one.

On Android we create first RUM scopes (RumApplicationScope for example) before this is called and account for the synthetic test attributes only when the events are created (for example like this). So for us is is kind of "override" indeed.

@aleksandr-gringauz
aleksandr-gringauz force-pushed the aleksandr-gringauz/force-user-session-type branch from fa65f79 to 04acd57 Compare July 7, 2025 14:31

@ambushwork ambushwork left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@aleksandr-gringauz aleksandr-gringauz changed the title Introduce _RumInternalProxy.setRumSessionType Introduce _RumInternalProxy.setRumSessionTypeOverride Jul 7, 2025
@aleksandr-gringauz
aleksandr-gringauz merged commit 0fc87f5 into develop Jul 7, 2025
25 of 26 checks passed
@aleksandr-gringauz
aleksandr-gringauz deleted the aleksandr-gringauz/force-user-session-type branch July 7, 2025 15:28
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.

4 participants