Skip to content

Conversation

@rebeccahum
Copy link
Contributor

@rebeccahum rebeccahum commented Nov 14, 2025

Description

Adds tracking to successful email sends

Pre-review checklist

Please make sure the items below have been covered before requesting a review:

  • This change works and has been tested locally or in Codespaces (or has an appropriate fallback).
  • This change works and has been tested on a sandbox.
  • This change has relevant unit tests (if applicable).
  • This change uses a rollout method to ease with deployment (if applicable - especially for large scale actions that require writes).
  • This change has relevant documentation additions / updates (if applicable).
  • I've created a changelog description that aligns with the provided examples.

Pre-deploy checklist

  • VIP staff: Ensure any alerts added/updated conform to internal standards (see internal documentation).

Steps to Test

  1. Sandbox and add the PR code
  2. In build_tracks_event_args(), add:
		error_log( sprintf(
			'%s: calling Tracks::record_event( %s, %s )',
			__METHOD__,
			'wpcom_email_send',
			wp_json_encode( $event_args )
		) );
  1. ks sandbox logs -f in another screen
  2. shell in and do wp_mail( '[email protected]', 'VIP Tracks Test', 'Hello world' );
    Expect to see in the sandbox logs:
[17-Nov-2025 20:59:42 UTC] Automattic\VIP\Mail\VIP_SMTP::build_tracks_event_args: calling Tracks::record_event( wpcom_email_send, {"date_sent":"2025-11-17","email_domain":"example.com","_ut":"anon","_ui":"<ui>","email_id":"<email_id>"} )

@rebeccahum rebeccahum force-pushed the PLTFRM-1777 branch 3 times, most recently from 507d0a6 to a471523 Compare November 14, 2025 22:05
@codecov
Copy link

codecov bot commented Nov 14, 2025

Codecov Report

❌ Patch coverage is 34.09091% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 34.81%. Comparing base (e64d608) to head (c07cb18).

Files with missing lines Patch % Lines
vip-mail.php 34.09% 29 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #6615      +/-   ##
=============================================
- Coverage      34.82%   34.81%   -0.02%     
- Complexity      5032     5048      +16     
=============================================
  Files            295      295              
  Lines          20743    20783      +40     
=============================================
+ Hits            7224     7235      +11     
- Misses         13519    13548      +29     

☔ View full report in Codecov by Sentry.
📢 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.

@rebeccahum rebeccahum marked this pull request as ready for review November 14, 2025 22:20
@rebeccahum rebeccahum requested a review from a team as a code owner November 14, 2025 22:20
Copilot AI review requested due to automatic review settings November 14, 2025 22:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds tracking functionality for successful email sends in the VIP Mail system. The implementation integrates with Automattic's Tracks telemetry system to record email send events with relevant metadata.

  • Adds tracking of successful email sends via the wp_mail_succeeded action hook
  • Refactors mail blocking logic into a reusable is_mail_blocked() method
  • Implements event data collection including user identification, email domain, and blog ID

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 17, 2025

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@PZ01
Copy link

PZ01 commented Nov 17, 2025

Started looking at this w/ Rebecca over Slack, to address a few questions on how it should be implemented. I was given access to VIP to do tests, but it is EOD for me now and will resume tomorrow.

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.

3 participants