@esri/telemetry
Advanced tools
Comparing version 3.0.2 to 3.1.0
@@ -7,2 +7,6 @@ # Change Log | ||
## [3.1.0] - 03/29/2021 | ||
## Added | ||
* Add ability to disable individual trackers [Hub 169](https://devtopia.esri.com/dc/hub/issues/169) | ||
## [3.0.2] - 03/17/2021 | ||
@@ -137,2 +141,3 @@ ### Fixed | ||
[3.1.0]: https://github.com/arcgis/telemetry.js/compare/v3.0.2...v3.1.0 | ||
[3.0.2]: https://github.com/arcgis/telemetry.js/compare/v3.0.1...v3.0.2 | ||
@@ -139,0 +144,0 @@ [3.0.1]: https://github.com/arcgis/telemetry.js/compare/v3.0.0...v3.0.1 |
@@ -779,4 +779,8 @@ define('telemetry', ['analytics', '@analytics/aws-pinpoint'], function (Analytics, awsPinpointPlugin) { 'use strict'; | ||
if (this.test && !this.disabled) return attributes; | ||
var trackers = this.trackers.filter(function (_ref) { | ||
var disabled = _ref.disabled; | ||
return !disabled; | ||
}); | ||
if (!this.trackers.length || this.disabled) { | ||
if (!trackers.length || this.disabled) { | ||
if (!this.disabled) console.error(new Error('Page view was not logged because no trackers are configured.')); | ||
@@ -786,3 +790,3 @@ return false; | ||
var promises = this.trackers.map(function (tracker) { | ||
var promises = trackers.map(function (tracker) { | ||
return tracker.logPageView(page, attributes); | ||
@@ -803,4 +807,8 @@ }); | ||
if (this.test) return event; | ||
var trackers = this.trackers.filter(function (_ref2) { | ||
var disabled = _ref2.disabled; | ||
return !disabled; | ||
}); | ||
if (!this.trackers.length || this.disabled) { | ||
if (!trackers.length || this.disabled) { | ||
if (!this.disabled) console.error(new Error('Event was not logged because no trackers are configured.')); | ||
@@ -810,3 +818,3 @@ return false; | ||
var promises = this.trackers.map(function (tracker) { | ||
var promises = trackers.map(function (tracker) { | ||
return tracker.logEvent(event); | ||
@@ -949,2 +957,24 @@ }); | ||
} | ||
}, { | ||
key: 'disableTracker', | ||
value: function disableTracker(trackerName) { | ||
var tracker = this.trackers.find(function (_ref3) { | ||
var name = _ref3.name; | ||
return name === trackerName; | ||
}); | ||
if (tracker) { | ||
tracker.disabled = true; | ||
} | ||
} | ||
}, { | ||
key: 'enableTracker', | ||
value: function enableTracker(trackerName) { | ||
var tracker = this.trackers.find(function (_ref4) { | ||
var name = _ref4.name; | ||
return name === trackerName; | ||
}); | ||
if (tracker) { | ||
tracker.disabled = false; | ||
} | ||
} | ||
}]); | ||
@@ -951,0 +981,0 @@ return Telemetry; |
@@ -1,2 +0,2 @@ | ||
define("telemetry",["analytics","@analytics/aws-pinpoint"],function(e,t){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=!0===t.fips?"-fips":"",r="https://cognito-identity"+n+".us-east-1.amazonaws.com/",i=p.get(y);if(i&&Date.now()/1e3<i.Expiration)return Promise.resolve(i);var o={method:"POST",headers:{"Content-type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityService.GetId"},body:JSON.stringify({IdentityPoolId:e})};return fetch(r,o).then(function(e){if(!e.ok)throw new Error(e.statusText);return e.json()}).then(function(e){var t=e.IdentityId,n={method:"POST",headers:{"Content-type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityService.GetCredentialsForIdentity"},body:JSON.stringify({IdentityId:t})};return fetch(r,n)}).then(function(e){if(!e.ok)throw new Error(e.statusText);return e.json()}).then(function(e){var t=e.Credentials;return p.set(y,t),t})}function r(e){var t=e.telemetryData,n=e.dimensionLookup,r=void 0===n?{}:n,s=e.excludeKeys,a=void 0===s?[]:s;return Object.keys(t).filter(function(e){return!a.includes(e)}).map(function(e){return r[e]?{key:o(r,e),value:t[e]}:{key:e,value:i(t,e)}}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function i(e,t){return"json"===t?e[t]?JSON.stringify(e[t]):"null":void 0===e[t]?"null":e[t].toString()}function o(e,t){return"dimension"+e[t]}function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).filter(function(e){return t[e]||m.includes(e)}).map(function(n){return t[n]?{key:a(t,n),value:e[n]}:{key:n,value:e[n]}}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function a(e,t){return"metric"+e[t]}function u(e){var t=e.event,n=void 0===t?{}:t,i=e.dimensionLookup,o=void 0===i?{}:i,a=e.metricLookup,u=void 0===a?{}:a,c=n.eventType,l=void 0===c?"other":c,f=s(n,u),h=r({telemetryData:b({eventType:l},n),dimensionLookup:o,excludeKeys:["workflow"].concat(_(Object.keys(f)),_(Object.keys(u)))});return{name:l,attributes:b({referrer:document.referrer,hostname:window.location.hostname,path:window.location.pathname},h),metrics:f}}function c(e){var t=e.page,n=e.previousPage,i=void 0===n?{}:n,o=e.options,a=void 0===o?{}:o,u=e.dimensionLookup,c=void 0===u?{}:u,l=e.metricLookup,f=void 0===l?{}:l,h=s(a,f),d=r({telemetryData:a,dimensionLookup:c,excludeKeys:["workflow"].concat(_(Object.keys(h)),_(Object.keys(f)))}),g=document||{},v=g.referrer,p=g.title,y=window&&window.location?window.location:{},m=y.hostname,w=y.pathname;return{name:"pageView",attributes:b({referrer:v,hostname:m,path:t||w,pageUrl:t||w,pageName:p,previousPageUrl:i.pageUrl,previousPageName:i.pageName},d),metrics:h}}function l(e){var t=e.customTelemetryData,n=void 0===t?{}:t,r=e.dimensionLookup,i=void 0===r?{}:r,o=e.metricLookup,s=void 0===o?{}:o;return Object.keys(n).map(function(e){return i[e]?{key:f(i,e),value:n[e]}:s[e]?{key:h(s,e),value:n[e]}:void 0}).filter(function(e){return e}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function f(e,t){return"dimension"+e[t]}function h(e,t){return"metric"+e[t]}function d(e){window.ga?window.ga(function(){e(window.ga.getAll())}):console.log(new Error("Google Analytics trackers not available"))}function g(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i={hitType:"pageview",page:e||window.location.pathname},o=l({customTelemetryData:t,dimensionLookup:n,metricLookup:r});return b({},i,o)}function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r={hitType:"event",eventCategory:e.category||"none",eventAction:e.action,eventLabel:e.label},i=l({customTelemetryData:e,dimensionLookup:t,metricLookup:n});return b({},r,i)}e="default"in e?e.default:e,t="default"in t?t.default:t;var p={storage:{},memory:!0,get:function(e){var t=void 0;try{t=window.localStorage&&window.localStorage.getItem(e)||this.storage[e]}catch(n){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(n){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]}}},y="TELEMETRY_COGNITO_CREDENTIALS",m=["size","duration","position","number","count"],w=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},k=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),b=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)},S=function(){function r(i){w(this,r);var o=i.app,s=void 0===o?{}:o,a=i.fips,u=i.userPoolID;this.analytics=e({app:s.name,plugins:[t({fips:a,pinpointAppId:s.id,getCredentials:function(){return n(u,{fips:a})}})]}),this.name="amazon",b(this,i)}return k(r,[{key:"logPageView",value:function(e,t){var n=c({page:e,previousPage:this.previousPage,options:t,dimensionLookup:this.dimensions,metricLookup:this.metrics});this.previousPage=n.attributes,this.analytics.track("pageView",n)}},{key:"logEvent",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=u({event:e,dimensionLookup:this.dimensions,metricLookup:this.metrics}),n=t.name;this.analytics.track(n,t)}}]),r}(),T=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};w(this,e),this.name="google",b(this,t)}return k(e,[{key:"logPageView",value:function(e,t){var n=g(e,t,this.dimensions,this.metrics);d(function(e){e.forEach(function(e){e.send(n)})})}},{key:"logEvent",value:function(e){var t=v(e,this.dimensions,this.metrics);d(function(e){e.forEach(function(e){e.send(t)})})}}]),e}(),E=function(e,t){var n={},r=n.lib={},i=function(){},o=r.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=r.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||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i<e;i++)t[r+i>>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(n.length>65535)for(i=0;i<e;i+=4)t[r+i>>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r<t;r+=4)n.push(4294967296*e.random()|0);return new s.init(n,t)}}),a=n.enc={},u=a.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r<e;r++){var i=t[r>>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r<e;r++)n.push(String.fromCharCode(t[r>>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=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=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.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 u=0;u<t;u+=o)this._doProcessBlock(r,u);u=r.splice(0,t),n.sigBytes-=i}return new s.init(u,i)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});r.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,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new h.HMAC.init(e,n).finalize(t)}}});var h=n.algo={};return n}(Math);!function(e){for(var t=E,n=t.lib,r=n.WordArray,i=n.Hasher,n=t.algo,o=[],s=[],a=function(e){return 4294967296*(e-(0|e))|0},u=2,c=0;c<64;){var l;e:{l=u;for(var f=e.sqrt(l),h=2;h<=f;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(c<8&&(o[c]=a(e.pow(u,.5))),s[c]=a(e.pow(u,1/3)),c++),u++}var d=[],n=n.SHA256=i.extend({_doReset:function(){this._hash=new r.init(o.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],u=n[4],c=n[5],l=n[6],f=n[7],h=0;h<64;h++){if(h<16)d[h]=0|e[t+h];else{var g=d[h-15],v=d[h-2];d[h]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[h-7]+((v<<15|v>>>17)^(v<<13|v>>>19)^v>>>10)+d[h-16]}g=f+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[h]+d[h],v=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),f=l,l=c,c=u,u=a+g|0,a=o,o=i,i=r,r=g+v|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+f|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(n),t.HmacSHA256=i._createHmacHelper(n)}(Math),function(){var e=E,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,n){e=this._hasher=new e.init,"string"==typeof n&&(n=t.parse(n));var r=e.blockSize,i=4*r;n.sigBytes>i&&(n=e.finalize(n)),n.clamp();for(var o=this._oKey=n.clone(),s=this._iKey=n.clone(),a=o.words,u=s.words,c=0;c<r;c++)a[c]^=1549556828,u[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 O=function(e){if(e)return E.SHA256(e).toString(E.enc.Hex)},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"],P=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.portal||{};return!e.disabled&&("1"!==navigator.doNotTrack&&"1"!==window.doNotTrack&&((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))))))};return function(){function e(t){w(this,e);try{if(this.trackers=[],this.workflows={},this.test=t.test,this.debug=t.debug,this.disabled=!P(t),this.disabled&&console.log("Telemetry Disabled"),t.portal&&t.portal.user){var n=t.portal.subscriptionInfo||{};this.setUser(t.portal.user,n.type)}else t.user&&this.setUser(t.user);this.disabled||this._initTrackers(t)}catch(e){console.error("Telemetry Disabled"),console.error(e),this.disabled=!0}}return k(e,[{key:"_initTrackers",value:function(e){if(e.amazon){var t=new S(e.amazon);this.trackers.push(t)}if(e.google){var n=new T(e.google);this.trackers.push(n)}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 n=void 0;if(e.email&&e.email.split){var r=e.email.split("@")[1];n=I.filter(function(e){return r===e}).length>0}(n||["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]:{},n=this.preProcess(t);if(this.debug&&console.log("Tracking page view",JSON.stringify(n)),this.test&&!this.disabled)return n;if(!this.trackers.length||this.disabled)return this.disabled||console.error(new Error("Page view was not logged because no trackers are configured.")),!1;var r=this.trackers.map(function(t){return t.logPageView(e,n)});return Promise.all(r).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;if(!this.trackers.length||this.disabled)return this.disabled||console.error(new Error("Event was not logged because no trackers are configured.")),!1;var n=this.trackers.map(function(e){return e.logEvent(t)});return Promise.all(n).then(),!0}},{key:"logError",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=b({eventType:"error"},e);this.logEvent(t)}},{key:"startWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={name:e,start:Date.now(),steps:[],workflowId:Math.floor(17592186044416*(1+Math.random())).toString(16)};this._saveWorkflow(n);var r=b({name:e,step:"start"},t);return this._logWorkflow(r),n}},{key:"stepWorkflow",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r="string"==typeof options?n:n.details,i=b({name:e,step:t,details:r},n);this._logWorkflow(i)}},{key:"endWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=b({name:e,step:"finish"},t);this._logWorkflow(n)}},{key:"cancelWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=b({name:e,step:"cancel"},t);this._logWorkflow(n)}},{key:"getWorkflow",value:function(e){var t=p.get("TELEMETRY-WORKFLOW:"+e);if(t){if(Date.now()-t.start<18e5)return t;this._deleteWorkflow(t)}}},{key:"_saveWorkflow",value:function(e){p.set("TELEMETRY-WORKFLOW:"+e.name,e)}},{key:"_deleteWorkflow",value:function(e){p.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 n=b(e,{eventType:"workflow",category:e.name,action:e.step,label:e.details,duration:t.duration,workflowId:t.workflowId});this.logEvent(n)}},{key:"preProcess",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={};return this.user&&(t={user:O(this.user.username),org:O(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),b({},e,t)}}]),e}()}); | ||
define("telemetry",["analytics","@analytics/aws-pinpoint"],function(e,t){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=!0===t.fips?"-fips":"",r="https://cognito-identity"+n+".us-east-1.amazonaws.com/",i=p.get(y);if(i&&Date.now()/1e3<i.Expiration)return Promise.resolve(i);var o={method:"POST",headers:{"Content-type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityService.GetId"},body:JSON.stringify({IdentityPoolId:e})};return fetch(r,o).then(function(e){if(!e.ok)throw new Error(e.statusText);return e.json()}).then(function(e){var t=e.IdentityId,n={method:"POST",headers:{"Content-type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityService.GetCredentialsForIdentity"},body:JSON.stringify({IdentityId:t})};return fetch(r,n)}).then(function(e){if(!e.ok)throw new Error(e.statusText);return e.json()}).then(function(e){var t=e.Credentials;return p.set(y,t),t})}function r(e){var t=e.telemetryData,n=e.dimensionLookup,r=void 0===n?{}:n,s=e.excludeKeys,a=void 0===s?[]:s;return Object.keys(t).filter(function(e){return!a.includes(e)}).map(function(e){return r[e]?{key:o(r,e),value:t[e]}:{key:e,value:i(t,e)}}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function i(e,t){return"json"===t?e[t]?JSON.stringify(e[t]):"null":void 0===e[t]?"null":e[t].toString()}function o(e,t){return"dimension"+e[t]}function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).filter(function(e){return t[e]||m.includes(e)}).map(function(n){return t[n]?{key:a(t,n),value:e[n]}:{key:n,value:e[n]}}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function a(e,t){return"metric"+e[t]}function u(e){var t=e.event,n=void 0===t?{}:t,i=e.dimensionLookup,o=void 0===i?{}:i,a=e.metricLookup,u=void 0===a?{}:a,c=n.eventType,l=void 0===c?"other":c,f=s(n,u),h=r({telemetryData:b({eventType:l},n),dimensionLookup:o,excludeKeys:["workflow"].concat(_(Object.keys(f)),_(Object.keys(u)))});return{name:l,attributes:b({referrer:document.referrer,hostname:window.location.hostname,path:window.location.pathname},h),metrics:f}}function c(e){var t=e.page,n=e.previousPage,i=void 0===n?{}:n,o=e.options,a=void 0===o?{}:o,u=e.dimensionLookup,c=void 0===u?{}:u,l=e.metricLookup,f=void 0===l?{}:l,h=s(a,f),d=r({telemetryData:a,dimensionLookup:c,excludeKeys:["workflow"].concat(_(Object.keys(h)),_(Object.keys(f)))}),g=document||{},v=g.referrer,p=g.title,y=window&&window.location?window.location:{},m=y.hostname,w=y.pathname;return{name:"pageView",attributes:b({referrer:v,hostname:m,path:t||w,pageUrl:t||w,pageName:p,previousPageUrl:i.pageUrl,previousPageName:i.pageName},d),metrics:h}}function l(e){var t=e.customTelemetryData,n=void 0===t?{}:t,r=e.dimensionLookup,i=void 0===r?{}:r,o=e.metricLookup,s=void 0===o?{}:o;return Object.keys(n).map(function(e){return i[e]?{key:f(i,e),value:n[e]}:s[e]?{key:h(s,e),value:n[e]}:void 0}).filter(function(e){return e}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function f(e,t){return"dimension"+e[t]}function h(e,t){return"metric"+e[t]}function d(e){window.ga?window.ga(function(){e(window.ga.getAll())}):console.log(new Error("Google Analytics trackers not available"))}function g(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i={hitType:"pageview",page:e||window.location.pathname},o=l({customTelemetryData:t,dimensionLookup:n,metricLookup:r});return b({},i,o)}function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r={hitType:"event",eventCategory:e.category||"none",eventAction:e.action,eventLabel:e.label},i=l({customTelemetryData:e,dimensionLookup:t,metricLookup:n});return b({},r,i)}e="default"in e?e.default:e,t="default"in t?t.default:t;var p={storage:{},memory:!0,get:function(e){var t=void 0;try{t=window.localStorage&&window.localStorage.getItem(e)||this.storage[e]}catch(n){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(n){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]}}},y="TELEMETRY_COGNITO_CREDENTIALS",m=["size","duration","position","number","count"],w=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},k=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),b=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)},S=function(){function r(i){w(this,r);var o=i.app,s=void 0===o?{}:o,a=i.fips,u=i.userPoolID;this.analytics=e({app:s.name,plugins:[t({fips:a,pinpointAppId:s.id,getCredentials:function(){return n(u,{fips:a})}})]}),this.name="amazon",b(this,i)}return k(r,[{key:"logPageView",value:function(e,t){var n=c({page:e,previousPage:this.previousPage,options:t,dimensionLookup:this.dimensions,metricLookup:this.metrics});this.previousPage=n.attributes,this.analytics.track("pageView",n)}},{key:"logEvent",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=u({event:e,dimensionLookup:this.dimensions,metricLookup:this.metrics}),n=t.name;this.analytics.track(n,t)}}]),r}(),T=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};w(this,e),this.name="google",b(this,t)}return k(e,[{key:"logPageView",value:function(e,t){var n=g(e,t,this.dimensions,this.metrics);d(function(e){e.forEach(function(e){e.send(n)})})}},{key:"logEvent",value:function(e){var t=v(e,this.dimensions,this.metrics);d(function(e){e.forEach(function(e){e.send(t)})})}}]),e}(),E=function(e,t){var n={},r=n.lib={},i=function(){},o=r.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=r.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||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i<e;i++)t[r+i>>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(n.length>65535)for(i=0;i<e;i+=4)t[r+i>>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r<t;r+=4)n.push(4294967296*e.random()|0);return new s.init(n,t)}}),a=n.enc={},u=a.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r<e;r++){var i=t[r>>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r<e;r++)n.push(String.fromCharCode(t[r>>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=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=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.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 u=0;u<t;u+=o)this._doProcessBlock(r,u);u=r.splice(0,t),n.sigBytes-=i}return new s.init(u,i)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});r.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,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new h.HMAC.init(e,n).finalize(t)}}});var h=n.algo={};return n}(Math);!function(e){for(var t=E,n=t.lib,r=n.WordArray,i=n.Hasher,n=t.algo,o=[],s=[],a=function(e){return 4294967296*(e-(0|e))|0},u=2,c=0;c<64;){var l;e:{l=u;for(var f=e.sqrt(l),h=2;h<=f;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(c<8&&(o[c]=a(e.pow(u,.5))),s[c]=a(e.pow(u,1/3)),c++),u++}var d=[],n=n.SHA256=i.extend({_doReset:function(){this._hash=new r.init(o.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],u=n[4],c=n[5],l=n[6],f=n[7],h=0;h<64;h++){if(h<16)d[h]=0|e[t+h];else{var g=d[h-15],v=d[h-2];d[h]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[h-7]+((v<<15|v>>>17)^(v<<13|v>>>19)^v>>>10)+d[h-16]}g=f+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[h]+d[h],v=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),f=l,l=c,c=u,u=a+g|0,a=o,o=i,i=r,r=g+v|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+f|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(n),t.HmacSHA256=i._createHmacHelper(n)}(Math),function(){var e=E,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,n){e=this._hasher=new e.init,"string"==typeof n&&(n=t.parse(n));var r=e.blockSize,i=4*r;n.sigBytes>i&&(n=e.finalize(n)),n.clamp();for(var o=this._oKey=n.clone(),s=this._iKey=n.clone(),a=o.words,u=s.words,c=0;c<r;c++)a[c]^=1549556828,u[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 O=function(e){if(e)return E.SHA256(e).toString(E.enc.Hex)},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"],P=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.portal||{};return!e.disabled&&("1"!==navigator.doNotTrack&&"1"!==window.doNotTrack&&((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))))))};return function(){function e(t){w(this,e);try{if(this.trackers=[],this.workflows={},this.test=t.test,this.debug=t.debug,this.disabled=!P(t),this.disabled&&console.log("Telemetry Disabled"),t.portal&&t.portal.user){var n=t.portal.subscriptionInfo||{};this.setUser(t.portal.user,n.type)}else t.user&&this.setUser(t.user);this.disabled||this._initTrackers(t)}catch(e){console.error("Telemetry Disabled"),console.error(e),this.disabled=!0}}return k(e,[{key:"_initTrackers",value:function(e){if(e.amazon){var t=new S(e.amazon);this.trackers.push(t)}if(e.google){var n=new T(e.google);this.trackers.push(n)}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 n=void 0;if(e.email&&e.email.split){var r=e.email.split("@")[1];n=I.filter(function(e){return r===e}).length>0}(n||["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]:{},n=this.preProcess(t);if(this.debug&&console.log("Tracking page view",JSON.stringify(n)),this.test&&!this.disabled)return n;var r=this.trackers.filter(function(e){return!e.disabled});if(!r.length||this.disabled)return this.disabled||console.error(new Error("Page view was not logged because no trackers are configured.")),!1;var i=r.map(function(t){return t.logPageView(e,n)});return Promise.all(i).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 n=this.trackers.filter(function(e){return!e.disabled});if(!n.length||this.disabled)return this.disabled||console.error(new Error("Event was not logged because no trackers are configured.")),!1;var r=n.map(function(e){return e.logEvent(t)});return Promise.all(r).then(),!0}},{key:"logError",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=b({eventType:"error"},e);this.logEvent(t)}},{key:"startWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={name:e,start:Date.now(),steps:[],workflowId:Math.floor(17592186044416*(1+Math.random())).toString(16)};this._saveWorkflow(n);var r=b({name:e,step:"start"},t);return this._logWorkflow(r),n}},{key:"stepWorkflow",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r="string"==typeof options?n:n.details,i=b({name:e,step:t,details:r},n);this._logWorkflow(i)}},{key:"endWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=b({name:e,step:"finish"},t);this._logWorkflow(n)}},{key:"cancelWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=b({name:e,step:"cancel"},t);this._logWorkflow(n)}},{key:"getWorkflow",value:function(e){var t=p.get("TELEMETRY-WORKFLOW:"+e);if(t){if(Date.now()-t.start<18e5)return t;this._deleteWorkflow(t)}}},{key:"_saveWorkflow",value:function(e){p.set("TELEMETRY-WORKFLOW:"+e.name,e)}},{key:"_deleteWorkflow",value:function(e){p.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 n=b(e,{eventType:"workflow",category:e.name,action:e.step,label:e.details,duration:t.duration,workflowId:t.workflowId});this.logEvent(n)}},{key:"preProcess",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={};return this.user&&(t={user:O(this.user.username),org:O(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),b({},e,t)}},{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)}}]),e}()}); | ||
//# sourceMappingURL=telemetry.amd.min.js.map |
@@ -779,4 +779,8 @@ define(['analytics', '@analytics/aws-pinpoint'], function (Analytics, awsPinpointPlugin) { 'use strict'; | ||
if (this.test && !this.disabled) return attributes; | ||
var trackers = this.trackers.filter(function (_ref) { | ||
var disabled = _ref.disabled; | ||
return !disabled; | ||
}); | ||
if (!this.trackers.length || this.disabled) { | ||
if (!trackers.length || this.disabled) { | ||
if (!this.disabled) console.error(new Error('Page view was not logged because no trackers are configured.')); | ||
@@ -786,3 +790,3 @@ return false; | ||
var promises = this.trackers.map(function (tracker) { | ||
var promises = trackers.map(function (tracker) { | ||
return tracker.logPageView(page, attributes); | ||
@@ -803,4 +807,8 @@ }); | ||
if (this.test) return event; | ||
var trackers = this.trackers.filter(function (_ref2) { | ||
var disabled = _ref2.disabled; | ||
return !disabled; | ||
}); | ||
if (!this.trackers.length || this.disabled) { | ||
if (!trackers.length || this.disabled) { | ||
if (!this.disabled) console.error(new Error('Event was not logged because no trackers are configured.')); | ||
@@ -810,3 +818,3 @@ return false; | ||
var promises = this.trackers.map(function (tracker) { | ||
var promises = trackers.map(function (tracker) { | ||
return tracker.logEvent(event); | ||
@@ -949,2 +957,24 @@ }); | ||
} | ||
}, { | ||
key: 'disableTracker', | ||
value: function disableTracker(trackerName) { | ||
var tracker = this.trackers.find(function (_ref3) { | ||
var name = _ref3.name; | ||
return name === trackerName; | ||
}); | ||
if (tracker) { | ||
tracker.disabled = true; | ||
} | ||
} | ||
}, { | ||
key: 'enableTracker', | ||
value: function enableTracker(trackerName) { | ||
var tracker = this.trackers.find(function (_ref4) { | ||
var name = _ref4.name; | ||
return name === trackerName; | ||
}); | ||
if (tracker) { | ||
tracker.disabled = false; | ||
} | ||
} | ||
}]); | ||
@@ -951,0 +981,0 @@ return Telemetry; |
@@ -1,2 +0,2 @@ | ||
define(["analytics","@analytics/aws-pinpoint"],function(e,t){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=!0===t.fips?"-fips":"",r="https://cognito-identity"+n+".us-east-1.amazonaws.com/",i=p.get(y);if(i&&Date.now()/1e3<i.Expiration)return Promise.resolve(i);var o={method:"POST",headers:{"Content-type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityService.GetId"},body:JSON.stringify({IdentityPoolId:e})};return fetch(r,o).then(function(e){if(!e.ok)throw new Error(e.statusText);return e.json()}).then(function(e){var t=e.IdentityId,n={method:"POST",headers:{"Content-type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityService.GetCredentialsForIdentity"},body:JSON.stringify({IdentityId:t})};return fetch(r,n)}).then(function(e){if(!e.ok)throw new Error(e.statusText);return e.json()}).then(function(e){var t=e.Credentials;return p.set(y,t),t})}function r(e){var t=e.telemetryData,n=e.dimensionLookup,r=void 0===n?{}:n,s=e.excludeKeys,a=void 0===s?[]:s;return Object.keys(t).filter(function(e){return!a.includes(e)}).map(function(e){return r[e]?{key:o(r,e),value:t[e]}:{key:e,value:i(t,e)}}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function i(e,t){return"json"===t?e[t]?JSON.stringify(e[t]):"null":void 0===e[t]?"null":e[t].toString()}function o(e,t){return"dimension"+e[t]}function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).filter(function(e){return t[e]||m.includes(e)}).map(function(n){return t[n]?{key:a(t,n),value:e[n]}:{key:n,value:e[n]}}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function a(e,t){return"metric"+e[t]}function u(e){var t=e.event,n=void 0===t?{}:t,i=e.dimensionLookup,o=void 0===i?{}:i,a=e.metricLookup,u=void 0===a?{}:a,c=n.eventType,l=void 0===c?"other":c,f=s(n,u),h=r({telemetryData:b({eventType:l},n),dimensionLookup:o,excludeKeys:["workflow"].concat(_(Object.keys(f)),_(Object.keys(u)))});return{name:l,attributes:b({referrer:document.referrer,hostname:window.location.hostname,path:window.location.pathname},h),metrics:f}}function c(e){var t=e.page,n=e.previousPage,i=void 0===n?{}:n,o=e.options,a=void 0===o?{}:o,u=e.dimensionLookup,c=void 0===u?{}:u,l=e.metricLookup,f=void 0===l?{}:l,h=s(a,f),d=r({telemetryData:a,dimensionLookup:c,excludeKeys:["workflow"].concat(_(Object.keys(h)),_(Object.keys(f)))}),g=document||{},v=g.referrer,p=g.title,y=window&&window.location?window.location:{},m=y.hostname,w=y.pathname;return{name:"pageView",attributes:b({referrer:v,hostname:m,path:t||w,pageUrl:t||w,pageName:p,previousPageUrl:i.pageUrl,previousPageName:i.pageName},d),metrics:h}}function l(e){var t=e.customTelemetryData,n=void 0===t?{}:t,r=e.dimensionLookup,i=void 0===r?{}:r,o=e.metricLookup,s=void 0===o?{}:o;return Object.keys(n).map(function(e){return i[e]?{key:f(i,e),value:n[e]}:s[e]?{key:h(s,e),value:n[e]}:void 0}).filter(function(e){return e}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function f(e,t){return"dimension"+e[t]}function h(e,t){return"metric"+e[t]}function d(e){window.ga?window.ga(function(){e(window.ga.getAll())}):console.log(new Error("Google Analytics trackers not available"))}function g(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i={hitType:"pageview",page:e||window.location.pathname},o=l({customTelemetryData:t,dimensionLookup:n,metricLookup:r});return b({},i,o)}function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r={hitType:"event",eventCategory:e.category||"none",eventAction:e.action,eventLabel:e.label},i=l({customTelemetryData:e,dimensionLookup:t,metricLookup:n});return b({},r,i)}e="default"in e?e.default:e,t="default"in t?t.default:t;var p={storage:{},memory:!0,get:function(e){var t=void 0;try{t=window.localStorage&&window.localStorage.getItem(e)||this.storage[e]}catch(n){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(n){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]}}},y="TELEMETRY_COGNITO_CREDENTIALS",m=["size","duration","position","number","count"],w=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},k=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),b=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)},S=function(){function r(i){w(this,r);var o=i.app,s=void 0===o?{}:o,a=i.fips,u=i.userPoolID;this.analytics=e({app:s.name,plugins:[t({fips:a,pinpointAppId:s.id,getCredentials:function(){return n(u,{fips:a})}})]}),this.name="amazon",b(this,i)}return k(r,[{key:"logPageView",value:function(e,t){var n=c({page:e,previousPage:this.previousPage,options:t,dimensionLookup:this.dimensions,metricLookup:this.metrics});this.previousPage=n.attributes,this.analytics.track("pageView",n)}},{key:"logEvent",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=u({event:e,dimensionLookup:this.dimensions,metricLookup:this.metrics}),n=t.name;this.analytics.track(n,t)}}]),r}(),T=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};w(this,e),this.name="google",b(this,t)}return k(e,[{key:"logPageView",value:function(e,t){var n=g(e,t,this.dimensions,this.metrics);d(function(e){e.forEach(function(e){e.send(n)})})}},{key:"logEvent",value:function(e){var t=v(e,this.dimensions,this.metrics);d(function(e){e.forEach(function(e){e.send(t)})})}}]),e}(),E=function(e,t){var n={},r=n.lib={},i=function(){},o=r.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=r.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||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i<e;i++)t[r+i>>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(n.length>65535)for(i=0;i<e;i+=4)t[r+i>>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r<t;r+=4)n.push(4294967296*e.random()|0);return new s.init(n,t)}}),a=n.enc={},u=a.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r<e;r++){var i=t[r>>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r<e;r++)n.push(String.fromCharCode(t[r>>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=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=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.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 u=0;u<t;u+=o)this._doProcessBlock(r,u);u=r.splice(0,t),n.sigBytes-=i}return new s.init(u,i)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});r.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,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new h.HMAC.init(e,n).finalize(t)}}});var h=n.algo={};return n}(Math);!function(e){for(var t=E,n=t.lib,r=n.WordArray,i=n.Hasher,n=t.algo,o=[],s=[],a=function(e){return 4294967296*(e-(0|e))|0},u=2,c=0;c<64;){var l;e:{l=u;for(var f=e.sqrt(l),h=2;h<=f;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(c<8&&(o[c]=a(e.pow(u,.5))),s[c]=a(e.pow(u,1/3)),c++),u++}var d=[],n=n.SHA256=i.extend({_doReset:function(){this._hash=new r.init(o.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],u=n[4],c=n[5],l=n[6],f=n[7],h=0;h<64;h++){if(h<16)d[h]=0|e[t+h];else{var g=d[h-15],v=d[h-2];d[h]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[h-7]+((v<<15|v>>>17)^(v<<13|v>>>19)^v>>>10)+d[h-16]}g=f+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[h]+d[h],v=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),f=l,l=c,c=u,u=a+g|0,a=o,o=i,i=r,r=g+v|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+f|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(n),t.HmacSHA256=i._createHmacHelper(n)}(Math),function(){var e=E,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,n){e=this._hasher=new e.init,"string"==typeof n&&(n=t.parse(n));var r=e.blockSize,i=4*r;n.sigBytes>i&&(n=e.finalize(n)),n.clamp();for(var o=this._oKey=n.clone(),s=this._iKey=n.clone(),a=o.words,u=s.words,c=0;c<r;c++)a[c]^=1549556828,u[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 O=function(e){if(e)return E.SHA256(e).toString(E.enc.Hex)},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"],P=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.portal||{};return!e.disabled&&("1"!==navigator.doNotTrack&&"1"!==window.doNotTrack&&((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))))))};return function(){function e(t){w(this,e);try{if(this.trackers=[],this.workflows={},this.test=t.test,this.debug=t.debug,this.disabled=!P(t),this.disabled&&console.log("Telemetry Disabled"),t.portal&&t.portal.user){var n=t.portal.subscriptionInfo||{};this.setUser(t.portal.user,n.type)}else t.user&&this.setUser(t.user);this.disabled||this._initTrackers(t)}catch(e){console.error("Telemetry Disabled"),console.error(e),this.disabled=!0}}return k(e,[{key:"_initTrackers",value:function(e){if(e.amazon){var t=new S(e.amazon);this.trackers.push(t)}if(e.google){var n=new T(e.google);this.trackers.push(n)}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 n=void 0;if(e.email&&e.email.split){var r=e.email.split("@")[1];n=I.filter(function(e){return r===e}).length>0}(n||["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]:{},n=this.preProcess(t);if(this.debug&&console.log("Tracking page view",JSON.stringify(n)),this.test&&!this.disabled)return n;if(!this.trackers.length||this.disabled)return this.disabled||console.error(new Error("Page view was not logged because no trackers are configured.")),!1;var r=this.trackers.map(function(t){return t.logPageView(e,n)});return Promise.all(r).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;if(!this.trackers.length||this.disabled)return this.disabled||console.error(new Error("Event was not logged because no trackers are configured.")),!1;var n=this.trackers.map(function(e){return e.logEvent(t)});return Promise.all(n).then(),!0}},{key:"logError",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=b({eventType:"error"},e);this.logEvent(t)}},{key:"startWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={name:e,start:Date.now(),steps:[],workflowId:Math.floor(17592186044416*(1+Math.random())).toString(16)};this._saveWorkflow(n);var r=b({name:e,step:"start"},t);return this._logWorkflow(r),n}},{key:"stepWorkflow",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r="string"==typeof options?n:n.details,i=b({name:e,step:t,details:r},n);this._logWorkflow(i)}},{key:"endWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=b({name:e,step:"finish"},t);this._logWorkflow(n)}},{key:"cancelWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=b({name:e,step:"cancel"},t);this._logWorkflow(n)}},{key:"getWorkflow",value:function(e){var t=p.get("TELEMETRY-WORKFLOW:"+e);if(t){if(Date.now()-t.start<18e5)return t;this._deleteWorkflow(t)}}},{key:"_saveWorkflow",value:function(e){p.set("TELEMETRY-WORKFLOW:"+e.name,e)}},{key:"_deleteWorkflow",value:function(e){p.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 n=b(e,{eventType:"workflow",category:e.name,action:e.step,label:e.details,duration:t.duration,workflowId:t.workflowId});this.logEvent(n)}},{key:"preProcess",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={};return this.user&&(t={user:O(this.user.username),org:O(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),b({},e,t)}}]),e}()}); | ||
define(["analytics","@analytics/aws-pinpoint"],function(e,t){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=!0===t.fips?"-fips":"",r="https://cognito-identity"+n+".us-east-1.amazonaws.com/",i=p.get(y);if(i&&Date.now()/1e3<i.Expiration)return Promise.resolve(i);var o={method:"POST",headers:{"Content-type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityService.GetId"},body:JSON.stringify({IdentityPoolId:e})};return fetch(r,o).then(function(e){if(!e.ok)throw new Error(e.statusText);return e.json()}).then(function(e){var t=e.IdentityId,n={method:"POST",headers:{"Content-type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityService.GetCredentialsForIdentity"},body:JSON.stringify({IdentityId:t})};return fetch(r,n)}).then(function(e){if(!e.ok)throw new Error(e.statusText);return e.json()}).then(function(e){var t=e.Credentials;return p.set(y,t),t})}function r(e){var t=e.telemetryData,n=e.dimensionLookup,r=void 0===n?{}:n,s=e.excludeKeys,a=void 0===s?[]:s;return Object.keys(t).filter(function(e){return!a.includes(e)}).map(function(e){return r[e]?{key:o(r,e),value:t[e]}:{key:e,value:i(t,e)}}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function i(e,t){return"json"===t?e[t]?JSON.stringify(e[t]):"null":void 0===e[t]?"null":e[t].toString()}function o(e,t){return"dimension"+e[t]}function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).filter(function(e){return t[e]||m.includes(e)}).map(function(n){return t[n]?{key:a(t,n),value:e[n]}:{key:n,value:e[n]}}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function a(e,t){return"metric"+e[t]}function u(e){var t=e.event,n=void 0===t?{}:t,i=e.dimensionLookup,o=void 0===i?{}:i,a=e.metricLookup,u=void 0===a?{}:a,c=n.eventType,l=void 0===c?"other":c,f=s(n,u),h=r({telemetryData:b({eventType:l},n),dimensionLookup:o,excludeKeys:["workflow"].concat(_(Object.keys(f)),_(Object.keys(u)))});return{name:l,attributes:b({referrer:document.referrer,hostname:window.location.hostname,path:window.location.pathname},h),metrics:f}}function c(e){var t=e.page,n=e.previousPage,i=void 0===n?{}:n,o=e.options,a=void 0===o?{}:o,u=e.dimensionLookup,c=void 0===u?{}:u,l=e.metricLookup,f=void 0===l?{}:l,h=s(a,f),d=r({telemetryData:a,dimensionLookup:c,excludeKeys:["workflow"].concat(_(Object.keys(h)),_(Object.keys(f)))}),g=document||{},v=g.referrer,p=g.title,y=window&&window.location?window.location:{},m=y.hostname,w=y.pathname;return{name:"pageView",attributes:b({referrer:v,hostname:m,path:t||w,pageUrl:t||w,pageName:p,previousPageUrl:i.pageUrl,previousPageName:i.pageName},d),metrics:h}}function l(e){var t=e.customTelemetryData,n=void 0===t?{}:t,r=e.dimensionLookup,i=void 0===r?{}:r,o=e.metricLookup,s=void 0===o?{}:o;return Object.keys(n).map(function(e){return i[e]?{key:f(i,e),value:n[e]}:s[e]?{key:h(s,e),value:n[e]}:void 0}).filter(function(e){return e}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function f(e,t){return"dimension"+e[t]}function h(e,t){return"metric"+e[t]}function d(e){window.ga?window.ga(function(){e(window.ga.getAll())}):console.log(new Error("Google Analytics trackers not available"))}function g(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i={hitType:"pageview",page:e||window.location.pathname},o=l({customTelemetryData:t,dimensionLookup:n,metricLookup:r});return b({},i,o)}function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r={hitType:"event",eventCategory:e.category||"none",eventAction:e.action,eventLabel:e.label},i=l({customTelemetryData:e,dimensionLookup:t,metricLookup:n});return b({},r,i)}e="default"in e?e.default:e,t="default"in t?t.default:t;var p={storage:{},memory:!0,get:function(e){var t=void 0;try{t=window.localStorage&&window.localStorage.getItem(e)||this.storage[e]}catch(n){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(n){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]}}},y="TELEMETRY_COGNITO_CREDENTIALS",m=["size","duration","position","number","count"],w=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},k=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),b=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)},S=function(){function r(i){w(this,r);var o=i.app,s=void 0===o?{}:o,a=i.fips,u=i.userPoolID;this.analytics=e({app:s.name,plugins:[t({fips:a,pinpointAppId:s.id,getCredentials:function(){return n(u,{fips:a})}})]}),this.name="amazon",b(this,i)}return k(r,[{key:"logPageView",value:function(e,t){var n=c({page:e,previousPage:this.previousPage,options:t,dimensionLookup:this.dimensions,metricLookup:this.metrics});this.previousPage=n.attributes,this.analytics.track("pageView",n)}},{key:"logEvent",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=u({event:e,dimensionLookup:this.dimensions,metricLookup:this.metrics}),n=t.name;this.analytics.track(n,t)}}]),r}(),T=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};w(this,e),this.name="google",b(this,t)}return k(e,[{key:"logPageView",value:function(e,t){var n=g(e,t,this.dimensions,this.metrics);d(function(e){e.forEach(function(e){e.send(n)})})}},{key:"logEvent",value:function(e){var t=v(e,this.dimensions,this.metrics);d(function(e){e.forEach(function(e){e.send(t)})})}}]),e}(),E=function(e,t){var n={},r=n.lib={},i=function(){},o=r.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=r.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||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i<e;i++)t[r+i>>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(n.length>65535)for(i=0;i<e;i+=4)t[r+i>>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r<t;r+=4)n.push(4294967296*e.random()|0);return new s.init(n,t)}}),a=n.enc={},u=a.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r<e;r++){var i=t[r>>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r<e;r++)n.push(String.fromCharCode(t[r>>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=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=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.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 u=0;u<t;u+=o)this._doProcessBlock(r,u);u=r.splice(0,t),n.sigBytes-=i}return new s.init(u,i)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});r.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,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new h.HMAC.init(e,n).finalize(t)}}});var h=n.algo={};return n}(Math);!function(e){for(var t=E,n=t.lib,r=n.WordArray,i=n.Hasher,n=t.algo,o=[],s=[],a=function(e){return 4294967296*(e-(0|e))|0},u=2,c=0;c<64;){var l;e:{l=u;for(var f=e.sqrt(l),h=2;h<=f;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(c<8&&(o[c]=a(e.pow(u,.5))),s[c]=a(e.pow(u,1/3)),c++),u++}var d=[],n=n.SHA256=i.extend({_doReset:function(){this._hash=new r.init(o.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],u=n[4],c=n[5],l=n[6],f=n[7],h=0;h<64;h++){if(h<16)d[h]=0|e[t+h];else{var g=d[h-15],v=d[h-2];d[h]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[h-7]+((v<<15|v>>>17)^(v<<13|v>>>19)^v>>>10)+d[h-16]}g=f+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[h]+d[h],v=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),f=l,l=c,c=u,u=a+g|0,a=o,o=i,i=r,r=g+v|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+f|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(n),t.HmacSHA256=i._createHmacHelper(n)}(Math),function(){var e=E,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,n){e=this._hasher=new e.init,"string"==typeof n&&(n=t.parse(n));var r=e.blockSize,i=4*r;n.sigBytes>i&&(n=e.finalize(n)),n.clamp();for(var o=this._oKey=n.clone(),s=this._iKey=n.clone(),a=o.words,u=s.words,c=0;c<r;c++)a[c]^=1549556828,u[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 O=function(e){if(e)return E.SHA256(e).toString(E.enc.Hex)},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"],P=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.portal||{};return!e.disabled&&("1"!==navigator.doNotTrack&&"1"!==window.doNotTrack&&((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))))))};return function(){function e(t){w(this,e);try{if(this.trackers=[],this.workflows={},this.test=t.test,this.debug=t.debug,this.disabled=!P(t),this.disabled&&console.log("Telemetry Disabled"),t.portal&&t.portal.user){var n=t.portal.subscriptionInfo||{};this.setUser(t.portal.user,n.type)}else t.user&&this.setUser(t.user);this.disabled||this._initTrackers(t)}catch(e){console.error("Telemetry Disabled"),console.error(e),this.disabled=!0}}return k(e,[{key:"_initTrackers",value:function(e){if(e.amazon){var t=new S(e.amazon);this.trackers.push(t)}if(e.google){var n=new T(e.google);this.trackers.push(n)}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 n=void 0;if(e.email&&e.email.split){var r=e.email.split("@")[1];n=I.filter(function(e){return r===e}).length>0}(n||["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]:{},n=this.preProcess(t);if(this.debug&&console.log("Tracking page view",JSON.stringify(n)),this.test&&!this.disabled)return n;var r=this.trackers.filter(function(e){return!e.disabled});if(!r.length||this.disabled)return this.disabled||console.error(new Error("Page view was not logged because no trackers are configured.")),!1;var i=r.map(function(t){return t.logPageView(e,n)});return Promise.all(i).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 n=this.trackers.filter(function(e){return!e.disabled});if(!n.length||this.disabled)return this.disabled||console.error(new Error("Event was not logged because no trackers are configured.")),!1;var r=n.map(function(e){return e.logEvent(t)});return Promise.all(r).then(),!0}},{key:"logError",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=b({eventType:"error"},e);this.logEvent(t)}},{key:"startWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={name:e,start:Date.now(),steps:[],workflowId:Math.floor(17592186044416*(1+Math.random())).toString(16)};this._saveWorkflow(n);var r=b({name:e,step:"start"},t);return this._logWorkflow(r),n}},{key:"stepWorkflow",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r="string"==typeof options?n:n.details,i=b({name:e,step:t,details:r},n);this._logWorkflow(i)}},{key:"endWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=b({name:e,step:"finish"},t);this._logWorkflow(n)}},{key:"cancelWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=b({name:e,step:"cancel"},t);this._logWorkflow(n)}},{key:"getWorkflow",value:function(e){var t=p.get("TELEMETRY-WORKFLOW:"+e);if(t){if(Date.now()-t.start<18e5)return t;this._deleteWorkflow(t)}}},{key:"_saveWorkflow",value:function(e){p.set("TELEMETRY-WORKFLOW:"+e.name,e)}},{key:"_deleteWorkflow",value:function(e){p.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 n=b(e,{eventType:"workflow",category:e.name,action:e.step,label:e.details,duration:t.duration,workflowId:t.workflowId});this.logEvent(n)}},{key:"preProcess",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={};return this.user&&(t={user:O(this.user.username),org:O(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),b({},e,t)}},{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)}}]),e}()}); | ||
//# sourceMappingURL=telemetry.dojo.min.js.map |
@@ -783,4 +783,8 @@ (function (global, factory) { | ||
if (this.test && !this.disabled) return attributes; | ||
var trackers = this.trackers.filter(function (_ref) { | ||
var disabled = _ref.disabled; | ||
return !disabled; | ||
}); | ||
if (!this.trackers.length || this.disabled) { | ||
if (!trackers.length || this.disabled) { | ||
if (!this.disabled) console.error(new Error('Page view was not logged because no trackers are configured.')); | ||
@@ -790,3 +794,3 @@ return false; | ||
var promises = this.trackers.map(function (tracker) { | ||
var promises = trackers.map(function (tracker) { | ||
return tracker.logPageView(page, attributes); | ||
@@ -807,4 +811,8 @@ }); | ||
if (this.test) return event; | ||
var trackers = this.trackers.filter(function (_ref2) { | ||
var disabled = _ref2.disabled; | ||
return !disabled; | ||
}); | ||
if (!this.trackers.length || this.disabled) { | ||
if (!trackers.length || this.disabled) { | ||
if (!this.disabled) console.error(new Error('Event was not logged because no trackers are configured.')); | ||
@@ -814,3 +822,3 @@ return false; | ||
var promises = this.trackers.map(function (tracker) { | ||
var promises = trackers.map(function (tracker) { | ||
return tracker.logEvent(event); | ||
@@ -953,2 +961,24 @@ }); | ||
} | ||
}, { | ||
key: 'disableTracker', | ||
value: function disableTracker(trackerName) { | ||
var tracker = this.trackers.find(function (_ref3) { | ||
var name = _ref3.name; | ||
return name === trackerName; | ||
}); | ||
if (tracker) { | ||
tracker.disabled = true; | ||
} | ||
} | ||
}, { | ||
key: 'enableTracker', | ||
value: function enableTracker(trackerName) { | ||
var tracker = this.trackers.find(function (_ref4) { | ||
var name = _ref4.name; | ||
return name === trackerName; | ||
}); | ||
if (tracker) { | ||
tracker.disabled = false; | ||
} | ||
} | ||
}]); | ||
@@ -955,0 +985,0 @@ return Telemetry; |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("analytics"),require("@analytics/aws-pinpoint")):"function"==typeof define&&define.amd?define("telemetry",["analytics","@analytics/aws-pinpoint"],t):e.Telemetry=t(e.Analytics,e.awsPinpointPlugin)}(this,function(e,t){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=!0===t.fips?"-fips":"",r="https://cognito-identity"+n+".us-east-1.amazonaws.com/",i=v.get(y);if(i&&Date.now()/1e3<i.Expiration)return Promise.resolve(i);var o={method:"POST",headers:{"Content-type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityService.GetId"},body:JSON.stringify({IdentityPoolId:e})};return fetch(r,o).then(function(e){if(!e.ok)throw new Error(e.statusText);return e.json()}).then(function(e){var t=e.IdentityId,n={method:"POST",headers:{"Content-type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityService.GetCredentialsForIdentity"},body:JSON.stringify({IdentityId:t})};return fetch(r,n)}).then(function(e){if(!e.ok)throw new Error(e.statusText);return e.json()}).then(function(e){var t=e.Credentials;return v.set(y,t),t})}function r(e){var t=e.telemetryData,n=e.dimensionLookup,r=void 0===n?{}:n,s=e.excludeKeys,a=void 0===s?[]:s;return Object.keys(t).filter(function(e){return!a.includes(e)}).map(function(e){return r[e]?{key:o(r,e),value:t[e]}:{key:e,value:i(t,e)}}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function i(e,t){return"json"===t?e[t]?JSON.stringify(e[t]):"null":void 0===e[t]?"null":e[t].toString()}function o(e,t){return"dimension"+e[t]}function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).filter(function(e){return t[e]||m.includes(e)}).map(function(n){return t[n]?{key:a(t,n),value:e[n]}:{key:n,value:e[n]}}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function a(e,t){return"metric"+e[t]}function u(e){var t=e.event,n=void 0===t?{}:t,i=e.dimensionLookup,o=void 0===i?{}:i,a=e.metricLookup,u=void 0===a?{}:a,c=n.eventType,l=void 0===c?"other":c,f=s(n,u),h=r({telemetryData:b({eventType:l},n),dimensionLookup:o,excludeKeys:["workflow"].concat(_(Object.keys(f)),_(Object.keys(u)))});return{name:l,attributes:b({referrer:document.referrer,hostname:window.location.hostname,path:window.location.pathname},h),metrics:f}}function c(e){var t=e.page,n=e.previousPage,i=void 0===n?{}:n,o=e.options,a=void 0===o?{}:o,u=e.dimensionLookup,c=void 0===u?{}:u,l=e.metricLookup,f=void 0===l?{}:l,h=s(a,f),d=r({telemetryData:a,dimensionLookup:c,excludeKeys:["workflow"].concat(_(Object.keys(h)),_(Object.keys(f)))}),g=document||{},p=g.referrer,v=g.title,y=window&&window.location?window.location:{},m=y.hostname,w=y.pathname;return{name:"pageView",attributes:b({referrer:p,hostname:m,path:t||w,pageUrl:t||w,pageName:v,previousPageUrl:i.pageUrl,previousPageName:i.pageName},d),metrics:h}}function l(e){var t=e.customTelemetryData,n=void 0===t?{}:t,r=e.dimensionLookup,i=void 0===r?{}:r,o=e.metricLookup,s=void 0===o?{}:o;return Object.keys(n).map(function(e){return i[e]?{key:f(i,e),value:n[e]}:s[e]?{key:h(s,e),value:n[e]}:void 0}).filter(function(e){return e}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function f(e,t){return"dimension"+e[t]}function h(e,t){return"metric"+e[t]}function d(e){window.ga?window.ga(function(){e(window.ga.getAll())}):console.log(new Error("Google Analytics trackers not available"))}function g(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i={hitType:"pageview",page:e||window.location.pathname},o=l({customTelemetryData:t,dimensionLookup:n,metricLookup:r});return b({},i,o)}function p(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r={hitType:"event",eventCategory:e.category||"none",eventAction:e.action,eventLabel:e.label},i=l({customTelemetryData:e,dimensionLookup:t,metricLookup:n});return b({},r,i)}e="default"in e?e.default:e,t="default"in t?t.default:t;var v={storage:{},memory:!0,get:function(e){var t=void 0;try{t=window.localStorage&&window.localStorage.getItem(e)||this.storage[e]}catch(n){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(n){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]}}},y="TELEMETRY_COGNITO_CREDENTIALS",m=["size","duration","position","number","count"],w=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},k=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),b=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)},S=function(){function r(i){w(this,r);var o=i.app,s=void 0===o?{}:o,a=i.fips,u=i.userPoolID;this.analytics=e({app:s.name,plugins:[t({fips:a,pinpointAppId:s.id,getCredentials:function(){return n(u,{fips:a})}})]}),this.name="amazon",b(this,i)}return k(r,[{key:"logPageView",value:function(e,t){var n=c({page:e,previousPage:this.previousPage,options:t,dimensionLookup:this.dimensions,metricLookup:this.metrics});this.previousPage=n.attributes,this.analytics.track("pageView",n)}},{key:"logEvent",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=u({event:e,dimensionLookup:this.dimensions,metricLookup:this.metrics}),n=t.name;this.analytics.track(n,t)}}]),r}(),T=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};w(this,e),this.name="google",b(this,t)}return k(e,[{key:"logPageView",value:function(e,t){var n=g(e,t,this.dimensions,this.metrics);d(function(e){e.forEach(function(e){e.send(n)})})}},{key:"logEvent",value:function(e){var t=p(e,this.dimensions,this.metrics);d(function(e){e.forEach(function(e){e.send(t)})})}}]),e}(),E=function(e,t){var n={},r=n.lib={},i=function(){},o=r.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=r.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||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i<e;i++)t[r+i>>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(n.length>65535)for(i=0;i<e;i+=4)t[r+i>>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r<t;r+=4)n.push(4294967296*e.random()|0);return new s.init(n,t)}}),a=n.enc={},u=a.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r<e;r++){var i=t[r>>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r<e;r++)n.push(String.fromCharCode(t[r>>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=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=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.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 u=0;u<t;u+=o)this._doProcessBlock(r,u);u=r.splice(0,t),n.sigBytes-=i}return new s.init(u,i)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});r.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,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new h.HMAC.init(e,n).finalize(t)}}});var h=n.algo={};return n}(Math);!function(e){for(var t=E,n=t.lib,r=n.WordArray,i=n.Hasher,n=t.algo,o=[],s=[],a=function(e){return 4294967296*(e-(0|e))|0},u=2,c=0;c<64;){var l;e:{l=u;for(var f=e.sqrt(l),h=2;h<=f;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(c<8&&(o[c]=a(e.pow(u,.5))),s[c]=a(e.pow(u,1/3)),c++),u++}var d=[],n=n.SHA256=i.extend({_doReset:function(){this._hash=new r.init(o.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],u=n[4],c=n[5],l=n[6],f=n[7],h=0;h<64;h++){if(h<16)d[h]=0|e[t+h];else{var g=d[h-15],p=d[h-2];d[h]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[h-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+d[h-16]}g=f+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[h]+d[h],p=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),f=l,l=c,c=u,u=a+g|0,a=o,o=i,i=r,r=g+p|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+f|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(n),t.HmacSHA256=i._createHmacHelper(n)}(Math),function(){var e=E,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,n){e=this._hasher=new e.init,"string"==typeof n&&(n=t.parse(n));var r=e.blockSize,i=4*r;n.sigBytes>i&&(n=e.finalize(n)),n.clamp();for(var o=this._oKey=n.clone(),s=this._iKey=n.clone(),a=o.words,u=s.words,c=0;c<r;c++)a[c]^=1549556828,u[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 O=function(e){if(e)return E.SHA256(e).toString(E.enc.Hex)},P=["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"],I=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.portal||{};return!e.disabled&&("1"!==navigator.doNotTrack&&"1"!==window.doNotTrack&&((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))))))};return function(){function e(t){w(this,e);try{if(this.trackers=[],this.workflows={},this.test=t.test,this.debug=t.debug,this.disabled=!I(t),this.disabled&&console.log("Telemetry Disabled"),t.portal&&t.portal.user){var n=t.portal.subscriptionInfo||{};this.setUser(t.portal.user,n.type)}else t.user&&this.setUser(t.user);this.disabled||this._initTrackers(t)}catch(e){console.error("Telemetry Disabled"),console.error(e),this.disabled=!0}}return k(e,[{key:"_initTrackers",value:function(e){if(e.amazon){var t=new S(e.amazon);this.trackers.push(t)}if(e.google){var n=new T(e.google);this.trackers.push(n)}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 n=void 0;if(e.email&&e.email.split){var r=e.email.split("@")[1];n=P.filter(function(e){return r===e}).length>0}(n||["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]:{},n=this.preProcess(t);if(this.debug&&console.log("Tracking page view",JSON.stringify(n)),this.test&&!this.disabled)return n;if(!this.trackers.length||this.disabled)return this.disabled||console.error(new Error("Page view was not logged because no trackers are configured.")),!1;var r=this.trackers.map(function(t){return t.logPageView(e,n)});return Promise.all(r).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;if(!this.trackers.length||this.disabled)return this.disabled||console.error(new Error("Event was not logged because no trackers are configured.")),!1;var n=this.trackers.map(function(e){return e.logEvent(t)});return Promise.all(n).then(),!0}},{key:"logError",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=b({eventType:"error"},e);this.logEvent(t)}},{key:"startWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={name:e,start:Date.now(),steps:[],workflowId:Math.floor(17592186044416*(1+Math.random())).toString(16)};this._saveWorkflow(n);var r=b({name:e,step:"start"},t);return this._logWorkflow(r),n}},{key:"stepWorkflow",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r="string"==typeof options?n:n.details,i=b({name:e,step:t,details:r},n);this._logWorkflow(i)}},{key:"endWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=b({name:e,step:"finish"},t);this._logWorkflow(n)}},{key:"cancelWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=b({name:e,step:"cancel"},t);this._logWorkflow(n)}},{key:"getWorkflow",value:function(e){var t=v.get("TELEMETRY-WORKFLOW:"+e);if(t){if(Date.now()-t.start<18e5)return t;this._deleteWorkflow(t)}}},{key:"_saveWorkflow",value:function(e){v.set("TELEMETRY-WORKFLOW:"+e.name,e)}},{key:"_deleteWorkflow",value:function(e){v.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 n=b(e,{eventType:"workflow",category:e.name,action:e.step,label:e.details,duration:t.duration,workflowId:t.workflowId});this.logEvent(n)}},{key:"preProcess",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={};return this.user&&(t={user:O(this.user.username),org:O(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),b({},e,t)}}]),e}()}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("analytics"),require("@analytics/aws-pinpoint")):"function"==typeof define&&define.amd?define("telemetry",["analytics","@analytics/aws-pinpoint"],t):e.Telemetry=t(e.Analytics,e.awsPinpointPlugin)}(this,function(e,t){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=!0===t.fips?"-fips":"",r="https://cognito-identity"+n+".us-east-1.amazonaws.com/",i=p.get(y);if(i&&Date.now()/1e3<i.Expiration)return Promise.resolve(i);var o={method:"POST",headers:{"Content-type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityService.GetId"},body:JSON.stringify({IdentityPoolId:e})};return fetch(r,o).then(function(e){if(!e.ok)throw new Error(e.statusText);return e.json()}).then(function(e){var t=e.IdentityId,n={method:"POST",headers:{"Content-type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityService.GetCredentialsForIdentity"},body:JSON.stringify({IdentityId:t})};return fetch(r,n)}).then(function(e){if(!e.ok)throw new Error(e.statusText);return e.json()}).then(function(e){var t=e.Credentials;return p.set(y,t),t})}function r(e){var t=e.telemetryData,n=e.dimensionLookup,r=void 0===n?{}:n,s=e.excludeKeys,a=void 0===s?[]:s;return Object.keys(t).filter(function(e){return!a.includes(e)}).map(function(e){return r[e]?{key:o(r,e),value:t[e]}:{key:e,value:i(t,e)}}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function i(e,t){return"json"===t?e[t]?JSON.stringify(e[t]):"null":void 0===e[t]?"null":e[t].toString()}function o(e,t){return"dimension"+e[t]}function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).filter(function(e){return t[e]||m.includes(e)}).map(function(n){return t[n]?{key:a(t,n),value:e[n]}:{key:n,value:e[n]}}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function a(e,t){return"metric"+e[t]}function u(e){var t=e.event,n=void 0===t?{}:t,i=e.dimensionLookup,o=void 0===i?{}:i,a=e.metricLookup,u=void 0===a?{}:a,c=n.eventType,l=void 0===c?"other":c,f=s(n,u),h=r({telemetryData:b({eventType:l},n),dimensionLookup:o,excludeKeys:["workflow"].concat(_(Object.keys(f)),_(Object.keys(u)))});return{name:l,attributes:b({referrer:document.referrer,hostname:window.location.hostname,path:window.location.pathname},h),metrics:f}}function c(e){var t=e.page,n=e.previousPage,i=void 0===n?{}:n,o=e.options,a=void 0===o?{}:o,u=e.dimensionLookup,c=void 0===u?{}:u,l=e.metricLookup,f=void 0===l?{}:l,h=s(a,f),d=r({telemetryData:a,dimensionLookup:c,excludeKeys:["workflow"].concat(_(Object.keys(h)),_(Object.keys(f)))}),g=document||{},v=g.referrer,p=g.title,y=window&&window.location?window.location:{},m=y.hostname,w=y.pathname;return{name:"pageView",attributes:b({referrer:v,hostname:m,path:t||w,pageUrl:t||w,pageName:p,previousPageUrl:i.pageUrl,previousPageName:i.pageName},d),metrics:h}}function l(e){var t=e.customTelemetryData,n=void 0===t?{}:t,r=e.dimensionLookup,i=void 0===r?{}:r,o=e.metricLookup,s=void 0===o?{}:o;return Object.keys(n).map(function(e){return i[e]?{key:f(i,e),value:n[e]}:s[e]?{key:h(s,e),value:n[e]}:void 0}).filter(function(e){return e}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function f(e,t){return"dimension"+e[t]}function h(e,t){return"metric"+e[t]}function d(e){window.ga?window.ga(function(){e(window.ga.getAll())}):console.log(new Error("Google Analytics trackers not available"))}function g(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i={hitType:"pageview",page:e||window.location.pathname},o=l({customTelemetryData:t,dimensionLookup:n,metricLookup:r});return b({},i,o)}function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r={hitType:"event",eventCategory:e.category||"none",eventAction:e.action,eventLabel:e.label},i=l({customTelemetryData:e,dimensionLookup:t,metricLookup:n});return b({},r,i)}e="default"in e?e.default:e,t="default"in t?t.default:t;var p={storage:{},memory:!0,get:function(e){var t=void 0;try{t=window.localStorage&&window.localStorage.getItem(e)||this.storage[e]}catch(n){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(n){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]}}},y="TELEMETRY_COGNITO_CREDENTIALS",m=["size","duration","position","number","count"],w=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},k=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),b=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)},T=function(){function r(i){w(this,r);var o=i.app,s=void 0===o?{}:o,a=i.fips,u=i.userPoolID;this.analytics=e({app:s.name,plugins:[t({fips:a,pinpointAppId:s.id,getCredentials:function(){return n(u,{fips:a})}})]}),this.name="amazon",b(this,i)}return k(r,[{key:"logPageView",value:function(e,t){var n=c({page:e,previousPage:this.previousPage,options:t,dimensionLookup:this.dimensions,metricLookup:this.metrics});this.previousPage=n.attributes,this.analytics.track("pageView",n)}},{key:"logEvent",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=u({event:e,dimensionLookup:this.dimensions,metricLookup:this.metrics}),n=t.name;this.analytics.track(n,t)}}]),r}(),S=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};w(this,e),this.name="google",b(this,t)}return k(e,[{key:"logPageView",value:function(e,t){var n=g(e,t,this.dimensions,this.metrics);d(function(e){e.forEach(function(e){e.send(n)})})}},{key:"logEvent",value:function(e){var t=v(e,this.dimensions,this.metrics);d(function(e){e.forEach(function(e){e.send(t)})})}}]),e}(),E=function(e,t){var n={},r=n.lib={},i=function(){},o=r.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=r.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||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i<e;i++)t[r+i>>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(n.length>65535)for(i=0;i<e;i+=4)t[r+i>>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r<t;r+=4)n.push(4294967296*e.random()|0);return new s.init(n,t)}}),a=n.enc={},u=a.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r<e;r++){var i=t[r>>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r<e;r++)n.push(String.fromCharCode(t[r>>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=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=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.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 u=0;u<t;u+=o)this._doProcessBlock(r,u);u=r.splice(0,t),n.sigBytes-=i}return new s.init(u,i)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});r.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,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new h.HMAC.init(e,n).finalize(t)}}});var h=n.algo={};return n}(Math);!function(e){for(var t=E,n=t.lib,r=n.WordArray,i=n.Hasher,n=t.algo,o=[],s=[],a=function(e){return 4294967296*(e-(0|e))|0},u=2,c=0;c<64;){var l;e:{l=u;for(var f=e.sqrt(l),h=2;h<=f;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(c<8&&(o[c]=a(e.pow(u,.5))),s[c]=a(e.pow(u,1/3)),c++),u++}var d=[],n=n.SHA256=i.extend({_doReset:function(){this._hash=new r.init(o.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],u=n[4],c=n[5],l=n[6],f=n[7],h=0;h<64;h++){if(h<16)d[h]=0|e[t+h];else{var g=d[h-15],v=d[h-2];d[h]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[h-7]+((v<<15|v>>>17)^(v<<13|v>>>19)^v>>>10)+d[h-16]}g=f+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[h]+d[h],v=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),f=l,l=c,c=u,u=a+g|0,a=o,o=i,i=r,r=g+v|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+f|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(n),t.HmacSHA256=i._createHmacHelper(n)}(Math),function(){var e=E,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,n){e=this._hasher=new e.init,"string"==typeof n&&(n=t.parse(n));var r=e.blockSize,i=4*r;n.sigBytes>i&&(n=e.finalize(n)),n.clamp();for(var o=this._oKey=n.clone(),s=this._iKey=n.clone(),a=o.words,u=s.words,c=0;c<r;c++)a[c]^=1549556828,u[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 O=function(e){if(e)return E.SHA256(e).toString(E.enc.Hex)},P=["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"],I=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.portal||{};return!e.disabled&&("1"!==navigator.doNotTrack&&"1"!==window.doNotTrack&&((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))))))};return function(){function e(t){w(this,e);try{if(this.trackers=[],this.workflows={},this.test=t.test,this.debug=t.debug,this.disabled=!I(t),this.disabled&&console.log("Telemetry Disabled"),t.portal&&t.portal.user){var n=t.portal.subscriptionInfo||{};this.setUser(t.portal.user,n.type)}else t.user&&this.setUser(t.user);this.disabled||this._initTrackers(t)}catch(e){console.error("Telemetry Disabled"),console.error(e),this.disabled=!0}}return k(e,[{key:"_initTrackers",value:function(e){if(e.amazon){var t=new T(e.amazon);this.trackers.push(t)}if(e.google){var n=new S(e.google);this.trackers.push(n)}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 n=void 0;if(e.email&&e.email.split){var r=e.email.split("@")[1];n=P.filter(function(e){return r===e}).length>0}(n||["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]:{},n=this.preProcess(t);if(this.debug&&console.log("Tracking page view",JSON.stringify(n)),this.test&&!this.disabled)return n;var r=this.trackers.filter(function(e){return!e.disabled});if(!r.length||this.disabled)return this.disabled||console.error(new Error("Page view was not logged because no trackers are configured.")),!1;var i=r.map(function(t){return t.logPageView(e,n)});return Promise.all(i).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 n=this.trackers.filter(function(e){return!e.disabled});if(!n.length||this.disabled)return this.disabled||console.error(new Error("Event was not logged because no trackers are configured.")),!1;var r=n.map(function(e){return e.logEvent(t)});return Promise.all(r).then(),!0}},{key:"logError",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=b({eventType:"error"},e);this.logEvent(t)}},{key:"startWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={name:e,start:Date.now(),steps:[],workflowId:Math.floor(17592186044416*(1+Math.random())).toString(16)};this._saveWorkflow(n);var r=b({name:e,step:"start"},t);return this._logWorkflow(r),n}},{key:"stepWorkflow",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r="string"==typeof options?n:n.details,i=b({name:e,step:t,details:r},n);this._logWorkflow(i)}},{key:"endWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=b({name:e,step:"finish"},t);this._logWorkflow(n)}},{key:"cancelWorkflow",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=b({name:e,step:"cancel"},t);this._logWorkflow(n)}},{key:"getWorkflow",value:function(e){var t=p.get("TELEMETRY-WORKFLOW:"+e);if(t){if(Date.now()-t.start<18e5)return t;this._deleteWorkflow(t)}}},{key:"_saveWorkflow",value:function(e){p.set("TELEMETRY-WORKFLOW:"+e.name,e)}},{key:"_deleteWorkflow",value:function(e){p.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 n=b(e,{eventType:"workflow",category:e.name,action:e.step,label:e.details,duration:t.duration,workflowId:t.workflowId});this.logEvent(n)}},{key:"preProcess",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={};return this.user&&(t={user:O(this.user.username),org:O(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),b({},e,t)}},{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)}}]),e}()}); | ||
//# sourceMappingURL=telemetry.min.js.map |
{ | ||
"name": "@esri/telemetry", | ||
"version": "3.0.2", | ||
"version": "3.1.0", | ||
"description": "A JavaScript Implementation of the ArcGIS Telemetry Specification", | ||
@@ -5,0 +5,0 @@ "main": "dist/telemetry.js", |
@@ -245,2 +245,28 @@ # Telemetry.js | ||
Additionally, you can disable individual trackers when initializing the `Telemetry` object by passing `disabled: true` in the tracker options. | ||
```js | ||
{ | ||
google: { | ||
disabled: true, | ||
... | ||
}, | ||
amazon: { | ||
disabled: false, | ||
... | ||
} | ||
} | ||
``` | ||
Post initialization, it is possible to disable & enable specific trackers using `disableTracker` and `enableTracker` methods. | ||
```js | ||
telemetry.disableTracker('google') | ||
telemetry.logPageView() // no google page view logged | ||
telemetry.logEvent() // no google event logged | ||
telemetry.enableTracker('google') | ||
telemetry.logPageView() // google page view logged | ||
telemetry.logEvent() // google event logged | ||
``` | ||
## Develop | ||
@@ -247,0 +273,0 @@ |
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
461188
2744
304