getsentry / getsentry/sentry-javascript
Feature: simplify microfrontend project provisioning and DSN routing
- 主要语言
- TypeScript
- 星标
- 8.7k
- 派生
- 1.8k
- 平均合并
- 1 天 17 小时
- 30 天内合并 PR
- 515
描述
The current microfrontend setup requires manually creating a Sentry project per microfrontend and hardcoding its DSN into the bundler plugin config. For organizations with hundreds of microfrontends this doesn't scale — provisioning and wiring up each project is a significant operational burden.
**Current behavior**
- One Sentry project must be created per microfrontend
- Each DSN must be manually retrieved and embedded via `moduleMetadata` in the bundler plugin
- `makeMultiplexedTransport` handles runtime routing, but project creation is entirely out-of-band
**Gap**
The [Sentry Exporter for OpenTelemetry](https://docs.sentry.io/concepts/otlp/forwarding/pipelines/sentry-exporter/) already solves this at the collector layer with `auto_create_projects` + `routing.project_from_attribute`. There's no equivalent DX for browser microfrontends — the routing primitive exists (`makeMultiplexedTransport`) but project provisioning is a manual step that doesn't scale.
**Options**
- Auto-provision projects from the bundler plugin at build time using a server-side auth token (matches the OTel exporter model — token stays in CI, not the browser)
- Support a named-project routing mode where DSNs are resolved at build time from a project slug, eliminating the need to manually look up and embed DSNs
- A first-party CLI/script to bulk-create projects from a list and emit a DSN map for bundler consumption
**Workaround (available today)**
Projects can be bulk-created server-side and DSNs injected at build time using existing primitives:
1. **Sentry API** — `POST /api/0/teams/{org}/{team}/projects/` ([docs](https://docs.sentry.io/api/projects/create-a-new-project/)) with `project:write` scope; loop over your microfrontend list in CI to create projects and capture returned DSNs
2. **Terraform** — use the [`jianyuan/sentry`](https://registry.terraform.io/providers/jianyuan/sentry/latest/docs) or [`labd/sentry`](https://registry.terraform.io/providers/labd/sentry/latest/docs) provider with `sentry_project` + `for_each`; outputs the DSN as a resource attribute
3. Inject the resulting DSNs at build time via `moduleMetadata` in your bundler plugin config — the existing `makeMultiplexedTransport` setup ([docs](https://docs.sentry.io/platforms/javascript/best-practices/micro-frontends/)) handles runtime routing from there
The workaround is functional but requires owning the provisioning layer separately. The feature request is to make this a first-class, low-friction part of the microfrontend setup.
--
[View Junior Session in Sentry](https://sentry.sentry.io/explore/conversations/slack%3AD0AP8R5C3UH%3A1783018228.982239/?project=4510944073809921)
贡献指南
评估
这个 Issue 还没有评估数据。