11<?php namespace GeneaLabs \LaravelMixpanel ;
22
3- use hisorange \BrowserDetect \Parser ;
4- use hisorange \BrowserDetect \Result ;
53use Illuminate \Http \Request ;
64use Illuminate \Support \Facades \App ;
5+ use Sinergi \BrowserDetector \Browser ;
6+ use Sinergi \BrowserDetector \Device ;
7+ use Sinergi \BrowserDetector \Os ;
78
89class LaravelMixpanel extends \Mixpanel
910{
@@ -12,32 +13,17 @@ class LaravelMixpanel extends \Mixpanel
1213 'connect_timeout ' => 2 ,
1314 'timeout ' => 2 ,
1415 ];
15- /**
16- * @var Request
17- */
1816 private $ request ;
19- /**
20- * @var Parser
21- */
22- private $ browserParser ;
23- /**
24- * @var Result
25- */
26- private $ browserResult ;
2717
2818 /**
2919 * @param Request $request
30- * @param Parser $browserParser
31- * @param Result $browserResult
3220 * @param array $options
3321 *
3422 * @internal param Result $browser
3523 */
36- public function __construct (Request $ request , Parser $ browserParser , Result $ browserResult , array $ options = [])
24+ public function __construct (Request $ request , array $ options = [])
3725 {
3826 $ this ->request = $ request ;
39- $ this ->browserParser = $ browserParser ;
40- $ this ->browserResult = $ browserResult ;
4127
4228 $ options = array_merge ($ this ->defaults , $ options );
4329 parent ::__construct (config ('services.mixpanel.token ' ), $ options );
@@ -49,16 +35,18 @@ public function __construct(Request $request, Parser $browserParser, Result $bro
4935 *
5036 * @internal param array $data
5137 */
52- public function track ($ event , array $ properties = [])
38+ public function track ($ event , $ properties = [])
5339 {
54- $ browserInfo = $ this ->browserParser ->detect ();
55- $ osVersion = $ this ->browserResult ->osName ();
56- $ hardware = $ browserInfo ['deviceFamily ' ] . ' ' . $ browserInfo ['deviceModel ' ];
40+ $ browserInfo = new Browser ();
41+ $ osInfo = new Os ();
42+ $ deviceInfo = new Device ();
43+ $ osVersion = $ osInfo ->getName () . ' ' . $ osInfo ->getVersion ();
44+ $ hardware = $ deviceInfo ->getName () . ' ' . $ deviceInfo ->getVersion ();
5745 $ data = [
5846 'Url ' => $ this ->request ->getUri (),
5947 'Operating System ' => $ osVersion ,
6048 'Hardware ' => $ hardware ,
61- '$browser ' => $ this -> browserResult -> browserName (),
49+ '$browser ' => $ browserInfo -> getName () . ' ' . $ browserInfo -> getVersion (),
6250 '$referring_domain ' => ($ this ->request ->header ('referer ' )
6351 ? parse_url ($ this ->request ->header ('referer ' ))['host ' ]
6452 : null ),
0 commit comments