Skip to content

Added logic to show/hide automation email opens/clicks#29497

Merged
troyciesco merged 1 commit into
mainfrom
NY-1466_show-hide-atmns-opens-clicks-stats
Jul 22, 2026
Merged

Added logic to show/hide automation email opens/clicks#29497
troyciesco merged 1 commit into
mainfrom
NY-1466_show-hide-atmns-opens-clicks-stats

Conversation

@troyciesco

@troyciesco troyciesco commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

closes NY-1466

When "Email opens" or "Email clicks" is disabled in Settings → Analytics, automation email metrics show a muted "Off" instead of a number — on the canvas step footer and in the step sidebar's Email performance panel.

Metrics stay in place rather than hiding, and "Off" is distinct from "--" (tracking on, no data yet). Untracked sidebar tiles get a hover card explaining why, their chart rings fade to an empty track, and the status is exposed to screen readers. Display-only — re-enabling tracking restores the numbers immediately.

Gated behind the automationAnalytics labs flag. To test: open an automation with a Send email step and toggle the two settings.

Note that there's no actual click data yet, so you'll only see "Off" or "--".

demo:

ghost-automation-tracking-off-states-2026-07-21-1258-nocaptions-share.mp4

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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: 345c5b20-8f17-4fd2-83d9-54aa0ea78b3c

📥 Commits

Reviewing files that changed from the base of the PR and between afb45a2 and e7762eb.

📒 Files selected for processing (5)
  • apps/admin/src/automations/components/canvas/email-performance-section.tsx
  • apps/admin/src/automations/components/canvas/nodes.tsx
  • apps/admin/src/automations/components/canvas/off-value.tsx
  • apps/admin/src/automations/editor.test.tsx
  • apps/admin/src/automations/hooks/use-email-tracking-settings.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • apps/admin/src/automations/hooks/use-email-tracking-settings.ts
  • apps/admin/src/automations/components/canvas/off-value.tsx
  • apps/admin/src/automations/components/canvas/nodes.tsx
  • apps/admin/src/automations/editor.test.tsx
  • apps/admin/src/automations/components/canvas/email-performance-section.tsx

Walkthrough

Email automation analytics now reads application-level open and click tracking settings. Performance charts and KPIs render tracked values or accessible Off states, with disabled rings dimmed and their chart values suppressed. Email node footers apply the same tracking behavior to opened and clicked metrics. Editor tests now provide controlled app settings, shared email statistics, and coverage for enabled, disabled, and unresolved tracking configurations.

Suggested reviewers: evanhahn

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change by describing automation email opens/clicks visibility behavior.
Description check ✅ Passed The description accurately matches the PR's tracking-toggle behavior, UI changes, and labs flag gating.
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.
✨ 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 NY-1466_show-hide-atmns-opens-clicks-stats

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.

@nx-cloud

nx-cloud Bot commented Jul 21, 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 e7762eb

Command Status Duration Result
nx run @tryghost/admin:test:acceptance ✅ Succeeded 6m 46s View ↗
nx run-many -t test:unit -p @tryghost/admin ✅ Succeeded 1m 37s View ↗
nx run ghost-monorepo:lint:boundaries ✅ Succeeded 21s View ↗
nx run-many -t lint -p @tryghost/admin,ghost-mo... ✅ Succeeded 58s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded 1s View ↗
nx run @tryghost/admin:build ✅ Succeeded 16s View ↗

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


☁️ Nx Cloud last updated this comment at 2026-07-22 12:55:38 UTC

@troyciesco
troyciesco force-pushed the NY-1466_show-hide-atmns-opens-clicks-stats branch 3 times, most recently from 55ee804 to 0a7c872 Compare July 21, 2026 18:15

@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

🧹 Nitpick comments (2)
apps/admin/src/automations/components/canvas/email-performance-section.tsx (1)

143-146: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the duplicated tracking-settings read into a shared hook. Both files independently re-implement the identical useAppContext() read + appSettings?.analytics ?? {} destructuring with the same defaults; a single shared hook (e.g. useEmailTrackingSettings()) would remove the duplication and centralize the "unresolved settings → untracked" fallback behavior in one place.

  • apps/admin/src/automations/components/canvas/email-performance-section.tsx#L143-L146: replace the local useAppContext()/destructuring with a shared useEmailTrackingSettings() hook returning {emailTrackOpens, emailTrackClicks}.
  • apps/admin/src/automations/components/canvas/nodes.tsx#L182-L183: replace the identical block with the same shared hook.
