MozillaReality / unity-webxr-export

INACTIVE - Assets for creating WebXR-enabled Unity3D projects.
https://mixedreality.mozilla.org/unity-webxr-export/Build/
Apache License 2.0
627 stars 127 forks source link

Move telemetry.js to a hosted solution #193

Closed cvan closed 3 months ago

cvan commented 6 years ago

Move https://github.com/mozillareality/metrics to its own repo. Instead of using Google's analytics.js, we can use Google's Universal Analytics. You can just use navigator.sendBeacon to POST a JSON payload to https://ssl.google-analytics.com/collect.

Current work in progress: https://github.com/MozillaReality/metrics

Some context here about documenting it: https://github.com/mozilla/unity-webvr-export/issues/164#issuecomment-372900401

That way, it won't interfere with a user's Google Analytics script they put on their page. And it's as simple as dropping in this script:

Telemetry Usage

To opt in to telemetry (i.e., collecting usage statistics, performance metrics, and catching errors) it in your WebXR site, simply include this snippet of JavaScript code in your HTML (ideally, immediately before the </head> or before </body>):

<script src="https://webxr.services/metrics.js" async defer></script>

Or this:

<script>
  // Telemetry for collecting basic usage statistics, performance metrics, and catching errors.
  (function () {
    function injectScript () {
      if (injectScript.injected || !navigator.onLine) {
        return;
      }
      injectScript.injected = true;
      var refScript = document.querySelector('script');
      var script = document.createElement('script');
      script.src = 'https://webxr.services/metrics.js';
      script.async = true;
      script.crossorigin = 'anonymous';
      (refScript ? refScript.parentNode : document.head).insertBefore(script, ref);
    }
    injectScript();
    window.addEventListener('online', injectScript);
  })();
</script>
cvan commented 6 years ago

I'm going to defer working on this for now, since @delapuente has gotten Google Analytics-based Telemetry working quite nicely with in the telemetry branch branch and the incoming changes in PR #200.

The main reason I filed this was to hide the complexity in a script we could remotely update/improve whenever we needed. I still think we should do it. I've been iterating on a proof-of-concept in branches at https://github.com/MozillaReality/metrics It's built atop Google's Universal Analytics (i.e., the server-side Measurement Protocol API).

But the analytics.js approach taken here is sufficient. So given the lack of urgency here, I'm moving this issue out of this milestone.

@delapuente: I'd like your input on whether we should move some of these Telemetry issues I just filed into the Telemetry milestone or the v1.1.0 milestone: #206, #207, #208

Ideally, we get those three resolved before we tag and release a new version of this package to the Unity Asset Store. I can most definitely help here; I just wanted you to see the feedback from https://github.com/mozilla/unity-webvr-export/pull/200/files first before I started triaging Telemetry issues more. Thanks!