1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
<?php
namespace AutomateWoo\Usage_Tracking;
/** * Event_Helper Trait. * * Use to provide Tracks event recording for an object. * * @since 4.9.0 */ trait Event_Helper {
/** * The tracks object. * * @var Tracks_Interface */ protected $tracks = null;
/** * Set the Tracks object that will be used for tracking. * * @param Tracks_Interface $tracks */ public function set_tracks( Tracks_Interface $tracks ) { $this->tracks = $tracks; }
/** * Record an event using the Tracks instance * * @param string $event_name * @param array $properties */ private function record_event( $event_name, $properties = [] ) { // Ensure we have a valid object. if ( null === $this->tracks ) { $this->tracks = new Tracks(); }
$this->tracks->record_event( $event_name, $properties ); } }
|