Skip to content

Added track_clicks and clicked_at columns to automated_email_recipients table#29529

Merged
troyciesco merged 1 commit into
mainfrom
chris-ny-1487-add-track_clicks-and-clicked_at-to
Jul 22, 2026
Merged

Added track_clicks and clicked_at columns to automated_email_recipients table#29529
troyciesco merged 1 commit into
mainfrom
chris-ny-1487-add-track_clicks-and-clicked_at-to

Conversation

@cmraible

@cmraible cmraible commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

closes https://linear.app/ghost/issue/NY-1487/

Summary

  • Added track_clicks and clicked_at columns to automated email recipients
  • Updated the current schema definition and integrity hash

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds track_clicks and clicked_at to automated_email_recipients through a migration and schema update. Recipient creation paths initialize click tracking as disabled. Schema integrity and repository tests include the new columns and expected default values.

Possibly related PRs

Suggested reviewers: evanhahn

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title accurately summarizes the main schema change to automated_email_recipients.
Description check ✅ Passed The description is directly related to the schema update and integrity hash change.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chris-ny-1487-add-track_clicks-and-clicked_at-to

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.

@github-actions github-actions Bot added the migration [pull request] Includes migration for review label Jul 22, 2026
@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

It looks like this PR contains a migration 👀
Here's the checklist for reviewing migrations:

General requirements

- [ ] ⚠️ Tested performance on staging database servers, as performance on local machines is not comparable to a production environment
we're just adding some columns to a relatively small table, no need to test performance in staging.

  • Satisfies idempotency requirement (both up() and down())
  • Does not reference models
  • Filename is in the correct format (and correctly ordered)
  • Targets the next minor version
  • All code paths have appropriate log messages
  • Uses the correct utils
  • Contains a minimal changeset
  • Does not mix DDL/DML operations
  • Tested in MySQL and SQLite

Schema changes

  • Both schema change and related migration have been implemented
    - [ ] For index changes: has been performance tested for large tables
  • For new tables/columns: fields use the appropriate predefined field lengths
  • For new tables/columns: field names follow the appropriate conventions
  • Does not drop a non-alpha table outside of a major version

Data changes

- [ ] Mass updates/inserts are batched appropriately
- [ ] Does not loop over large tables/datasets
- [ ] Defends against missing or invalid data
- [ ] For settings updates: follows the appropriate guidelines

@nx-cloud

nx-cloud Bot commented Jul 22, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 5f8108b

Command Status Duration Result
nx run ghost:test:ci:integration ✅ Succeeded 2m 17s View ↗
nx run ghost:test:legacy ✅ Succeeded 1m 50s View ↗
nx run ghost:test:integration ✅ Succeeded 3m 20s View ↗
nx run ghost-monorepo:lint:boundaries ✅ Succeeded 21s View ↗
nx run-many -t lint -p ghost,ghost-monorepo ✅ Succeeded 20s View ↗
nx run-many -t test:unit -p ghost ✅ Succeeded 30s View ↗
nx run ghost:test:e2e ✅ Succeeded 2m 47s View ↗
nx run @tryghost/admin:build ✅ Succeeded 9s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded <1s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-22 15:32:45 UTC

@github-actions

Copy link
Copy Markdown
Contributor

E2E Tests Failed

To view the Playwright test report locally, run:

REPORT_DIR=$(mktemp -d) && gh run download 29926481869 -n playwright-report -D "$REPORT_DIR" && npx playwright show-report "$REPORT_DIR"

@cmraible
cmraible force-pushed the chris-ny-1487-add-track_clicks-and-clicked_at-to branch from fe9bfc5 to c7b7ced Compare July 22, 2026 14:27
@@ -242,6 +242,8 @@ export function createDatabaseAutomationsRepository({
automation_action_revision_id: options.automationActionRevisionId,
...(options.mailgunMessageId ? {mailgun_message_id: options.mailgunMessageId} : {}),
track_opens: options.trackOpens,
// TODO(NY-1491) Snapshot the email_track_clicks setting when creating recipients.
track_clicks: false,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

note: bookshelf passes track_clicks: null if we omit this, so we have to explicitly pass track_clicks: false or this migration will effectively break migrations.

@@ -235,7 +235,8 @@ async function processRun({
member_uuid: member.get('uuid'),
member_email: member.get('email'),
member_name: member.get('name'),
track_opens: false
track_opens: false,
track_clicks: false

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

note: same as above, but this will always remain false since we don't care about click tracking for welcome emails.

@cmraible
cmraible force-pushed the chris-ny-1487-add-track_clicks-and-clicked_at-to branch 2 times, most recently from 640fae5 to fad725f Compare July 22, 2026 14:45
@cmraible

Copy link
Copy Markdown
Collaborator Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cmraible
cmraible marked this pull request as ready for review July 22, 2026 14:59

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@ghost/core/core/server/services/automations/database-automations-repository.ts`:
- Around line 245-246: Update recordEmailSent and its callers to thread the
automation’s email_track_clicks setting through options, then assign that value
to track_clicks when creating regular automation recipients instead of
hardcoding false. Preserve the welcome-email path’s explicitly disabled tracking
behavior if it is intentionally separate.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 051dedd5-9384-4a05-a82a-96193ebd7c1e

📥 Commits

Reviewing files that changed from the base of the PR and between e91932a and fad725f.

📒 Files selected for processing (6)
  • ghost/core/core/server/data/migrations/versions/6.54/2026-07-22-10-41-08-add-click-tracking-to-automated-email-recipients.js
  • ghost/core/core/server/data/schema/schema.js
  • ghost/core/core/server/services/automations/database-automations-repository.ts
  • ghost/core/core/server/services/automations/welcome-email-automation-poll.js
  • ghost/core/test/unit/server/data/schema/integrity.test.js
  • ghost/core/test/unit/server/services/automations/automations-repository.test.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fad725f0e6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

ref https://linear.app/ghost/issue/NY-1487/

Automation sends need to retain the click-tracking setting and first-click timestamp alongside the existing open analytics fields.
@cmraible
cmraible force-pushed the chris-ny-1487-add-track_clicks-and-clicked_at-to branch from fad725f to 5f8108b Compare July 22, 2026 15:15
@cmraible cmraible changed the title Added recipient click-tracking migration Added track_clicks and clicked_at columns to automated_email_recipients table Jul 22, 2026
@cmraible
cmraible requested a review from EvanHahn July 22, 2026 15:29
@cmraible

Copy link
Copy Markdown
Collaborator Author

CI seems a bit backed up, but this should pass.

@cmraible cmraible added the ok to merge for me You can merge this on my behalf if you want. label Jul 22, 2026
@cmraible
cmraible requested review from troyciesco and removed request for EvanHahn July 22, 2026 15:55
@troyciesco
troyciesco merged commit 49d24c7 into main Jul 22, 2026
50 checks passed
@troyciesco
troyciesco deleted the chris-ny-1487-add-track_clicks-and-clicked_at-to branch July 22, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

migration [pull request] Includes migration for review ok to merge for me You can merge this on my behalf if you want.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants