Skip to content

feat(browser): Include culture context with events#19148

Open
logaretm wants to merge 7 commits intodevelopfrom
awad/js-1455-capture-culture-context-from-browser-sdks
Open

feat(browser): Include culture context with events#19148
logaretm wants to merge 7 commits intodevelopfrom
awad/js-1455-capture-culture-context-from-browser-sdks

Conversation

@logaretm
Copy link
Member

@logaretm logaretm commented Feb 3, 2026

This PR includes the culture context containing the locale, timeZone and calendar information as outlined by the Contexts interface doc.

I had this lying in my stash since the last Triage, just got some time to tidy it up and PR it.

closes #18801

@logaretm logaretm requested review from Lms24 and timfish February 3, 2026 19:23
@linear
Copy link

linear bot commented Feb 3, 2026

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

Codecov Results 📊


Generated by Codecov Action

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 25.54 kB +0.41% +104 B 🔺
@sentry/browser - with treeshaking flags 24 kB +0.46% +108 B 🔺
@sentry/browser (incl. Tracing) 42.37 kB +0.24% +100 B 🔺
@sentry/browser (incl. Tracing, Profiling) 47.02 kB +0.21% +97 B 🔺
@sentry/browser (incl. Tracing, Replay) 81 kB +0.13% +103 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.59 kB +0.14% +96 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 85.71 kB +0.12% +102 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 97.89 kB +0.11% +98 B 🔺
@sentry/browser (incl. Feedback) 42.26 kB +0.27% +111 B 🔺
@sentry/browser (incl. sendFeedback) 30.22 kB +0.34% +101 B 🔺
@sentry/browser (incl. FeedbackAsync) 35.23 kB +0.31% +108 B 🔺
@sentry/browser (incl. Metrics) 26.64 kB +0.39% +102 B 🔺
@sentry/browser (incl. Logs) 26.8 kB +0.4% +106 B 🔺
@sentry/browser (incl. Metrics & Logs) 27.46 kB +0.38% +103 B 🔺
@sentry/react 27.26 kB +0.38% +103 B 🔺
@sentry/react (incl. Tracing) 44.63 kB +0.25% +108 B 🔺
@sentry/vue 29.97 kB +0.36% +105 B 🔺
@sentry/vue (incl. Tracing) 44.2 kB +0.27% +115 B 🔺
@sentry/svelte 25.55 kB +0.41% +102 B 🔺
CDN Bundle 28.08 kB +0.38% +106 B 🔺
CDN Bundle (incl. Tracing) 43.16 kB +0.26% +111 B 🔺
CDN Bundle (incl. Logs, Metrics) 28.92 kB +0.37% +104 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 43.98 kB +0.27% +118 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 67.87 kB +0.17% +111 B 🔺
CDN Bundle (incl. Tracing, Replay) 79.89 kB +0.14% +106 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 80.77 kB +0.13% +102 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 85.33 kB +0.12% +102 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.24 kB +0.12% +99 B 🔺
CDN Bundle - uncompressed 82.1 kB +0.36% +292 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 127.81 kB +0.23% +292 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 84.94 kB +0.35% +292 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 130.65 kB +0.23% +292 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 208.32 kB +0.15% +292 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 244.42 kB +0.12% +292 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 247.24 kB +0.12% +292 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 257.22 kB +0.12% +292 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 260.03 kB +0.12% +292 B 🔺
@sentry/nextjs (client) 46.98 kB +0.22% +103 B 🔺
@sentry/sveltekit (client) 42.76 kB +0.26% +107 B 🔺
@sentry/node-core 52.18 kB - -
@sentry/node 166.29 kB - -
@sentry/node - without tracing 93.97 kB - -
@sentry/aws-serverless 109.48 kB - -

View base workflow run

@logaretm logaretm requested a review from a team as a code owner February 3, 2026 20:18
Copilot AI review requested due to automatic review settings February 3, 2026 20:48
@logaretm logaretm force-pushed the awad/js-1455-capture-culture-context-from-browser-sdks branch from 1b4fd0d to 94966b7 Compare February 3, 2026 20:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new cultureContextIntegration to the browser SDK that automatically captures culture-related information (locale, timezone, and calendar) from the browser's Intl.DateTimeFormat API and includes it in all events sent to Sentry.

