Skip to content

Moved "track email delivered and opened" to new automations interface - #32573

Open
EvanHahn wants to merge 1 commit into
automations-trackEmailDeliveredAndOpened-hold-transaction-for-less-timefrom
ny1704-trackemaildeliveredandopened
Open

EvanHahn wants to merge 1 commit into
automations-trackEmailDeliveredAndOpened-hold-transaction-for-less-timefrom
ny1704-trackemaildeliveredandopened

Conversation

@EvanHahn

@EvanHahn EvanHahn commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

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

Moves another function to the new automations interface. No user impact expected.

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

Moves another function to the new automations interface. No user impact expected.
@EvanHahn
EvanHahn added this pull request to stack #32574 November 4, 2026 20:16
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Email delivery and open tracking moves from the legacy repository to the v2 automations API and repository. The v2 repository records timestamps while preserving the earliest values, locks recipients without a recorded open, and increments revision open counts. The analytics processor and tests use the updated tracking data type and API.

Possibly related PRs

  • TryGhost/Ghost#32569: Changes the same tracking behavior and transaction; this PR relocates that behavior to the v2 API and repository.
  • TryGhost/Ghost#30625: Filters generic bot opens before event-map creation; this PR records opens from that map.

Suggested labels: migration

Suggested reviewers: troyciesco, cmraible

Merge Risk: Minimal · up to dd18a

No material regression has been identified in the migrated email delivery and open tracking path; the PR is ready for normal merge checks.

Pre-merge checks: Passed 7
Check name Status Explanation
Title check Passed The title names the moved method, 'track email delivered and opened', and the new automations interface. The changeset moves that method from the legacy repository to automationsApi2, so the title mat…
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.
Type-Safe Boundaries Passed The PR does not introduce a type-safety boundary defect. It moves the existing tracking logic from the legacy repository into automations-api-2.ts; the Mailgun event normalization and batch processi…
New Files Are Typescript Passed The pull request adds no files. All changed source files use the .ts extension, so it does not add a .js, .jsx, .cjs, or .mjs source file.
Tooling Ownership Passed The pull request changes only automations implementation files and tests under ghost/core and ghost/test. It does not add or modify scripts, tools, shared configuration, build inputs, shipped …
Description check Passed The description says the PR moves another function to the new automations interface, referring to the "track email delivered and opened" method. The changeset does exactly that: it adds trackEmailDeli…
Full details: Title check

Explanation

The title names the moved method, 'track email delivered and opened', and the new automations interface. The changeset moves that method from the legacy repository to automationsApi2, so the title matches the main change.

Full details: Type-Safe Boundaries

Explanation

The PR does not introduce a type-safety boundary defect. It moves the existing tracking logic from the legacy repository into automations-api-2.ts; the Mailgun event normalization and batch processing path already existed, and the changed processor only changes the imported TypeScript type. The new database row read in lockNotYetOpenedEmailRecipients uses a Zod schema. No new unchecked as, any, @ts-ignore, or @ts-nocheck appears in production changes, and the new tracking type does not duplicate a Zod-described shape.

Full details: Tooling Ownership

Explanation

The pull request changes only automations implementation files and tests under ghost/core and ghost/test. It does not add or modify scripts, tools, shared configuration, build inputs, shipped commands, or other tooling paths. The tooling-ownership criteria therefore do not apply, and no placement or execution problem is introduced.

Full details: Description check

Explanation

The description says the PR moves another function to the new automations interface, referring to the "track email delivered and opened" method. The changeset does exactly that: it adds trackEmailDeliveredAndOpened to automationsApi2, removes it from the legacy repository, and updates the related tests. The description is related to the changes, so this check passes. It is brief, but it names the migration and links the tracking issue, which is enough for this lenient check.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between ef4edea and dd18aa4.

