From c25e092c6d3b79dc16362ec0ed4c80dafe342997 Mon Sep 17 00:00:00 2001 From: Joshua Flowers Date: Thu, 27 Jan 2022 11:34:34 -0500 Subject: [PATCH] Add logger for tracks events --- api/api.php | 1 + api/tracks/tracks-debug-log.php | 53 +++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 api/tracks/tracks-debug-log.php diff --git a/api/api.php b/api/api.php index 2d752a1783a..9a3a02173bf 100644 --- a/api/api.php +++ b/api/api.php @@ -35,3 +35,4 @@ require( 'options/rest-api.php' ); require( 'tools/delete-all-products.php'); require( 'tools/disable-wc-email.php' ); require( 'tools/trigger-update-callbacks.php' ); +require( 'tracks/tracks-debug-log.php' ); diff --git a/api/tracks/tracks-debug-log.php b/api/tracks/tracks-debug-log.php new file mode 100644 index 00000000000..7971664cf38 --- /dev/null +++ b/api/tracks/tracks-debug-log.php @@ -0,0 +1,53 @@ +logger = $logger; + $this->logger = $logger; + } + + /** + * Log the event. + * + * @param array $properties Event properties. + * @param string $event_name Event name. + */ + public function log_event( $properties, $event_name ) { + $this->logger->debug( + $event_name, + array( 'source' => $this->source ) + ); + foreach ( $properties as $key => $property ) { + $this->logger->debug( + " - {$key}: {$property}", + array( 'source' => $this->source ) + ); + } + + return $properties; + } +} + +new TracksDebugLog(); \ No newline at end of file