🤖 Prompt for 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.

In `@apps/admin/src/automations/components/canvas/email-performance-section.tsx`
around lines 143 - 146, The tracking-settings lookup is duplicated across
EmailPerformanceSection and nodes.tsx. Create a shared useEmailTrackingSettings
hook that reads appSettings analytics through useAppContext, applies false
defaults for unresolved settings, and returns emailTrackOpens and
emailTrackClicks; replace the local reads in
apps/admin/src/automations/components/canvas/email-performance-section.tsx lines
143-146 and apps/admin/src/automations/components/canvas/nodes.tsx lines 182-183
with this hook.
apps/admin/src/automations/editor.test.tsx (1)

473-483: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider extending the "unresolved app settings" test to the sidebar too.

This test only asserts the footer shows Off for both metrics when mockAppSettings is undefined; it doesn't open the sidebar or check the ring data-tracked attributes the way the parameterized test above does. Given this is the edge case for the whole feature (settings not yet loaded), covering the sidebar here would close a coverage gap symmetric with the it.each test.

🤖 Prompt for 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.

In `@apps/admin/src/automations/editor.test.tsx` around lines 473 - 483, Extend
the “treats unresolved app settings as untracked” test to open the relevant
sidebar and assert both metric ring data-tracked attributes indicate untracked,
matching the sidebar assertions in the nearby parameterized test while
preserving the existing footer checks.
🤖 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 `@apps/admin/src/automations/components/canvas/off-value.tsx`:
- Line 4: Replace the hardcoded TRACKING_OFF_MESSAGE and visible “Off” label in
the off-value component with the project’s translation hook, and add the
corresponding Admin UI translation keys and English values to
packages/i18n/locales/en/ghost.json. Ensure both rendered strings use translated
values for the active admin locale.

---

Nitpick comments:
In `@apps/admin/src/automations/components/canvas/email-performance-section.tsx`:
- Around line 143-146: The tracking-settings lookup is duplicated across
EmailPerformanceSection and nodes.tsx. Create a shared useEmailTrackingSettings
hook that reads appSettings analytics through useAppContext, applies false
defaults for unresolved settings, and returns emailTrackOpens and
emailTrackClicks; replace the local reads in
apps/admin/src/automations/components/canvas/email-performance-section.tsx lines
143-146 and apps/admin/src/automations/components/canvas/nodes.tsx lines 182-183
with this hook.

In `@apps/admin/src/automations/editor.test.tsx`:
- Around line 473-483: Extend the “treats unresolved app settings as untracked”
test to open the relevant sidebar and assert both metric ring data-tracked
attributes indicate untracked, matching the sidebar assertions in the nearby
parameterized test while preserving the existing footer checks.
🪄 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: a1de8bfd-f343-405a-9d70-13bc34e4d2d6

📥 Commits

Reviewing files that changed from the base of the PR and between 0d930ee and 0a7c872.

📒 Files selected for processing (4)
  • apps/admin/src/automations/components/canvas/email-performance-section.tsx
  • apps/admin/src/automations/components/canvas/nodes.tsx
  • apps/admin/src/automations/components/canvas/off-value.tsx
  • apps/admin/src/automations/editor.test.tsx

Comment thread apps/admin/src/automations/components/canvas/off-value.tsx
@troyciesco
troyciesco force-pushed the NY-1466_show-hide-atmns-opens-clicks-stats branch from 0a7c872 to afb45a2 Compare July 21, 2026 20:02
@troyciesco
troyciesco marked this pull request as ready for review July 21, 2026 20:11
@troyciesco
troyciesco requested a review from EvanHahn July 21, 2026 20:17
@troyciesco
troyciesco force-pushed the NY-1466_show-hide-atmns-opens-clicks-stats branch from afb45a2 to e7762eb Compare July 22, 2026 12:46

@EvanHahn EvanHahn 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.

Didn't pull this down. Code LGTM.

@troyciesco
troyciesco merged commit 3bc63bf into main Jul 22, 2026
44 checks passed
@troyciesco
troyciesco deleted the NY-1466_show-hide-atmns-opens-clicks-stats branch July 22, 2026 16:39
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.

2 participants