@esri/telemetry
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -269,2 +269,18 @@ define('telemetry', function () { 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { | ||
return typeof obj; | ||
} : function (obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
var classCallCheck = function (instance, Constructor) { | ||
@@ -334,6 +350,39 @@ if (!(instance instanceof Constructor)) { | ||
var slicedToArray = function () { | ||
function sliceIterator(arr, i) { | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
try { | ||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i["return"]) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
return function (arr, i) { | ||
if (Array.isArray(arr)) { | ||
return arr; | ||
} else if (Symbol.iterator in Object(arr)) { | ||
return sliceIterator(arr, i); | ||
} else { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
} | ||
}; | ||
}(); | ||
@@ -349,2 +398,5 @@ | ||
var toConsumableArray = function (arr) { | ||
@@ -431,5 +483,6 @@ if (Array.isArray(arr)) { | ||
value: function logPageView(page) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var event = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var attributes = this.preProcess(options); | ||
var attributes = this.preProcess(event, options); | ||
@@ -467,6 +520,6 @@ if (this.debug) { | ||
key: 'logEvent', | ||
value: function logEvent() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
value: function logEvent(event) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var event = this.preProcess(options); | ||
event = this.preProcess(event, options); | ||
@@ -618,8 +671,9 @@ if (this.debug) { | ||
value: function preProcess() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var userOptions = {}; | ||
var userMetadata = {}; | ||
if (this.user) { | ||
userOptions = { | ||
userMetadata = { | ||
user: anonymize(this.user.username), | ||
@@ -634,3 +688,3 @@ org: anonymize(this.user.orgId), | ||
return _extends({}, options, userOptions); | ||
return Object.entries(_extends({}, event, userMetadata)).reduce(_makeEventPayload(options.omitComplexData), {}); | ||
} | ||
@@ -667,3 +721,23 @@ }, { | ||
Telemetry.storage = storage; | ||
function _makeEventPayload(omitComplexData) { | ||
return function (acc, _ref5) { | ||
var _ref6 = slicedToArray(_ref5, 2), | ||
key = _ref6[0], | ||
val = _ref6[1]; | ||
if (_isPrimitive(val)) { | ||
acc[key] = val; | ||
} else if (!omitComplexData) { | ||
console.warn('You are trying to log a non-primitive value, ' + key + ':' + JSON.stringify(val) + '. This will get logged as [object Object]'); | ||
acc[key] = val; | ||
} | ||
return acc; | ||
}; | ||
} | ||
function _isPrimitive(val) { | ||
var primitives = ['string', 'number', 'boolean', 'undefined']; | ||
return primitives.includes(typeof val === 'undefined' ? 'undefined' : _typeof(val)) || val && typeof val.valueOf() === 'string'; | ||
} | ||
return Telemetry; | ||
@@ -670,0 +744,0 @@ |
@@ -1,2 +0,2 @@ | ||
define("telemetry",function(){"use strict";function e(e){if(e)return o.SHA256(e).toString(o.enc.Hex)}function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.portal||{};return!e.disabled&&(!r()&&((void 0===t.eueiEnabled||!1!==t.eueiEnabled)&&(!(!t.eueiEnabled||!t.user||t.user.orgId!==t.id)||(!(!t.user||t.user.orgId||"US"!==t.ipCntryCode)||(!t.user&&"US"===t.ipCntryCode||!(Object.keys(t).length>0))))))}function r(){return"1"===("undefined"!=typeof navigator&&navigator.doNotTrack)||"undefined"!=typeof window&&"1"===window.doNotTrack}var i=["esri.com","esriuk.com","esri.de","esri.ca","esrifrance.fr","esri.nl","esri-portugal.pt","esribulgaria.com","esri.fi","esri.kr","esrimalaysia.com.my","esri.es","esriaustralia.com.au","esri-southafrica.com","esri.cl","esrichina.com.cn","esri.co","esriturkey.com.tr","geodata.no","esriitalia.it","esri.pl"],n={storage:{},memory:!0,get:function(e){var t=void 0;try{t=window.localStorage&&window.localStorage.getItem(e)||this.storage[e]}catch(r){t=this.storage[e]}if(t)try{return JSON.parse(t)}catch(e){return}},set:function(e,t){t=JSON.stringify(t);try{window.localStorage.setItem(e,t)}catch(r){this.memory||(console.error("setting local storage failed, falling back to in-memory storage"),this.memory=!0),this.storage[e]=t}},delete:function(e){try{window.localStorage.removeItem(e)}catch(t){this.memory||(console.error("setting local storage failed, falling back to in-memory storage"),this.memory=!0),delete this.storage[e]}}},o=function(e,t){var r={},i=r.lib={},n=function(){},o=i.Base={extend:function(e){n.prototype=this;var t=new n;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},s=i.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,i=this.sigBytes;if(e=e.sigBytes,this.clamp(),i%4)for(var n=0;n<e;n++)t[i+n>>>2]|=(r[n>>>2]>>>24-n%4*8&255)<<24-(i+n)%4*8;else if(r.length>65535)for(n=0;n<e;n+=4)t[i+n>>>2]=r[n>>>2];else t.push.apply(t,r);return this.sigBytes+=e,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r=[],i=0;i<t;i+=4)r.push(4294967296*e.random()|0);return new s.init(r,t)}}),a=r.enc={},l=a.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var r=[],i=0;i<e;i++){var n=t[i>>>2]>>>24-i%4*8&255;r.push((n>>>4).toString(16)),r.push((15&n).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i+=2)r[i>>>3]|=parseInt(e.substr(i,2),16)<<24-i%8*4;return new s.init(r,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var r=[],i=0;i<e;i++)r.push(String.fromCharCode(t[i>>>2]>>>24-i%4*8&255));return r.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i++)r[i>>>2]|=(255&e.charCodeAt(i))<<24-i%4*8;return new s.init(r,t)}},u=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r=this._data,i=r.words,n=r.sigBytes,o=this.blockSize,a=n/(4*o),a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0);if(t=a*o,n=e.min(4*t,n),t){for(var l=0;l<t;l+=o)this._doProcessBlock(i,l);l=i.splice(0,t),r.sigBytes-=n}return new s.init(l,n)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});i.Hasher=f.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new h.HMAC.init(e,r).finalize(t)}}});var h=r.algo={};return r}(Math);!function(e){for(var t=o,r=t.lib,i=r.WordArray,n=r.Hasher,r=t.algo,s=[],a=[],l=function(e){return 4294967296*(e-(0|e))|0},c=2,u=0;u<64;){var f;e:{f=c;for(var h=e.sqrt(f),d=2;d<=h;d++)if(!(f%d)){f=!1;break e}f=!0}f&&(u<8&&(s[u]=l(e.pow(c,.5))),a[u]=l(e.pow(c,1/3)),u++),c++}var g=[],r=r.SHA256=n.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,i=r[0],n=r[1],o=r[2],s=r[3],l=r[4],c=r[5],u=r[6],f=r[7],h=0;h<64;h++){if(h<16)g[h]=0|e[t+h];else{var d=g[h-15],v=g[h-2];g[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+g[h-7]+((v<<15|v>>>17)^(v<<13|v>>>19)^v>>>10)+g[h-16]}d=f+((l<<26|l>>>6)^(l<<21|l>>>11)^(l<<7|l>>>25))+(l&c^~l&u)+a[h]+g[h],v=((i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22))+(i&n^i&o^n&o),f=u,u=c,c=l,l=s+d|0,s=o,o=n,n=i,i=d+v|0}r[0]=r[0]+i|0,r[1]=r[1]+n|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+l|0,r[5]=r[5]+c|0,r[6]=r[6]+u|0,r[7]=r[7]+f|0},_doFinalize:function(){var t=this._data,r=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return r[n>>>5]|=128<<24-n%32,r[14+(n+64>>>9<<4)]=e.floor(i/4294967296),r[15+(n+64>>>9<<4)]=i,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=n._createHelper(r),t.HmacSHA256=n._createHmacHelper(r)}(Math),function(){var e=o,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,r){e=this._hasher=new e.init,"string"==typeof r&&(r=t.parse(r));var i=e.blockSize,n=4*i;r.sigBytes>n&&(r=e.finalize(r)),r.clamp();for(var o=this._oKey=r.clone(),s=this._iKey=r.clone(),a=o.words,l=s.words,c=0;c<i;c++)a[c]^=1549556828,l[c]^=909522486;o.sigBytes=s.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher;return e=t.finalize(e),t.reset(),t.finalize(this._oKey.clone().concat(e))}})}();var s=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},a=function(){function e(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},c=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)},u=function(){function r(e){s(this,r);try{if(this.trackers=[],this.workflows={},this.test=e.test,this.debug=e.debug,this.disabled=!t(e),this.disabled&&console.log("Telemetry Disabled"),e.portal&&e.portal.user){var i=e.portal.subscriptionInfo||{};this.setUser(e.portal.user,i.type)}else e.user&&this.setUser(e.user);this.disabled||this._initializeTrackers(e)}catch(e){console.error("Telemetry Disabled"),console.error(e),this.disabled=!0}}return a(r,[{key:"_initializeTrackers",value:function(e){if(e.plugins){var t;(t=this.trackers).push.apply(t,c(e.plugins))}this.trackers.length||console.error(new Error("No trackers configured"))}},{key:"setUser",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Public";e="string"==typeof e?{username:e}:e,this.user=e,this.user.accountType=t;var r=void 0;if(e.email&&e.email.split){var n=e.email.split("@")[1];r=i.filter(function(e){return n===e}).length>0}(r||["In House","Demo and Marketing"].indexOf(t)>-1)&&(this.user.internalUser=!0)}},{key:"logPageView",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this.preProcess(t);if(this.debug&&console.log("Tracking page view",JSON.stringify(r)),this.test&&!this.disabled)return r;var i=this.trackers.filter(function(e){return!e.disabled});if(!i.length||this.disabled)return this.disabled||console.error(new Error("Page view was not logged because no trackers are configured.")),!1;var n=i.map(function(t){return t.logPageView(e,r)});return Promise.all(n).then(),!0}},{key:"logEvent",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.preProcess(e);if(this.debug&&console.log("Tracking event",JSON.stringify(t)),this.test)return t;var r=this.trackers.filter(function(e){return!e.disabled});if(!r.length||this.disabled)return this.disabled||console.error(new Error("Event was not logged because no trackers are configured.")),!1;var i=r.map(function(e){return e.logEvent(t)});return Promise.all(i).then(),!0}},{key:"logError",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=l({eventType:"error"},e);this.logEvent(t)}},{key:"startWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={name:e,start:Date.now(),steps:[],workflowId:Math.floor(17592186044416*(1+Math.random())).toString(16)};this._saveWorkflow(r);var i=l({name:e,step:"start"},t);return this._logWorkflow(i),r}},{key:"stepWorkflow",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i="string"==typeof options?r:r.details,n=l({name:e,step:t,details:i},r);this._logWorkflow(n)}},{key:"endWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=l({name:e,step:"finish"},t);this._logWorkflow(r)}},{key:"cancelWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=l({name:e,step:"cancel"},t);this._logWorkflow(r)}},{key:"getWorkflow",value:function(e){var t=n.get("TELEMETRY-WORKFLOW:"+e);if(t){if(Date.now()-t.start<18e5)return t;this._deleteWorkflow(t)}}},{key:"_saveWorkflow",value:function(e){n.set("TELEMETRY-WORKFLOW:"+e.name,e)}},{key:"_deleteWorkflow",value:function(e){n.delete("TELEMETRY-WORKFLOW:"+e.name)}},{key:"_logWorkflow",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e=this.preProcess(e);var t=this.getWorkflow(e.name);t||(this.startWorkflow(e.name),t=this.getWorkflow(e.name)),t.steps.push(e.step),t.duration=(Date.now()-t.start)/1e3,["cancel","finish"].indexOf(e.step)>-1?this._deleteWorkflow(t):this._saveWorkflow(t);var r=l(e,{eventType:"workflow",category:e.name,action:e.step,label:e.details,duration:t.duration,workflowId:t.workflowId});this.logEvent(r)}},{key:"preProcess",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r={};return this.user&&(r={user:e(this.user.username),org:e(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),l({},t,r)}},{key:"disableTracker",value:function(e){var t=this.trackers.find(function(t){return t.name===e});t&&(t.disabled=!0)}},{key:"enableTracker",value:function(e){var t=this.trackers.find(function(t){return t.name===e});t&&(t.disabled=!1)}}]),r}();return u.anonymize=e,u.internalOrgs=i,u.telemetryEnabled=t,u.storage=n,u}); | ||
define("telemetry",function(){"use strict";function e(e){if(e)return a.SHA256(e).toString(a.enc.Hex)}function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.portal||{};return!e.disabled&&(!r()&&((void 0===t.eueiEnabled||!1!==t.eueiEnabled)&&(!(!t.eueiEnabled||!t.user||t.user.orgId!==t.id)||(!(!t.user||t.user.orgId||"US"!==t.ipCntryCode)||(!t.user&&"US"===t.ipCntryCode||!(Object.keys(t).length>0))))))}function r(){return"1"===("undefined"!=typeof navigator&&navigator.doNotTrack)||"undefined"!=typeof window&&"1"===window.doNotTrack}function n(e){return function(t,r){var n=h(r,2),o=n[0],s=n[1];return i(s)?t[o]=s:e||(console.warn("You are trying to log a non-primitive value, "+o+":"+JSON.stringify(s)+". This will get logged as [object Object]"),t[o]=s),t}}function i(e){return["string","number","boolean","undefined"].includes(void 0===e?"undefined":l(e))||e&&"string"==typeof e.valueOf()}var o=["esri.com","esriuk.com","esri.de","esri.ca","esrifrance.fr","esri.nl","esri-portugal.pt","esribulgaria.com","esri.fi","esri.kr","esrimalaysia.com.my","esri.es","esriaustralia.com.au","esri-southafrica.com","esri.cl","esrichina.com.cn","esri.co","esriturkey.com.tr","geodata.no","esriitalia.it","esri.pl"],s={storage:{},memory:!0,get:function(e){var t=void 0;try{t=window.localStorage&&window.localStorage.getItem(e)||this.storage[e]}catch(r){t=this.storage[e]}if(t)try{return JSON.parse(t)}catch(e){return}},set:function(e,t){t=JSON.stringify(t);try{window.localStorage.setItem(e,t)}catch(r){this.memory||(console.error("setting local storage failed, falling back to in-memory storage"),this.memory=!0),this.storage[e]=t}},delete:function(e){try{window.localStorage.removeItem(e)}catch(t){this.memory||(console.error("setting local storage failed, falling back to in-memory storage"),this.memory=!0),delete this.storage[e]}}},a=function(e,t){var r={},n=r.lib={},i=function(){},o=n.Base={extend:function(e){i.prototype=this;var t=new i;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},s=n.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes;if(e=e.sigBytes,this.clamp(),n%4)for(var i=0;i<e;i++)t[n+i>>>2]|=(r[i>>>2]>>>24-i%4*8&255)<<24-(n+i)%4*8;else if(r.length>65535)for(i=0;i<e;i+=4)t[n+i>>>2]=r[i>>>2];else t.push.apply(t,r);return this.sigBytes+=e,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r=[],n=0;n<t;n+=4)r.push(4294967296*e.random()|0);return new s.init(r,t)}}),a=r.enc={},l=a.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var r=[],n=0;n<e;n++){var i=t[n>>>2]>>>24-n%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new s.init(r,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var r=[],n=0;n<e;n++)r.push(String.fromCharCode(t[n>>>2]>>>24-n%4*8&255));return r.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new s.init(r,t)}},u=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=n.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r=this._data,n=r.words,i=r.sigBytes,o=this.blockSize,a=i/(4*o),a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0);if(t=a*o,i=e.min(4*t,i),t){for(var l=0;l<t;l+=o)this._doProcessBlock(n,l);l=n.splice(0,t),r.sigBytes-=i}return new s.init(l,i)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});n.Hasher=f.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new h.HMAC.init(e,r).finalize(t)}}});var h=r.algo={};return r}(Math);!function(e){for(var t=a,r=t.lib,n=r.WordArray,i=r.Hasher,r=t.algo,o=[],s=[],l=function(e){return 4294967296*(e-(0|e))|0},c=2,u=0;u<64;){var f;e:{f=c;for(var h=e.sqrt(f),d=2;d<=h;d++)if(!(f%d)){f=!1;break e}f=!0}f&&(u<8&&(o[u]=l(e.pow(c,.5))),s[u]=l(e.pow(c,1/3)),u++),c++}var g=[],r=r.SHA256=i.extend({_doReset:function(){this._hash=new n.init(o.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],a=r[3],l=r[4],c=r[5],u=r[6],f=r[7],h=0;h<64;h++){if(h<16)g[h]=0|e[t+h];else{var d=g[h-15],y=g[h-2];g[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+g[h-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+g[h-16]}d=f+((l<<26|l>>>6)^(l<<21|l>>>11)^(l<<7|l>>>25))+(l&c^~l&u)+s[h]+g[h],y=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&i^n&o^i&o),f=u,u=c,c=l,l=a+d|0,a=o,o=i,i=n,n=d+y|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+l|0,r[5]=r[5]+c|0,r[6]=r[6]+u|0,r[7]=r[7]+f|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(r),t.HmacSHA256=i._createHmacHelper(r)}(Math),function(){var e=a,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,r){e=this._hasher=new e.init,"string"==typeof r&&(r=t.parse(r));var n=e.blockSize,i=4*n;r.sigBytes>i&&(r=e.finalize(r)),r.clamp();for(var o=this._oKey=r.clone(),s=this._iKey=r.clone(),a=o.words,l=s.words,c=0;c<n;c++)a[c]^=1549556828,l[c]^=909522486;o.sigBytes=s.sigBytes=i,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher;return e=t.finalize(e),t.reset(),t.finalize(this._oKey.clone().concat(e))}})}();var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},u=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},h=function(){function e(e,t){var r=[],n=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),d=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)},g=function(){function r(e){c(this,r);try{if(this.trackers=[],this.workflows={},this.test=e.test,this.debug=e.debug,this.disabled=!t(e),this.disabled&&console.log("Telemetry Disabled"),e.portal&&e.portal.user){var n=e.portal.subscriptionInfo||{};this.setUser(e.portal.user,n.type)}else e.user&&this.setUser(e.user);this.disabled||this._initializeTrackers(e)}catch(e){console.error("Telemetry Disabled"),console.error(e),this.disabled=!0}}return u(r,[{key:"_initializeTrackers",value:function(e){if(e.plugins){var t;(t=this.trackers).push.apply(t,d(e.plugins))}this.trackers.length||console.error(new Error("No trackers configured"))}},{key:"setUser",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Public";e="string"==typeof e?{username:e}:e,this.user=e,this.user.accountType=t;var r=void 0;if(e.email&&e.email.split){var n=e.email.split("@")[1];r=o.filter(function(e){return n===e}).length>0}(r||["In House","Demo and Marketing"].indexOf(t)>-1)&&(this.user.internalUser=!0)}},{key:"logPageView",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this.preProcess(t,r);if(this.debug&&console.log("Tracking page view",JSON.stringify(n)),this.test&&!this.disabled)return n;var i=this.trackers.filter(function(e){return!e.disabled});if(!i.length||this.disabled)return this.disabled||console.error(new Error("Page view was not logged because no trackers are configured.")),!1;var o=i.map(function(t){return t.logPageView(e,n)});return Promise.all(o).then(),!0}},{key:"logEvent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e=this.preProcess(e,t),this.debug&&console.log("Tracking event",JSON.stringify(e)),this.test)return e;var r=this.trackers.filter(function(e){return!e.disabled});if(!r.length||this.disabled)return this.disabled||console.error(new Error("Event was not logged because no trackers are configured.")),!1;var n=r.map(function(t){return t.logEvent(e)});return Promise.all(n).then(),!0}},{key:"logError",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=f({eventType:"error"},e);this.logEvent(t)}},{key:"startWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={name:e,start:Date.now(),steps:[],workflowId:Math.floor(17592186044416*(1+Math.random())).toString(16)};this._saveWorkflow(r);var n=f({name:e,step:"start"},t);return this._logWorkflow(n),r}},{key:"stepWorkflow",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="string"==typeof options?r:r.details,i=f({name:e,step:t,details:n},r);this._logWorkflow(i)}},{key:"endWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=f({name:e,step:"finish"},t);this._logWorkflow(r)}},{key:"cancelWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=f({name:e,step:"cancel"},t);this._logWorkflow(r)}},{key:"getWorkflow",value:function(e){var t=s.get("TELEMETRY-WORKFLOW:"+e);if(t){if(Date.now()-t.start<18e5)return t;this._deleteWorkflow(t)}}},{key:"_saveWorkflow",value:function(e){s.set("TELEMETRY-WORKFLOW:"+e.name,e)}},{key:"_deleteWorkflow",value:function(e){s.delete("TELEMETRY-WORKFLOW:"+e.name)}},{key:"_logWorkflow",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e=this.preProcess(e);var t=this.getWorkflow(e.name);t||(this.startWorkflow(e.name),t=this.getWorkflow(e.name)),t.steps.push(e.step),t.duration=(Date.now()-t.start)/1e3,["cancel","finish"].indexOf(e.step)>-1?this._deleteWorkflow(t):this._saveWorkflow(t);var r=f(e,{eventType:"workflow",category:e.name,action:e.step,label:e.details,duration:t.duration,workflowId:t.workflowId});this.logEvent(r)}},{key:"preProcess",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i={};return this.user&&(i={user:e(this.user.username),org:e(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),Object.entries(f({},t,i)).reduce(n(r.omitComplexData),{})}},{key:"disableTracker",value:function(e){var t=this.trackers.find(function(t){return t.name===e});t&&(t.disabled=!0)}},{key:"enableTracker",value:function(e){var t=this.trackers.find(function(t){return t.name===e});t&&(t.disabled=!1)}}]),r}();return g.anonymize=e,g.internalOrgs=o,g.telemetryEnabled=t,g.storage=s,g}); | ||
//# sourceMappingURL=telemetry.js.amd.min.js.map |
@@ -269,2 +269,18 @@ define('telemetry', function () { 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { | ||
return typeof obj; | ||
} : function (obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
var classCallCheck = function (instance, Constructor) { | ||
@@ -334,6 +350,39 @@ if (!(instance instanceof Constructor)) { | ||
var slicedToArray = function () { | ||
function sliceIterator(arr, i) { | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
try { | ||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i["return"]) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
return function (arr, i) { | ||
if (Array.isArray(arr)) { | ||
return arr; | ||
} else if (Symbol.iterator in Object(arr)) { | ||
return sliceIterator(arr, i); | ||
} else { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
} | ||
}; | ||
}(); | ||
@@ -349,2 +398,5 @@ | ||
var toConsumableArray = function (arr) { | ||
@@ -431,5 +483,6 @@ if (Array.isArray(arr)) { | ||
value: function logPageView(page) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var event = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var attributes = this.preProcess(options); | ||
var attributes = this.preProcess(event, options); | ||
@@ -467,6 +520,6 @@ if (this.debug) { | ||
key: 'logEvent', | ||
value: function logEvent() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
value: function logEvent(event) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var event = this.preProcess(options); | ||
event = this.preProcess(event, options); | ||
@@ -618,8 +671,9 @@ if (this.debug) { | ||
value: function preProcess() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var userOptions = {}; | ||
var userMetadata = {}; | ||
if (this.user) { | ||
userOptions = { | ||
userMetadata = { | ||
user: anonymize(this.user.username), | ||
@@ -634,3 +688,3 @@ org: anonymize(this.user.orgId), | ||
return _extends({}, options, userOptions); | ||
return Object.entries(_extends({}, event, userMetadata)).reduce(_makeEventPayload(options.omitComplexData), {}); | ||
} | ||
@@ -667,3 +721,23 @@ }, { | ||
Telemetry.storage = storage; | ||
function _makeEventPayload(omitComplexData) { | ||
return function (acc, _ref5) { | ||
var _ref6 = slicedToArray(_ref5, 2), | ||
key = _ref6[0], | ||
val = _ref6[1]; | ||
if (_isPrimitive(val)) { | ||
acc[key] = val; | ||
} else if (!omitComplexData) { | ||
console.warn('You are trying to log a non-primitive value, ' + key + ':' + JSON.stringify(val) + '. This will get logged as [object Object]'); | ||
acc[key] = val; | ||
} | ||
return acc; | ||
}; | ||
} | ||
function _isPrimitive(val) { | ||
var primitives = ['string', 'number', 'boolean', 'undefined']; | ||
return primitives.includes(typeof val === 'undefined' ? 'undefined' : _typeof(val)) || val && typeof val.valueOf() === 'string'; | ||
} | ||
return Telemetry; | ||
@@ -670,0 +744,0 @@ |
@@ -1,2 +0,2 @@ | ||
define("telemetry",function(){"use strict";function e(e){if(e)return o.SHA256(e).toString(o.enc.Hex)}function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.portal||{};return!e.disabled&&(!r()&&((void 0===t.eueiEnabled||!1!==t.eueiEnabled)&&(!(!t.eueiEnabled||!t.user||t.user.orgId!==t.id)||(!(!t.user||t.user.orgId||"US"!==t.ipCntryCode)||(!t.user&&"US"===t.ipCntryCode||!(Object.keys(t).length>0))))))}function r(){return"1"===("undefined"!=typeof navigator&&navigator.doNotTrack)||"undefined"!=typeof window&&"1"===window.doNotTrack}var i=["esri.com","esriuk.com","esri.de","esri.ca","esrifrance.fr","esri.nl","esri-portugal.pt","esribulgaria.com","esri.fi","esri.kr","esrimalaysia.com.my","esri.es","esriaustralia.com.au","esri-southafrica.com","esri.cl","esrichina.com.cn","esri.co","esriturkey.com.tr","geodata.no","esriitalia.it","esri.pl"],n={storage:{},memory:!0,get:function(e){var t=void 0;try{t=window.localStorage&&window.localStorage.getItem(e)||this.storage[e]}catch(r){t=this.storage[e]}if(t)try{return JSON.parse(t)}catch(e){return}},set:function(e,t){t=JSON.stringify(t);try{window.localStorage.setItem(e,t)}catch(r){this.memory||(console.error("setting local storage failed, falling back to in-memory storage"),this.memory=!0),this.storage[e]=t}},delete:function(e){try{window.localStorage.removeItem(e)}catch(t){this.memory||(console.error("setting local storage failed, falling back to in-memory storage"),this.memory=!0),delete this.storage[e]}}},o=function(e,t){var r={},i=r.lib={},n=function(){},o=i.Base={extend:function(e){n.prototype=this;var t=new n;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},s=i.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,i=this.sigBytes;if(e=e.sigBytes,this.clamp(),i%4)for(var n=0;n<e;n++)t[i+n>>>2]|=(r[n>>>2]>>>24-n%4*8&255)<<24-(i+n)%4*8;else if(r.length>65535)for(n=0;n<e;n+=4)t[i+n>>>2]=r[n>>>2];else t.push.apply(t,r);return this.sigBytes+=e,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r=[],i=0;i<t;i+=4)r.push(4294967296*e.random()|0);return new s.init(r,t)}}),a=r.enc={},l=a.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var r=[],i=0;i<e;i++){var n=t[i>>>2]>>>24-i%4*8&255;r.push((n>>>4).toString(16)),r.push((15&n).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i+=2)r[i>>>3]|=parseInt(e.substr(i,2),16)<<24-i%8*4;return new s.init(r,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var r=[],i=0;i<e;i++)r.push(String.fromCharCode(t[i>>>2]>>>24-i%4*8&255));return r.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i++)r[i>>>2]|=(255&e.charCodeAt(i))<<24-i%4*8;return new s.init(r,t)}},u=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r=this._data,i=r.words,n=r.sigBytes,o=this.blockSize,a=n/(4*o),a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0);if(t=a*o,n=e.min(4*t,n),t){for(var l=0;l<t;l+=o)this._doProcessBlock(i,l);l=i.splice(0,t),r.sigBytes-=n}return new s.init(l,n)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});i.Hasher=f.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new h.HMAC.init(e,r).finalize(t)}}});var h=r.algo={};return r}(Math);!function(e){for(var t=o,r=t.lib,i=r.WordArray,n=r.Hasher,r=t.algo,s=[],a=[],l=function(e){return 4294967296*(e-(0|e))|0},c=2,u=0;u<64;){var f;e:{f=c;for(var h=e.sqrt(f),d=2;d<=h;d++)if(!(f%d)){f=!1;break e}f=!0}f&&(u<8&&(s[u]=l(e.pow(c,.5))),a[u]=l(e.pow(c,1/3)),u++),c++}var g=[],r=r.SHA256=n.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,i=r[0],n=r[1],o=r[2],s=r[3],l=r[4],c=r[5],u=r[6],f=r[7],h=0;h<64;h++){if(h<16)g[h]=0|e[t+h];else{var d=g[h-15],v=g[h-2];g[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+g[h-7]+((v<<15|v>>>17)^(v<<13|v>>>19)^v>>>10)+g[h-16]}d=f+((l<<26|l>>>6)^(l<<21|l>>>11)^(l<<7|l>>>25))+(l&c^~l&u)+a[h]+g[h],v=((i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22))+(i&n^i&o^n&o),f=u,u=c,c=l,l=s+d|0,s=o,o=n,n=i,i=d+v|0}r[0]=r[0]+i|0,r[1]=r[1]+n|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+l|0,r[5]=r[5]+c|0,r[6]=r[6]+u|0,r[7]=r[7]+f|0},_doFinalize:function(){var t=this._data,r=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return r[n>>>5]|=128<<24-n%32,r[14+(n+64>>>9<<4)]=e.floor(i/4294967296),r[15+(n+64>>>9<<4)]=i,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=n._createHelper(r),t.HmacSHA256=n._createHmacHelper(r)}(Math),function(){var e=o,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,r){e=this._hasher=new e.init,"string"==typeof r&&(r=t.parse(r));var i=e.blockSize,n=4*i;r.sigBytes>n&&(r=e.finalize(r)),r.clamp();for(var o=this._oKey=r.clone(),s=this._iKey=r.clone(),a=o.words,l=s.words,c=0;c<i;c++)a[c]^=1549556828,l[c]^=909522486;o.sigBytes=s.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher;return e=t.finalize(e),t.reset(),t.finalize(this._oKey.clone().concat(e))}})}();var s=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},a=function(){function e(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},c=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)},u=function(){function r(e){s(this,r);try{if(this.trackers=[],this.workflows={},this.test=e.test,this.debug=e.debug,this.disabled=!t(e),this.disabled&&console.log("Telemetry Disabled"),e.portal&&e.portal.user){var i=e.portal.subscriptionInfo||{};this.setUser(e.portal.user,i.type)}else e.user&&this.setUser(e.user);this.disabled||this._initializeTrackers(e)}catch(e){console.error("Telemetry Disabled"),console.error(e),this.disabled=!0}}return a(r,[{key:"_initializeTrackers",value:function(e){if(e.plugins){var t;(t=this.trackers).push.apply(t,c(e.plugins))}this.trackers.length||console.error(new Error("No trackers configured"))}},{key:"setUser",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Public";e="string"==typeof e?{username:e}:e,this.user=e,this.user.accountType=t;var r=void 0;if(e.email&&e.email.split){var n=e.email.split("@")[1];r=i.filter(function(e){return n===e}).length>0}(r||["In House","Demo and Marketing"].indexOf(t)>-1)&&(this.user.internalUser=!0)}},{key:"logPageView",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this.preProcess(t);if(this.debug&&console.log("Tracking page view",JSON.stringify(r)),this.test&&!this.disabled)return r;var i=this.trackers.filter(function(e){return!e.disabled});if(!i.length||this.disabled)return this.disabled||console.error(new Error("Page view was not logged because no trackers are configured.")),!1;var n=i.map(function(t){return t.logPageView(e,r)});return Promise.all(n).then(),!0}},{key:"logEvent",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.preProcess(e);if(this.debug&&console.log("Tracking event",JSON.stringify(t)),this.test)return t;var r=this.trackers.filter(function(e){return!e.disabled});if(!r.length||this.disabled)return this.disabled||console.error(new Error("Event was not logged because no trackers are configured.")),!1;var i=r.map(function(e){return e.logEvent(t)});return Promise.all(i).then(),!0}},{key:"logError",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=l({eventType:"error"},e);this.logEvent(t)}},{key:"startWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={name:e,start:Date.now(),steps:[],workflowId:Math.floor(17592186044416*(1+Math.random())).toString(16)};this._saveWorkflow(r);var i=l({name:e,step:"start"},t);return this._logWorkflow(i),r}},{key:"stepWorkflow",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i="string"==typeof options?r:r.details,n=l({name:e,step:t,details:i},r);this._logWorkflow(n)}},{key:"endWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=l({name:e,step:"finish"},t);this._logWorkflow(r)}},{key:"cancelWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=l({name:e,step:"cancel"},t);this._logWorkflow(r)}},{key:"getWorkflow",value:function(e){var t=n.get("TELEMETRY-WORKFLOW:"+e);if(t){if(Date.now()-t.start<18e5)return t;this._deleteWorkflow(t)}}},{key:"_saveWorkflow",value:function(e){n.set("TELEMETRY-WORKFLOW:"+e.name,e)}},{key:"_deleteWorkflow",value:function(e){n.delete("TELEMETRY-WORKFLOW:"+e.name)}},{key:"_logWorkflow",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e=this.preProcess(e);var t=this.getWorkflow(e.name);t||(this.startWorkflow(e.name),t=this.getWorkflow(e.name)),t.steps.push(e.step),t.duration=(Date.now()-t.start)/1e3,["cancel","finish"].indexOf(e.step)>-1?this._deleteWorkflow(t):this._saveWorkflow(t);var r=l(e,{eventType:"workflow",category:e.name,action:e.step,label:e.details,duration:t.duration,workflowId:t.workflowId});this.logEvent(r)}},{key:"preProcess",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r={};return this.user&&(r={user:e(this.user.username),org:e(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),l({},t,r)}},{key:"disableTracker",value:function(e){var t=this.trackers.find(function(t){return t.name===e});t&&(t.disabled=!0)}},{key:"enableTracker",value:function(e){var t=this.trackers.find(function(t){return t.name===e});t&&(t.disabled=!1)}}]),r}();return u.anonymize=e,u.internalOrgs=i,u.telemetryEnabled=t,u.storage=n,u}); | ||
define("telemetry",function(){"use strict";function e(e){if(e)return a.SHA256(e).toString(a.enc.Hex)}function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.portal||{};return!e.disabled&&(!r()&&((void 0===t.eueiEnabled||!1!==t.eueiEnabled)&&(!(!t.eueiEnabled||!t.user||t.user.orgId!==t.id)||(!(!t.user||t.user.orgId||"US"!==t.ipCntryCode)||(!t.user&&"US"===t.ipCntryCode||!(Object.keys(t).length>0))))))}function r(){return"1"===("undefined"!=typeof navigator&&navigator.doNotTrack)||"undefined"!=typeof window&&"1"===window.doNotTrack}function n(e){return function(t,r){var n=h(r,2),o=n[0],s=n[1];return i(s)?t[o]=s:e||(console.warn("You are trying to log a non-primitive value, "+o+":"+JSON.stringify(s)+". This will get logged as [object Object]"),t[o]=s),t}}function i(e){return["string","number","boolean","undefined"].includes(void 0===e?"undefined":l(e))||e&&"string"==typeof e.valueOf()}var o=["esri.com","esriuk.com","esri.de","esri.ca","esrifrance.fr","esri.nl","esri-portugal.pt","esribulgaria.com","esri.fi","esri.kr","esrimalaysia.com.my","esri.es","esriaustralia.com.au","esri-southafrica.com","esri.cl","esrichina.com.cn","esri.co","esriturkey.com.tr","geodata.no","esriitalia.it","esri.pl"],s={storage:{},memory:!0,get:function(e){var t=void 0;try{t=window.localStorage&&window.localStorage.getItem(e)||this.storage[e]}catch(r){t=this.storage[e]}if(t)try{return JSON.parse(t)}catch(e){return}},set:function(e,t){t=JSON.stringify(t);try{window.localStorage.setItem(e,t)}catch(r){this.memory||(console.error("setting local storage failed, falling back to in-memory storage"),this.memory=!0),this.storage[e]=t}},delete:function(e){try{window.localStorage.removeItem(e)}catch(t){this.memory||(console.error("setting local storage failed, falling back to in-memory storage"),this.memory=!0),delete this.storage[e]}}},a=function(e,t){var r={},n=r.lib={},i=function(){},o=n.Base={extend:function(e){i.prototype=this;var t=new i;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},s=n.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes;if(e=e.sigBytes,this.clamp(),n%4)for(var i=0;i<e;i++)t[n+i>>>2]|=(r[i>>>2]>>>24-i%4*8&255)<<24-(n+i)%4*8;else if(r.length>65535)for(i=0;i<e;i+=4)t[n+i>>>2]=r[i>>>2];else t.push.apply(t,r);return this.sigBytes+=e,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r=[],n=0;n<t;n+=4)r.push(4294967296*e.random()|0);return new s.init(r,t)}}),a=r.enc={},l=a.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var r=[],n=0;n<e;n++){var i=t[n>>>2]>>>24-n%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new s.init(r,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var r=[],n=0;n<e;n++)r.push(String.fromCharCode(t[n>>>2]>>>24-n%4*8&255));return r.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new s.init(r,t)}},u=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=n.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r=this._data,n=r.words,i=r.sigBytes,o=this.blockSize,a=i/(4*o),a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0);if(t=a*o,i=e.min(4*t,i),t){for(var l=0;l<t;l+=o)this._doProcessBlock(n,l);l=n.splice(0,t),r.sigBytes-=i}return new s.init(l,i)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});n.Hasher=f.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new h.HMAC.init(e,r).finalize(t)}}});var h=r.algo={};return r}(Math);!function(e){for(var t=a,r=t.lib,n=r.WordArray,i=r.Hasher,r=t.algo,o=[],s=[],l=function(e){return 4294967296*(e-(0|e))|0},c=2,u=0;u<64;){var f;e:{f=c;for(var h=e.sqrt(f),d=2;d<=h;d++)if(!(f%d)){f=!1;break e}f=!0}f&&(u<8&&(o[u]=l(e.pow(c,.5))),s[u]=l(e.pow(c,1/3)),u++),c++}var g=[],r=r.SHA256=i.extend({_doReset:function(){this._hash=new n.init(o.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],a=r[3],l=r[4],c=r[5],u=r[6],f=r[7],h=0;h<64;h++){if(h<16)g[h]=0|e[t+h];else{var d=g[h-15],y=g[h-2];g[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+g[h-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+g[h-16]}d=f+((l<<26|l>>>6)^(l<<21|l>>>11)^(l<<7|l>>>25))+(l&c^~l&u)+s[h]+g[h],y=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&i^n&o^i&o),f=u,u=c,c=l,l=a+d|0,a=o,o=i,i=n,n=d+y|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+l|0,r[5]=r[5]+c|0,r[6]=r[6]+u|0,r[7]=r[7]+f|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(r),t.HmacSHA256=i._createHmacHelper(r)}(Math),function(){var e=a,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,r){e=this._hasher=new e.init,"string"==typeof r&&(r=t.parse(r));var n=e.blockSize,i=4*n;r.sigBytes>i&&(r=e.finalize(r)),r.clamp();for(var o=this._oKey=r.clone(),s=this._iKey=r.clone(),a=o.words,l=s.words,c=0;c<n;c++)a[c]^=1549556828,l[c]^=909522486;o.sigBytes=s.sigBytes=i,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher;return e=t.finalize(e),t.reset(),t.finalize(this._oKey.clone().concat(e))}})}();var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},u=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},h=function(){function e(e,t){var r=[],n=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),d=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)},g=function(){function r(e){c(this,r);try{if(this.trackers=[],this.workflows={},this.test=e.test,this.debug=e.debug,this.disabled=!t(e),this.disabled&&console.log("Telemetry Disabled"),e.portal&&e.portal.user){var n=e.portal.subscriptionInfo||{};this.setUser(e.portal.user,n.type)}else e.user&&this.setUser(e.user);this.disabled||this._initializeTrackers(e)}catch(e){console.error("Telemetry Disabled"),console.error(e),this.disabled=!0}}return u(r,[{key:"_initializeTrackers",value:function(e){if(e.plugins){var t;(t=this.trackers).push.apply(t,d(e.plugins))}this.trackers.length||console.error(new Error("No trackers configured"))}},{key:"setUser",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Public";e="string"==typeof e?{username:e}:e,this.user=e,this.user.accountType=t;var r=void 0;if(e.email&&e.email.split){var n=e.email.split("@")[1];r=o.filter(function(e){return n===e}).length>0}(r||["In House","Demo and Marketing"].indexOf(t)>-1)&&(this.user.internalUser=!0)}},{key:"logPageView",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this.preProcess(t,r);if(this.debug&&console.log("Tracking page view",JSON.stringify(n)),this.test&&!this.disabled)return n;var i=this.trackers.filter(function(e){return!e.disabled});if(!i.length||this.disabled)return this.disabled||console.error(new Error("Page view was not logged because no trackers are configured.")),!1;var o=i.map(function(t){return t.logPageView(e,n)});return Promise.all(o).then(),!0}},{key:"logEvent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e=this.preProcess(e,t),this.debug&&console.log("Tracking event",JSON.stringify(e)),this.test)return e;var r=this.trackers.filter(function(e){return!e.disabled});if(!r.length||this.disabled)return this.disabled||console.error(new Error("Event was not logged because no trackers are configured.")),!1;var n=r.map(function(t){return t.logEvent(e)});return Promise.all(n).then(),!0}},{key:"logError",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=f({eventType:"error"},e);this.logEvent(t)}},{key:"startWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={name:e,start:Date.now(),steps:[],workflowId:Math.floor(17592186044416*(1+Math.random())).toString(16)};this._saveWorkflow(r);var n=f({name:e,step:"start"},t);return this._logWorkflow(n),r}},{key:"stepWorkflow",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="string"==typeof options?r:r.details,i=f({name:e,step:t,details:n},r);this._logWorkflow(i)}},{key:"endWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=f({name:e,step:"finish"},t);this._logWorkflow(r)}},{key:"cancelWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=f({name:e,step:"cancel"},t);this._logWorkflow(r)}},{key:"getWorkflow",value:function(e){var t=s.get("TELEMETRY-WORKFLOW:"+e);if(t){if(Date.now()-t.start<18e5)return t;this._deleteWorkflow(t)}}},{key:"_saveWorkflow",value:function(e){s.set("TELEMETRY-WORKFLOW:"+e.name,e)}},{key:"_deleteWorkflow",value:function(e){s.delete("TELEMETRY-WORKFLOW:"+e.name)}},{key:"_logWorkflow",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e=this.preProcess(e);var t=this.getWorkflow(e.name);t||(this.startWorkflow(e.name),t=this.getWorkflow(e.name)),t.steps.push(e.step),t.duration=(Date.now()-t.start)/1e3,["cancel","finish"].indexOf(e.step)>-1?this._deleteWorkflow(t):this._saveWorkflow(t);var r=f(e,{eventType:"workflow",category:e.name,action:e.step,label:e.details,duration:t.duration,workflowId:t.workflowId});this.logEvent(r)}},{key:"preProcess",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i={};return this.user&&(i={user:e(this.user.username),org:e(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),Object.entries(f({},t,i)).reduce(n(r.omitComplexData),{})}},{key:"disableTracker",value:function(e){var t=this.trackers.find(function(t){return t.name===e});t&&(t.disabled=!0)}},{key:"enableTracker",value:function(e){var t=this.trackers.find(function(t){return t.name===e});t&&(t.disabled=!1)}}]),r}();return g.anonymize=e,g.internalOrgs=o,g.telemetryEnabled=t,g.storage=s,g}); | ||
//# sourceMappingURL=telemetry.js.dojo.min.js.map |
@@ -273,2 +273,18 @@ (function (global, factory) { | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { | ||
return typeof obj; | ||
} : function (obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
var classCallCheck = function (instance, Constructor) { | ||
@@ -338,6 +354,39 @@ if (!(instance instanceof Constructor)) { | ||
var slicedToArray = function () { | ||
function sliceIterator(arr, i) { | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
try { | ||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i["return"]) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
return function (arr, i) { | ||
if (Array.isArray(arr)) { | ||
return arr; | ||
} else if (Symbol.iterator in Object(arr)) { | ||
return sliceIterator(arr, i); | ||
} else { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
} | ||
}; | ||
}(); | ||
@@ -353,2 +402,5 @@ | ||
var toConsumableArray = function (arr) { | ||
@@ -435,5 +487,6 @@ if (Array.isArray(arr)) { | ||
value: function logPageView(page) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var event = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var attributes = this.preProcess(options); | ||
var attributes = this.preProcess(event, options); | ||
@@ -471,6 +524,6 @@ if (this.debug) { | ||
key: 'logEvent', | ||
value: function logEvent() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
value: function logEvent(event) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var event = this.preProcess(options); | ||
event = this.preProcess(event, options); | ||
@@ -622,8 +675,9 @@ if (this.debug) { | ||
value: function preProcess() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var userOptions = {}; | ||
var userMetadata = {}; | ||
if (this.user) { | ||
userOptions = { | ||
userMetadata = { | ||
user: anonymize(this.user.username), | ||
@@ -638,3 +692,3 @@ org: anonymize(this.user.orgId), | ||
return _extends({}, options, userOptions); | ||
return Object.entries(_extends({}, event, userMetadata)).reduce(_makeEventPayload(options.omitComplexData), {}); | ||
} | ||
@@ -671,3 +725,23 @@ }, { | ||
Telemetry.storage = storage; | ||
function _makeEventPayload(omitComplexData) { | ||
return function (acc, _ref5) { | ||
var _ref6 = slicedToArray(_ref5, 2), | ||
key = _ref6[0], | ||
val = _ref6[1]; | ||
if (_isPrimitive(val)) { | ||
acc[key] = val; | ||
} else if (!omitComplexData) { | ||
console.warn('You are trying to log a non-primitive value, ' + key + ':' + JSON.stringify(val) + '. This will get logged as [object Object]'); | ||
acc[key] = val; | ||
} | ||
return acc; | ||
}; | ||
} | ||
function _isPrimitive(val) { | ||
var primitives = ['string', 'number', 'boolean', 'undefined']; | ||
return primitives.includes(typeof val === 'undefined' ? 'undefined' : _typeof(val)) || val && typeof val.valueOf() === 'string'; | ||
} | ||
return Telemetry; | ||
@@ -674,0 +748,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define("telemetry",t):e.telemetry=t()}(this,function(){"use strict";function e(e){if(e)return o.SHA256(e).toString(o.enc.Hex)}function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.portal||{};return!e.disabled&&(!r()&&((void 0===t.eueiEnabled||!1!==t.eueiEnabled)&&(!(!t.eueiEnabled||!t.user||t.user.orgId!==t.id)||(!(!t.user||t.user.orgId||"US"!==t.ipCntryCode)||(!t.user&&"US"===t.ipCntryCode||!(Object.keys(t).length>0))))))}function r(){return"1"===("undefined"!=typeof navigator&&navigator.doNotTrack)||"undefined"!=typeof window&&"1"===window.doNotTrack}var i=["esri.com","esriuk.com","esri.de","esri.ca","esrifrance.fr","esri.nl","esri-portugal.pt","esribulgaria.com","esri.fi","esri.kr","esrimalaysia.com.my","esri.es","esriaustralia.com.au","esri-southafrica.com","esri.cl","esrichina.com.cn","esri.co","esriturkey.com.tr","geodata.no","esriitalia.it","esri.pl"],n={storage:{},memory:!0,get:function(e){var t=void 0;try{t=window.localStorage&&window.localStorage.getItem(e)||this.storage[e]}catch(r){t=this.storage[e]}if(t)try{return JSON.parse(t)}catch(e){return}},set:function(e,t){t=JSON.stringify(t);try{window.localStorage.setItem(e,t)}catch(r){this.memory||(console.error("setting local storage failed, falling back to in-memory storage"),this.memory=!0),this.storage[e]=t}},delete:function(e){try{window.localStorage.removeItem(e)}catch(t){this.memory||(console.error("setting local storage failed, falling back to in-memory storage"),this.memory=!0),delete this.storage[e]}}},o=function(e,t){var r={},i=r.lib={},n=function(){},o=i.Base={extend:function(e){n.prototype=this;var t=new n;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},s=i.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,i=this.sigBytes;if(e=e.sigBytes,this.clamp(),i%4)for(var n=0;n<e;n++)t[i+n>>>2]|=(r[n>>>2]>>>24-n%4*8&255)<<24-(i+n)%4*8;else if(r.length>65535)for(n=0;n<e;n+=4)t[i+n>>>2]=r[n>>>2];else t.push.apply(t,r);return this.sigBytes+=e,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r=[],i=0;i<t;i+=4)r.push(4294967296*e.random()|0);return new s.init(r,t)}}),a=r.enc={},l=a.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var r=[],i=0;i<e;i++){var n=t[i>>>2]>>>24-i%4*8&255;r.push((n>>>4).toString(16)),r.push((15&n).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i+=2)r[i>>>3]|=parseInt(e.substr(i,2),16)<<24-i%8*4;return new s.init(r,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var r=[],i=0;i<e;i++)r.push(String.fromCharCode(t[i>>>2]>>>24-i%4*8&255));return r.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i++)r[i>>>2]|=(255&e.charCodeAt(i))<<24-i%4*8;return new s.init(r,t)}},u=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r=this._data,i=r.words,n=r.sigBytes,o=this.blockSize,a=n/(4*o),a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0);if(t=a*o,n=e.min(4*t,n),t){for(var l=0;l<t;l+=o)this._doProcessBlock(i,l);l=i.splice(0,t),r.sigBytes-=n}return new s.init(l,n)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});i.Hasher=f.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new h.HMAC.init(e,r).finalize(t)}}});var h=r.algo={};return r}(Math);!function(e){for(var t=o,r=t.lib,i=r.WordArray,n=r.Hasher,r=t.algo,s=[],a=[],l=function(e){return 4294967296*(e-(0|e))|0},c=2,u=0;u<64;){var f;e:{f=c;for(var h=e.sqrt(f),d=2;d<=h;d++)if(!(f%d)){f=!1;break e}f=!0}f&&(u<8&&(s[u]=l(e.pow(c,.5))),a[u]=l(e.pow(c,1/3)),u++),c++}var g=[],r=r.SHA256=n.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,i=r[0],n=r[1],o=r[2],s=r[3],l=r[4],c=r[5],u=r[6],f=r[7],h=0;h<64;h++){if(h<16)g[h]=0|e[t+h];else{var d=g[h-15],p=g[h-2];g[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+g[h-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+g[h-16]}d=f+((l<<26|l>>>6)^(l<<21|l>>>11)^(l<<7|l>>>25))+(l&c^~l&u)+a[h]+g[h],p=((i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22))+(i&n^i&o^n&o),f=u,u=c,c=l,l=s+d|0,s=o,o=n,n=i,i=d+p|0}r[0]=r[0]+i|0,r[1]=r[1]+n|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+l|0,r[5]=r[5]+c|0,r[6]=r[6]+u|0,r[7]=r[7]+f|0},_doFinalize:function(){var t=this._data,r=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return r[n>>>5]|=128<<24-n%32,r[14+(n+64>>>9<<4)]=e.floor(i/4294967296),r[15+(n+64>>>9<<4)]=i,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=n._createHelper(r),t.HmacSHA256=n._createHmacHelper(r)}(Math),function(){var e=o,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,r){e=this._hasher=new e.init,"string"==typeof r&&(r=t.parse(r));var i=e.blockSize,n=4*i;r.sigBytes>n&&(r=e.finalize(r)),r.clamp();for(var o=this._oKey=r.clone(),s=this._iKey=r.clone(),a=o.words,l=s.words,c=0;c<i;c++)a[c]^=1549556828,l[c]^=909522486;o.sigBytes=s.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher;return e=t.finalize(e),t.reset(),t.finalize(this._oKey.clone().concat(e))}})}();var s=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},a=function(){function e(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},c=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)},u=function(){function r(e){s(this,r);try{if(this.trackers=[],this.workflows={},this.test=e.test,this.debug=e.debug,this.disabled=!t(e),this.disabled&&console.log("Telemetry Disabled"),e.portal&&e.portal.user){var i=e.portal.subscriptionInfo||{};this.setUser(e.portal.user,i.type)}else e.user&&this.setUser(e.user);this.disabled||this._initializeTrackers(e)}catch(e){console.error("Telemetry Disabled"),console.error(e),this.disabled=!0}}return a(r,[{key:"_initializeTrackers",value:function(e){if(e.plugins){var t;(t=this.trackers).push.apply(t,c(e.plugins))}this.trackers.length||console.error(new Error("No trackers configured"))}},{key:"setUser",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Public";e="string"==typeof e?{username:e}:e,this.user=e,this.user.accountType=t;var r=void 0;if(e.email&&e.email.split){var n=e.email.split("@")[1];r=i.filter(function(e){return n===e}).length>0}(r||["In House","Demo and Marketing"].indexOf(t)>-1)&&(this.user.internalUser=!0)}},{key:"logPageView",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this.preProcess(t);if(this.debug&&console.log("Tracking page view",JSON.stringify(r)),this.test&&!this.disabled)return r;var i=this.trackers.filter(function(e){return!e.disabled});if(!i.length||this.disabled)return this.disabled||console.error(new Error("Page view was not logged because no trackers are configured.")),!1;var n=i.map(function(t){return t.logPageView(e,r)});return Promise.all(n).then(),!0}},{key:"logEvent",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.preProcess(e);if(this.debug&&console.log("Tracking event",JSON.stringify(t)),this.test)return t;var r=this.trackers.filter(function(e){return!e.disabled});if(!r.length||this.disabled)return this.disabled||console.error(new Error("Event was not logged because no trackers are configured.")),!1;var i=r.map(function(e){return e.logEvent(t)});return Promise.all(i).then(),!0}},{key:"logError",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=l({eventType:"error"},e);this.logEvent(t)}},{key:"startWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={name:e,start:Date.now(),steps:[],workflowId:Math.floor(17592186044416*(1+Math.random())).toString(16)};this._saveWorkflow(r);var i=l({name:e,step:"start"},t);return this._logWorkflow(i),r}},{key:"stepWorkflow",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i="string"==typeof options?r:r.details,n=l({name:e,step:t,details:i},r);this._logWorkflow(n)}},{key:"endWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=l({name:e,step:"finish"},t);this._logWorkflow(r)}},{key:"cancelWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=l({name:e,step:"cancel"},t);this._logWorkflow(r)}},{key:"getWorkflow",value:function(e){var t=n.get("TELEMETRY-WORKFLOW:"+e);if(t){if(Date.now()-t.start<18e5)return t;this._deleteWorkflow(t)}}},{key:"_saveWorkflow",value:function(e){n.set("TELEMETRY-WORKFLOW:"+e.name,e)}},{key:"_deleteWorkflow",value:function(e){n.delete("TELEMETRY-WORKFLOW:"+e.name)}},{key:"_logWorkflow",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e=this.preProcess(e);var t=this.getWorkflow(e.name);t||(this.startWorkflow(e.name),t=this.getWorkflow(e.name)),t.steps.push(e.step),t.duration=(Date.now()-t.start)/1e3,["cancel","finish"].indexOf(e.step)>-1?this._deleteWorkflow(t):this._saveWorkflow(t);var r=l(e,{eventType:"workflow",category:e.name,action:e.step,label:e.details,duration:t.duration,workflowId:t.workflowId});this.logEvent(r)}},{key:"preProcess",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r={};return this.user&&(r={user:e(this.user.username),org:e(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),l({},t,r)}},{key:"disableTracker",value:function(e){var t=this.trackers.find(function(t){return t.name===e});t&&(t.disabled=!0)}},{key:"enableTracker",value:function(e){var t=this.trackers.find(function(t){return t.name===e});t&&(t.disabled=!1)}}]),r}();return u.anonymize=e,u.internalOrgs=i,u.telemetryEnabled=t,u.storage=n,u}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define("telemetry",t):e.telemetry=t()}(this,function(){"use strict";function e(e){if(e)return a.SHA256(e).toString(a.enc.Hex)}function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.portal||{};return!e.disabled&&(!r()&&((void 0===t.eueiEnabled||!1!==t.eueiEnabled)&&(!(!t.eueiEnabled||!t.user||t.user.orgId!==t.id)||(!(!t.user||t.user.orgId||"US"!==t.ipCntryCode)||(!t.user&&"US"===t.ipCntryCode||!(Object.keys(t).length>0))))))}function r(){return"1"===("undefined"!=typeof navigator&&navigator.doNotTrack)||"undefined"!=typeof window&&"1"===window.doNotTrack}function n(e){return function(t,r){var n=h(r,2),o=n[0],s=n[1];return i(s)?t[o]=s:e||(console.warn("You are trying to log a non-primitive value, "+o+":"+JSON.stringify(s)+". This will get logged as [object Object]"),t[o]=s),t}}function i(e){return["string","number","boolean","undefined"].includes(void 0===e?"undefined":l(e))||e&&"string"==typeof e.valueOf()}var o=["esri.com","esriuk.com","esri.de","esri.ca","esrifrance.fr","esri.nl","esri-portugal.pt","esribulgaria.com","esri.fi","esri.kr","esrimalaysia.com.my","esri.es","esriaustralia.com.au","esri-southafrica.com","esri.cl","esrichina.com.cn","esri.co","esriturkey.com.tr","geodata.no","esriitalia.it","esri.pl"],s={storage:{},memory:!0,get:function(e){var t=void 0;try{t=window.localStorage&&window.localStorage.getItem(e)||this.storage[e]}catch(r){t=this.storage[e]}if(t)try{return JSON.parse(t)}catch(e){return}},set:function(e,t){t=JSON.stringify(t);try{window.localStorage.setItem(e,t)}catch(r){this.memory||(console.error("setting local storage failed, falling back to in-memory storage"),this.memory=!0),this.storage[e]=t}},delete:function(e){try{window.localStorage.removeItem(e)}catch(t){this.memory||(console.error("setting local storage failed, falling back to in-memory storage"),this.memory=!0),delete this.storage[e]}}},a=function(e,t){var r={},n=r.lib={},i=function(){},o=n.Base={extend:function(e){i.prototype=this;var t=new i;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},s=n.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes;if(e=e.sigBytes,this.clamp(),n%4)for(var i=0;i<e;i++)t[n+i>>>2]|=(r[i>>>2]>>>24-i%4*8&255)<<24-(n+i)%4*8;else if(r.length>65535)for(i=0;i<e;i+=4)t[n+i>>>2]=r[i>>>2];else t.push.apply(t,r);return this.sigBytes+=e,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r=[],n=0;n<t;n+=4)r.push(4294967296*e.random()|0);return new s.init(r,t)}}),a=r.enc={},l=a.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var r=[],n=0;n<e;n++){var i=t[n>>>2]>>>24-n%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new s.init(r,t/2)}},u=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var r=[],n=0;n<e;n++)r.push(String.fromCharCode(t[n>>>2]>>>24-n%4*8&255));return r.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new s.init(r,t)}},c=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},f=n.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=c.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r=this._data,n=r.words,i=r.sigBytes,o=this.blockSize,a=i/(4*o),a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0);if(t=a*o,i=e.min(4*t,i),t){for(var l=0;l<t;l+=o)this._doProcessBlock(n,l);l=n.splice(0,t),r.sigBytes-=i}return new s.init(l,i)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});n.Hasher=f.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new h.HMAC.init(e,r).finalize(t)}}});var h=r.algo={};return r}(Math);!function(e){for(var t=a,r=t.lib,n=r.WordArray,i=r.Hasher,r=t.algo,o=[],s=[],l=function(e){return 4294967296*(e-(0|e))|0},u=2,c=0;c<64;){var f;e:{f=u;for(var h=e.sqrt(f),d=2;d<=h;d++)if(!(f%d)){f=!1;break e}f=!0}f&&(c<8&&(o[c]=l(e.pow(u,.5))),s[c]=l(e.pow(u,1/3)),c++),u++}var g=[],r=r.SHA256=i.extend({_doReset:function(){this._hash=new n.init(o.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],a=r[3],l=r[4],u=r[5],c=r[6],f=r[7],h=0;h<64;h++){if(h<16)g[h]=0|e[t+h];else{var d=g[h-15],y=g[h-2];g[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+g[h-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+g[h-16]}d=f+((l<<26|l>>>6)^(l<<21|l>>>11)^(l<<7|l>>>25))+(l&u^~l&c)+s[h]+g[h],y=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&i^n&o^i&o),f=c,c=u,u=l,l=a+d|0,a=o,o=i,i=n,n=d+y|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+l|0,r[5]=r[5]+u|0,r[6]=r[6]+c|0,r[7]=r[7]+f|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(r),t.HmacSHA256=i._createHmacHelper(r)}(Math),function(){var e=a,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,r){e=this._hasher=new e.init,"string"==typeof r&&(r=t.parse(r));var n=e.blockSize,i=4*n;r.sigBytes>i&&(r=e.finalize(r)),r.clamp();for(var o=this._oKey=r.clone(),s=this._iKey=r.clone(),a=o.words,l=s.words,u=0;u<n;u++)a[u]^=1549556828,l[u]^=909522486;o.sigBytes=s.sigBytes=i,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher;return e=t.finalize(e),t.reset(),t.finalize(this._oKey.clone().concat(e))}})}();var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},c=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},h=function(){function e(e,t){var r=[],n=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),d=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)},g=function(){function r(e){u(this,r);try{if(this.trackers=[],this.workflows={},this.test=e.test,this.debug=e.debug,this.disabled=!t(e),this.disabled&&console.log("Telemetry Disabled"),e.portal&&e.portal.user){var n=e.portal.subscriptionInfo||{};this.setUser(e.portal.user,n.type)}else e.user&&this.setUser(e.user);this.disabled||this._initializeTrackers(e)}catch(e){console.error("Telemetry Disabled"),console.error(e),this.disabled=!0}}return c(r,[{key:"_initializeTrackers",value:function(e){if(e.plugins){var t;(t=this.trackers).push.apply(t,d(e.plugins))}this.trackers.length||console.error(new Error("No trackers configured"))}},{key:"setUser",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Public";e="string"==typeof e?{username:e}:e,this.user=e,this.user.accountType=t;var r=void 0;if(e.email&&e.email.split){var n=e.email.split("@")[1];r=o.filter(function(e){return n===e}).length>0}(r||["In House","Demo and Marketing"].indexOf(t)>-1)&&(this.user.internalUser=!0)}},{key:"logPageView",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this.preProcess(t,r);if(this.debug&&console.log("Tracking page view",JSON.stringify(n)),this.test&&!this.disabled)return n;var i=this.trackers.filter(function(e){return!e.disabled});if(!i.length||this.disabled)return this.disabled||console.error(new Error("Page view was not logged because no trackers are configured.")),!1;var o=i.map(function(t){return t.logPageView(e,n)});return Promise.all(o).then(),!0}},{key:"logEvent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e=this.preProcess(e,t),this.debug&&console.log("Tracking event",JSON.stringify(e)),this.test)return e;var r=this.trackers.filter(function(e){return!e.disabled});if(!r.length||this.disabled)return this.disabled||console.error(new Error("Event was not logged because no trackers are configured.")),!1;var n=r.map(function(t){return t.logEvent(e)});return Promise.all(n).then(),!0}},{key:"logError",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=f({eventType:"error"},e);this.logEvent(t)}},{key:"startWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={name:e,start:Date.now(),steps:[],workflowId:Math.floor(17592186044416*(1+Math.random())).toString(16)};this._saveWorkflow(r);var n=f({name:e,step:"start"},t);return this._logWorkflow(n),r}},{key:"stepWorkflow",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="string"==typeof options?r:r.details,i=f({name:e,step:t,details:n},r);this._logWorkflow(i)}},{key:"endWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=f({name:e,step:"finish"},t);this._logWorkflow(r)}},{key:"cancelWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=f({name:e,step:"cancel"},t);this._logWorkflow(r)}},{key:"getWorkflow",value:function(e){var t=s.get("TELEMETRY-WORKFLOW:"+e);if(t){if(Date.now()-t.start<18e5)return t;this._deleteWorkflow(t)}}},{key:"_saveWorkflow",value:function(e){s.set("TELEMETRY-WORKFLOW:"+e.name,e)}},{key:"_deleteWorkflow",value:function(e){s.delete("TELEMETRY-WORKFLOW:"+e.name)}},{key:"_logWorkflow",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e=this.preProcess(e);var t=this.getWorkflow(e.name);t||(this.startWorkflow(e.name),t=this.getWorkflow(e.name)),t.steps.push(e.step),t.duration=(Date.now()-t.start)/1e3,["cancel","finish"].indexOf(e.step)>-1?this._deleteWorkflow(t):this._saveWorkflow(t);var r=f(e,{eventType:"workflow",category:e.name,action:e.step,label:e.details,duration:t.duration,workflowId:t.workflowId});this.logEvent(r)}},{key:"preProcess",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i={};return this.user&&(i={user:e(this.user.username),org:e(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),Object.entries(f({},t,i)).reduce(n(r.omitComplexData),{})}},{key:"disableTracker",value:function(e){var t=this.trackers.find(function(t){return t.name===e});t&&(t.disabled=!0)}},{key:"enableTracker",value:function(e){var t=this.trackers.find(function(t){return t.name===e});t&&(t.disabled=!1)}}]),r}();return g.anonymize=e,g.internalOrgs=o,g.telemetryEnabled=t,g.storage=s,g}); | ||
//# sourceMappingURL=telemetry.js.min.js.map |
{ | ||
"name": "@esri/telemetry", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "A JavaScript Implementation of the ArcGIS Telemetry Specification", | ||
@@ -40,4 +40,3 @@ "main": "dist/telemetry.js", | ||
"dist/*" | ||
], | ||
"gitHead": "010e9517264cc02f5e5da766458433c154b799f5" | ||
] | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
325723
2006
13