Add Sentry monitoring with browser tracing and session replay#38
Add Sentry monitoring with browser tracing and session replay#38
Conversation
Co-authored-by: Sunwuyuan <88357633+Sunwuyuan@users.noreply.github.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Co-authored-by: Sunwuyuan <88357633+Sunwuyuan@users.noreply.github.com>
代码审查反馈总体评价这个 PR 成功集成了 Sentry 监控系统,用于错误追踪、性能监控和会话回放。总体实现正确,但有几个需要注意的问题。 ✅ 优点
|
There was a problem hiding this comment.
Pull request overview
Integrates Sentry into the Vue app to capture errors, performance traces, and session replays.
Changes:
- Added
@sentry/vuedependency. - Initialized Sentry in
src/main.jswith browser tracing (router-based) and session replay. - Enabled tracing/logging options and configured sampling + trace propagation targets.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/main.js | Adds Sentry initialization with tracing, replay, and logging configuration before plugin registration. |
| package.json | Adds @sentry/vue dependency required for Sentry SDK integration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| Sentry.init({ | ||
| app, | ||
| dsn: "https://2f8e5e4ec986c6077d3798ba9f683fdd@o4510762489151488.ingest.us.sentry.io/4510762503438336", |
There was a problem hiding this comment.
The Sentry DSN is hard-coded in source. Please load it from an environment variable (e.g., import.meta.env.VITE_SENTRY_DSN) and consider skipping Sentry.init (or setting enabled: false) when the DSN isn’t provided, so different environments/forks don’t report into the same Sentry project.
| Sentry.init({ | ||
| app, | ||
| dsn: "https://2f8e5e4ec986c6077d3798ba9f683fdd@o4510762489151488.ingest.us.sentry.io/4510762503438336", | ||
| // Setting this option to true will send default PII data to Sentry. | ||
| // For example, automatic IP address collection on events | ||
| sendDefaultPii: true, |
There was a problem hiding this comment.
sendDefaultPii: true enables sending default PII to Sentry. This should be gated via environment/config (and ideally user consent) so production builds can disable it when required.
| Sentry.init({ | |
| app, | |
| dsn: "https://2f8e5e4ec986c6077d3798ba9f683fdd@o4510762489151488.ingest.us.sentry.io/4510762503438336", | |
| // Setting this option to true will send default PII data to Sentry. | |
| // For example, automatic IP address collection on events | |
| sendDefaultPii: true, | |
| const enableDefaultPii = | |
| typeof process !== 'undefined' && | |
| process.env && | |
| process.env.VUE_APP_SENTRY_SEND_DEFAULT_PII === 'true'; | |
| Sentry.init({ | |
| app, | |
| dsn: "https://2f8e5e4ec986c6077d3798ba9f683fdd@o4510762489151488.ingest.us.sentry.io/4510762503438336", | |
| // Setting this option to true will send default PII data to Sentry. | |
| // For example, automatic IP address collection on events | |
| // Controlled via the VUE_APP_SENTRY_SEND_DEFAULT_PII environment variable. | |
| sendDefaultPii: enableDefaultPii, |
| // Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled | ||
| tracePropagationTargets: ["localhost", /^https:\/\/kv-service\.(houlang\.cloud|wuyuan\.dev)/], | ||
| // Session Replay | ||
| replaysSessionSampleRate: 0.01, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production. |
There was a problem hiding this comment.
The replaysSessionSampleRate value (0.01 = 1%) doesn’t match the comment saying 10%. Please either update the value to 0.1 or fix the comment to reflect the intended sampling rate.
| replaysSessionSampleRate: 0.01, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production. | |
| replaysSessionSampleRate: 0.01, // This sets the sample rate at 1%. You may want to change it to 100% while in development and then sample at a lower rate in production. |
| tracesSampleRate: 1.0, // Capture 100% of the transactions | ||
| // Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled |
There was a problem hiding this comment.
tracesSampleRate: 1.0 captures 100% of transactions and can create significant overhead/cost in production. Consider making this environment-based (or using tracesSampler) so production can sample at a lower rate.
| // Logs | ||
| enableLogs: true |
There was a problem hiding this comment.
enableLogs: true will increase data volume and may capture sensitive information depending on what gets logged. Please make this configurable per environment (and/or add scrubbing) so production can disable it if needed.
| "@fingerprintjs/fingerprintjs": "^5.0.1", | ||
| "@mdi/font": "7.4.47", | ||
| "@microsoft/clarity": "^1.0.2", | ||
| "@sentry/vue": "^10.36.0", |
There was a problem hiding this comment.
This PR adds a new dependency but doesn’t update the lockfile (the repo contains pnpm-lock.yaml). Please regenerate and commit the lockfile so installs/CI are reproducible.
| "@sentry/vue": "^10.36.0", |
Integrates Sentry SDK for error tracking, performance monitoring, and session replay capabilities.
Changes
@sentry/vue@^10.36.0main.jsbefore plugin registration with:Configuration Notes
tracePropagationTargetsincludes placeholderyourserver.io- update to match actual API endpointsOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.