Files selected for processing: 12
  • ghost/core/server/services/automations/automations-api-2.ts
  • ghost/core/server/services/automations/automations-api.ts
  • ghost/core/server/services/automations/automations-repository-2.ts
  • ghost/core/server/services/automations/automations-repository.ts
  • ghost/core/server/services/automations/database-automations-repository-2.ts
  • ghost/core/server/services/automations/database-automations-repository.ts
  • ghost/core/server/services/email-analytics/automation-email-analytics-batch-processor.ts
  • ghost/test/e2e-api/admin/automation-run-history-execution.test.ts
  • ghost/test/integration/services/automations/database-automations-repository-2.test.ts
  • ghost/test/unit/server/services/automations/automations-api-2.test.ts
  • ghost/test/unit/server/services/automations/database-automations-repository.test.ts
  • ghost/test/unit/server/services/automations/test-automations-repository-2.ts
Files with no reviewable changes: 3
  • ghost/test/unit/server/services/automations/database-automations-repository.test.ts
  • ghost/core/server/services/automations/automations-repository.ts
  • ghost/core/server/services/automations/database-automations-repository.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Recent review details
Context from checks skipped due to timeout: 11
  • GitHub Check: Unit tests (Node 22.23.4)
  • GitHub Check: Typecheck
  • GitHub Check: Legacy tests (Node 24.20.0, mysql8)
  • GitHub Check: Unit tests (Node 24.20.0)
  • GitHub Check: Acceptance tests (Node 24.20.0, mysql8)
  • GitHub Check: Legacy tests (Node 22.23.4, mysql8)
  • GitHub Check: Acceptance tests (Node 22.23.4, mysql8)
  • GitHub Check: Lint
  • GitHub Check: Build Admin
  • GitHub Check: CodeRabbit
  • GitHub Check: Analyze (javascript-typescript)
Additional context used
Code guidelines: 6
docs/contributing/testing.md — configured
docs/practices/error-handling.md — configured
tools/README.md — configured
ghost/core/server/services/README.md — auto-discovered
docs/codebase/jobs.md — configured
docs/codebase/monorepo-structure.md — configured
Path-based instructions: 10
Review new or changed service boundaries for explicit dependency ownership, deterministic/idempotent initialisation, boot ordering, transaction and event semantics, cache coherence, and restart/multi-instance safety.

CodeRabbit configuration file

Files:

  • ghost/core/server/services/email-analytics/automation-email-analytics-batch-processor.ts
  • ghost/core/server/services/automations/database-automations-repository-2.ts
  • ghost/core/server/services/automations/automations-api.ts
  • ghost/core/server/services/automations/automations-api-2.ts
  • ghost/core/server/services/automations/automations-repository-2.ts
Review whether tests prove changed behaviour, meaningful error/edge paths, and externally observable contracts without coupling to implementation details.

CodeRabbit configuration file

Files:

  • ghost/test/integration/services/automations/database-automations-repository-2.test.ts
  • ghost/test/e2e-api/admin/automation-run-history-execution.test.ts
  • ghost/test/unit/server/services/automations/automations-api-2.test.ts
Review lens: "where does this data become trusted?" Boundary data (HTTP input, external API/SDK responses, env/config, DB/filesystem reads, queue/webhook/event payloads) is `unknown` until validated — Zod by default.

CodeRabbit configuration file

Files:

  • ghost/core/server/services/email-analytics/automation-email-analytics-batch-processor.ts
  • ghost/core/server/services/automations/database-automations-repository-2.ts
  • ghost/test/integration/services/automations/database-automations-repository-2.test.ts
  • ghost/test/e2e-api/admin/automation-run-history-execution.test.ts
  • ghost/core/server/services/automations/automations-api.ts
  • ghost/core/server/services/automations/automations-api-2.ts
  • ghost/test/unit/server/services/automations/automations-api-2.test.ts
  • ghost/test/unit/server/services/automations/test-automations-repository-2.ts
  • ghost/core/server/services/automations/automations-repository-2.ts
Prioritise concrete correctness, security, data-integrity, compatibility, and regression risks.

CodeRabbit configuration file

