Skip to content

Commit

Permalink
log time spent better
Browse files Browse the repository at this point in the history
  • Loading branch information
cabanier committed Oct 20, 2023
1 parent a55d28d commit 12c8493
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion map.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,22 @@ AFRAME.registerComponent("map", {
});

document.querySelector('a-scene').addEventListener('exit-vr', function () {
gtag('event', 'exit-vr', { duration: Math.floor((performance.now() - this.XRStart)/1000) });
let d = Math.floor((performance.now() - this.XRStart)/1000);
let timeSpent = "unknown";
if (d < 30)
timeSpent = "< 30 seconds";
else if (d < 60)
timeSpent = "< 1 minute";
else if (d < 300)
timeSpent = "< 5 minutes";
else if (d < 600)
timeSpent = "< 10 minutes";
else if (d < 1200)
timeSpent = "< 20 minutes";
else
timeSpent = Math.floor(d/60) + " minutes";

gtag('event', 'exit-vr', { time_spent: timeSpent });
this.XRStart = 0;
});

Expand Down

0 comments on commit 12c8493

Please sign in to comment.