FILE: C:\Windows\SystemApps\Microsoft.Windows.CloudExperienceHost_cw5n1h2txyewy\js\telemetry.js
--
//
// Copyright (C) Microsoft. All rights reserved.
//
/// JS2085.EnableStrictMode
"use strict";
var CloudExperienceHost;
(function (CloudExperienceHost) {
var Telemetry;
(function (Telemetry) {
class AppTelemetry {
constructor() {
this._appActivity = null;
if (!AppTelemetry._allowInstantiation) {
throw new Error("Error: Instantiation failed: Use getInstance() instead of new.");
}
this._appActivity = new Microsoft.CloudExperienceHost.AppActivity();
}
static getInstance() {
if (AppTelemetry._instance === null) {
AppTelemetry._allowInstantiation = true;
AppTelemetry._instance = new AppTelemetry();
AppTelemetry._allowInstantiation = false;
}
return AppTelemetry._instance;
}
start(source, experience, correlationId) {
this._appActivity.start(source, experience, correlationId);
// This call is crashing regularly on some Xbox consoles in the wild. At this point in time,
// we could not repro on a devkit and since this is supposed to be a no-op on the console
// we put this within a try / catch block to keep CXH from crashing.
try {
CloudExperienceHostAPI.EventLogging.appActivityStart(source, experience);
}
catch (e) {
}
}
stop(appResult) {
this._appActivity.stop(appResult);
// This call is crashing regularly on some Xbox consoles in the wild. At this point in time,
// we could not repro on a devkit and since this is supposed to be a no-op on the console
// we put this within a try / catch block to keep CXH from crashing.
try {
CloudExperienceHostAPI.EventLogging.appActivityStop(appResult);
}
catch (e) {
}
}
getId() {
return this._appActivity.getId();
}
appCheckpoint() {
this._appActivity.appCheckpoint();
}
logCriticalEvent2(eventName, eventValue) {
this._appActivity.logCriticalEvent2(eventName, eventValue);
this._logEventInternal(eventName, eventValue);
}
logEvent(...params) {
var func = "logEvent" + params.length;
this._appActivity[func].apply(this._appActivity, params);
if (params.length == 1) {
this._logEventInternal(params[0]);
}
else {
this._logEventInternal(params[0], params[1]);
}
}
_logEventInternal(...params) {
var func = "appEvent" + params.length;
// This call is crashing regularly on some Xbox consoles in the wild. At this point in time,
// we could not repro on a devkit and since this is supposed to be a no-op on the console
// we put this within a try / catch block to keep CXH from crashing.
try {
CloudExperienceHostAPI.EventLogging[func].apply(undefined, params);
}
catch (e) {
}
}
static logChromeEvent(...params) {
var self = AppTelemetry.getInstance();
var func = "logChromeEvent" + params.length;
self._appActivity[func].apply(self._appActivity, params);
}
}
AppTelemetry._instance = null;
Telemetry.AppTelemetry = AppTelemetry;
class WebAppTelemetry {
constructor() {
this._webAppActivity = null;
if (!WebAppTelemetry._allowInstantiation) {
throw new Error("Error: Instantiation failed: Use getInstance() instead of new.");
}
}
static getInstance() {
if (WebAppTelemetry._instance === null) {
WebAppTelemetry._allowInstantiation = true;
WebAppTelemetry._instance = new WebAppTelemetry();
WebAppTelemetry._allowInstantiation = false;
}
return WebAppTelemetry._instance;
}
start(cxid) {
if (this._webAppActivity) {
this.stop(CloudExperienceHost.AppResult.fail);
}
this._webAppActivity = new Microsoft.CloudExperienceHost.WebAppActivity(AppTelemetry.getInstance().getId());
this._webAppActivity.start(cxid);
// This call is crashing regularly on some Xbox consoles in the wild. At this point in time,
// we could not repro on a devkit and since this is supposed to be a no-op on the console
// we put this within a try / catch block to keep CXH from crashing.
try {
CloudExperienceHostAPI.EventLogging.webAppActivityStart(cxid);
}
catch (e) {
}
}
stop(appResult) {
if (!this._webAppActivity) {
AppTelemetry.getInstance().logCriticalEvent2("NoActiveWebAppRunning", "StopCalled");
return;
}
this._webAppActivity.stop(appResult);
this._webAppActivity = null;
// This call is crashing regularly on some Xbox consoles in the wild. At this point in time,
// we could not repro on a devkit and since this is supposed to be a no-op on the console
// we put this within a try / catch block to keep CXH from crashing.
try {
CloudExperienceHostAPI.EventLogging.webAppActivityStop(appResult);
}
catch (e) {
}
}
isStarted() {
return (this._webAppActivity != null);
}
getId() {
return this._webAppActivity.getId();
}
logUserInteractionEvent(...params) {
this._logEventInternal("logUserInteractionEvent", params);
}
logEvent(...params) {
this._logEventInternal("logEvent", params);
}
_logEventInternal(eventType, params) {
if (!this._webAppActivity) {
AppTelemetry.getInstance().logCriticalEvent2("NoActiveWebAppRunning", JSON.stringify(params));
return;
}
var func = eventType + params.length;
this._webAppActivity[func].apply(this._webAppActivity, params);
func = "webAppEvent" + params.length;
// This call is crashing regularly on some Xbox consoles in the wild. At this point in time,
// we could not repro on a devkit and since this is supposed to be a no-op on the console
// we put this within a try / catch block to keep CXH from crashing.
try {
CloudExperienceHostAPI.EventLogging[func].apply(undefined, params);
}
catch (e) {
}
}
}
WebAppTelemetry._instance = null;
Telemetry.WebAppTelemetry = WebAppTelemetry;
function getId() {
return WebAppTelemetry.getInstance().getId();
}
Telemetry.getId = getId;
function logEvent(...params) {
var webAppTelemetry = WebAppTelemetry.getInstance();
webAppTelemetry.logEvent.apply(webAppTelemetry, params);
}
Telemetry.logEvent = logEvent;
function logUserInteractionEvent(...params) {
var webAppTelemetry = WebAppTelemetry.getInstance();
webAppTelemetry.logUserInteractionEvent.apply(webAppTelemetry, params);
}
Telemetry.logUserInteractionEvent = logUserInteractionEvent;
function oobeHealthEvent(healthEvent, errorCode) {
CloudExperienceHostAPI.EventLogging.oobeHealthEvent(healthEvent, errorCode);
}
Telemetry.oobeHealthEvent = oobeHealthEvent;
})(Telemetry = CloudExperienceHost.Telemetry || (CloudExperienceHost.Telemetry = {}));
})(CloudExperienceHost || (CloudExperienceHost = {}));
if ((typeof define === "function") && define.amd) {
define(function () {
return {
AppTelemetry: CloudExperienceHost.Telemetry.AppTelemetry,
WebAppResult: CloudExperienceHost.Telemetry.WebAppTelemetry
};
});
}
//# sourceMappingURL=telemetry.js.map
--