@esri/telemetry
Advanced tools
Comparing version 2.0.0-beta.10 to 2.0.0-beta.11
@@ -7,2 +7,9 @@ # Change Log | ||
## Unreleased | ||
## Changed | ||
* Remove handrolled code that send telemetry via the deprecated AWS mobileanalytics service | ||
* Use "analytics" library to send telemetry via AWS pinpoint service | ||
* Add option to use FIPS compliant pinpoint endpoints | ||
* Require `analytics` and `@analytics/aws-pinpoint` as peer dependencies if amazon tracker to be used | ||
## [2.0.0] - 02/18/2021 | ||
@@ -9,0 +16,0 @@ ### Changed |
@@ -34,3 +34,3 @@ { | ||
"analytics": "^0.7.3", | ||
"zanalytics-aws-pinpoint": "^0.4.2-beta.1" | ||
"rgwozdz-aws-pinpoint": "0.1.0-alpha.0" | ||
}, | ||
@@ -42,3 +42,4 @@ "peerDependencies": {}, | ||
"document", | ||
"XMLHttpRequest" | ||
"XMLHttpRequest", | ||
"fetch" | ||
], | ||
@@ -45,0 +46,0 @@ "ignore": [ |
@@ -1,2 +0,2 @@ | ||
define('telemetry', ['analytics', 'zanalytics-aws-pinpoint'], function (Analytics, awsPinpointPlugin) { 'use strict'; | ||
define('telemetry', ['analytics', 'rgwozdz-aws-pinpoint'], function (Analytics, awsPinpointPlugin) { 'use strict'; | ||
@@ -53,9 +53,12 @@ Analytics = 'default' in Analytics ? Analytics['default'] : Analytics; | ||
var COGNITO_KEY = 'TELEMETRY_COGNITO_CREDENTIALS'; | ||
var COGNITO_URL = 'https://cognito-identity.us-east-1.amazonaws.com/'; | ||
function getCredentials(IdentityPoolId) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var fipsSubdomainSuffix = options.fips === 'true' ? '-fips' : ''; | ||
var COGNITO_URL = 'https://cognito-identity' + fipsSubdomainSuffix + '.us-east-1.amazonaws.com/'; | ||
var cached = Storage.get(COGNITO_KEY); | ||
if (cached && Date.now() / 1000 < cached.Expiration) return Promise.resolve(cached); | ||
var options = { | ||
var fetchOptions = { | ||
method: 'POST', | ||
@@ -69,3 +72,3 @@ headers: { | ||
return fetch(COGNITO_URL, options).then(function (response) { | ||
return fetch(COGNITO_URL, fetchOptions).then(function (response) { | ||
if (!response.ok) { | ||
@@ -337,8 +340,8 @@ throw new Error(response.statusText); | ||
this.analytics = Analytics({ | ||
app: 'Hub Analytics', | ||
app: options.app.name, | ||
plugins: [awsPinpointPlugin({ | ||
fips: options.fips, | ||
pinpointAppId: 'de54da32bb1f44e682ba1adcdc71762e', | ||
pinpointAppId: options.app.id, | ||
getCredentials: function getCredentials$$1() { | ||
return getCredentials('us-east-1:7345bcf2-bffa-4849-a379-a83178f63eef'); | ||
return getCredentials(options.userPoolID); | ||
} | ||
@@ -350,9 +353,2 @@ })] | ||
_extends(this, options); | ||
// const session = getUser().session | ||
// if (session.new && !options.test) { | ||
// this.logEvent({ eventType: '_session.start' }) | ||
// .catch(err => { | ||
// console.error(`Failed to log _session.start: ${err.message}`) | ||
// }) | ||
// } | ||
} | ||
@@ -372,3 +368,2 @@ | ||
this.analytics.track('pageView', telemetryPayload); | ||
//return sendTelemetry(telemetryPayload, this.userPoolID, this.app) | ||
} | ||
@@ -383,4 +378,3 @@ }, { | ||
}); | ||
this.analytics.track(event.eventTyp, telemetryPayload); | ||
//return sendTelemetry(telemetryPayload, this.userPoolID, this.app) | ||
this.analytics.track(event.eventType, telemetryPayload); | ||
} | ||
@@ -387,0 +381,0 @@ }]); |
@@ -1,2 +0,2 @@ | ||
define("telemetry",["analytics","zanalytics-aws-pinpoint"],function(e,t){"use strict";function n(e){var t=p.get(y);if(t&&Date.now()/1e3<t.Expiration)return Promise.resolve(t);var n={method:"POST",headers:{"Content-type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityService.GetId"},body:JSON.stringify({IdentityPoolId:e})};return fetch(m,n).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(m,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]||w.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=e.dimensionLookup,i=void 0===n?{}:n,o=e.metricLookup,a=void 0===o?{}:o,u=s(t,a),c=r({telemetryData:t,dimensionLookup:i,excludeKeys:["workflow"].concat(S(Object.keys(u)),S(Object.keys(a)))});return{name:t.eventType||"other",attributes:_({referrer:document.referrer,hostname:window.location.hostname,path:window.location.pathname},c),metrics:u}}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(S(Object.keys(h)),S(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:_({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 _({},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 _({},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="https://cognito-identity.us-east-1.amazonaws.com/",w=["size","duration","position","number","count"],k=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},b=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}}(),_=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},S=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){k(this,r),this.analytics=e({app:"Hub Analytics",plugins:[t({fips:i.fips,pinpointAppId:"de54da32bb1f44e682ba1adcdc71762e",getCredentials:function(){return n("us-east-1:7345bcf2-bffa-4849-a379-a83178f63eef")}})]}),this.name="amazon",_(this,i)}return b(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(e){var t=u({event:e,dimensionLookup:this.dimensions,metricLookup:this.metrics});this.analytics.track(e.eventTyp,t)}}]),r}(),E=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};k(this,e),this.name="google",_(this,t)}return b(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}(),O=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=O,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=O,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 I=function(e){if(e)return O.SHA256(e).toString(O.enc.Hex)},L=["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){k(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 b(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 E(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=L.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=_({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=_({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=_({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=_({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=_({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=_(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:I(this.user.username),org:I(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),_({},e,t)}}]),e}()}); | ||
define("telemetry",["analytics","rgwozdz-aws-pinpoint"],function(e,t){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="true"===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=e.dimensionLookup,i=void 0===n?{}:n,o=e.metricLookup,a=void 0===o?{}:o,u=s(t,a),c=r({telemetryData:t,dimensionLookup:i,excludeKeys:["workflow"].concat(_(Object.keys(u)),_(Object.keys(a)))});return{name:t.eventType||"other",attributes:b({referrer:document.referrer,hostname:window.location.hostname,path:window.location.pathname},c),metrics:u}}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),this.analytics=e({app:i.app.name,plugins:[t({fips:i.fips,pinpointAppId:i.app.id,getCredentials:function(){return n(i.userPoolID)}})]}),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(e){var t=u({event:e,dimensionLookup:this.dimensions,metricLookup:this.metrics});this.analytics.track(e.eventType,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}()}); | ||
//# sourceMappingURL=telemetry.amd.min.js.map |
@@ -1,2 +0,2 @@ | ||
define(['analytics', 'zanalytics-aws-pinpoint'], function (Analytics, awsPinpointPlugin) { 'use strict'; | ||
define(['analytics', 'rgwozdz-aws-pinpoint'], function (Analytics, awsPinpointPlugin) { 'use strict'; | ||
@@ -53,9 +53,12 @@ Analytics = 'default' in Analytics ? Analytics['default'] : Analytics; | ||
var COGNITO_KEY = 'TELEMETRY_COGNITO_CREDENTIALS'; | ||
var COGNITO_URL = 'https://cognito-identity.us-east-1.amazonaws.com/'; | ||
function getCredentials(IdentityPoolId) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var fipsSubdomainSuffix = options.fips === 'true' ? '-fips' : ''; | ||
var COGNITO_URL = 'https://cognito-identity' + fipsSubdomainSuffix + '.us-east-1.amazonaws.com/'; | ||
var cached = Storage.get(COGNITO_KEY); | ||
if (cached && Date.now() / 1000 < cached.Expiration) return Promise.resolve(cached); | ||
var options = { | ||
var fetchOptions = { | ||
method: 'POST', | ||
@@ -69,3 +72,3 @@ headers: { | ||
return fetch(COGNITO_URL, options).then(function (response) { | ||
return fetch(COGNITO_URL, fetchOptions).then(function (response) { | ||
if (!response.ok) { | ||
@@ -337,8 +340,8 @@ throw new Error(response.statusText); | ||
this.analytics = Analytics({ | ||
app: 'Hub Analytics', | ||
app: options.app.name, | ||
plugins: [awsPinpointPlugin({ | ||
fips: options.fips, | ||
pinpointAppId: 'de54da32bb1f44e682ba1adcdc71762e', | ||
pinpointAppId: options.app.id, | ||
getCredentials: function getCredentials$$1() { | ||
return getCredentials('us-east-1:7345bcf2-bffa-4849-a379-a83178f63eef'); | ||
return getCredentials(options.userPoolID); | ||
} | ||
@@ -350,9 +353,2 @@ })] | ||
_extends(this, options); | ||
// const session = getUser().session | ||
// if (session.new && !options.test) { | ||
// this.logEvent({ eventType: '_session.start' }) | ||
// .catch(err => { | ||
// console.error(`Failed to log _session.start: ${err.message}`) | ||
// }) | ||
// } | ||
} | ||
@@ -372,3 +368,2 @@ | ||
this.analytics.track('pageView', telemetryPayload); | ||
//return sendTelemetry(telemetryPayload, this.userPoolID, this.app) | ||
} | ||
@@ -383,4 +378,3 @@ }, { | ||
}); | ||
this.analytics.track(event.eventTyp, telemetryPayload); | ||
//return sendTelemetry(telemetryPayload, this.userPoolID, this.app) | ||
this.analytics.track(event.eventType, telemetryPayload); | ||
} | ||
@@ -387,0 +381,0 @@ }]); |
@@ -1,2 +0,2 @@ | ||
define(["analytics","zanalytics-aws-pinpoint"],function(e,t){"use strict";function n(e){var t=p.get(y);if(t&&Date.now()/1e3<t.Expiration)return Promise.resolve(t);var n={method:"POST",headers:{"Content-type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityService.GetId"},body:JSON.stringify({IdentityPoolId:e})};return fetch(m,n).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(m,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]||w.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=e.dimensionLookup,i=void 0===n?{}:n,o=e.metricLookup,a=void 0===o?{}:o,u=s(t,a),c=r({telemetryData:t,dimensionLookup:i,excludeKeys:["workflow"].concat(S(Object.keys(u)),S(Object.keys(a)))});return{name:t.eventType||"other",attributes:_({referrer:document.referrer,hostname:window.location.hostname,path:window.location.pathname},c),metrics:u}}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(S(Object.keys(h)),S(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:_({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 _({},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 _({},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="https://cognito-identity.us-east-1.amazonaws.com/",w=["size","duration","position","number","count"],k=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},b=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}}(),_=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},S=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){k(this,r),this.analytics=e({app:"Hub Analytics",plugins:[t({fips:i.fips,pinpointAppId:"de54da32bb1f44e682ba1adcdc71762e",getCredentials:function(){return n("us-east-1:7345bcf2-bffa-4849-a379-a83178f63eef")}})]}),this.name="amazon",_(this,i)}return b(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(e){var t=u({event:e,dimensionLookup:this.dimensions,metricLookup:this.metrics});this.analytics.track(e.eventTyp,t)}}]),r}(),E=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};k(this,e),this.name="google",_(this,t)}return b(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}(),O=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=O,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=O,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 I=function(e){if(e)return O.SHA256(e).toString(O.enc.Hex)},L=["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){k(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 b(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 E(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=L.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=_({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=_({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=_({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=_({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=_({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=_(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:I(this.user.username),org:I(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),_({},e,t)}}]),e}()}); | ||
define(["analytics","rgwozdz-aws-pinpoint"],function(e,t){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="true"===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=e.dimensionLookup,i=void 0===n?{}:n,o=e.metricLookup,a=void 0===o?{}:o,u=s(t,a),c=r({telemetryData:t,dimensionLookup:i,excludeKeys:["workflow"].concat(_(Object.keys(u)),_(Object.keys(a)))});return{name:t.eventType||"other",attributes:b({referrer:document.referrer,hostname:window.location.hostname,path:window.location.pathname},c),metrics:u}}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),this.analytics=e({app:i.app.name,plugins:[t({fips:i.fips,pinpointAppId:i.app.id,getCredentials:function(){return n(i.userPoolID)}})]}),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(e){var t=u({event:e,dimensionLookup:this.dimensions,metricLookup:this.metrics});this.analytics.track(e.eventType,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}()}); | ||
//# sourceMappingURL=telemetry.dojo.min.js.map |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('analytics'), require('zanalytics-aws-pinpoint')) : | ||
typeof define === 'function' && define.amd ? define('telemetry', ['analytics', 'zanalytics-aws-pinpoint'], factory) : | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('analytics'), require('rgwozdz-aws-pinpoint')) : | ||
typeof define === 'function' && define.amd ? define('telemetry', ['analytics', 'rgwozdz-aws-pinpoint'], factory) : | ||
(global.Telemetry = factory(global.Analytics,global.awsPinpointPlugin)); | ||
@@ -57,9 +57,12 @@ }(this, (function (Analytics,awsPinpointPlugin) { 'use strict'; | ||
var COGNITO_KEY = 'TELEMETRY_COGNITO_CREDENTIALS'; | ||
var COGNITO_URL = 'https://cognito-identity.us-east-1.amazonaws.com/'; | ||
function getCredentials(IdentityPoolId) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var fipsSubdomainSuffix = options.fips === 'true' ? '-fips' : ''; | ||
var COGNITO_URL = 'https://cognito-identity' + fipsSubdomainSuffix + '.us-east-1.amazonaws.com/'; | ||
var cached = Storage.get(COGNITO_KEY); | ||
if (cached && Date.now() / 1000 < cached.Expiration) return Promise.resolve(cached); | ||
var options = { | ||
var fetchOptions = { | ||
method: 'POST', | ||
@@ -73,3 +76,3 @@ headers: { | ||
return fetch(COGNITO_URL, options).then(function (response) { | ||
return fetch(COGNITO_URL, fetchOptions).then(function (response) { | ||
if (!response.ok) { | ||
@@ -341,8 +344,8 @@ throw new Error(response.statusText); | ||
this.analytics = Analytics({ | ||
app: 'Hub Analytics', | ||
app: options.app.name, | ||
plugins: [awsPinpointPlugin({ | ||
fips: options.fips, | ||
pinpointAppId: 'de54da32bb1f44e682ba1adcdc71762e', | ||
pinpointAppId: options.app.id, | ||
getCredentials: function getCredentials$$1() { | ||
return getCredentials('us-east-1:7345bcf2-bffa-4849-a379-a83178f63eef'); | ||
return getCredentials(options.userPoolID); | ||
} | ||
@@ -354,9 +357,2 @@ })] | ||
_extends(this, options); | ||
// const session = getUser().session | ||
// if (session.new && !options.test) { | ||
// this.logEvent({ eventType: '_session.start' }) | ||
// .catch(err => { | ||
// console.error(`Failed to log _session.start: ${err.message}`) | ||
// }) | ||
// } | ||
} | ||
@@ -376,3 +372,2 @@ | ||
this.analytics.track('pageView', telemetryPayload); | ||
//return sendTelemetry(telemetryPayload, this.userPoolID, this.app) | ||
} | ||
@@ -387,4 +382,3 @@ }, { | ||
}); | ||
this.analytics.track(event.eventTyp, telemetryPayload); | ||
//return sendTelemetry(telemetryPayload, this.userPoolID, this.app) | ||
this.analytics.track(event.eventType, telemetryPayload); | ||
} | ||
@@ -391,0 +385,0 @@ }]); |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("analytics"),require("zanalytics-aws-pinpoint")):"function"==typeof define&&define.amd?define("telemetry",["analytics","zanalytics-aws-pinpoint"],t):e.Telemetry=t(e.Analytics,e.awsPinpointPlugin)}(this,function(e,t){"use strict";function n(e){var t=v.get(y);if(t&&Date.now()/1e3<t.Expiration)return Promise.resolve(t);var n={method:"POST",headers:{"Content-type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityService.GetId"},body:JSON.stringify({IdentityPoolId:e})};return fetch(m,n).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(m,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]||w.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=e.dimensionLookup,i=void 0===n?{}:n,o=e.metricLookup,a=void 0===o?{}:o,u=s(t,a),c=r({telemetryData:t,dimensionLookup:i,excludeKeys:["workflow"].concat(S(Object.keys(u)),S(Object.keys(a)))});return{name:t.eventType||"other",attributes:_({referrer:document.referrer,hostname:window.location.hostname,path:window.location.pathname},c),metrics:u}}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(S(Object.keys(h)),S(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:_({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 _({},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 _({},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="https://cognito-identity.us-east-1.amazonaws.com/",w=["size","duration","position","number","count"],k=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},b=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}}(),_=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},S=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){k(this,r),this.analytics=e({app:"Hub Analytics",plugins:[t({fips:i.fips,pinpointAppId:"de54da32bb1f44e682ba1adcdc71762e",getCredentials:function(){return n("us-east-1:7345bcf2-bffa-4849-a379-a83178f63eef")}})]}),this.name="amazon",_(this,i)}return b(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(e){var t=u({event:e,dimensionLookup:this.dimensions,metricLookup:this.metrics});this.analytics.track(e.eventTyp,t)}}]),r}(),E=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};k(this,e),this.name="google",_(this,t)}return b(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}(),O=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=O,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=O,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 P=function(e){if(e)return O.SHA256(e).toString(O.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"],L=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){k(this,e);try{if(this.trackers=[],this.workflows={},this.test=t.test,this.debug=t.debug,this.disabled=!L(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 b(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 E(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=_({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=_({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=_({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=_({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=_({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=_(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:P(this.user.username),org:P(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),_({},e,t)}}]),e}()}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("analytics"),require("rgwozdz-aws-pinpoint")):"function"==typeof define&&define.amd?define("telemetry",["analytics","rgwozdz-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="true"===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=e.dimensionLookup,i=void 0===n?{}:n,o=e.metricLookup,a=void 0===o?{}:o,u=s(t,a),c=r({telemetryData:t,dimensionLookup:i,excludeKeys:["workflow"].concat(_(Object.keys(u)),_(Object.keys(a)))});return{name:t.eventType||"other",attributes:b({referrer:document.referrer,hostname:window.location.hostname,path:window.location.pathname},c),metrics:u}}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),this.analytics=e({app:i.app.name,plugins:[t({fips:i.fips,pinpointAppId:i.app.id,getCredentials:function(){return n(i.userPoolID)}})]}),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(e){var t=u({event:e,dimensionLookup:this.dimensions,metricLookup:this.metrics});this.analytics.track(e.eventType,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}()}); | ||
//# sourceMappingURL=telemetry.min.js.map |
{ | ||
"name": "@esri/telemetry", | ||
"version": "2.0.0-beta.10", | ||
"version": "2.0.0-beta.11", | ||
"description": "A JavaScript Implementation of the ArcGIS Telemetry Specification", | ||
@@ -39,6 +39,6 @@ "main": "dist/telemetry.js", | ||
"dependencies": { | ||
"analytics": "^0.7.3", | ||
"zanalytics-aws-pinpoint": "^0.4.2-beta.1" | ||
"@analytics/aws-pinpoint": "^0.4.3" | ||
}, | ||
"devDependencies": { | ||
"analytics": "^0.7.4", | ||
"babel-cli": "^6.24.1", | ||
@@ -69,3 +69,6 @@ "babel-plugin-external-helpers": "^6.22.0", | ||
}, | ||
"peerDependencies": {}, | ||
"peerDependencies": { | ||
"analytics": "^0.7.4", | ||
"@analytics/aws-pinpoint": "^0.4.3" | ||
}, | ||
"standard": { | ||
@@ -75,9 +78,9 @@ "globals": [ | ||
"document", | ||
"XMLHttpRequest" | ||
], | ||
"ignore": [ | ||
"src/*.js", | ||
"test.html" | ||
"XMLHttpRequest", | ||
"fetch" | ||
] | ||
} | ||
}, | ||
"files": [ | ||
"dist/**" | ||
] | ||
} |
@@ -13,3 +13,3 @@ # Telemetry.js | ||
## Initialization | ||
## Usage | ||
@@ -19,2 +19,3 @@ ```js | ||
debug: false, // OPTIONAL true || false whether to log each event to the console | ||
// Trackers to use: "amazon" or "google". "google" tracker currently needs no options | ||
amazon: { | ||
@@ -30,2 +31,3 @@ amazon: { | ||
}, | ||
google: {}, | ||
portal: { // Optional portal/self object | ||
@@ -197,4 +199,5 @@ subscriptionInfo: { | ||
- Amazon | ||
- Request your app and user pool ID from (TBD) | ||
- Get your app and user pool ID from AWS Pinpoint instance | ||
- Pass in options for `amazon` when initiating the Telemetry object | ||
- the `fips` option determines if AWS FIPS endpoints are used for cognito and pinpoint requests | ||
@@ -204,2 +207,3 @@ ```js | ||
userPoolID: USER_POOL_ID, | ||
fips: true, // defaults to false | ||
app: { | ||
@@ -206,0 +210,0 @@ name: APP_NAME, |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
273
0
12
450036
3
25
18
2636
+ Added@analytics/aws-pinpoint@0.4.4(transitive)
- Removedanalytics@^0.7.3
- Removedzanalytics-aws-pinpoint@0.4.2-beta.1(transitive)