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

feat: Persist logging flag in session #1264

Merged
merged 13 commits into from
Dec 3, 2024

Conversation

ptang-nr
Copy link
Contributor

@ptang-nr ptang-nr commented Nov 25, 2024

This is another part of the work for the auto-logging feature. The auto-logging mode should stay consistent within a given session and will auto-disable upon session expiration after 4 hours or session inactivity after 30 minutes.

Overview

The auto-logging mode should stay consistent within a given session and will auto-disable upon session expiration after 4 hours or session inactivity after 30 minutes.

If cookies are not enabled, then the logging mode for each page will be set independently based on the rum response.

Related Issue(s)

https://new-relic.atlassian.net/browse/NR-341932

Testing

Added/updated relevant tests for logging with regards to session

This will ensure the logging mode is consistent across the session and stops collecting logging events after session expiration/inactivity.
Copy link

github-actions bot commented Nov 25, 2024

Asset Size Report

Merging this pull request will result in the following asset size changes:

Agent Asset Previous Size New Size Diff
lite loader 29.24 kB / 10.6 kB (gzip) 29.39 kB / 10.65 kB (gzip) 0.51% / 0.5% (gzip)
lite async-chunk 54.3 kB / 17.59 kB (gzip) 54.53 kB / 17.65 kB (gzip) 0.42% / 0.38% (gzip)
pro loader 50.34 kB / 17.4 kB (gzip) 50.78 kB / 17.5 kB (gzip) 0.88% / 0.62% (gzip)
pro async-chunk 100.5 kB / 30.62 kB (gzip) 101.54 kB / 30.93 kB (gzip) 1.04% / 1.01% (gzip)
spa loader 57.93 kB / 19.71 kB (gzip) 58.37 kB / 19.82 kB (gzip) 0.76% / 0.54% (gzip)
spa async-chunk 115.22 kB / 34.91 kB (gzip) 116.26 kB / 35.23 kB (gzip) 0.91% / 0.92% (gzip)

Copy link

codecov bot commented Nov 25, 2024

Codecov Report

Attention: Patch coverage is 71.42857% with 10 lines in your changes missing coverage. Please review.

Please upload report for BASE (auto-logging@1b7681d). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/features/logging/aggregate/index.js 67.85% 9 Missing ⚠️
src/features/session_replay/aggregate/index.js 50.00% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##             auto-logging    #1264   +/-   ##
===============================================
  Coverage                ?   88.90%           
===============================================
  Files                   ?      170           
  Lines                   ?     7418           
  Branches                ?     1501           
===============================================
  Hits                    ?     6595           
  Misses                  ?      700           
  Partials                ?      123           
Flag Coverage Δ
integration-tests 91.64% <100.00%> (?)
unit-tests 79.44% <48.14%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Nov 25, 2024

Static Badge

Last ran on December 02, 2024 17:17:14 CST
Checking merge of (ad8a6ec) into auto-logging (1b7681d)

@ptang-nr ptang-nr marked this pull request as ready for review December 2, 2024 16:46
Comment on lines 142 to 143
case FEATURE_NAMES.logging:
return !!session
Copy link
Member

Choose a reason for hiding this comment

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

While this makes sense and I can see why you added this bit, product decided that the logging feature should still import and run if session is disabled.

Comment on lines 44 to 46
this.syncWithSessionManager({
loggingMode: this.loggingMode
})
Copy link
Member

@metal-messiah metal-messiah Dec 2, 2024

Choose a reason for hiding this comment

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

I think we need to double check that this wont cause issues. One of the two cases that could trigger this line is that session tracking is disabled, meaning there is no session object. I fear calling this method could cause errors when that is the case

Copy link
Member

Choose a reason for hiding this comment

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

Should probably only try to sync with the session manager if we know it exists for sure. Either handled here or in the base class method

if (session.isNew || !this.isSessionTrackingEnabled) {
this.loggingMode = loggingMode

if (this.isSessionTrackingEnabled) {
Copy link
Member

Choose a reason for hiding this comment

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

this if statement is redundant now (since syncWith.. does the same check), but nbd

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, i wasn't sure if it's worth blocking the extra call so added it. Sounds like probably not worth it (?) I can avoid doing that in the future.

@ptang-nr ptang-nr merged commit 6658bca into auto-logging Dec 3, 2024
14 checks passed
@ptang-nr ptang-nr deleted the NR-323599-persist-logging-flag-in-session branch December 3, 2024 19:18
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