trim comments

This commit is contained in:
Owen Greenhalgh
2026-05-18 11:31:52 +01:00
parent e73a6aa9cc
commit 5161e39239
7 changed files with 11 additions and 54 deletions

2
ai

Submodule ai updated: bf528179eb...e66bb80796

View File

@@ -65,9 +65,6 @@ SVIX_API_KEY=
# This is used to generate singular / plural names for your features, which are used when in the dashboard and when you use Autumn UI components
ANTHROPIC_API_KEY=
# TINYBIRD US-EAST CLICKHOUSE (required for analytics paths that hit ClickHouse-direct)
# During the us-west → us-east cutover, ClickHouse-direct reads (revenue
# analytics, getCountAndSum, etc.) are routed to the us-east workspace via
# this URL plus TINYBIRD_US_EAST_TOKEN. Legacy TINYBIRD_CLICKHOUSE_URL is
# ignored at runtime.
# TINYBIRD
# ClickHouse endpoint for the us-east workspace (primary after cutover).
TINYBIRD_US_EAST_CLICKHOUSE_URL=

View File

@@ -1,18 +1,5 @@
import { type ClickHouseClient, createClient } from "@clickhouse/client";
/**
* ClickHouse-direct client for Tinybird (used by analytics paths like
* revenue analytics, getCountAndSum, getTopEventNames, etc.). During the
* us-west → us-east cutover transition this reads from the us-east
* workspace's ClickHouse endpoint and admin token. The legacy
* `TINYBIRD_CLICKHOUSE_URL` / `TINYBIRD_TOKEN` env vars are ignored at
* runtime — primary moved to TINYBIRD_US_EAST_* in `tinybirdUtils.ts` and
* this client follows it.
*
* Tinybird URL pattern reference:
* API: https://api.<region>.aws.tinybird.co
* ClickHouse: https://clickhouse.<region>.aws.tinybird.co
*/
const primaryClickhouseUrl = process.env.TINYBIRD_US_EAST_CLICKHOUSE_URL;
const primaryToken = process.env.TINYBIRD_US_EAST_TOKEN;

View File

@@ -8,13 +8,7 @@ import { createListEventsPaginatedPipe } from "./pipes/listEventsPaginatedPipe.j
import { tinybirdConfig } from "./tinybirdUtils.js";
import { z } from "./tinybirdZod.js";
/**
* Primary Tinybird REST API client — handles reads (pipes) and primary
* writes (ingest). Configured from `TINYBIRD_US_EAST_*` env vars during the
* us-west → us-east cutover transition (see `tinybirdUtils.ts`). The
* dual-write safety-net secondary lives in `initTinybirdV2.ts` and
* reads the legacy `TINYBIRD_API_URL` / `TINYBIRD_TOKEN` vars.
*/
/** Primary Tinybird client — reads (pipes) and primary writes (ingest). */
const tinybirdClient: Tinybird | null = tinybirdConfig
? new Tinybird(tinybirdConfig)
: null;

View File

@@ -1,14 +1,8 @@
import { createTinybirdApi } from "@tinybirdco/sdk";
/**
* Secondary Tinybird API client for dual-write safety net during the
* us-west → us-east region cutover. Reads from the legacy `TINYBIRD_API_URL`
* / `TINYBIRD_TOKEN` env vars, which point at us-west during the transition.
* Primary lives on `TINYBIRD_US_EAST_*` (see `tinybirdUtils.ts`). Once
* us-east is stable, delete this file + the dual-write logic in
* `sendEvents.ts`, and remove `TINYBIRD_API_URL` / `TINYBIRD_TOKEN` from
* Infisical.
*/
// Dual-write safety net during the us-east cutover. Reads the legacy
// us-west env vars; delete with the dual-write logic in `sendEvents.ts`
// once us-east is stable.
const secondaryApiUrl = process.env.TINYBIRD_API_URL;
const secondaryToken = process.env.TINYBIRD_TOKEN;

View File

@@ -11,13 +11,7 @@ const generateErrorId = (): string => {
return `TB_ERR_${crypto.randomBytes(8).toString("hex").toUpperCase()}`;
};
/**
* Send EventInsert[] to Tinybird primary and (if configured) the secondary
* dual-write safety-net client. Each path is fired independently so a missing
* or broken primary doesn't disable the secondary. Does not throw — failures
* are logged and captured in Sentry with `tinybird_region=primary|secondary`
* (the tag name is legacy from when the second client was region-specific).
*/
/** Dual-write to Tinybird primary + secondary. Failures logged, never thrown. */
export const sendEventsToTinybird = async ({
events,
logger,
@@ -29,10 +23,7 @@ export const sendEventsToTinybird = async ({
return;
}
// During the region cutover, primary (us-east via TINYBIRD_US_EAST_*) and
// secondary (us-west via legacy TINYBIRD_API_URL/TOKEN) are independent.
// If primary is misconfigured or down, the secondary safety net must
// still fire — that's the whole point of dual-write.
// Gate on either being configured — a broken primary must not silence the secondary.
if (!tinybirdIngest && !tinybirdSecondaryApi) {
logger?.debug(
"Tinybird not configured (neither primary nor secondary), skipping event send",

View File

@@ -1,14 +1,8 @@
import { ErrCode, RecaseError } from "@autumn/shared";
import { StatusCodes } from "http-status-codes";
/**
* Primary Tinybird config — reads from `TINYBIRD_US_EAST_API_URL` /
* `TINYBIRD_US_EAST_TOKEN` during the us-west → us-east cutover transition.
* The legacy `TINYBIRD_API_URL` / `TINYBIRD_TOKEN` env vars now feed the
* dual-write *secondary* client (`initTinybirdV2.ts`) as a safety net
* during the transition. After cutover stabilises, the secondary client and
* legacy env vars get removed in a follow-up cleanup.
*/
// Primary points at us-east during the cutover; legacy us-west vars feed
// the dual-write secondary in `initTinybirdV2.ts`.
const primaryApiUrl = process.env.TINYBIRD_US_EAST_API_URL;
const primaryToken = process.env.TINYBIRD_US_EAST_TOKEN;