Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Move telemetry.js to a hosted solution #193

@cvan

Description

@cvan

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: #164 (comment)

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>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Completed and shipped to Asset Store

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions