@@ -53,10 +53,11 @@ private function tempDirectoryInit(): void
5353
5454 private function track (): void
5555 {
56- foreach (glob ($ _ENV ['TEMP_DIR ' ] . DIRECTORY_SEPARATOR . 'php-bolt-analytics ' . DIRECTORY_SEPARATOR . 'queries .*.cnt ' ) as $ file ) {
56+ foreach (glob ($ _ENV ['TEMP_DIR ' ] . DIRECTORY_SEPARATOR . 'php-bolt-analytics ' . DIRECTORY_SEPARATOR . 'analytics .*.json ' ) as $ file ) {
5757 $ time = intval (explode ('. ' , basename ($ file ))[1 ]);
5858 if ($ time < strtotime ('today ' )) {
59- $ count = file_get_contents ($ file );
59+ $ data = json_decode (file_get_contents ($ file ), true );
60+ $ distinctId = sha1 (implode ('' , [php_uname (), disk_total_space ('. ' ), filectime ('/ ' ), phpversion ()]));
6061
6162 $ curl = curl_init ();
6263 curl_setopt_array ($ curl , [
@@ -72,11 +73,20 @@ private function track(): void
7273 [
7374 'properties ' => [
7475 '$insert_id ' => (string )$ time ,
75- 'distinct_id ' => sha1 ( implode ( '' , [ php_uname (), disk_total_space ( ' . ' ), filectime ( ' / ' ), phpversion ()])) ,
76- 'amount ' => $ count ,
76+ 'distinct_id ' => $ distinctId ,
77+ 'amount ' => $ data [ ' queries ' ] ?? 0 ,
7778 'time ' => $ time
7879 ],
7980 'event ' => 'queries '
81+ ],
82+ [
83+ 'properties ' => [
84+ '$insert_id ' => (string )$ time ,
85+ 'distinct_id ' => $ distinctId ,
86+ 'amount ' => $ data ['sessions ' ] ?? 0 ,
87+ 'time ' => $ time
88+ ],
89+ 'event ' => 'sessions '
8090 ]
8191 ]),
8292 CURLOPT_HTTPHEADER => [
0 commit comments