@@ -27,14 +27,15 @@ public function __construct(Request $request, array $options = [])
27
27
);
28
28
}
29
29
30
- public function track ( $ event , $ properties = [] )
30
+ public function getData ( )
31
31
{
32
32
$ browserInfo = new Browser ();
33
33
$ osInfo = new Os ();
34
34
$ deviceInfo = new Device ();
35
35
$ browserVersion = trim (str_replace ('unknown ' , '' , $ browserInfo ->getName () . ' ' . $ browserInfo ->getVersion ()));
36
36
$ osVersion = trim (str_replace ('unknown ' , '' , $ osInfo ->getName () . ' ' . $ osInfo ->getVersion ()));
37
37
$ hardwareVersion = trim (str_replace ('unknown ' , '' , $ deviceInfo ->getName ()));
38
+
38
39
$ data = [
39
40
'Url ' => $ this ->request ->getUri (),
40
41
'Operating System ' => $ osVersion ,
@@ -46,13 +47,19 @@ public function track($event, $properties = [])
46
47
: null ),
47
48
'ip ' => $ this ->request ->ip (),
48
49
];
49
- $ data = array_filter ($ data );
50
- $ properties = array_filter ($ properties );
51
50
52
51
if ((! array_key_exists ('$browser ' , $ data )) && $ browserInfo ->isRobot ()) {
53
52
$ data ['$browser ' ] = 'Robot ' ;
54
53
}
55
54
56
- parent ::track ($ event , $ data + $ properties );
55
+ return $ data ;
56
+ }
57
+
58
+ public function track ($ event , $ properties = [])
59
+ {
60
+ $ data = array_filter ($ this ->getData ());
61
+ $ properties = array_filter ($ properties );
62
+
63
+ parent ::track ($ event , $ properties + $ data );
57
64
}
58
65
}
0 commit comments