Skip to content

Commit

Permalink
Fix enter vr analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarcos committed Feb 20, 2023
1 parent c80f92f commit 2507597
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/state/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,11 @@ AFRAME.registerState({

displayconnected: state => {
state.hasVR = true;

if (HAS_LOGGED_VR) { return; }
try {
if ('getVRDisplays' in navigator) {
navigator.getVRDisplays().then(displays => {
if (!displays.length) { return; }
gtag('event', 'entervr', { event_label: displays[0].displayName });
HAS_LOGGED_VR = true;
});
}
Expand Down Expand Up @@ -803,6 +801,12 @@ AFRAME.registerState({

'enter-vr': state => {
state.inVR = AFRAME.utils.device.checkHeadsetConnected();
if (!AFRAME.utils.device.isMobile()) {
gtag('event', 'entervr', {});
if (AFRAME.utils.device.isOculusBrowser()) {
gtag('event', 'oculusbrowser', {});
}
}
},

'exit-vr': state => {
Expand Down

0 comments on commit 2507597

Please sign in to comment.