-
Notifications
You must be signed in to change notification settings - Fork 7
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
Conversation
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 ); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
inc/Telemetry/Telemetry.php
Outdated
* @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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No return value now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 9a721d3
Co-authored-by: Max Schmeling <[email protected]>
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
toTelemetry
since it is no longer pinned to that service. Note that much of the code, includingtrack_remote_data_blocks_usage
is unchanged.I've also added an integration test to cover this work.