Skip to content

Started inserting automation run when member signs up#28263

Open
EvanHahn wants to merge 1 commit into
mainfrom
insert-automation-run-when-member-signs-up
Open

Started inserting automation run when member signs up#28263
EvanHahn wants to merge 1 commit into
mainfrom
insert-automation-run-when-member-signs-up

Conversation

@EvanHahn
Copy link
Copy Markdown
Contributor

@EvanHahn EvanHahn commented May 30, 2026

towards https://linear.app/ghost/issue/NY-1286
ref #28120

I recommend reviewing this with whitespace changes disabled.

When a member signs up, we should trigger an automation run and possibly insert a new row.

Nothing happens yet when these rows are inserted. That will be done in a future change.

This is development-only; triggering is a no-op in production.

I tested this by:

  • Adding automated tests.

  • Verified that the old member welcome email is still sent on member signup.

  • Creating this temporary endpoint and verifying that the results looked expected after member signup:

    router.get('/automations/database-dump', (_req, res) => {
        const db = getTemporaryFakeAutomationsDatabase();
        res.json({
            automation_runs: db.prepare('SELECT * FROM automation_runs').all(),
            automation_run_steps: db.prepare('SELECT * FROM automation_run_steps').all()
        });
    });

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 30, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0a3ddf87-304e-430e-9d02-3f6ffa01e8b3

📥 Commits

Reviewing files that changed from the base of the PR and between 4289304 and 66fb886.

📒 Files selected for processing (10)
  • ghost/core/core/server/services/automations/automations-api.ts
  • ghost/core/core/server/services/automations/automations-repository.ts
  • ghost/core/core/server/services/automations/fake-database-automations-repository.ts
  • ghost/core/core/server/services/automations/temporary-fake-database.ts
  • ghost/core/core/server/services/gifts/gift-service.ts
  • ghost/core/core/server/services/members/members-api/members-api.js
  • ghost/core/core/server/services/members/members-api/repositories/member-repository.js
  • ghost/core/test/unit/server/services/automations/automations-repository.test.ts
  • ghost/core/test/unit/server/services/gifts/gift-service.test.ts
  • ghost/core/test/unit/server/services/members/members-api/repositories/member-repository.test.js
✅ Files skipped from review due to trivial changes (1)
  • ghost/core/core/server/services/automations/automations-repository.ts
🚧 Files skipped from review as they are similar to previous changes (8)
  • ghost/core/core/server/services/members/members-api/members-api.js
  • ghost/core/core/server/services/gifts/gift-service.ts
  • ghost/core/core/server/services/automations/automations-api.ts
  • ghost/core/core/server/services/automations/temporary-fake-database.ts
  • ghost/core/test/unit/server/services/members/members-api/repositories/member-repository.test.js
  • ghost/core/core/server/services/automations/fake-database-automations-repository.ts
  • ghost/core/test/unit/server/services/gifts/gift-service.test.ts
  • ghost/core/core/server/services/members/members-api/repositories/member-repository.js

Walkthrough

This PR adds a public automationsApi.trigger(options) entrypoint (event restricted to 'member_sign_up'), a repository-level trigger implementation that schedules automation runs/steps based on the first eligible action revision and action type (wait/send_email), ES-module and schema updates for the temporary fake automations DB, MemberRepository wiring to call the new trigger (while preserving the legacy welcome-email enqueue path), GiftService updates to use the new method for paid signups, and unit tests covering repository and integration behaviors.

Possibly related PRs

  • TryGhost/Ghost#28243: Both PRs modify member-repository.test.js to exercise the member-signup automation path via automationsApi.trigger.
  • TryGhost/Ghost#28170: Both PRs interact with StartAutomationsPollEvent/polling flow—one dispatches the event after trigger, the other updates the poll handler.
  • TryGhost/Ghost#27658: Overlaps with automation/welcome-email model changes used by member signup automation flows.

Suggested labels

ok to merge for me

Suggested reviewers

  • troyciesco
  • cmraible
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: introducing automation run insertion logic when members sign up.
Description check ✅ Passed The description is clearly related to the changeset, explaining the purpose, scope, development-only behavior, and testing approach.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch insert-automation-run-when-member-signs-up

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.42.3)
ghost/core/test/unit/server/services/members/members-api/repositories/member-repository.test.js

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

towards https://linear.app/ghost/issue/NY-1286

*I recommend reviewing this with whitespace changes disabled.*

When a member signs up, we should trigger an automation run and possibly
insert a new row.

Nothing happens yet when these rows are inserted--that will be done in a
future change.

This is development-only; triggering is a no-op in production.
@EvanHahn EvanHahn force-pushed the insert-automation-run-when-member-signs-up branch from 4289304 to 66fb886 Compare May 30, 2026 20:28
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Had to convert this to TypeScript so I could import it from another TypeScript file. (Alternatively, I could've added temporary-fake-database.d.ts, but I think that's strictly worse.

Comment thread ghost/core/core/server/services/automations/automations-api.ts
@EvanHahn EvanHahn requested a review from troyciesco May 30, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant