diff --git a/packages/auth/src/lib/lifecycle.ts b/packages/auth/src/lib/lifecycle.ts deleted file mode 100644 index 5b1ea35311c..00000000000 --- a/packages/auth/src/lib/lifecycle.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { posthog } from "./analytics"; - -export const ACTIVATION_CAMPAIGN_FLAG = "activation-email-campaign"; - -/** - * Arm for the activation-drip A/B. `getFeatureFlag` emits the - * `$feature_flag_called` exposure PostHog scores the experiment on, so a user - * enters the analysis only when this call succeeds. - * - * The flag must be MULTIVARIATE with variants keyed exactly `control` and - * `test`. Only `control` withholds the drip; a missing, disabled or boolean - * flag reads as `test`, so shipping this before the flag exists changes - * nothing — everyone keeps getting the campaign until someone creates the - * flag at 50/50. - * - * Fails OPEN for the same reason: the drip is what ships to everyone today, so - * a PostHog outage must not silently stop it. Those signups emit no exposure - * either, which keeps them out of both arms instead of polluting control. - */ -export async function getActivationVariant( - userId: string, -): Promise<"control" | "test"> { - try { - const variant = await posthog.getFeatureFlag( - ACTIVATION_CAMPAIGN_FLAG, - userId, - ); - await posthog.flush(); - return variant === "control" ? "control" : "test"; - } catch (error) { - console.error("[lifecycle] Failed to evaluate activation flag:", error); - return "test"; - } -} diff --git a/packages/auth/src/server.ts b/packages/auth/src/server.ts index 5413d04e93b..eae7356ce09 100644 --- a/packages/auth/src/server.ts +++ b/packages/auth/src/server.ts @@ -52,7 +52,6 @@ import { } from "./lib/billing/subscription-events"; import { jwksAdapter } from "./lib/cached-jwks"; import { generateMagicTokenForInvite } from "./lib/generate-magic-token"; -import { getActivationVariant } from "./lib/lifecycle"; import { loadCustomSessionData } from "./lib/load-custom-session-data"; import { convertPendingShares, @@ -311,11 +310,8 @@ export const auth = betterAuth({ .where(eq(authSchema.sessions.userId, user.id)); } - // The welcome email is unconditional in BOTH arms. Gating it is - // what invalidated experiment 387868: a6beb048b changed the control - // condition mid-flight and the run became unreadable. The `welcome` - // automation sends it, because only automation sends get Resend's - // unsubscribe link and List-Unsubscribe headers. + // The `welcome` automation sends this, because only automation + // sends get Resend's unsubscribe link and List-Unsubscribe headers. try { const { error } = await resend.events.send({ event: "user.welcome", @@ -330,35 +326,18 @@ export const auth = betterAuth({ ); } - // Only drip enrolment is randomised. Nothing differs between arms - // until the first nudge (>=23h after signup), so "not activated at - // 22h" stays a pre-treatment covariate and the analysis can restrict - // to it without selection bias. Kill switch for the nudges is still - // the Resend automation toggle. - // - // CAUTION: withholding this event withholds it from EVERY consumer, - // not just the activation drip. Safe today because activation-drip - // is the only automation in sync-automations.ts triggering on - // `user.signed_up` — but that script is create-only and Resend can - // hold automations it never defined, so check the live account - // before trusting that. A second consumer means splitting enrolment - // first: emit `user.signed_up` unconditionally and gate an - // activation-only event instead, or the control arm silently drops - // out of that campaign too. - if ((await getActivationVariant(user.id)) === "test") { - try { - const { error } = await resend.events.send({ - event: "user.signed_up", - email: user.email, - payload: { userId: user.id, name: user.name }, - }); - if (error) throw new Error(error.message); - } catch (error) { - console.error( - `[lifecycle] Failed to emit signup event for ${user.id}:`, - error, - ); - } + try { + const { error } = await resend.events.send({ + event: "user.signed_up", + email: user.email, + payload: { userId: user.id, name: user.name }, + }); + if (error) throw new Error(error.message); + } catch (error) { + console.error( + `[lifecycle] Failed to emit signup event for ${user.id}:`, + error, + ); } }, }, diff --git a/packages/email/scripts/sync-automations.ts b/packages/email/scripts/sync-automations.ts index 373d53b1913..88ebb022430 100644 --- a/packages/email/scripts/sync-automations.ts +++ b/packages/email/scripts/sync-automations.ts @@ -17,11 +17,9 @@ * 230 people on 2026-08-21. Repeating events belong in `wait_for_event`, * which absorbs duplicates. Events fan out to every matching consumer, so * any number of automations can wait on the same one. - * - GATING an emitter is the mirror of that rule: it hits every consumer. The - * signup hook withholds `user.signed_up` from the activation A/B's control - * arm, so a second automation triggering on it would silently lose that arm - * too. Only activation-drip uses that trigger here. Before adding - * another `user.signed_up` trigger, split enrolment into its own event. + * - GATING an emitter is the mirror of that rule: it hits every consumer. To + * withhold a campaign from some users, gate an event of its own rather than + * one other automations trigger on. * - NEVER update an enabled automation's steps: despite the API's wording, * doing so cancelled every in-flight run (2026-08-20, ~324 users dropped * mid-drip). Migration is create-new-enabled, then stop (not edit) the old @@ -71,8 +69,7 @@ function template(alias: string, variables?: Record) { const desired: DesiredAutomation[] = [ { - // Every signup's welcome email; stopping this stops them all. It has its - // own event because `user.signed_up` is withheld from the A/B control arm. + // Every signup's welcome email; stopping this stops them all. name: "welcome", steps: [ { diff --git a/packages/shared/src/constants.ts b/packages/shared/src/constants.ts index d62a6010bb2..6193b6ab761 100644 --- a/packages/shared/src/constants.ts +++ b/packages/shared/src/constants.ts @@ -128,12 +128,8 @@ export const FEATURE_FLAGS = { * hash the site's single distinct id to one side. */ MOBILE_LAUNCH: "mobile-launch", - /** Gates access to Cloud features (environment variables, sandboxes). */ - CLOUD_ACCESS: "cloud-access", /** Allowlist for mobile voice mode: shows the entry and authorizes `voice.createSession`. */ MOBILE_VOICE_MODE: "mobile-voice-mode", - /** When enabled, blocks remote agent execution on the desktop (e.g., for enterprise orgs). */ - DISABLE_REMOTE_AGENT: "disable-remote-agent", /** * Paces the v1→v2 auto-migration rollout (percentage ramp + high-profile * org exclusions). Gates only NEW migrations on the v1 surface — post-flip @@ -192,12 +188,6 @@ export const FEATURE_FLAGS = { * flag. */ NEW_WORKSPACE_PROMPT_CARDS_OVERRIDE: "new-workspace-prompt-cards-override", - /** - * Shows the rebuilt chat pane (ChatV3Pane). UI-only: host-service always - * serves its `/chat-v3/*` routes, so this flag decides who sees the pane, - * not what the host can do — flips take effect live, with no host restart. - */ - CHAT_V3: "chat-v3", /** * Replaces the v2 workspace's right sidebar with a second pane area that * holds Files, Changes, Review, Browser and Chat panes.