Skip to content

Commit a545251

Browse files
committed
Updated with browser, os, and hardware info
1 parent 2552e24 commit a545251

File tree

3 files changed

+12
-25
lines changed

3 files changed

+12
-25
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"illuminate/routing": "^5.1",
2222
"nesbot/carbon": "^1.19",
2323
"mixpanel/mixpanel-php": "~2.0",
24-
"hisorange/browser-detect": "~2.0"
24+
"sinergi/browser-detector": "~5.0"
2525
},
2626
"require-dev": {
2727
"phpunit/phpunit": "4.*"

src/LaravelMixpanel.php

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php namespace GeneaLabs\LaravelMixpanel;
22

3-
use hisorange\BrowserDetect\Parser;
4-
use hisorange\BrowserDetect\Result;
53
use Illuminate\Http\Request;
64
use Illuminate\Support\Facades\App;
5+
use Sinergi\BrowserDetector\Browser;
6+
use Sinergi\BrowserDetector\Device;
7+
use Sinergi\BrowserDetector\Os;
78

89
class 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),

src/Providers/LaravelMixpanelServiceProvider.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public function boot(Request $request, Guard $guard, LaravelMixpanel $mixPanel)
2424

2525
public function register()
2626
{
27-
$this->app->register(hisorange\BrowserDetect\Provider\BrowserDetectService::class);
2827
$this->app->singleton(LaravelMixpanel::class);
2928
}
3029

0 commit comments

Comments
 (0)