Repository navigation
Conversation
The Logs RUM plugin can't import the main entry, which defines DD_LOGS. This entry exports what it needs to run Logs on top of RUM, following @datadog/browser-rum/internal, and stays internal. The built entry loads in Node with the expected exports and leaves DD_LOGS undefined, and the package lists internal/package.json. The enum re-export carries a disallow-enum-exports disable, which the rule's notes allow for internal modules.
… internal entry The entry's comment named the account and user contexts without saying the entry doesn't export them. It now points at startAccountContextHook and startUserContextHook in @datadog/browser-core. Comment only: Prettier, ESLint and typecheck are clean.
The internal entry exports LifeCycleEventType, and exporting an enum from an entry is a lint error (disallow-enum-exports). A const object, like rum-core's NodePrivacyLevel, keeps the same values and needs no lint exception, and the isolatedModules workaround the const enum needed in the emitted declarations goes. yarn test:compat:tsc passes without it, and the unit suite is unchanged.
…t order The internal entry's comment listed session, account, user and RUM internal contexts, but standalone Logs also registers the global context between user and RUM internal (startLogs.ts). A plugin following the comment would drop global context or misplace it. The comment now lists all five and names startGlobalContext with useContextNamespace false. Comment only. typecheck, lint, test:unit, build, the Node entry check and test:compat:tsc pass.
… hook The Logs plugin shares RUM's global context so customers set it once for both. The comment named startGlobalContext, which creates its own context, so a plugin following it would not share RUM's. It now names startGlobalContextHook, called with RUM's getGlobalContext and useContextNamespace false, keeping the registration order. Comment only. typecheck, lint, test:unit, build, the Node entry check and test:compat:tsc pass.
Bundles Sizes Evolution
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: ed258b1 | Docs | View more details | Give us feedback! |
…ry comment A throwaway plugin built from the entry also had to register startTrackingConsentContext and pass a buffered data observable to startLogsEventCollection, which the comment didn't say. Comment only.
This branch has not been deployed
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
The Logs plugin from the RFC runs Logs on top of RUM from its own package. It needs the Logs pieces the previous PRs prepared, without importing the main entry, which defines
DD_LOGS.This is the last of 4 stacked PRs. It adds a
@datadog/browser-logs/internalentry that exports those pieces. Nothing imports it yet, the plugin package comes next.Stacked on #5349.
Refs: RUM-19971
Changes
@datadog/browser-logs/internalexports what the plugin wires on top of RUM: the configuration,startLogsEventCollection(), Logs'LifeCycle,createHooks(),startReportError(), the common, session, RUM internal and consent contexts, andLoggerwithHandlerTypeandStatusType. Like@datadog/browser-rum/internal, it's not for public use and doesn't follow semver. It doesn't defineDD_LOGS.Its comment lists the contexts a plugin registers and their order, so a log's context precedence matches standalone Logs. The account, user and global context hooks come from
@datadog/browser-core(#5349).LifeCycleEventTypebecomes aconstobject with the same values, likeNodePrivacyLevelin rum-core, so the entry can export it. It also removes theisolatedModulesworkaround from #5320.The entry is published through
internal/package.jsonandfiles, mapped intsconfig.base.json, and allowed by the side-effect lint rule.Bundle size:
logs,rumandrum_slimdon't change.Test instructions
The built entry exports the pieces and doesn't define
DD_LOGS:yarn build node -e "const m = require('./packages/browser-logs/internal'); console.log(Object.keys(m).sort().join(',')); console.log(JSON.stringify(m.LifeCycleEventType)); console.log(typeof globalThis.DD_LOGS)"Expected output:
The package publishes it:
Expected output:
Checklist