Skip to content

Commit df7ea02

Browse files
authored
Merge pull request mikebronner#59 from alberthaff/master
Support GeoLocation while using queues
2 parents 9021f65 + 789273c commit df7ea02

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/LaravelMixpanel.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ public function __construct(Request $request, array $options = [])
2727
);
2828
}
2929

30-
public function track($event, $properties = [])
30+
public function getData()
3131
{
3232
$browserInfo = new Browser();
3333
$osInfo = new Os();
3434
$deviceInfo = new Device();
3535
$browserVersion = trim(str_replace('unknown', '', $browserInfo->getName() . ' ' . $browserInfo->getVersion()));
3636
$osVersion = trim(str_replace('unknown', '', $osInfo->getName() . ' ' . $osInfo->getVersion()));
3737
$hardwareVersion = trim(str_replace('unknown', '', $deviceInfo->getName()));
38+
3839
$data = [
3940
'Url' => $this->request->getUri(),
4041
'Operating System' => $osVersion,
@@ -46,13 +47,19 @@ public function track($event, $properties = [])
4647
: null),
4748
'ip' => $this->request->ip(),
4849
];
49-
$data = array_filter($data);
50-
$properties = array_filter($properties);
5150

5251
if ((! array_key_exists('$browser', $data)) && $browserInfo->isRobot()) {
5352
$data['$browser'] = 'Robot';
5453
}
5554

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);
5764
}
5865
}

0 commit comments

Comments
 (0)