rebase on oct-10-2023
This commit is contained in:
@@ -64,9 +64,10 @@ class WC_Site_Tracking {
|
||||
* Adds the tracking function to the admin footer.
|
||||
*/
|
||||
public static function add_tracking_function() {
|
||||
$user = wp_get_current_user();
|
||||
$server_details = WC_Tracks::get_server_details();
|
||||
$blog_details = WC_Tracks::get_blog_details( $user->ID );
|
||||
$user = wp_get_current_user();
|
||||
$server_details = WC_Tracks::get_server_details();
|
||||
$blog_details = WC_Tracks::get_blog_details( $user->ID );
|
||||
$tracks_identity = WC_Tracks_Client::get_identity( $user->ID );
|
||||
|
||||
$client_tracking_properties = array_merge( $server_details, $blog_details );
|
||||
/**
|
||||
@@ -81,6 +82,11 @@ class WC_Site_Tracking {
|
||||
<script type="text/javascript">
|
||||
window.wcTracks = window.wcTracks || {};
|
||||
window.wcTracks.isEnabled = <?php echo self::is_tracking_enabled() ? 'true' : 'false'; ?>;
|
||||
window._tkq = window._tkq || [];
|
||||
|
||||
<?php if ( 'anon' !== $tracks_identity['_ut'] ) { ?>
|
||||
window._tkq.push( [ 'identifyUser', '<?php echo esc_js( $tracks_identity['_ui'] ); ?>' ] );
|
||||
<?php } ?>
|
||||
window.wcTracks.validateEvent = function( eventName, props = {} ) {
|
||||
let isValid = true;
|
||||
if ( ! <?php echo esc_js( WC_Tracks_Event::EVENT_NAME_REGEX ); ?>.test( eventName ) ) {
|
||||
@@ -124,7 +130,6 @@ class WC_Site_Tracking {
|
||||
if ( ! window.wcTracks.validateEvent( eventName, eventProperties ) ) {
|
||||
return;
|
||||
}
|
||||
window._tkq = window._tkq || [];
|
||||
window._tkq.push( [ 'recordEvent', eventName, eventProperties ] );
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user