Skip to content

Use new Telemetry class from VIP mu-plugins #452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 11, 2025

Conversation

chriszarate
Copy link
Member

Use the new Telemetry class from VIP mu-plugins. This class abstracts away many of the checks that were being performed in this plugin, and as a result we can remove a large amount of code.

I also renamed TracksTelemetry to Telemetry since it is no longer pinned to that service. Note that much of the code, including track_remote_data_blocks_usage is unchanged.

I've also added an integration test to cover this work.

@chriszarate chriszarate requested a review from shekharnwagh April 8, 2025 18:37
Copy link
Contributor

github-actions bot commented Apr 8, 2025

Test this PR in WordPress Playground.

add_action( 'save_post', [ $this, 'track_remote_data_blocks_usage' ], 10, 2 );

// Custom hook to allow other plugin code to track events
add_action( 'remote_data_blocks_track_event', [ $this, 'record_event' ], 10, 2 );
Copy link
Contributor

Choose a reason for hiding this comment

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

We're inconsistent between the action and the EVENT_PREFIX value (remote_data_blocks vs remotedatablocks)

Any reason we can't make those consistent?

Copy link
Member Author

Choose a reason for hiding this comment

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

Most of the namespacing we've done in the WordPress plugin uses remote_data_blocks. However, Tracks is external to WordPress and the event names were already registered months ago using remotedatablocks as the prefix. It's a bit painful to change, otherwise I would have done it.

* @param string $event_name The name of the event.
* @param array $props The properties to send with the event.
*
* @return bool True if the event was recorded, false otherwise.
Copy link
Contributor

Choose a reason for hiding this comment

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

No return value now

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 9a721d3

@chriszarate chriszarate merged commit 9f1f60b into trunk Apr 11, 2025
13 checks passed
@chriszarate chriszarate deleted the improve/new-telemetry-class branch April 11, 2025 14:12
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