Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions packages/auth/src/lib/lifecycle.ts

This file was deleted.

49 changes: 14 additions & 35 deletions packages/auth/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Comment on lines +329 to +331

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Campaign instructions describe removed gate

The signup hook now always sends user.signed_up, but sync-automations.ts:20–24 still says it withholds the event from the experiment's control group and requires a separate event before adding another automation. Update that paragraph too. It could lead future campaign authors to split events unnecessarily.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/auth/src/server.ts
Line: 329-331

Comment:
**Campaign instructions describe removed gate**

The signup hook now always sends `user.signed_up`, but `sync-automations.ts:20–24` still says it withholds the event from the experiment's control group and requires a separate event before adding another automation. Update that paragraph too. It could lead future campaign authors to split events unnecessarily.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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,
);
}
},
},
Expand Down
11 changes: 4 additions & 7 deletions packages/email/scripts/sync-automations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -71,8 +69,7 @@ function template(alias: string, variables?: Record<string, unknown>) {

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: [
{
Expand Down
10 changes: 0 additions & 10 deletions packages/shared/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
Loading