| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
feat(design-system): validate removed tokens against webapp usages (#6816) ## Problem When design tokens are consolidated or renamed, CSS variables disappear from `tokens.generated.css` but webapp code can still reference them — directly via `var(--token)` or via Tailwind utilities (`bg-token`, `rounded-ds-*`, …). These orphaned references only surface when something visually breaks. We caught exactly this by hand in #6788; this PR automates that check. ## Solution - **`tokens-check-removed.mjs`**: diffs merge-base vs current `tokens.generated.css` for removed CSS variables, then scans `packages/webapp/src` for each removed token's real references — direct `var()` (including fallback forms) and the exact Tailwind utilities it generates. Matches at token boundaries so `text-link` doesn't false-positive on `text-text-link-hover`. - **`--strict` build flag**: unresolved token aliases warn-and-skip locally but throw in CI, so a broken alias can't silently produce incomplete CSS. - **CI workflow** (`tokens-check.yaml`) on PRs/merge-queue touching tokens/scripts/webapp: build `--strict`, assert the committed CSS matches the rebuild (`git diff --exit-code`), then run the removed-token check. A `token-check` aggregation job provides a stable required-status-check name. ## Testing - `npm test --workspace=@nangohq/design-system` passes. - `tokens:build --strict` and `tokens:check` exit 0 on the current token set with no CSS drift. - Verified the gates fire: removing `--radius-ds-xs`, `--color-border-muted`, and used semantic tokens each flag their webapp references. ## Follow-up - `token-check` still needs to be added as a required status check in `master` branch protection (a repo setting) for the gate to block merges. Fixes [NAN-5679](https://linear.app/nango/issue/NAN-5679) | 3 个月前 | |
feat(design-system): validate removed tokens against webapp usages (#6816) ## Problem When design tokens are consolidated or renamed, CSS variables disappear from `tokens.generated.css` but webapp code can still reference them — directly via `var(--token)` or via Tailwind utilities (`bg-token`, `rounded-ds-*`, …). These orphaned references only surface when something visually breaks. We caught exactly this by hand in #6788; this PR automates that check. ## Solution - **`tokens-check-removed.mjs`**: diffs merge-base vs current `tokens.generated.css` for removed CSS variables, then scans `packages/webapp/src` for each removed token's real references — direct `var()` (including fallback forms) and the exact Tailwind utilities it generates. Matches at token boundaries so `text-link` doesn't false-positive on `text-text-link-hover`. - **`--strict` build flag**: unresolved token aliases warn-and-skip locally but throw in CI, so a broken alias can't silently produce incomplete CSS. - **CI workflow** (`tokens-check.yaml`) on PRs/merge-queue touching tokens/scripts/webapp: build `--strict`, assert the committed CSS matches the rebuild (`git diff --exit-code`), then run the removed-token check. A `token-check` aggregation job provides a stable required-status-check name. ## Testing - `npm test --workspace=@nangohq/design-system` passes. - `tokens:build --strict` and `tokens:check` exit 0 on the current token set with no CSS drift. - Verified the gates fire: removing `--radius-ds-xs`, `--color-border-muted`, and used semantic tokens each flag their webapp references. ## Follow-up - `token-check` still needs to be added as a required status check in `master` branch protection (a repo setting) for the gate to block merges. Fixes [NAN-5679](https://linear.app/nango/issue/NAN-5679) | 3 个月前 | |
feat(design-system): validate removed tokens against webapp usages (#6816) ## Problem When design tokens are consolidated or renamed, CSS variables disappear from `tokens.generated.css` but webapp code can still reference them — directly via `var(--token)` or via Tailwind utilities (`bg-token`, `rounded-ds-*`, …). These orphaned references only surface when something visually breaks. We caught exactly this by hand in #6788; this PR automates that check. ## Solution - **`tokens-check-removed.mjs`**: diffs merge-base vs current `tokens.generated.css` for removed CSS variables, then scans `packages/webapp/src` for each removed token's real references — direct `var()` (including fallback forms) and the exact Tailwind utilities it generates. Matches at token boundaries so `text-link` doesn't false-positive on `text-text-link-hover`. - **`--strict` build flag**: unresolved token aliases warn-and-skip locally but throw in CI, so a broken alias can't silently produce incomplete CSS. - **CI workflow** (`tokens-check.yaml`) on PRs/merge-queue touching tokens/scripts/webapp: build `--strict`, assert the committed CSS matches the rebuild (`git diff --exit-code`), then run the removed-token check. A `token-check` aggregation job provides a stable required-status-check name. ## Testing - `npm test --workspace=@nangohq/design-system` passes. - `tokens:build --strict` and `tokens:check` exit 0 on the current token set with no CSS drift. - Verified the gates fire: removing `--radius-ds-xs`, `--color-border-muted`, and used semantic tokens each flag their webapp references. ## Follow-up - `token-check` still needs to be added as a required status check in `master` branch protection (a repo setting) for the gate to block merges. Fixes [NAN-5679](https://linear.app/nango/issue/NAN-5679) | 3 个月前 | |
feat(audit): publish audit events to pub/sub, consume in metering (NAN-6271) (#6783) - Replaces the server's direct ClickHouse write with a pub/sub publish, consumed by a new `AuditProcessor` in metering that writes to `audit_trail_events`. Registers `audit` as a pub/sub subject and allows it in `NANGO_PUBSUB_SNS_SQS_CONFIG`. - Splits `AuditStore` into `AuditWriter` (record) and `AuditReader` (list), so the server can publish writes while still reading from ClickHouse. `ClickhouseAuditStore` implements both; `PubSubAuditWriter` implements only the writer. - Stamps the event `id` and `version` at the emit boundary rather than at storage, so a redelivered message keeps one identity and `ReplacingMergeTree` can collapse the duplicate (NAN-6285). - Adds `NANGO_AUDIT_TRANSPORT` (`direct` | `pubsub`, default `direct`) so each environment cuts over independently. This PR changes no behaviour on deploy — dev is flipped separately in nango-environments. - Counts successful publishes in `nango.pubsub.publish`, which previously only counted failures. Paired with `nango.audit.clickhouse.ingest.result` on the consumer side, this gives an emitted-vs-stored signal for detecting loss. ### The wire payload is the serialized event, not the typed object `SerializedAuditEvent` (`{ event: string }`) carries the canonical JSON, serialized once at the emit boundary and stored verbatim. `@nangohq/types` cannot import from `@nangohq/audit`, so a typed payload would have meant relocating `AuditEvent` and converting its whole tree to type aliases to satisfy the pub/sub `Serializable` constraint. Keeping the blob on the wire also makes it byte-identical to the stored `event` column, so nothing re-serializes between emit and storage. ### Deploy order The env schema rejects unknown subjects, so config referencing `audit` before this code is deployed fails startup for every pod mounting `nango-pubsub-sns-sqs`, not just audit. 1. This PR 2. NangoHQ/nango-infra#172 — topic, queue and DLQ 3. NangoHQ/nango-environments#155 — topic ARN, queue URL, and `NANGO_AUDIT_TRANSPORT=pubsub` on dev 4. Same variable on staging, then production ## Follow-ups - **Production-ready consumer, separate PR.** The consumer currently logs and acknowledges on a failed write, matching the direct-write path — so a ClickHouse failure drops the event. Redelivery, DLQ handling and publish-side batching land with the hardened consumer; the SNS/SQS transport already supports commit-after-write when it does. - **Audit event types and names, once this and #6917 are merged.** Move the event model into `@nangohq/types`, fold `id`/`version` into `AuditEvent` and construct them at the single emit site (which needs the `as AuditEvent` cast in the middleware removed first, otherwise the required fields are not enforced), drop `StoredAuditEvent`, and derive `ApiAuditTrailEvent` from the model instead of restating it. Both files this touches are rewritten by #6917, so it has to follow it. - Dedicated `audit` ClickHouse database, replacing the current colocation in `usage`. - `nango.pubsub.publish` now emits successes, so the "Usage metrics publish failures" widget on the Data Transfer dashboard needs `success:false` added to its query. The `[PubSub] High failure rate` monitor already filters correctly. ## Test plan - [x] `npm run ts-build` clean across the monorepo - [x] Unit: `packages/audit` (14), `packages/pubsub` (35, including new `Publisher` coverage), `packages/metering` (3), `packages/utils` (345) - [x] Integration: `packages/audit` store (5), `getAuditTrail` + audit middleware private/public (13) - [x] Verified by deliberate regression that the id-stamping, publish-metric, consumer-ack and Publisher tests fail when the behaviour they guard is removed - [x] prettier + oxlint clean on changed files - [ ] Deploy to dev, flip `NANGO_AUDIT_TRANSPORT=pubsub`, confirm events reach `audit_trail_events` via the consumer and appear in the dashboard - [ ] Confirm the queue drains and the DLQ stays empty - [ ] Staging, then production --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> | 2 个月前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 3 个月前 | ||
| 3 个月前 | ||
| 3 个月前 | ||
| 2 个月前 |