Skip to content

feat: Configure Sentry source map uploads using environment variables…#662

Merged
ashwin31 merged 1 commit intomasterfrom
sf_import
Feb 27, 2026
Merged

feat: Configure Sentry source map uploads using environment variables…#662
ashwin31 merged 1 commit intomasterfrom
sf_import

Conversation

@ashwin31
Copy link
Copy Markdown
Member

@ashwin31 ashwin31 commented Feb 27, 2026

… loaded via loadEnv.

Summary by CodeRabbit

  • Chores
    • Updated build configuration to dynamically load environment variables and enhanced error tracking service integration with secure credential handling for source map uploads.

Copilot AI review requested due to automatic review settings February 27, 2026 18:24
exclude: ['esm-env']
}
}); No newline at end of file
export default defineConfig(({ mode }) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

import tailwindcss from '@tailwindcss/vite';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import { defineConfig, loadEnv } from 'vite';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'import' is only available in ES6 (use 'esversion: 6').

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 27, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a4df27 and f37731d.

📒 Files selected for processing (1)
  • frontend/vite.config.js

📝 Walkthrough

Walkthrough

The vite.config.js was refactored from a static configuration object to a dynamic function-based approach that accepts the mode parameter, loads environment variables via loadEnv, and updates Sentry plugin configuration to use environment-loaded values instead of process.env.

Changes

Cohort / File(s) Summary
Vite Configuration Refactor
frontend/vite.config.js
Converted from static to function-based config accepting mode parameter. Added loadEnv for dynamic environment variable loading. Updated Sentry SvelteKit plugin to inject authToken via sourceMapsUploadOptions and switched autoUploadSourceMaps from process.env to loaded env variables.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Sf import #661: Modifies frontend/vite.config.js Sentry plugin configuration, adjusting autoUploadSourceMaps and related Sentry setup options.

Poem

🐰 From static stones to flowing streams,
Config now dreams dynamic dreams,
With loadEnv's gentle, guiding hand,
Environment variables expand!
Sentry tokens tucked up safe,
Better builds with better fate. 🌟

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sf_import

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ashwin31 ashwin31 merged commit 2ca6afa into master Feb 27, 2026
6 of 7 checks passed
@ashwin31 ashwin31 deleted the sf_import branch February 27, 2026 18:24
Copy link
Copy Markdown

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 updates the frontend Vite configuration to load Sentry source map upload settings from environment variables (via loadEnv) instead of relying directly on process.env.

Changes:

  • Switch vite.config.js to use defineConfig(({ mode }) => ...) and load env via loadEnv.
  • Provide SENTRY_AUTH_TOKEN to the Sentry plugin via sourceMapsUploadOptions.authToken.
  • Keep source map auto-upload toggled by presence of PUBLIC_SENTRY_DSN.

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

}
}); No newline at end of file
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

loadEnv(mode, process.cwd(), '') makes the env file lookup dependent on the current working directory. In a monorepo/CI this can end up loading /.env* from the repo root instead of frontend/.env*, causing Sentry upload config to silently differ across environments. Consider resolving envDir relative to this config file (e.g., via new URL('.', import.meta.url) + fileURLToPath) so env loading is stable regardless of where the command is invoked from.

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +11
org: "micropyramid-fa",
project: "bottlecrm-app",
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

The PR description/title indicates Sentry source map upload configuration is environment-variable driven, but org and project are still hard-coded here. Either move these to env vars as well (so builds across forks/staging can configure without code changes) or adjust the PR description to reflect that only the auth token/enablement is env-configured.

Copilot uses AI. Check for mistakes.
return {
plugins: [sentrySvelteKit({
org: "micropyramid-fa",
project: "bottlecrm-app",
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

This introduces a dependency on SENTRY_AUTH_TOKEN, but that variable isn't documented anywhere in the frontend setup docs/templates (e.g., frontend/.env.example). Please add it (commented) to the relevant env template or documentation so deploy/CI configuration is discoverable.

Suggested change
project: "bottlecrm-app",
project: "bottlecrm-app",
// SENTRY_AUTH_TOKEN is required for uploading source maps to Sentry.
// Ensure this is set in your environment and documented in the frontend env template (e.g. .env.example)

Copilot uses AI. Check for mistakes.
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.

2 participants