Skip to content

Conversation

@ellisong
Copy link
Contributor

@ellisong ellisong commented Jul 28, 2025

Adds useConsentModel init property and functionality. Adds the consent() API call. The consent model, if enabled, disallows agent harvesting unless consent is given through the consent() API call.

Overview

Adds useConsentModel init property and functionality (defaults to false). When turning useConsentModel on, the agent will not harvest (send over the network) until given "consent". Consent is given by the consent value in the session entity's local storage being set to true.

Adds an API method called consent(accept?: boolean) that changes the consent value in the session entity's local storage. Calling true or undefined for the argument grants consent, calling false in consent() rejects consent.

Agent features are still manually or automatically started regardless of consent being enabled or not, but they won't send data over the network unless consent is granted.

Also adds a .nvmrc file for node version 22.11

Related Issue(s)

JIRA: https://new-relic.atlassian.net/browse/NR-438120
JIRA: https://new-relic.atlassian.net/browse/NR-438139

Testing

Tests are provided that tests the agent harvest blocking if the consent model is enabled in various situations. The default case (consent model not being enabled) is not tested since that's already covered.

@github-actions
Copy link

Supportability Metric Usage Changes:

No matching changes found

Supportability Metrics .md File Changes:

supportability_metrics.md was changed? false

New supportability metrics require changes to supportability_metrics.md, as well as a new PR to Angler. Please ensure an Angler PR is created and linked to this PR.

@github-actions
Copy link

github-actions bot commented Jul 28, 2025

Asset Size Report

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

Agent Asset Previous Size New Size Diff
lite loader 25.96 kB / 9.8 kB (gzip) 26.27 kB / 9.88 kB (gzip) 1.19% / 0.75% (gzip)
lite async-chunk 53.13 kB / 17.72 kB (gzip) 53.69 kB / 17.9 kB (gzip) 1.05% / 1.04% (gzip)
pro loader 54.48 kB / 19.27 kB (gzip) 54.79 kB / 19.35 kB (gzip) 0.57% / 0.42% (gzip)
pro async-chunk 91.8 kB / 28.82 kB (gzip) 92.35 kB / 28.99 kB (gzip) 0.6% / 0.59% (gzip)
spa loader 63.28 kB / 21.95 kB (gzip) 63.59 kB / 22.03 kB (gzip) 0.49% / 0.37% (gzip)
spa async-chunk 117.21 kB / 36.11 kB (gzip) 117.76 kB / 36.31 kB (gzip) 0.47% / 0.54% (gzip)

@codecov
Copy link

codecov bot commented Jul 28, 2025

Codecov Report

❌ Patch coverage is 68.75000% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.53%. Comparing base (984b05e) to head (d34c8b4).

Files with missing lines Patch % Lines
src/features/page_view_event/aggregate/index.js 28.57% 3 Missing and 2 partials ⚠️
src/features/utils/agent-session.js 60.00% 1 Missing and 1 partial ⚠️
src/loaders/api-base.js 0.00% 2 Missing ⚠️
src/loaders/agent.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1533      +/-   ##
==========================================
- Coverage   88.60%   88.53%   -0.08%     
==========================================
  Files         206      207       +1     
  Lines        7748     7770      +22     
  Branches     1586     1593       +7     
==========================================
+ Hits         6865     6879      +14     
- Misses        772      777       +5     
- Partials      111      114       +3     
Flag Coverage Δ
unit-tests 81.81% <68.75%> (-0.07%) ⬇️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link

github-actions bot commented Jul 28, 2025

Static Badge

Last ran on October 24, 2025 17:14:25 CDT
Checking merge of (d34c8b4) into main (984b05e)

@ellisong
Copy link
Contributor Author

Adding API changes to PR, do not merge until ready.

@metal-messiah metal-messiah self-assigned this Aug 4, 2025
@cwli24 cwli24 self-assigned this Aug 4, 2025
@ellisong ellisong force-pushed the NR-438120-consent-model branch from d4c9352 to 6d748e7 Compare August 13, 2025 20:20
@ellisong ellisong force-pushed the NR-438120-consent-model branch 2 times, most recently from aa4f567 to 39a2b8b Compare September 4, 2025 22:08
@metal-messiah
Copy link
Member

can you please add type-check conditions for your new API method to api.test-d.ts to ensure that the typings worked correctly.

@metal-messiah
Copy link
Member

we also haven't been very good about updating init-types.js but we probably should start to update that whenever we update the init.js file

@ellisong ellisong force-pushed the NR-438120-consent-model branch from ea363df to 609dda9 Compare September 8, 2025 22:19
Copy link
Member

@metal-messiah metal-messiah left a comment

Choose a reason for hiding this comment

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

very minor comment, i am fine with leaving as-is or changing. LGTM

@metal-messiah
Copy link
Member

Blocked until API team is out of code freeze and can implement settings changes.

Copy link
Member

@metal-messiah metal-messiah left a comment

Choose a reason for hiding this comment

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

manually blocking to prevent accidental merge

@ellisong ellisong force-pushed the NR-438120-consent-model branch from c7b091a to 1c16467 Compare October 22, 2025 17:53
@ellisong ellisong force-pushed the NR-438120-consent-model branch from 1c16467 to 0b04e4c Compare October 24, 2025 21:29
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.

4 participants