Skip to content

feat: Add useConsentModel functionality#1533

Merged
metal-messiah merged 14 commits intomainfrom
NR-438120-consent-model
Nov 11, 2025
Merged

feat: Add useConsentModel functionality#1533
metal-messiah merged 14 commits intomainfrom
NR-438120-consent-model

Conversation

@ellisong
Copy link
Contributor

@ellisong ellisong commented Jul 28, 2025

Adds use_consent_mode 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.18 kB / 9.86 kB (gzip) 0.84% / 0.58% (gzip)
lite async-chunk 54.01 kB / 18.09 kB (gzip) 54.44 kB / 18.24 kB (gzip) 0.79% / 0.8% (gzip)
pro loader 54.47 kB / 19.25 kB (gzip) 54.69 kB / 19.31 kB (gzip) 0.4% / 0.3% (gzip)
pro async-chunk 92.74 kB / 29.07 kB (gzip) 93.16 kB / 29.2 kB (gzip) 0.46% / 0.45% (gzip)
spa loader 63.32 kB / 21.95 kB (gzip) 63.54 kB / 22 kB (gzip) 0.34% / 0.26% (gzip)
spa async-chunk 118.14 kB / 36.35 kB (gzip) 118.57 kB / 36.5 kB (gzip) 0.36% / 0.42% (gzip)

@codecov
Copy link

codecov bot commented Jul 28, 2025

Codecov Report

❌ Patch coverage is 72.41379% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.27%. Comparing base (9770132) to head (cde8554).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/features/utils/agent-session.js 50.00% 2 Missing and 1 partial ⚠️
src/features/page_view_event/aggregate/index.js 33.33% 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.32%   88.27%   -0.06%     
==========================================
  Files         206      207       +1     
  Lines        7776     7793      +17     
  Branches     1591     1597       +6     
==========================================
+ Hits         6868     6879      +11     
- Misses        794      798       +4     
- Partials      114      116       +2     
Flag Coverage Δ
unit-tests 81.58% <72.41%> (-0.05%) ⬇️

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 November 10, 2025 14:55:45 CST
Checking merge of (8d19cd3) into main (9770132)

@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
@metal-messiah metal-messiah merged commit 4e8ad2a into main Nov 11, 2025
16 of 18 checks passed
@metal-messiah metal-messiah deleted the NR-438120-consent-model branch November 11, 2025 16:11
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.

3 participants

Comments