Files:

  • ghost/core/server/services/email-analytics/automation-email-analytics-batch-processor.ts
  • ghost/core/server/services/automations/database-automations-repository-2.ts
  • ghost/test/integration/services/automations/database-automations-repository-2.test.ts
  • ghost/test/e2e-api/admin/automation-run-history-execution.test.ts
  • ghost/core/server/services/automations/automations-api.ts
  • ghost/core/server/services/automations/automations-api-2.ts
  • ghost/test/unit/server/services/automations/automations-api-2.test.ts
  • ghost/test/unit/server/services/automations/test-automations-repository-2.ts
  • ghost/core/server/services/automations/automations-repository-2.ts
Applicability reference: AGENTS.md: # AGENTS.md Start with: [Testing](docs/contributing/testing.md) Source excerpt: Put tests as close as possible to the code and behavior under test: **Unit tests** cover a function, compo...

CodeRabbit inference engine (docs/contributing/testing.md)

Files:

  • ghost/test/integration/services/automations/database-automations-repository-2.test.ts
  • ghost/test/e2e-api/admin/automation-run-history-execution.test.ts
  • ghost/test/unit/server/services/automations/automations-api-2.test.ts
  • ghost/test/unit/server/services/automations/test-automations-repository-2.ts
Source excerpt: Use that fallback when there is no safe, useful message.

CodeRabbit inference engine (docs/practices/error-handling.md)

Files:

  • ghost/core/server/services/email-analytics/automation-email-analytics-batch-processor.ts
  • ghost/core/server/services/automations/database-automations-repository-2.ts
  • ghost/core/server/services/automations/automations-api.ts
  • ghost/core/server/services/automations/automations-api-2.ts
  • ghost/core/server/services/automations/automations-repository-2.ts
Applicability reference: AGENTS.md: # AGENTS.md **Repository tooling:** read the [tooling ownership guide](tools/README.md) Source excerpt: | Job | Home | How it runs | | ---------------------------------------------------...

CodeRabbit inference engine (tools/README.md)

Files:

  • ghost/core/server/services/email-analytics/automation-email-analytics-batch-processor.ts
  • ghost/core/server/services/automations/database-automations-repository-2.ts
  • ghost/test/integration/services/automations/database-automations-repository-2.test.ts
  • ghost/test/e2e-api/admin/automation-run-history-execution.test.ts
  • ghost/core/server/services/automations/automations-api.ts
  • ghost/core/server/services/automations/automations-api-2.ts
  • ghost/test/unit/server/services/automations/automations-api-2.test.ts
  • ghost/test/unit/server/services/automations/test-automations-repository-2.ts
  • ghost/core/server/services/automations/automations-repository-2.ts
Applicability reference: AGENTS.md: # AGENTS.md **Ghost Core:** use the [server map](docs/codebase/monorepo-structure.md#ghost-core) and read the [services guide](ghost/core/server/services/README.md) before Source excerpt...

CodeRabbit inference engine (ghost/core/server/services/README.md)

Files:

  • ghost/core/server/services/email-analytics/automation-email-analytics-batch-processor.ts
  • ghost/core/server/services/automations/database-automations-repository-2.ts
  • ghost/core/server/services/automations/automations-api.ts
  • ghost/core/server/services/automations/automations-api-2.ts
  • ghost/core/server/services/automations/automations-repository-2.ts
Source excerpt: Jobs run in-process and share the main process's initialized services.

CodeRabbit inference engine (docs/codebase/jobs.md)

Files:

  • ghost/core/server/services/email-analytics/automation-email-analytics-batch-processor.ts
  • ghost/core/server/services/automations/database-automations-repository-2.ts
  • ghost/core/server/services/automations/automations-api.ts
  • ghost/core/server/services/automations/automations-api-2.ts
  • ghost/core/server/services/automations/automations-repository-2.ts
Applicability reference: AGENTS.md: # AGENTS.md Start with: [Monorepo structure](docs/codebase/monorepo-structure.md) AGENTS.md: # AGENTS.md **Ghost Core:** use the [server map](docs/codebase/monorepo-structure.md#ghost-co...

CodeRabbit inference engine (docs/codebase/monorepo-structure.md)

