Skip to content

Conversation

@BeltranBulbarellaDD
Copy link
Contributor

@BeltranBulbarellaDD BeltranBulbarellaDD commented Sep 26, 2025

Motivation

The idea is to be able to inject the SDK on a page that does not have it. Injecting the local version and CDN version.

Changes

Load the extension dist folder, in chrome://extensions/. And on the SDK side go to developer-extension and yarn dev.
Disable the deployed Developer Extension to not have issues.
Added under Datadog Employee mode, the possibility to inject using CDN the SDK on pages that do not have it.

Test instructions

Screen.Recording.2025-09-26.at.16.37.02.mov

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.

@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Sep 26, 2025

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage
Patch Coverage: 100.00%
Total Coverage: 92.64% (+0.00%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 5e9f9ce | Docs | Datadog PR Page | Was this helpful? Give us feedback!

}

return 'us1'
}
Copy link
Contributor Author

@BeltranBulbarellaDD BeltranBulbarellaDD Sep 26, 2025

Choose a reason for hiding this comment

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

I can probably remove this, the thing is that I was getting 403 so this was the fallback.
Gonna look for a better way.
(Open to suggestions)

@cit-pr-commenter
Copy link

cit-pr-commenter bot commented Oct 7, 2025

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 162.96 KiB 162.96 KiB 0 B 0.00%
Rum Recorder 19.78 KiB 19.78 KiB 0 B 0.00%
Rum Profiler 4.89 KiB 4.89 KiB 0 B 0.00%
Logs 56.62 KiB 56.62 KiB 0 B 0.00%
Flagging 944 B 944 B 0 B 0.00%
Rum Slim 119.90 KiB 119.90 KiB 0 B 0.00%
Worker 23.60 KiB 23.60 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base CPU Time (ms) Local CPU Time (ms) 𝚫%
RUM - add global context 0.0041 0.0043 +4.88%
RUM - add action 0.0132 0.0155 +17.42%
RUM - add error 0.0132 0.013 -1.52%
RUM - add timing 0.003 0.003 0.00%
RUM - start view 0.0038 0.0033 -13.16%
RUM - start/stop session replay recording 0.0006 0.0009 +50.00%
Logs - log message 0.0134 0.0163 +21.64%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 25.79 KiB 25.20 KiB -603 B
RUM - add action 47.16 KiB 43.28 KiB -3.88 KiB
RUM - add timing 24.44 KiB 25.45 KiB +1.01 KiB
RUM - add error 52.34 KiB 48.72 KiB -3.62 KiB
RUM - start/stop session replay recording 23.46 KiB 24.74 KiB +1.28 KiB
RUM - start view 423.98 KiB 424.37 KiB +401 B
Logs - log message 43.09 KiB 41.71 KiB -1.38 KiB

🔗 RealWorld

@BeltranBulbarellaDD BeltranBulbarellaDD marked this pull request as ready for review October 7, 2025 08:34
@BeltranBulbarellaDD BeltranBulbarellaDD requested a review from a team as a code owner October 7, 2025 08:34
@thomas-lebeau
Copy link
Collaborator

@codex, can you review this pr please 🫶

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 52 to 56
if (settings.injectionVariant === 'local-dev' && settings.useDevBundles === 'npm') {
injectDevBundle(settings.useRumSlim ? DEV_RUM_SLIM_URL : DEV_RUM_URL, ddRumGlobal)
injectDevBundle(DEV_LOGS_URL, ddLogsGlobal)
} else if (settings.injectionVariant === 'cdn') {
injectCdnBundle(settings)

Choose a reason for hiding this comment

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

P1 Badge Gate CDN injection on Datadog mode state

The content script triggers CDN injection whenever settings.injectionVariant === 'cdn'. Because injectionVariant is persisted in storage, a user can enable Datadog mode, pick the CDN variant, and then disable Datadog mode. The UI hides the variant control, but the stored value remains cdn, so this branch still runs and injects scripts even though Datadog mode is off. This means turning off Datadog mode does not actually disable the CDN injection feature and there is no way to revert without re‑enabling Datadog mode. Consider resetting injectionVariant when Datadog mode is disabled or guarding the CDN path with settings.datadogMode.

Useful? React with 👍 / 👎.

Comment on lines +256 to +258
if (site?.endsWith('datad0g.com')) {
return 'us3'
}
Copy link
Member

Choose a reason for hiding this comment

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

🔨 warning: ‏this seems incorrect

Comment on lines +63 to +64
injectionVariant: InjectionVariant
sdkInjectionType: SdkInjectionType
Copy link
Member

Choose a reason for hiding this comment

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

🔨 warning: ‏The settings should be redesigned to make it more explicit and ideally avoid forbidden states. Things that should be clarified at the settings level:

  • useDevBundles: npm won't work if injectionVariant is not cdn.
  • How can I disable injection?
  • Why injection variant CDN only available in datadogMode?
  • What's the difference between injectionVariant and sdkInjectionType just by looking at property names?

My suggestion: keep things simple. Always inject both RUM and Logs CDN bundles with a default config. If dev bundle override is enabled, those bundles will be overridden (including rum-slim override). If config override is enabled, the config will be overridden. No need to do anything at the injection level.

So in the end you have a single option, inject: boolean. No need to enforce datadogMode usage, people can use it it's fine.

Comment on lines +9 to +11
export const CDN_RUM_URL = `${CDN_BASE_URL}/${CDN_VERSION}/datadog-rum.js`
export const CDN_RUM_SLIM_URL = `${CDN_BASE_URL}/${CDN_VERSION}/datadog-rum-slim.js`
export const CDN_LOGS_URL = `${CDN_BASE_URL}/${CDN_VERSION}/datadog-logs.js`
Copy link
Member

Choose a reason for hiding this comment

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

Looks like those constants aren't used

Comment on lines +233 to +241
function getRumBundleUrl(bundle: 'rum' | 'rum-slim', site?: string): string {
const region = getCdnRegion(site)
return `${CDN_BASE_URL}/${region}/${CDN_VERSION}/datadog-${bundle}.js`
}

function getLogsBundleUrl(site?: string) {
const region = getCdnRegion(site)
return `${CDN_BASE_URL}/${region}/${CDN_VERSION}/datadog-logs.js`
}
Copy link
Member

Choose a reason for hiding this comment

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

💬 suggestion: ‏Just include us1 prod rum and logs. No need to worry about regions, staging, etc.

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.

5 participants