Last active
July 15, 2022 14:06
-
-
Save octaedro/4559dc2b81cc01e2395795241bbba638 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Add custom event to record | |
* Description: This plugin adds the code to test event recording validation (on the client side). | |
* Version: 0.1 | |
* | |
*/ | |
function add_custom_event() { | |
wc_enqueue_js( | |
"const recordEvent = | |
window.wc.tracks.recordEvent || window.wcTracks.recordEvent || function() {}; | |
const props = confirm( 'Use broken props' ) ? { 'invalid-prop': 'foo' } : { valid_prop_name: 'bar' }; | |
recordEvent( 'my_event', props );" | |
); | |
} | |
add_action( 'init', 'add_custom_event' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment