⚗️ collect Network Efficiency Guardrails document-policy-violation reports as errors#4796
Draft
thomasbertet wants to merge 4 commits into
Draft
⚗️ collect Network Efficiency Guardrails document-policy-violation reports as errors#4796thomasbertet wants to merge 4 commits into
thomasbertet wants to merge 4 commits into
Conversation
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 9df763e | Docs | Datadog PR Page | Give us feedback! |
Bundles Sizes Evolution
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Add support for the Network Efficiency Guardrails experimental browser API (currently available in Edge 146+ and Chromium behind the
--enable-experimental-web-platform-featuresflag).When a page opts in via the
Document-Policy: network-efficiency-guardrailsheader, the browser firesdocument-policy-violationreports for resources that violate the policy (e.g. uncompressed JS/CSS). This change collects those reports as SDK errors/logs, following the same pattern ascsp_violation,intervention, anddeprecation.Jira: PROF-15113
Changes
browser-core—browser.types.ts: AddedDocumentPolicyViolationReportandDocumentPolicyViolationReportBodyinterfaces; widenedReport.bodyunion andReportTypeunion.browser-core—reportObservable.ts: AddedRawReportType.networkEfficiencyGuardrails = 'network-efficiency-guardrails';buildReportObserverTypes()maps it to thedocument-policy-violationReportingObserver type;buildRawReportErrorFromReport()handles the new type (filters to NEGfeatureId, reusescsp.dispositionfield).browser-rum-core—trackReportError.ts: AddednetworkEfficiencyGuardrailsto the subscribed report types so RUM collects these as errors.browser-coretests —mockReportingObserver.ts: AddedFAKE_DOCUMENT_POLICY_VIOLATION_REPORTfixture.reportObservable.spec.ts: 3 new unit tests (notification, stack trace, featureId filter).mock.ts: Added/?network-efficiency-guardrails=truequery param (setsDocument-Policyheader) and/uncompressed-script.jsendpoint.networkEfficiencyGuardrails.scenario.ts: 3 new E2E tests (RUM errors, Logs forwarding ON, Logs forwarding OFF).Test instructions
E2E tests require Chromium with
--enable-experimental-web-platform-features(handled automatically bytest.use({ launchOptions })in the scenario file):yarn build yarn test:e2e -g "network efficiency"Unit tests:
Checklist