Files:

  • ghost/core/server/services/email-analytics/automation-email-analytics-batch-processor.ts
  • ghost/core/server/services/automations/database-automations-repository-2.ts
  • ghost/test/integration/services/automations/database-automations-repository-2.test.ts
  • ghost/test/e2e-api/admin/automation-run-history-execution.test.ts
  • ghost/core/server/services/automations/automations-api.ts
  • ghost/core/server/services/automations/automations-api-2.ts
  • ghost/test/unit/server/services/automations/automations-api-2.test.ts
  • ghost/test/unit/server/services/automations/test-automations-repository-2.ts
  • ghost/core/server/services/automations/automations-repository-2.ts
Additional comments: 9
ghost/core/server/services/automations/automations-repository-2.ts: 1

41-45: LGTM!

Also applies to: 114-120, 166-171, 182-188

ghost/core/server/services/automations/database-automations-repository-2.ts: 1

8-11: LGTM!

Also applies to: 246-254, 343-354, 363-388

ghost/test/integration/services/automations/database-automations-repository-2.test.ts: 1

123-125: LGTM!

Also applies to: 159-192, 694-718, 1101-1158, 1185-1264

ghost/test/unit/server/services/automations/test-automations-repository-2.ts: 1

29-29: LGTM!

Also applies to: 39-39, 41-41

ghost/core/server/services/automations/automations-api-2.ts: 1

5-5: LGTM!

Also applies to: 8-8, 222-274

ghost/core/server/services/automations/automations-api.ts: 1

554-555: LGTM!

ghost/core/server/services/email-analytics/automation-email-analytics-batch-processor.ts: 1

1-1: LGTM!

Also applies to: 4-4, 46-46, 82-85

ghost/test/e2e-api/admin/automation-run-history-execution.test.ts: 1

29-29: LGTM!

Also applies to: 70-70, 153-153

ghost/test/unit/server/services/automations/automations-api-2.test.ts: 1

7-7: LGTM!

Also applies to: 18-19, 551-686

@nx-cloud

nx-cloud Bot commented Nov 4, 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 dd18aa4

Command Status Duration Result
nx run ghost:test:integration ✅ Succeeded 2m 3s View ↗
nx run ghost:test:ci:integration ✅ Succeeded 2m 21s View ↗
nx run ghost:test:bullmq:scenarios ✅ Succeeded 58s View ↗
nx run ghost:test:bullmq ✅ Succeeded 38s View ↗
nx run ghost:test:ci:e2e ✅ Succeeded 4m 27s View ↗
nx run ghost:test:e2e ✅ Succeeded 4m 19s View ↗
nx run ghost:test:legacy ✅ Succeeded 2m 22s View ↗
nx run ghost:test:ci:unit ✅ Succeeded 1m 24s View ↗
Additional runs (8) ✅ Succeeded ... View ↗

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


☁️ Nx Cloud last updated this comment at 2026-11-04 20:27:46 UTC

@codecov

codecov Bot commented Nov 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.80488% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.00%. Comparing base (ef4edea) to head (dd18aa4).

Files with missing lines Patch % Lines
...e/server/services/automations/automations-api-2.ts 86.36% 3 Missing ⚠️
...s/automations/database-automations-repository-2.ts 88.23% 2 Missing ⚠️
Additional details and impacted files
@@                                             Coverage Diff                                             @@
##           automations-trackEmailDeliveredAndOpened-hold-transaction-for-less-time   #32573      +/-   ##
===========================================================================================================
- Coverage                                                                    86.14%   86.00%   -0.14%     
===========================================================================================================
  Files                                                                         1414     1414              
  Lines                                                                        53630    53632       +2     
  Branches                                                                      9239     9238       -1     
===========================================================================================================
- Hits                                                                         46197    46126      -71     
- Misses                                                                        6335     6388      +53     
- Partials                                                                      1098     1118      +20     
Flag Coverage Δ
e2e-tests 73.23% <80.48%> (-0.03%) ⬇️
unit-tests 69.22% <48.78%> (-0.19%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@EvanHahn
EvanHahn requested a review from troyciesco November 4, 2026 20:31

This branch has not been deployed

No deployments
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