Send visit_token and visitor_token in body for JavaScript - closes #200

Andrew Kane committed Aug 19, 2016
commit 0a45cb33d140b42f49a0f9e624242e95a50f486d
Showing 1 changed file with 6 additions and 4 deletions
vendor/assets/javascripts/ahoy.js +6 -4
@@ @@ -98,10 +98,6 @@
}
function trackEvent(event) {
- if (!ahoy.getVisitId()) {
- ready(createVisit)
- }
-
ready( function () {
// ensure JSON is defined
if (canStringify) {
@@ @@ -220,9 +216,15 @@
};
ahoy.track = function (name, properties) {
+ if (!ahoy.getVisitId()) {
+ ready(createVisit)
+ }
+
// generate unique id
var event = {
id: generateId(),
+ visit_token: ahoy.getVisitId(),
+ visitor_token: ahoy.getVisitorId(),
name: name,
properties: properties,
time: (new Date()).getTime() / 1000.0