Changes:

  • Adds a new cultureContextIntegration that captures locale, timezone, and calendar information from the browser
  • Registers the integration as a default integration in the browser SDK
  • Updates test expectations across multiple test suites to account for the new culture context

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/browser/src/integrations/culturecontext.ts Implements the new culture context integration using the Intl API
packages/browser/src/sdk.ts Adds cultureContextIntegration to default integrations
packages/browser/src/index.ts Exports the new integration for public use
dev-packages/e2e-tests/test-applications/nextjs-pages-dir/tests/transactions.test.ts Updates test expectations to use expect.objectContaining for contexts
dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/transactions.test.ts Updates test expectations to use expect.objectContaining for contexts
dev-packages/browser-integration-tests/utils/replayEventTemplates.ts Adds culture context expectations to replay event templates
dev-packages/browser-integration-tests/suites/replay/captureReplayFromReplayPackage/test.ts Adds culture context expectations to replay tests
dev-packages/browser-integration-tests/suites/replay/captureReplay/test.ts Adds culture context expectations to replay tests
dev-packages/browser-integration-tests/suites/public-api/startSpan/standalone-mixed-transaction/test.ts Updates test expectations to use expect.objectContaining for contexts
dev-packages/browser-integration-tests/suites/public-api/debug/test.ts Adds CultureContext to expected integration logs
dev-packages/browser-integration-tests/suites/integrations/cultureContext/test.ts Adds new integration test verifying culture context capture
dev-packages/browser-integration-tests/suites/integrations/cultureContext/subject.js Test subject file that triggers an error for testing
dev-packages/browser-integration-tests/suites/integrations/cultureContext/init.js Test initialization file that sets up the CultureContext integration
dev-packages/browser-integration-tests/suites/feedback/captureFeedbackCsp/test.ts Adds culture context expectations to feedback tests
dev-packages/browser-integration-tests/suites/feedback/captureFeedbackAndReplay/hasSampling/test.ts Adds culture context expectations to feedback tests
dev-packages/browser-integration-tests/suites/feedback/captureFeedback/test.ts Adds culture context expectations to feedback tests
dev-packages/browser-integration-tests/suites/feedback/attachTo/test.ts Adds culture context expectations to feedback tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +54 to +57
calendar: options.calendar,
};
} catch {
// Ignore errors
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The calendar property from resolvedOptions() is included here but is not included in the Node.js implementation (packages/node-core/src/integrations/context.ts:190-193). Consider checking whether calendar is consistently available across all browsers, as it may not be present in older browsers or certain browser configurations. If consistency with the Node.js implementation is desired, or if browser compatibility is a concern, the calendar property could be made optional or omitted. The Node.js implementation only includes locale and timezone.

Suggested change
calendar: options.calendar,
};
} catch {
// Ignore errors
};
} catch {
// Ignore errors
// Ignore errors

Copilot uses AI. Check for mistakes.
linkedErrorsIntegration(),
dedupeIntegration(),
httpContextIntegration(),
cultureContextIntegration(),
Copy link
Member

Choose a reason for hiding this comment

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

q: Is that the only sdk where we need to add this separately?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, I checked the other SDKs and they don't override the browser's default integrations. Only the angular one does.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 9,420 - 8,878 +6%
GET With Sentry 1,652 18% 1,720 -4%
GET With Sentry (error only) 6,064 64% 6,007 +1%
POST Baseline 1,211 - 1,191 +2%
POST With Sentry 603 50% 595 +1%
POST With Sentry (error only) 1,067 88% 1,037 +3%
MYSQL Baseline 3,353 - 3,283 +2%
MYSQL With Sentry 488 15% 480 +2%
MYSQL With Sentry (error only) 2,716 81% 2,722 -0%

View base workflow run

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

I think this is a nice addition, thanks for taking care of it. One more context to convert to attributes for Spans though 😅 but that's a me/span-first problem to worry about.

I'm not approving yet because we should first check with Ingest if anything gets inferrerd from the request. LGTM besides that.

Copy link
Member

@cleptric cleptric left a comment

Choose a reason for hiding this comment

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

Please open a Conventions PR prior merging this.

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.

Capture culture context from browser SDKs

4 participants