Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@esri/telemetry

Package Overview
Dependencies
Maintainers
41
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@esri/telemetry - npm Package Compare versions

Comparing version 1.5.1-beta.0 to 1.5.1-beta.1

2

dist/package.json
{
"name": "@esri/telemetry",
"version": "1.5.1-beta.0",
"version": "1.5.1-beta.1",
"description": "A JavaScript Implementation of the ArcGIS Telemetry Specification",

@@ -5,0 +5,0 @@ "main": "dist/telemetry.js",

@@ -51,5 +51,6 @@ define('telemetry', function () { 'use strict';

var COGNITO_URL = 'https://cognito-identity.us-east-1.amazonaws.com/';
function getCredentials(IdentityPoolId, callback) {
function getCredentials(IdentityPoolId) {
var cached = Storage.get(COGNITO_KEY);
if (cached && Date.now() / 1000 < cached.Expiration) return callback(cached);
if (cached && Date.now() / 1000 < cached.Expiration) return cached;

@@ -56,0 +57,0 @@ var options = {

@@ -1,2 +0,2 @@

define("telemetry",function(){"use strict";function e(e,t){var n=q.get(D);if(n&&Date.now()/1e3<n.Expiration)return t(n);var r={method:"POST",headers:{"Content-type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityService.GetId"},body:JSON.stringify({IdentityPoolId:e})};return fetch(j,r).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(j,n)}).then(function(e){if(!e.ok)throw new Error(e.statusText);return e.json()}).then(function(e){var t=e.Credentials;return q.set(D,t),t})}function t(){return{session:n(),id:r()}}function n(){var e=void 0,t=q.get(K);return(!t||Date.now()>t.expiration)&&(e=!0,t=i()),t.expiration=Date.now()+B,q.set(K,t),e&&(t.new=!0),t}function r(){var e=q.get(U);return e||(e=o(),q.set(U,e)),e}function i(){return{id:Math.floor(17592186044416*(1+Math.random())).toString(16),startTimestamp:(new Date).toISOString()}}function o(){return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}function s(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function a(e,t){var n={host:t.uri.host,"content-type":e.config.defaultContentType,accept:e.config.defaultAcceptType,"x-amz-date":f(t.signDate)};t.request.method=t.request.method.toUpperCase(),t.request.body?t.payload=t.request.body:t.request.data&&e.payloadSerializer?t.payload=e.payloadSerializer(t.request.data):delete n["content-type"],t.request.headers=v(n,Object.keys(t.request.headers||{}).reduce(function(e,n){return e[n.toLowerCase()]=t.request.headers[n],e},{})),t.sortedHeaderKeys=Object.keys(t.request.headers).sort(),t.request.headers["content-type"]&&(t.request.headers["content-type"]=t.request.headers["content-type"].split(";")[0]),"object"===M(t.request.params)&&v(t.uri.queryParams,t.request.params)}function u(e,t){t.signedHeaders=t.sortedHeaderKeys.map(function(e){return e.toLowerCase()}).join(";"),t.canonicalRequest=String(t.request.method).toUpperCase()+"\n"+encodeURI(t.uri.path)+"\n"+Object.keys(t.uri.queryParams).sort().map(function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t.uri.queryParams[e])}).join("&")+"\n"+t.sortedHeaderKeys.map(function(e){return e.toLocaleLowerCase()+":"+t.request.headers[e]}).join("\n")+"\n\n"+t.signedHeaders+"\n"+e.hasher.hash(t.payload?t.payload:"")}function c(e,t){t.credentialScope=[f(t.signDate,!0),e.config.region,e.config.service,"aws4_request"].join("/"),t.stringToSign="AWS4-HMAC-SHA256\n"+f(t.signDate)+"\n"+t.credentialScope+"\n"+e.hasher.hash(t.canonicalRequest)}function l(e,t){var n=e.hasher.hmac,r=n(n(n(n("AWS4"+e.config.secretAccessKey,f(t.signDate,!0),{hexOutput:!1}),e.config.region,{hexOutput:!1,textInput:!1}),e.config.service,{hexOutput:!1,textInput:!1}),"aws4_request",{hexOutput:!1,textInput:!1});t.signature=n(r,t.stringToSign,{textInput:!1})}function h(e,t){t.authorization="AWS4-HMAC-SHA256 Credential="+e.config.accessKeyId+"/"+t.credentialScope+", SignedHeaders="+t.signedHeaders+", Signature="+t.signature}function f(e,t){var n=e.toISOString().replace(/[:\-]|\.\d{3}/g,"").substr(0,17);return t?n.substr(0,8):n}function d(){return function(e){return JSON.stringify(e)}}function p(){return function(e){var t=URL?new URL(e):document.createElement("a");return t.href=e,{protocol:t.protocol,host:t.host.replace(/^(.*):((80)|(443))$/,"$1"),path:("/"!==t.pathname.charAt(0)?"/":"")+t.pathname,queryParams:g(t.search)}}}function g(e){return/^\??(.*)$/.exec(e)[1].split("&").reduce(function(e,t){return t=/^(.+)=(.*)$/.exec(t),t&&(e[t[1]]=t[2]),e},{})}function y(){return{hash:function(e,t){t=v({hexOutput:!0,textInput:!0},t);var n=R.SHA256(e);return t.hexOutput?n.toString(R.enc.Hex):n},hmac:function(e,t,n){n=v({hexOutput:!0,textInput:!0},n);var r=R.HmacSHA256(t,e,{asBytes:!0});return n.hexOutput?r.toString(R.enc.Hex):r}}}function v(e){return[].slice.call(arguments,1).forEach(function(t){t&&"object"===(void 0===t?"undefined":M(t))&&Object.keys(t).forEach(function(n){var r=t[n];void 0!==r&&(null!==r&&"object"===(void 0===r?"undefined":M(r))?(e[n]=Array.isArray(r)?[]:{},v(e[n],r)):e[n]=r)})}),e}function m(e,t){if(void 0===e||!e)throw new Error(t)}function w(e){var t=e.telemetryData,n=e.dimensionLookup,r=void 0===n?{}:n,i=e.excludeKeys,o=void 0===i?[]:i;return Object.keys(t).filter(function(e){return!o.includes(e)}).map(function(e){return r[e]?{key:S(r,e),value:t[e]}:{key:e,value:k(t,e)}}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function k(e,t){return"json"===t?e[t]?JSON.stringify(e[t]):"null":void 0===e[t]?"null":e[t].toString()}function S(e,t){return"dimension"+e[t]}function b(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).filter(function(e){return t[e]||G.includes(e)}).map(function(n){return t[n]?{key:_(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 _(e,t){return"metric"+e[t]}function T(e){var t=e.event,n=e.session,r=n.id,i=n.startTimestamp,o=e.dimensionLookup,s=void 0===o?{}:o,a=e.metricLookup,u=void 0===a?{}:a,c=b(t,u),l=w({telemetryData:t,dimensionLookup:s,excludeKeys:["workflow"].concat(Y(Object.keys(c)),Y(Object.keys(u)))});return{eventType:t.eventType||"other",timestamp:(new Date).toISOString(),session:{id:r,startTimestamp:i},attributes:J({referrer:document.referrer,hostname:window.location.hostname,path:window.location.pathname},l),metrics:c}}function O(e){var t=e.page,n=e.session;n=void 0===n?{}:n;var r=n.id,i=n.startTimestamp,o=e.previousPage,s=void 0===o?{}:o,a=e.options,u=void 0===a?{}:a,c=e.dimensionLookup,l=void 0===c?{}:c,h=e.metricLookup,f=void 0===h?{}:h,d=b(u,f),p=w({telemetryData:u,dimensionLookup:l,excludeKeys:["workflow"].concat(Y(Object.keys(d)),Y(Object.keys(f)))}),g=document||{},y=g.referrer,v=g.title,m=window&&window.location?window.location:{},k=m.hostname,S=m.pathname;return{eventType:"pageView",timestamp:(new Date).toISOString(),session:{id:r,startTimestamp:i},attributes:J({referrer:y,hostname:k,path:t||S,pageUrl:t||S,pageName:v,previousPageUrl:s.pageUrl,previousPageName:s.pageName},p),metrics:d}}function x(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1],n={region:"us-east-1",service:"mobileanalytics",accessKeyId:e.AccessKeyId,secretAccessKey:e.SecretKey,sessionToken:e.SessionToken};return new V(n).sign(t)}function I(e,t){return JSON.stringify({client:{client_id:e,app_title:t.name,app_version_name:t.version||"unknown"},services:{mobile_analytics:{app_id:t.id}}})}function A(n,r,i,o){var s=t();n=Array.isArray(n)?n:[n];var a=E(n);return e(r).then(function(e){try{a.headers=x(e,a),a.headers["x-amz-Client-Context"]=I(s.id,i)}catch(e){return void console.error(e)}return fetch(X,a)}).then(function(e){if(e.ok)return{success:!0};throw new Error("Telemetry failed. "+e.status+", "+e.statusText)}).catch(function(e){console.error(e.message)})}function E(e){return{url:arguments.length>1&&void 0!==arguments[1]?arguments[1]:X,method:"POST",body:JSON.stringify({events:e})}}function P(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:z(i,e),value:n[e]}:s[e]?{key:L(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 z(e,t){return"dimension"+e[t]}function L(e,t){return"metric"+e[t]}function C(e){window.ga?window.ga(function(){e(window.ga.getAll())}):console.log(new Error("Google Analytics trackers not available"))}function H(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=P({customTelemetryData:t,dimensionLookup:n,metricLookup:r});return J({},i,o)}function W(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=P({customTelemetryData:e,dimensionLookup:t,metricLookup:n});return J({},r,i)}var q={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]}}},D="TELEMETRY_COGNITO_CREDENTIALS",j="https://cognito-identity.us-east-1.amazonaws.com/",B=18e5,K="TELEMETRY_SESSION",U="TELEMETRY_CLIENT_ID",R=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)))}},h=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=h.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.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 f.HMAC.init(e,n).finalize(t)}}});var f=n.algo={};return n}(Math);!function(e){for(var t=R,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 h=e.sqrt(l),f=2;f<=h;f++)if(!(l%f)){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],h=n[7],f=0;f<64;f++){if(f<16)d[f]=0|e[t+f];else{var p=d[f-15],g=d[f-2];d[f]=((p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3)+d[f-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+d[f-16]}p=h+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[f]+d[f],g=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),h=l,l=c,c=u,u=a+p|0,a=o,o=i,i=r,r=p+g|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]+h|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=R,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 M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},N=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},F=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}}(),J=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},Y=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)},$={region:"eu-west-1",service:"execute-api",defaultContentType:"application/json",defaultAcceptType:"application/json",payloadSerializerFactory:d,uriParserFactory:p,hasherFactory:y},V=function(){function e(t){N(this,e),this.config=v({},$,t),this.payloadSerializer=this.config.payloadSerializer||this.config.payloadSerializerFactory(),this.uriParser=this.config.uriParserFactory(),this.hasher=this.config.hasherFactory(),m(this.config.accessKeyId,"AwsSigner requires AWS AccessKeyID"),m(this.config.secretAccessKey,"AwsSigner requires AWS SecretAccessKey")}return F(e,[{key:"sign",value:function(e,t){var n={request:v({},e),signDate:t||new Date,uri:this.uriParser(e.url)};return a(this,n),u(this,n),c(this,n),l(this,n),h(this,n),{Accept:n.request.headers.accept,Authorization:n.authorization,"Content-Type":n.request.headers["content-type"],"x-amz-date":n.request.headers["x-amz-date"],"x-amz-security-token":this.config.sessionToken||void 0}}}]),e}(),G=["size","duration","position","number","count"],X="https://mobileanalytics.us-east-1.amazonaws.com/2014-06-05/events",Q=function(){function e(n){N(this,e),this.name="amazon",J(this,n),t().session.new&&!n.test&&this.logEvent({eventType:"_session.start"}).catch(function(e){console.error("Failed to log _session.start: "+e.message)})}return F(e,[{key:"logPageView",value:function(e,n){var r=t().session,i=O({page:e,session:r,previousPage:this.previousPage,options:n,dimensionLookup:this.dimensions,metricLookup:this.metrics});return this.previousPage=i.attributes,A(i,this.userPoolID,this.app)}},{key:"logEvent",value:function(e){return A(T({event:e,session:t().session,dimensionLookup:this.dimensions,metricLookup:this.metrics}),this.userPoolID,this.app)}}]),e}(),Z=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};N(this,e),this.name="google",J(this,t)}return F(e,[{key:"logPageView",value:function(e,t){var n=H(e,t,this.dimensions,this.metrics);C(function(e){e.forEach(function(e){e.send(n)})})}},{key:"logEvent",value:function(e){var t=W(e,this.dimensions,this.metrics);C(function(e){e.forEach(function(e){e.send(t)})})}}]),e}(),ee=function(e){if(e)return R.SHA256(e).toString(R.enc.Hex)},te=["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"],ne=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){N(this,e);try{if(this.trackers=[],this.workflows={},this.test=t.test,this.debug=t.debug,this.disabled=!ne(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 F(e,[{key:"_initTrackers",value:function(e){if(e.amazon){var t=new Q(e.amazon);this.trackers.push(t)}if(e.google){var n=new Z(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=te.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=J({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=J({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=J({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=J({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=J({name:e,step:"cancel"},t);this._logWorkflow(n)}},{key:"getWorkflow",value:function(e){var t=q.get("TELEMETRY-WORKFLOW:"+e);if(t){if(Date.now()-t.start<18e5)return t;this._deleteWorkflow(t)}}},{key:"_saveWorkflow",value:function(e){q.set("TELEMETRY-WORKFLOW:"+e.name,e)}},{key:"_deleteWorkflow",value:function(e){q.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=J(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:ee(this.user.username),org:ee(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),J({},e,t)}}]),e}()});
define("telemetry",function(){"use strict";function e(e){var t=q.get(D);if(t&&Date.now()/1e3<t.Expiration)return 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(j,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(j,n)}).then(function(e){if(!e.ok)throw new Error(e.statusText);return e.json()}).then(function(e){var t=e.Credentials;return q.set(D,t),t})}function t(){return{session:n(),id:r()}}function n(){var e=void 0,t=q.get(K);return(!t||Date.now()>t.expiration)&&(e=!0,t=i()),t.expiration=Date.now()+B,q.set(K,t),e&&(t.new=!0),t}function r(){var e=q.get(U);return e||(e=o(),q.set(U,e)),e}function i(){return{id:Math.floor(17592186044416*(1+Math.random())).toString(16),startTimestamp:(new Date).toISOString()}}function o(){return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}function s(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function a(e,t){var n={host:t.uri.host,"content-type":e.config.defaultContentType,accept:e.config.defaultAcceptType,"x-amz-date":f(t.signDate)};t.request.method=t.request.method.toUpperCase(),t.request.body?t.payload=t.request.body:t.request.data&&e.payloadSerializer?t.payload=e.payloadSerializer(t.request.data):delete n["content-type"],t.request.headers=v(n,Object.keys(t.request.headers||{}).reduce(function(e,n){return e[n.toLowerCase()]=t.request.headers[n],e},{})),t.sortedHeaderKeys=Object.keys(t.request.headers).sort(),t.request.headers["content-type"]&&(t.request.headers["content-type"]=t.request.headers["content-type"].split(";")[0]),"object"===M(t.request.params)&&v(t.uri.queryParams,t.request.params)}function u(e,t){t.signedHeaders=t.sortedHeaderKeys.map(function(e){return e.toLowerCase()}).join(";"),t.canonicalRequest=String(t.request.method).toUpperCase()+"\n"+encodeURI(t.uri.path)+"\n"+Object.keys(t.uri.queryParams).sort().map(function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t.uri.queryParams[e])}).join("&")+"\n"+t.sortedHeaderKeys.map(function(e){return e.toLocaleLowerCase()+":"+t.request.headers[e]}).join("\n")+"\n\n"+t.signedHeaders+"\n"+e.hasher.hash(t.payload?t.payload:"")}function c(e,t){t.credentialScope=[f(t.signDate,!0),e.config.region,e.config.service,"aws4_request"].join("/"),t.stringToSign="AWS4-HMAC-SHA256\n"+f(t.signDate)+"\n"+t.credentialScope+"\n"+e.hasher.hash(t.canonicalRequest)}function l(e,t){var n=e.hasher.hmac,r=n(n(n(n("AWS4"+e.config.secretAccessKey,f(t.signDate,!0),{hexOutput:!1}),e.config.region,{hexOutput:!1,textInput:!1}),e.config.service,{hexOutput:!1,textInput:!1}),"aws4_request",{hexOutput:!1,textInput:!1});t.signature=n(r,t.stringToSign,{textInput:!1})}function h(e,t){t.authorization="AWS4-HMAC-SHA256 Credential="+e.config.accessKeyId+"/"+t.credentialScope+", SignedHeaders="+t.signedHeaders+", Signature="+t.signature}function f(e,t){var n=e.toISOString().replace(/[:\-]|\.\d{3}/g,"").substr(0,17);return t?n.substr(0,8):n}function d(){return function(e){return JSON.stringify(e)}}function p(){return function(e){var t=URL?new URL(e):document.createElement("a");return t.href=e,{protocol:t.protocol,host:t.host.replace(/^(.*):((80)|(443))$/,"$1"),path:("/"!==t.pathname.charAt(0)?"/":"")+t.pathname,queryParams:g(t.search)}}}function g(e){return/^\??(.*)$/.exec(e)[1].split("&").reduce(function(e,t){return t=/^(.+)=(.*)$/.exec(t),t&&(e[t[1]]=t[2]),e},{})}function y(){return{hash:function(e,t){t=v({hexOutput:!0,textInput:!0},t);var n=R.SHA256(e);return t.hexOutput?n.toString(R.enc.Hex):n},hmac:function(e,t,n){n=v({hexOutput:!0,textInput:!0},n);var r=R.HmacSHA256(t,e,{asBytes:!0});return n.hexOutput?r.toString(R.enc.Hex):r}}}function v(e){return[].slice.call(arguments,1).forEach(function(t){t&&"object"===(void 0===t?"undefined":M(t))&&Object.keys(t).forEach(function(n){var r=t[n];void 0!==r&&(null!==r&&"object"===(void 0===r?"undefined":M(r))?(e[n]=Array.isArray(r)?[]:{},v(e[n],r)):e[n]=r)})}),e}function m(e,t){if(void 0===e||!e)throw new Error(t)}function w(e){var t=e.telemetryData,n=e.dimensionLookup,r=void 0===n?{}:n,i=e.excludeKeys,o=void 0===i?[]:i;return Object.keys(t).filter(function(e){return!o.includes(e)}).map(function(e){return r[e]?{key:S(r,e),value:t[e]}:{key:e,value:k(t,e)}}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function k(e,t){return"json"===t?e[t]?JSON.stringify(e[t]):"null":void 0===e[t]?"null":e[t].toString()}function S(e,t){return"dimension"+e[t]}function b(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).filter(function(e){return t[e]||G.includes(e)}).map(function(n){return t[n]?{key:_(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 _(e,t){return"metric"+e[t]}function T(e){var t=e.event,n=e.session,r=n.id,i=n.startTimestamp,o=e.dimensionLookup,s=void 0===o?{}:o,a=e.metricLookup,u=void 0===a?{}:a,c=b(t,u),l=w({telemetryData:t,dimensionLookup:s,excludeKeys:["workflow"].concat(Y(Object.keys(c)),Y(Object.keys(u)))});return{eventType:t.eventType||"other",timestamp:(new Date).toISOString(),session:{id:r,startTimestamp:i},attributes:J({referrer:document.referrer,hostname:window.location.hostname,path:window.location.pathname},l),metrics:c}}function O(e){var t=e.page,n=e.session;n=void 0===n?{}:n;var r=n.id,i=n.startTimestamp,o=e.previousPage,s=void 0===o?{}:o,a=e.options,u=void 0===a?{}:a,c=e.dimensionLookup,l=void 0===c?{}:c,h=e.metricLookup,f=void 0===h?{}:h,d=b(u,f),p=w({telemetryData:u,dimensionLookup:l,excludeKeys:["workflow"].concat(Y(Object.keys(d)),Y(Object.keys(f)))}),g=document||{},y=g.referrer,v=g.title,m=window&&window.location?window.location:{},k=m.hostname,S=m.pathname;return{eventType:"pageView",timestamp:(new Date).toISOString(),session:{id:r,startTimestamp:i},attributes:J({referrer:y,hostname:k,path:t||S,pageUrl:t||S,pageName:v,previousPageUrl:s.pageUrl,previousPageName:s.pageName},p),metrics:d}}function x(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1],n={region:"us-east-1",service:"mobileanalytics",accessKeyId:e.AccessKeyId,secretAccessKey:e.SecretKey,sessionToken:e.SessionToken};return new V(n).sign(t)}function I(e,t){return JSON.stringify({client:{client_id:e,app_title:t.name,app_version_name:t.version||"unknown"},services:{mobile_analytics:{app_id:t.id}}})}function A(n,r,i,o){var s=t();n=Array.isArray(n)?n:[n];var a=E(n);return e(r).then(function(e){try{a.headers=x(e,a),a.headers["x-amz-Client-Context"]=I(s.id,i)}catch(e){return void console.error(e)}return fetch(X,a)}).then(function(e){if(e.ok)return{success:!0};throw new Error("Telemetry failed. "+e.status+", "+e.statusText)}).catch(function(e){console.error(e.message)})}function E(e){return{url:arguments.length>1&&void 0!==arguments[1]?arguments[1]:X,method:"POST",body:JSON.stringify({events:e})}}function P(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:z(i,e),value:n[e]}:s[e]?{key:L(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 z(e,t){return"dimension"+e[t]}function L(e,t){return"metric"+e[t]}function C(e){window.ga?window.ga(function(){e(window.ga.getAll())}):console.log(new Error("Google Analytics trackers not available"))}function H(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=P({customTelemetryData:t,dimensionLookup:n,metricLookup:r});return J({},i,o)}function W(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=P({customTelemetryData:e,dimensionLookup:t,metricLookup:n});return J({},r,i)}var q={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]}}},D="TELEMETRY_COGNITO_CREDENTIALS",j="https://cognito-identity.us-east-1.amazonaws.com/",B=18e5,K="TELEMETRY_SESSION",U="TELEMETRY_CLIENT_ID",R=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)))}},h=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=h.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.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 f.HMAC.init(e,n).finalize(t)}}});var f=n.algo={};return n}(Math);!function(e){for(var t=R,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 h=e.sqrt(l),f=2;f<=h;f++)if(!(l%f)){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],h=n[7],f=0;f<64;f++){if(f<16)d[f]=0|e[t+f];else{var p=d[f-15],g=d[f-2];d[f]=((p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3)+d[f-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+d[f-16]}p=h+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[f]+d[f],g=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),h=l,l=c,c=u,u=a+p|0,a=o,o=i,i=r,r=p+g|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]+h|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=R,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 M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},N=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},F=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}}(),J=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},Y=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)},$={region:"eu-west-1",service:"execute-api",defaultContentType:"application/json",defaultAcceptType:"application/json",payloadSerializerFactory:d,uriParserFactory:p,hasherFactory:y},V=function(){function e(t){N(this,e),this.config=v({},$,t),this.payloadSerializer=this.config.payloadSerializer||this.config.payloadSerializerFactory(),this.uriParser=this.config.uriParserFactory(),this.hasher=this.config.hasherFactory(),m(this.config.accessKeyId,"AwsSigner requires AWS AccessKeyID"),m(this.config.secretAccessKey,"AwsSigner requires AWS SecretAccessKey")}return F(e,[{key:"sign",value:function(e,t){var n={request:v({},e),signDate:t||new Date,uri:this.uriParser(e.url)};return a(this,n),u(this,n),c(this,n),l(this,n),h(this,n),{Accept:n.request.headers.accept,Authorization:n.authorization,"Content-Type":n.request.headers["content-type"],"x-amz-date":n.request.headers["x-amz-date"],"x-amz-security-token":this.config.sessionToken||void 0}}}]),e}(),G=["size","duration","position","number","count"],X="https://mobileanalytics.us-east-1.amazonaws.com/2014-06-05/events",Q=function(){function e(n){N(this,e),this.name="amazon",J(this,n),t().session.new&&!n.test&&this.logEvent({eventType:"_session.start"}).catch(function(e){console.error("Failed to log _session.start: "+e.message)})}return F(e,[{key:"logPageView",value:function(e,n){var r=t().session,i=O({page:e,session:r,previousPage:this.previousPage,options:n,dimensionLookup:this.dimensions,metricLookup:this.metrics});return this.previousPage=i.attributes,A(i,this.userPoolID,this.app)}},{key:"logEvent",value:function(e){return A(T({event:e,session:t().session,dimensionLookup:this.dimensions,metricLookup:this.metrics}),this.userPoolID,this.app)}}]),e}(),Z=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};N(this,e),this.name="google",J(this,t)}return F(e,[{key:"logPageView",value:function(e,t){var n=H(e,t,this.dimensions,this.metrics);C(function(e){e.forEach(function(e){e.send(n)})})}},{key:"logEvent",value:function(e){var t=W(e,this.dimensions,this.metrics);C(function(e){e.forEach(function(e){e.send(t)})})}}]),e}(),ee=function(e){if(e)return R.SHA256(e).toString(R.enc.Hex)},te=["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"],ne=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){N(this,e);try{if(this.trackers=[],this.workflows={},this.test=t.test,this.debug=t.debug,this.disabled=!ne(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 F(e,[{key:"_initTrackers",value:function(e){if(e.amazon){var t=new Q(e.amazon);this.trackers.push(t)}if(e.google){var n=new Z(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=te.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=J({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=J({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=J({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=J({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=J({name:e,step:"cancel"},t);this._logWorkflow(n)}},{key:"getWorkflow",value:function(e){var t=q.get("TELEMETRY-WORKFLOW:"+e);if(t){if(Date.now()-t.start<18e5)return t;this._deleteWorkflow(t)}}},{key:"_saveWorkflow",value:function(e){q.set("TELEMETRY-WORKFLOW:"+e.name,e)}},{key:"_deleteWorkflow",value:function(e){q.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=J(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:ee(this.user.username),org:ee(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),J({},e,t)}}]),e}()});
//# sourceMappingURL=telemetry.amd.min.js.map

@@ -51,5 +51,6 @@ define(function () { 'use strict';

var COGNITO_URL = 'https://cognito-identity.us-east-1.amazonaws.com/';
function getCredentials(IdentityPoolId, callback) {
function getCredentials(IdentityPoolId) {
var cached = Storage.get(COGNITO_KEY);
if (cached && Date.now() / 1000 < cached.Expiration) return callback(cached);
if (cached && Date.now() / 1000 < cached.Expiration) return cached;

@@ -56,0 +57,0 @@ var options = {

@@ -1,2 +0,2 @@

define(function(){"use strict";function e(e,t){var n=q.get(D);if(n&&Date.now()/1e3<n.Expiration)return t(n);var r={method:"POST",headers:{"Content-type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityService.GetId"},body:JSON.stringify({IdentityPoolId:e})};return fetch(j,r).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(j,n)}).then(function(e){if(!e.ok)throw new Error(e.statusText);return e.json()}).then(function(e){var t=e.Credentials;return q.set(D,t),t})}function t(){return{session:n(),id:r()}}function n(){var e=void 0,t=q.get(K);return(!t||Date.now()>t.expiration)&&(e=!0,t=i()),t.expiration=Date.now()+B,q.set(K,t),e&&(t.new=!0),t}function r(){var e=q.get(U);return e||(e=o(),q.set(U,e)),e}function i(){return{id:Math.floor(17592186044416*(1+Math.random())).toString(16),startTimestamp:(new Date).toISOString()}}function o(){return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}function s(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function a(e,t){var n={host:t.uri.host,"content-type":e.config.defaultContentType,accept:e.config.defaultAcceptType,"x-amz-date":f(t.signDate)};t.request.method=t.request.method.toUpperCase(),t.request.body?t.payload=t.request.body:t.request.data&&e.payloadSerializer?t.payload=e.payloadSerializer(t.request.data):delete n["content-type"],t.request.headers=v(n,Object.keys(t.request.headers||{}).reduce(function(e,n){return e[n.toLowerCase()]=t.request.headers[n],e},{})),t.sortedHeaderKeys=Object.keys(t.request.headers).sort(),t.request.headers["content-type"]&&(t.request.headers["content-type"]=t.request.headers["content-type"].split(";")[0]),"object"===M(t.request.params)&&v(t.uri.queryParams,t.request.params)}function u(e,t){t.signedHeaders=t.sortedHeaderKeys.map(function(e){return e.toLowerCase()}).join(";"),t.canonicalRequest=String(t.request.method).toUpperCase()+"\n"+encodeURI(t.uri.path)+"\n"+Object.keys(t.uri.queryParams).sort().map(function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t.uri.queryParams[e])}).join("&")+"\n"+t.sortedHeaderKeys.map(function(e){return e.toLocaleLowerCase()+":"+t.request.headers[e]}).join("\n")+"\n\n"+t.signedHeaders+"\n"+e.hasher.hash(t.payload?t.payload:"")}function c(e,t){t.credentialScope=[f(t.signDate,!0),e.config.region,e.config.service,"aws4_request"].join("/"),t.stringToSign="AWS4-HMAC-SHA256\n"+f(t.signDate)+"\n"+t.credentialScope+"\n"+e.hasher.hash(t.canonicalRequest)}function l(e,t){var n=e.hasher.hmac,r=n(n(n(n("AWS4"+e.config.secretAccessKey,f(t.signDate,!0),{hexOutput:!1}),e.config.region,{hexOutput:!1,textInput:!1}),e.config.service,{hexOutput:!1,textInput:!1}),"aws4_request",{hexOutput:!1,textInput:!1});t.signature=n(r,t.stringToSign,{textInput:!1})}function h(e,t){t.authorization="AWS4-HMAC-SHA256 Credential="+e.config.accessKeyId+"/"+t.credentialScope+", SignedHeaders="+t.signedHeaders+", Signature="+t.signature}function f(e,t){var n=e.toISOString().replace(/[:\-]|\.\d{3}/g,"").substr(0,17);return t?n.substr(0,8):n}function d(){return function(e){return JSON.stringify(e)}}function p(){return function(e){var t=URL?new URL(e):document.createElement("a");return t.href=e,{protocol:t.protocol,host:t.host.replace(/^(.*):((80)|(443))$/,"$1"),path:("/"!==t.pathname.charAt(0)?"/":"")+t.pathname,queryParams:g(t.search)}}}function g(e){return/^\??(.*)$/.exec(e)[1].split("&").reduce(function(e,t){return t=/^(.+)=(.*)$/.exec(t),t&&(e[t[1]]=t[2]),e},{})}function y(){return{hash:function(e,t){t=v({hexOutput:!0,textInput:!0},t);var n=R.SHA256(e);return t.hexOutput?n.toString(R.enc.Hex):n},hmac:function(e,t,n){n=v({hexOutput:!0,textInput:!0},n);var r=R.HmacSHA256(t,e,{asBytes:!0});return n.hexOutput?r.toString(R.enc.Hex):r}}}function v(e){return[].slice.call(arguments,1).forEach(function(t){t&&"object"===(void 0===t?"undefined":M(t))&&Object.keys(t).forEach(function(n){var r=t[n];void 0!==r&&(null!==r&&"object"===(void 0===r?"undefined":M(r))?(e[n]=Array.isArray(r)?[]:{},v(e[n],r)):e[n]=r)})}),e}function m(e,t){if(void 0===e||!e)throw new Error(t)}function w(e){var t=e.telemetryData,n=e.dimensionLookup,r=void 0===n?{}:n,i=e.excludeKeys,o=void 0===i?[]:i;return Object.keys(t).filter(function(e){return!o.includes(e)}).map(function(e){return r[e]?{key:S(r,e),value:t[e]}:{key:e,value:k(t,e)}}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function k(e,t){return"json"===t?e[t]?JSON.stringify(e[t]):"null":void 0===e[t]?"null":e[t].toString()}function S(e,t){return"dimension"+e[t]}function b(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).filter(function(e){return t[e]||G.includes(e)}).map(function(n){return t[n]?{key:_(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 _(e,t){return"metric"+e[t]}function T(e){var t=e.event,n=e.session,r=n.id,i=n.startTimestamp,o=e.dimensionLookup,s=void 0===o?{}:o,a=e.metricLookup,u=void 0===a?{}:a,c=b(t,u),l=w({telemetryData:t,dimensionLookup:s,excludeKeys:["workflow"].concat(Y(Object.keys(c)),Y(Object.keys(u)))});return{eventType:t.eventType||"other",timestamp:(new Date).toISOString(),session:{id:r,startTimestamp:i},attributes:J({referrer:document.referrer,hostname:window.location.hostname,path:window.location.pathname},l),metrics:c}}function O(e){var t=e.page,n=e.session;n=void 0===n?{}:n;var r=n.id,i=n.startTimestamp,o=e.previousPage,s=void 0===o?{}:o,a=e.options,u=void 0===a?{}:a,c=e.dimensionLookup,l=void 0===c?{}:c,h=e.metricLookup,f=void 0===h?{}:h,d=b(u,f),p=w({telemetryData:u,dimensionLookup:l,excludeKeys:["workflow"].concat(Y(Object.keys(d)),Y(Object.keys(f)))}),g=document||{},y=g.referrer,v=g.title,m=window&&window.location?window.location:{},k=m.hostname,S=m.pathname;return{eventType:"pageView",timestamp:(new Date).toISOString(),session:{id:r,startTimestamp:i},attributes:J({referrer:y,hostname:k,path:t||S,pageUrl:t||S,pageName:v,previousPageUrl:s.pageUrl,previousPageName:s.pageName},p),metrics:d}}function x(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1],n={region:"us-east-1",service:"mobileanalytics",accessKeyId:e.AccessKeyId,secretAccessKey:e.SecretKey,sessionToken:e.SessionToken};return new V(n).sign(t)}function I(e,t){return JSON.stringify({client:{client_id:e,app_title:t.name,app_version_name:t.version||"unknown"},services:{mobile_analytics:{app_id:t.id}}})}function A(n,r,i,o){var s=t();n=Array.isArray(n)?n:[n];var a=E(n);return e(r).then(function(e){try{a.headers=x(e,a),a.headers["x-amz-Client-Context"]=I(s.id,i)}catch(e){return void console.error(e)}return fetch(X,a)}).then(function(e){if(e.ok)return{success:!0};throw new Error("Telemetry failed. "+e.status+", "+e.statusText)}).catch(function(e){console.error(e.message)})}function E(e){return{url:arguments.length>1&&void 0!==arguments[1]?arguments[1]:X,method:"POST",body:JSON.stringify({events:e})}}function P(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:z(i,e),value:n[e]}:s[e]?{key:L(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 z(e,t){return"dimension"+e[t]}function L(e,t){return"metric"+e[t]}function C(e){window.ga?window.ga(function(){e(window.ga.getAll())}):console.log(new Error("Google Analytics trackers not available"))}function H(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=P({customTelemetryData:t,dimensionLookup:n,metricLookup:r});return J({},i,o)}function W(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=P({customTelemetryData:e,dimensionLookup:t,metricLookup:n});return J({},r,i)}var q={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]}}},D="TELEMETRY_COGNITO_CREDENTIALS",j="https://cognito-identity.us-east-1.amazonaws.com/",B=18e5,K="TELEMETRY_SESSION",U="TELEMETRY_CLIENT_ID",R=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)))}},h=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=h.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.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 f.HMAC.init(e,n).finalize(t)}}});var f=n.algo={};return n}(Math);!function(e){for(var t=R,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 h=e.sqrt(l),f=2;f<=h;f++)if(!(l%f)){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],h=n[7],f=0;f<64;f++){if(f<16)d[f]=0|e[t+f];else{var p=d[f-15],g=d[f-2];d[f]=((p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3)+d[f-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+d[f-16]}p=h+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[f]+d[f],g=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),h=l,l=c,c=u,u=a+p|0,a=o,o=i,i=r,r=p+g|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]+h|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=R,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 M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},N=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},F=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}}(),J=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},Y=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)},$={region:"eu-west-1",service:"execute-api",defaultContentType:"application/json",defaultAcceptType:"application/json",payloadSerializerFactory:d,uriParserFactory:p,hasherFactory:y},V=function(){function e(t){N(this,e),this.config=v({},$,t),this.payloadSerializer=this.config.payloadSerializer||this.config.payloadSerializerFactory(),this.uriParser=this.config.uriParserFactory(),this.hasher=this.config.hasherFactory(),m(this.config.accessKeyId,"AwsSigner requires AWS AccessKeyID"),m(this.config.secretAccessKey,"AwsSigner requires AWS SecretAccessKey")}return F(e,[{key:"sign",value:function(e,t){var n={request:v({},e),signDate:t||new Date,uri:this.uriParser(e.url)};return a(this,n),u(this,n),c(this,n),l(this,n),h(this,n),{Accept:n.request.headers.accept,Authorization:n.authorization,"Content-Type":n.request.headers["content-type"],"x-amz-date":n.request.headers["x-amz-date"],"x-amz-security-token":this.config.sessionToken||void 0}}}]),e}(),G=["size","duration","position","number","count"],X="https://mobileanalytics.us-east-1.amazonaws.com/2014-06-05/events",Q=function(){function e(n){N(this,e),this.name="amazon",J(this,n),t().session.new&&!n.test&&this.logEvent({eventType:"_session.start"}).catch(function(e){console.error("Failed to log _session.start: "+e.message)})}return F(e,[{key:"logPageView",value:function(e,n){var r=t().session,i=O({page:e,session:r,previousPage:this.previousPage,options:n,dimensionLookup:this.dimensions,metricLookup:this.metrics});return this.previousPage=i.attributes,A(i,this.userPoolID,this.app)}},{key:"logEvent",value:function(e){return A(T({event:e,session:t().session,dimensionLookup:this.dimensions,metricLookup:this.metrics}),this.userPoolID,this.app)}}]),e}(),Z=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};N(this,e),this.name="google",J(this,t)}return F(e,[{key:"logPageView",value:function(e,t){var n=H(e,t,this.dimensions,this.metrics);C(function(e){e.forEach(function(e){e.send(n)})})}},{key:"logEvent",value:function(e){var t=W(e,this.dimensions,this.metrics);C(function(e){e.forEach(function(e){e.send(t)})})}}]),e}(),ee=function(e){if(e)return R.SHA256(e).toString(R.enc.Hex)},te=["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"],ne=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){N(this,e);try{if(this.trackers=[],this.workflows={},this.test=t.test,this.debug=t.debug,this.disabled=!ne(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 F(e,[{key:"_initTrackers",value:function(e){if(e.amazon){var t=new Q(e.amazon);this.trackers.push(t)}if(e.google){var n=new Z(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=te.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=J({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=J({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=J({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=J({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=J({name:e,step:"cancel"},t);this._logWorkflow(n)}},{key:"getWorkflow",value:function(e){var t=q.get("TELEMETRY-WORKFLOW:"+e);if(t){if(Date.now()-t.start<18e5)return t;this._deleteWorkflow(t)}}},{key:"_saveWorkflow",value:function(e){q.set("TELEMETRY-WORKFLOW:"+e.name,e)}},{key:"_deleteWorkflow",value:function(e){q.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=J(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:ee(this.user.username),org:ee(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),J({},e,t)}}]),e}()});
define(function(){"use strict";function e(e){var t=q.get(D);if(t&&Date.now()/1e3<t.Expiration)return 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(j,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(j,n)}).then(function(e){if(!e.ok)throw new Error(e.statusText);return e.json()}).then(function(e){var t=e.Credentials;return q.set(D,t),t})}function t(){return{session:n(),id:r()}}function n(){var e=void 0,t=q.get(K);return(!t||Date.now()>t.expiration)&&(e=!0,t=i()),t.expiration=Date.now()+B,q.set(K,t),e&&(t.new=!0),t}function r(){var e=q.get(U);return e||(e=o(),q.set(U,e)),e}function i(){return{id:Math.floor(17592186044416*(1+Math.random())).toString(16),startTimestamp:(new Date).toISOString()}}function o(){return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}function s(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function a(e,t){var n={host:t.uri.host,"content-type":e.config.defaultContentType,accept:e.config.defaultAcceptType,"x-amz-date":f(t.signDate)};t.request.method=t.request.method.toUpperCase(),t.request.body?t.payload=t.request.body:t.request.data&&e.payloadSerializer?t.payload=e.payloadSerializer(t.request.data):delete n["content-type"],t.request.headers=v(n,Object.keys(t.request.headers||{}).reduce(function(e,n){return e[n.toLowerCase()]=t.request.headers[n],e},{})),t.sortedHeaderKeys=Object.keys(t.request.headers).sort(),t.request.headers["content-type"]&&(t.request.headers["content-type"]=t.request.headers["content-type"].split(";")[0]),"object"===M(t.request.params)&&v(t.uri.queryParams,t.request.params)}function u(e,t){t.signedHeaders=t.sortedHeaderKeys.map(function(e){return e.toLowerCase()}).join(";"),t.canonicalRequest=String(t.request.method).toUpperCase()+"\n"+encodeURI(t.uri.path)+"\n"+Object.keys(t.uri.queryParams).sort().map(function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t.uri.queryParams[e])}).join("&")+"\n"+t.sortedHeaderKeys.map(function(e){return e.toLocaleLowerCase()+":"+t.request.headers[e]}).join("\n")+"\n\n"+t.signedHeaders+"\n"+e.hasher.hash(t.payload?t.payload:"")}function c(e,t){t.credentialScope=[f(t.signDate,!0),e.config.region,e.config.service,"aws4_request"].join("/"),t.stringToSign="AWS4-HMAC-SHA256\n"+f(t.signDate)+"\n"+t.credentialScope+"\n"+e.hasher.hash(t.canonicalRequest)}function l(e,t){var n=e.hasher.hmac,r=n(n(n(n("AWS4"+e.config.secretAccessKey,f(t.signDate,!0),{hexOutput:!1}),e.config.region,{hexOutput:!1,textInput:!1}),e.config.service,{hexOutput:!1,textInput:!1}),"aws4_request",{hexOutput:!1,textInput:!1});t.signature=n(r,t.stringToSign,{textInput:!1})}function h(e,t){t.authorization="AWS4-HMAC-SHA256 Credential="+e.config.accessKeyId+"/"+t.credentialScope+", SignedHeaders="+t.signedHeaders+", Signature="+t.signature}function f(e,t){var n=e.toISOString().replace(/[:\-]|\.\d{3}/g,"").substr(0,17);return t?n.substr(0,8):n}function d(){return function(e){return JSON.stringify(e)}}function p(){return function(e){var t=URL?new URL(e):document.createElement("a");return t.href=e,{protocol:t.protocol,host:t.host.replace(/^(.*):((80)|(443))$/,"$1"),path:("/"!==t.pathname.charAt(0)?"/":"")+t.pathname,queryParams:g(t.search)}}}function g(e){return/^\??(.*)$/.exec(e)[1].split("&").reduce(function(e,t){return t=/^(.+)=(.*)$/.exec(t),t&&(e[t[1]]=t[2]),e},{})}function y(){return{hash:function(e,t){t=v({hexOutput:!0,textInput:!0},t);var n=R.SHA256(e);return t.hexOutput?n.toString(R.enc.Hex):n},hmac:function(e,t,n){n=v({hexOutput:!0,textInput:!0},n);var r=R.HmacSHA256(t,e,{asBytes:!0});return n.hexOutput?r.toString(R.enc.Hex):r}}}function v(e){return[].slice.call(arguments,1).forEach(function(t){t&&"object"===(void 0===t?"undefined":M(t))&&Object.keys(t).forEach(function(n){var r=t[n];void 0!==r&&(null!==r&&"object"===(void 0===r?"undefined":M(r))?(e[n]=Array.isArray(r)?[]:{},v(e[n],r)):e[n]=r)})}),e}function m(e,t){if(void 0===e||!e)throw new Error(t)}function w(e){var t=e.telemetryData,n=e.dimensionLookup,r=void 0===n?{}:n,i=e.excludeKeys,o=void 0===i?[]:i;return Object.keys(t).filter(function(e){return!o.includes(e)}).map(function(e){return r[e]?{key:S(r,e),value:t[e]}:{key:e,value:k(t,e)}}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function k(e,t){return"json"===t?e[t]?JSON.stringify(e[t]):"null":void 0===e[t]?"null":e[t].toString()}function S(e,t){return"dimension"+e[t]}function b(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).filter(function(e){return t[e]||G.includes(e)}).map(function(n){return t[n]?{key:_(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 _(e,t){return"metric"+e[t]}function T(e){var t=e.event,n=e.session,r=n.id,i=n.startTimestamp,o=e.dimensionLookup,s=void 0===o?{}:o,a=e.metricLookup,u=void 0===a?{}:a,c=b(t,u),l=w({telemetryData:t,dimensionLookup:s,excludeKeys:["workflow"].concat(Y(Object.keys(c)),Y(Object.keys(u)))});return{eventType:t.eventType||"other",timestamp:(new Date).toISOString(),session:{id:r,startTimestamp:i},attributes:J({referrer:document.referrer,hostname:window.location.hostname,path:window.location.pathname},l),metrics:c}}function O(e){var t=e.page,n=e.session;n=void 0===n?{}:n;var r=n.id,i=n.startTimestamp,o=e.previousPage,s=void 0===o?{}:o,a=e.options,u=void 0===a?{}:a,c=e.dimensionLookup,l=void 0===c?{}:c,h=e.metricLookup,f=void 0===h?{}:h,d=b(u,f),p=w({telemetryData:u,dimensionLookup:l,excludeKeys:["workflow"].concat(Y(Object.keys(d)),Y(Object.keys(f)))}),g=document||{},y=g.referrer,v=g.title,m=window&&window.location?window.location:{},k=m.hostname,S=m.pathname;return{eventType:"pageView",timestamp:(new Date).toISOString(),session:{id:r,startTimestamp:i},attributes:J({referrer:y,hostname:k,path:t||S,pageUrl:t||S,pageName:v,previousPageUrl:s.pageUrl,previousPageName:s.pageName},p),metrics:d}}function x(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1],n={region:"us-east-1",service:"mobileanalytics",accessKeyId:e.AccessKeyId,secretAccessKey:e.SecretKey,sessionToken:e.SessionToken};return new V(n).sign(t)}function I(e,t){return JSON.stringify({client:{client_id:e,app_title:t.name,app_version_name:t.version||"unknown"},services:{mobile_analytics:{app_id:t.id}}})}function A(n,r,i,o){var s=t();n=Array.isArray(n)?n:[n];var a=E(n);return e(r).then(function(e){try{a.headers=x(e,a),a.headers["x-amz-Client-Context"]=I(s.id,i)}catch(e){return void console.error(e)}return fetch(X,a)}).then(function(e){if(e.ok)return{success:!0};throw new Error("Telemetry failed. "+e.status+", "+e.statusText)}).catch(function(e){console.error(e.message)})}function E(e){return{url:arguments.length>1&&void 0!==arguments[1]?arguments[1]:X,method:"POST",body:JSON.stringify({events:e})}}function P(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:z(i,e),value:n[e]}:s[e]?{key:L(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 z(e,t){return"dimension"+e[t]}function L(e,t){return"metric"+e[t]}function C(e){window.ga?window.ga(function(){e(window.ga.getAll())}):console.log(new Error("Google Analytics trackers not available"))}function H(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=P({customTelemetryData:t,dimensionLookup:n,metricLookup:r});return J({},i,o)}function W(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=P({customTelemetryData:e,dimensionLookup:t,metricLookup:n});return J({},r,i)}var q={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]}}},D="TELEMETRY_COGNITO_CREDENTIALS",j="https://cognito-identity.us-east-1.amazonaws.com/",B=18e5,K="TELEMETRY_SESSION",U="TELEMETRY_CLIENT_ID",R=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)))}},h=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=h.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.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 f.HMAC.init(e,n).finalize(t)}}});var f=n.algo={};return n}(Math);!function(e){for(var t=R,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 h=e.sqrt(l),f=2;f<=h;f++)if(!(l%f)){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],h=n[7],f=0;f<64;f++){if(f<16)d[f]=0|e[t+f];else{var p=d[f-15],g=d[f-2];d[f]=((p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3)+d[f-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+d[f-16]}p=h+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[f]+d[f],g=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),h=l,l=c,c=u,u=a+p|0,a=o,o=i,i=r,r=p+g|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]+h|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=R,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 M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},N=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},F=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}}(),J=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},Y=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)},$={region:"eu-west-1",service:"execute-api",defaultContentType:"application/json",defaultAcceptType:"application/json",payloadSerializerFactory:d,uriParserFactory:p,hasherFactory:y},V=function(){function e(t){N(this,e),this.config=v({},$,t),this.payloadSerializer=this.config.payloadSerializer||this.config.payloadSerializerFactory(),this.uriParser=this.config.uriParserFactory(),this.hasher=this.config.hasherFactory(),m(this.config.accessKeyId,"AwsSigner requires AWS AccessKeyID"),m(this.config.secretAccessKey,"AwsSigner requires AWS SecretAccessKey")}return F(e,[{key:"sign",value:function(e,t){var n={request:v({},e),signDate:t||new Date,uri:this.uriParser(e.url)};return a(this,n),u(this,n),c(this,n),l(this,n),h(this,n),{Accept:n.request.headers.accept,Authorization:n.authorization,"Content-Type":n.request.headers["content-type"],"x-amz-date":n.request.headers["x-amz-date"],"x-amz-security-token":this.config.sessionToken||void 0}}}]),e}(),G=["size","duration","position","number","count"],X="https://mobileanalytics.us-east-1.amazonaws.com/2014-06-05/events",Q=function(){function e(n){N(this,e),this.name="amazon",J(this,n),t().session.new&&!n.test&&this.logEvent({eventType:"_session.start"}).catch(function(e){console.error("Failed to log _session.start: "+e.message)})}return F(e,[{key:"logPageView",value:function(e,n){var r=t().session,i=O({page:e,session:r,previousPage:this.previousPage,options:n,dimensionLookup:this.dimensions,metricLookup:this.metrics});return this.previousPage=i.attributes,A(i,this.userPoolID,this.app)}},{key:"logEvent",value:function(e){return A(T({event:e,session:t().session,dimensionLookup:this.dimensions,metricLookup:this.metrics}),this.userPoolID,this.app)}}]),e}(),Z=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};N(this,e),this.name="google",J(this,t)}return F(e,[{key:"logPageView",value:function(e,t){var n=H(e,t,this.dimensions,this.metrics);C(function(e){e.forEach(function(e){e.send(n)})})}},{key:"logEvent",value:function(e){var t=W(e,this.dimensions,this.metrics);C(function(e){e.forEach(function(e){e.send(t)})})}}]),e}(),ee=function(e){if(e)return R.SHA256(e).toString(R.enc.Hex)},te=["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"],ne=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){N(this,e);try{if(this.trackers=[],this.workflows={},this.test=t.test,this.debug=t.debug,this.disabled=!ne(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 F(e,[{key:"_initTrackers",value:function(e){if(e.amazon){var t=new Q(e.amazon);this.trackers.push(t)}if(e.google){var n=new Z(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=te.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=J({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=J({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=J({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=J({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=J({name:e,step:"cancel"},t);this._logWorkflow(n)}},{key:"getWorkflow",value:function(e){var t=q.get("TELEMETRY-WORKFLOW:"+e);if(t){if(Date.now()-t.start<18e5)return t;this._deleteWorkflow(t)}}},{key:"_saveWorkflow",value:function(e){q.set("TELEMETRY-WORKFLOW:"+e.name,e)}},{key:"_deleteWorkflow",value:function(e){q.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=J(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:ee(this.user.username),org:ee(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),J({},e,t)}}]),e}()});
//# sourceMappingURL=telemetry.dojo.min.js.map

@@ -55,5 +55,6 @@ (function (global, factory) {

var COGNITO_URL = 'https://cognito-identity.us-east-1.amazonaws.com/';
function getCredentials(IdentityPoolId, callback) {
function getCredentials(IdentityPoolId) {
var cached = Storage.get(COGNITO_KEY);
if (cached && Date.now() / 1000 < cached.Expiration) return callback(cached);
if (cached && Date.now() / 1000 < cached.Expiration) return cached;

@@ -60,0 +61,0 @@ var options = {

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define("telemetry",t):e.Telemetry=t()}(this,function(){"use strict";function e(e,t){var n=j.get(q);if(n&&Date.now()/1e3<n.Expiration)return t(n);var r={method:"POST",headers:{"Content-type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityService.GetId"},body:JSON.stringify({IdentityPoolId:e})};return fetch(D,r).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(D,n)}).then(function(e){if(!e.ok)throw new Error(e.statusText);return e.json()}).then(function(e){var t=e.Credentials;return j.set(q,t),t})}function t(){return{session:n(),id:r()}}function n(){var e=void 0,t=j.get(K);return(!t||Date.now()>t.expiration)&&(e=!0,t=i()),t.expiration=Date.now()+B,j.set(K,t),e&&(t.new=!0),t}function r(){var e=j.get(U);return e||(e=o(),j.set(U,e)),e}function i(){return{id:Math.floor(17592186044416*(1+Math.random())).toString(16),startTimestamp:(new Date).toISOString()}}function o(){return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}function s(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function a(e,t){var n={host:t.uri.host,"content-type":e.config.defaultContentType,accept:e.config.defaultAcceptType,"x-amz-date":f(t.signDate)};t.request.method=t.request.method.toUpperCase(),t.request.body?t.payload=t.request.body:t.request.data&&e.payloadSerializer?t.payload=e.payloadSerializer(t.request.data):delete n["content-type"],t.request.headers=v(n,Object.keys(t.request.headers||{}).reduce(function(e,n){return e[n.toLowerCase()]=t.request.headers[n],e},{})),t.sortedHeaderKeys=Object.keys(t.request.headers).sort(),t.request.headers["content-type"]&&(t.request.headers["content-type"]=t.request.headers["content-type"].split(";")[0]),"object"===M(t.request.params)&&v(t.uri.queryParams,t.request.params)}function u(e,t){t.signedHeaders=t.sortedHeaderKeys.map(function(e){return e.toLowerCase()}).join(";"),t.canonicalRequest=String(t.request.method).toUpperCase()+"\n"+encodeURI(t.uri.path)+"\n"+Object.keys(t.uri.queryParams).sort().map(function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t.uri.queryParams[e])}).join("&")+"\n"+t.sortedHeaderKeys.map(function(e){return e.toLocaleLowerCase()+":"+t.request.headers[e]}).join("\n")+"\n\n"+t.signedHeaders+"\n"+e.hasher.hash(t.payload?t.payload:"")}function c(e,t){t.credentialScope=[f(t.signDate,!0),e.config.region,e.config.service,"aws4_request"].join("/"),t.stringToSign="AWS4-HMAC-SHA256\n"+f(t.signDate)+"\n"+t.credentialScope+"\n"+e.hasher.hash(t.canonicalRequest)}function l(e,t){var n=e.hasher.hmac,r=n(n(n(n("AWS4"+e.config.secretAccessKey,f(t.signDate,!0),{hexOutput:!1}),e.config.region,{hexOutput:!1,textInput:!1}),e.config.service,{hexOutput:!1,textInput:!1}),"aws4_request",{hexOutput:!1,textInput:!1});t.signature=n(r,t.stringToSign,{textInput:!1})}function h(e,t){t.authorization="AWS4-HMAC-SHA256 Credential="+e.config.accessKeyId+"/"+t.credentialScope+", SignedHeaders="+t.signedHeaders+", Signature="+t.signature}function f(e,t){var n=e.toISOString().replace(/[:\-]|\.\d{3}/g,"").substr(0,17);return t?n.substr(0,8):n}function d(){return function(e){return JSON.stringify(e)}}function p(){return function(e){var t=URL?new URL(e):document.createElement("a");return t.href=e,{protocol:t.protocol,host:t.host.replace(/^(.*):((80)|(443))$/,"$1"),path:("/"!==t.pathname.charAt(0)?"/":"")+t.pathname,queryParams:g(t.search)}}}function g(e){return/^\??(.*)$/.exec(e)[1].split("&").reduce(function(e,t){return t=/^(.+)=(.*)$/.exec(t),t&&(e[t[1]]=t[2]),e},{})}function y(){return{hash:function(e,t){t=v({hexOutput:!0,textInput:!0},t);var n=R.SHA256(e);return t.hexOutput?n.toString(R.enc.Hex):n},hmac:function(e,t,n){n=v({hexOutput:!0,textInput:!0},n);var r=R.HmacSHA256(t,e,{asBytes:!0});return n.hexOutput?r.toString(R.enc.Hex):r}}}function v(e){return[].slice.call(arguments,1).forEach(function(t){t&&"object"===(void 0===t?"undefined":M(t))&&Object.keys(t).forEach(function(n){var r=t[n];void 0!==r&&(null!==r&&"object"===(void 0===r?"undefined":M(r))?(e[n]=Array.isArray(r)?[]:{},v(e[n],r)):e[n]=r)})}),e}function m(e,t){if(void 0===e||!e)throw new Error(t)}function w(e){var t=e.telemetryData,n=e.dimensionLookup,r=void 0===n?{}:n,i=e.excludeKeys,o=void 0===i?[]:i;return Object.keys(t).filter(function(e){return!o.includes(e)}).map(function(e){return r[e]?{key:S(r,e),value:t[e]}:{key:e,value:k(t,e)}}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function k(e,t){return"json"===t?e[t]?JSON.stringify(e[t]):"null":void 0===e[t]?"null":e[t].toString()}function S(e,t){return"dimension"+e[t]}function b(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).filter(function(e){return t[e]||G.includes(e)}).map(function(n){return t[n]?{key:_(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 _(e,t){return"metric"+e[t]}function T(e){var t=e.event,n=e.session,r=n.id,i=n.startTimestamp,o=e.dimensionLookup,s=void 0===o?{}:o,a=e.metricLookup,u=void 0===a?{}:a,c=b(t,u),l=w({telemetryData:t,dimensionLookup:s,excludeKeys:["workflow"].concat(Y(Object.keys(c)),Y(Object.keys(u)))});return{eventType:t.eventType||"other",timestamp:(new Date).toISOString(),session:{id:r,startTimestamp:i},attributes:J({referrer:document.referrer,hostname:window.location.hostname,path:window.location.pathname},l),metrics:c}}function x(e){var t=e.page,n=e.session;n=void 0===n?{}:n;var r=n.id,i=n.startTimestamp,o=e.previousPage,s=void 0===o?{}:o,a=e.options,u=void 0===a?{}:a,c=e.dimensionLookup,l=void 0===c?{}:c,h=e.metricLookup,f=void 0===h?{}:h,d=b(u,f),p=w({telemetryData:u,dimensionLookup:l,excludeKeys:["workflow"].concat(Y(Object.keys(d)),Y(Object.keys(f)))}),g=document||{},y=g.referrer,v=g.title,m=window&&window.location?window.location:{},k=m.hostname,S=m.pathname;return{eventType:"pageView",timestamp:(new Date).toISOString(),session:{id:r,startTimestamp:i},attributes:J({referrer:y,hostname:k,path:t||S,pageUrl:t||S,pageName:v,previousPageUrl:s.pageUrl,previousPageName:s.pageName},p),metrics:d}}function O(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1],n={region:"us-east-1",service:"mobileanalytics",accessKeyId:e.AccessKeyId,secretAccessKey:e.SecretKey,sessionToken:e.SessionToken};return new V(n).sign(t)}function I(e,t){return JSON.stringify({client:{client_id:e,app_title:t.name,app_version_name:t.version||"unknown"},services:{mobile_analytics:{app_id:t.id}}})}function A(n,r,i,o){var s=t();n=Array.isArray(n)?n:[n];var a=E(n);return e(r).then(function(e){try{a.headers=O(e,a),a.headers["x-amz-Client-Context"]=I(s.id,i)}catch(e){return void console.error(e)}return fetch(X,a)}).then(function(e){if(e.ok)return{success:!0};throw new Error("Telemetry failed. "+e.status+", "+e.statusText)}).catch(function(e){console.error(e.message)})}function E(e){return{url:arguments.length>1&&void 0!==arguments[1]?arguments[1]:X,method:"POST",body:JSON.stringify({events:e})}}function P(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:z(i,e),value:n[e]}:s[e]?{key:L(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 z(e,t){return"dimension"+e[t]}function L(e,t){return"metric"+e[t]}function C(e){window.ga?window.ga(function(){e(window.ga.getAll())}):console.log(new Error("Google Analytics trackers not available"))}function H(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=P({customTelemetryData:t,dimensionLookup:n,metricLookup:r});return J({},i,o)}function W(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=P({customTelemetryData:e,dimensionLookup:t,metricLookup:n});return J({},r,i)}var j={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]}}},q="TELEMETRY_COGNITO_CREDENTIALS",D="https://cognito-identity.us-east-1.amazonaws.com/",B=18e5,K="TELEMETRY_SESSION",U="TELEMETRY_CLIENT_ID",R=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)))}},h=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=h.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.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 f.HMAC.init(e,n).finalize(t)}}});var f=n.algo={};return n}(Math);!function(e){for(var t=R,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 h=e.sqrt(l),f=2;f<=h;f++)if(!(l%f)){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],h=n[7],f=0;f<64;f++){if(f<16)d[f]=0|e[t+f];else{var p=d[f-15],g=d[f-2];d[f]=((p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3)+d[f-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+d[f-16]}p=h+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[f]+d[f],g=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),h=l,l=c,c=u,u=a+p|0,a=o,o=i,i=r,r=p+g|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]+h|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=R,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 M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},N=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},F=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}}(),J=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},Y=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)},$={region:"eu-west-1",service:"execute-api",defaultContentType:"application/json",defaultAcceptType:"application/json",payloadSerializerFactory:d,uriParserFactory:p,hasherFactory:y},V=function(){function e(t){N(this,e),this.config=v({},$,t),this.payloadSerializer=this.config.payloadSerializer||this.config.payloadSerializerFactory(),this.uriParser=this.config.uriParserFactory(),this.hasher=this.config.hasherFactory(),m(this.config.accessKeyId,"AwsSigner requires AWS AccessKeyID"),m(this.config.secretAccessKey,"AwsSigner requires AWS SecretAccessKey")}return F(e,[{key:"sign",value:function(e,t){var n={request:v({},e),signDate:t||new Date,uri:this.uriParser(e.url)};return a(this,n),u(this,n),c(this,n),l(this,n),h(this,n),{Accept:n.request.headers.accept,Authorization:n.authorization,"Content-Type":n.request.headers["content-type"],"x-amz-date":n.request.headers["x-amz-date"],"x-amz-security-token":this.config.sessionToken||void 0}}}]),e}(),G=["size","duration","position","number","count"],X="https://mobileanalytics.us-east-1.amazonaws.com/2014-06-05/events",Q=function(){function e(n){N(this,e),this.name="amazon",J(this,n),t().session.new&&!n.test&&this.logEvent({eventType:"_session.start"}).catch(function(e){console.error("Failed to log _session.start: "+e.message)})}return F(e,[{key:"logPageView",value:function(e,n){var r=t().session,i=x({page:e,session:r,previousPage:this.previousPage,options:n,dimensionLookup:this.dimensions,metricLookup:this.metrics});return this.previousPage=i.attributes,A(i,this.userPoolID,this.app)}},{key:"logEvent",value:function(e){return A(T({event:e,session:t().session,dimensionLookup:this.dimensions,metricLookup:this.metrics}),this.userPoolID,this.app)}}]),e}(),Z=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};N(this,e),this.name="google",J(this,t)}return F(e,[{key:"logPageView",value:function(e,t){var n=H(e,t,this.dimensions,this.metrics);C(function(e){e.forEach(function(e){e.send(n)})})}},{key:"logEvent",value:function(e){var t=W(e,this.dimensions,this.metrics);C(function(e){e.forEach(function(e){e.send(t)})})}}]),e}(),ee=function(e){if(e)return R.SHA256(e).toString(R.enc.Hex)},te=["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"],ne=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){N(this,e);try{if(this.trackers=[],this.workflows={},this.test=t.test,this.debug=t.debug,this.disabled=!ne(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 F(e,[{key:"_initTrackers",value:function(e){if(e.amazon){var t=new Q(e.amazon);this.trackers.push(t)}if(e.google){var n=new Z(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=te.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=J({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=J({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=J({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=J({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=J({name:e,step:"cancel"},t);this._logWorkflow(n)}},{key:"getWorkflow",value:function(e){var t=j.get("TELEMETRY-WORKFLOW:"+e);if(t){if(Date.now()-t.start<18e5)return t;this._deleteWorkflow(t)}}},{key:"_saveWorkflow",value:function(e){j.set("TELEMETRY-WORKFLOW:"+e.name,e)}},{key:"_deleteWorkflow",value:function(e){j.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=J(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:ee(this.user.username),org:ee(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),J({},e,t)}}]),e}()});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define("telemetry",t):e.Telemetry=t()}(this,function(){"use strict";function e(e){var t=j.get(q);if(t&&Date.now()/1e3<t.Expiration)return 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(D,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(D,n)}).then(function(e){if(!e.ok)throw new Error(e.statusText);return e.json()}).then(function(e){var t=e.Credentials;return j.set(q,t),t})}function t(){return{session:n(),id:r()}}function n(){var e=void 0,t=j.get(K);return(!t||Date.now()>t.expiration)&&(e=!0,t=i()),t.expiration=Date.now()+B,j.set(K,t),e&&(t.new=!0),t}function r(){var e=j.get(U);return e||(e=o(),j.set(U,e)),e}function i(){return{id:Math.floor(17592186044416*(1+Math.random())).toString(16),startTimestamp:(new Date).toISOString()}}function o(){return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}function s(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function a(e,t){var n={host:t.uri.host,"content-type":e.config.defaultContentType,accept:e.config.defaultAcceptType,"x-amz-date":f(t.signDate)};t.request.method=t.request.method.toUpperCase(),t.request.body?t.payload=t.request.body:t.request.data&&e.payloadSerializer?t.payload=e.payloadSerializer(t.request.data):delete n["content-type"],t.request.headers=v(n,Object.keys(t.request.headers||{}).reduce(function(e,n){return e[n.toLowerCase()]=t.request.headers[n],e},{})),t.sortedHeaderKeys=Object.keys(t.request.headers).sort(),t.request.headers["content-type"]&&(t.request.headers["content-type"]=t.request.headers["content-type"].split(";")[0]),"object"===M(t.request.params)&&v(t.uri.queryParams,t.request.params)}function u(e,t){t.signedHeaders=t.sortedHeaderKeys.map(function(e){return e.toLowerCase()}).join(";"),t.canonicalRequest=String(t.request.method).toUpperCase()+"\n"+encodeURI(t.uri.path)+"\n"+Object.keys(t.uri.queryParams).sort().map(function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t.uri.queryParams[e])}).join("&")+"\n"+t.sortedHeaderKeys.map(function(e){return e.toLocaleLowerCase()+":"+t.request.headers[e]}).join("\n")+"\n\n"+t.signedHeaders+"\n"+e.hasher.hash(t.payload?t.payload:"")}function c(e,t){t.credentialScope=[f(t.signDate,!0),e.config.region,e.config.service,"aws4_request"].join("/"),t.stringToSign="AWS4-HMAC-SHA256\n"+f(t.signDate)+"\n"+t.credentialScope+"\n"+e.hasher.hash(t.canonicalRequest)}function l(e,t){var n=e.hasher.hmac,r=n(n(n(n("AWS4"+e.config.secretAccessKey,f(t.signDate,!0),{hexOutput:!1}),e.config.region,{hexOutput:!1,textInput:!1}),e.config.service,{hexOutput:!1,textInput:!1}),"aws4_request",{hexOutput:!1,textInput:!1});t.signature=n(r,t.stringToSign,{textInput:!1})}function h(e,t){t.authorization="AWS4-HMAC-SHA256 Credential="+e.config.accessKeyId+"/"+t.credentialScope+", SignedHeaders="+t.signedHeaders+", Signature="+t.signature}function f(e,t){var n=e.toISOString().replace(/[:\-]|\.\d{3}/g,"").substr(0,17);return t?n.substr(0,8):n}function d(){return function(e){return JSON.stringify(e)}}function p(){return function(e){var t=URL?new URL(e):document.createElement("a");return t.href=e,{protocol:t.protocol,host:t.host.replace(/^(.*):((80)|(443))$/,"$1"),path:("/"!==t.pathname.charAt(0)?"/":"")+t.pathname,queryParams:g(t.search)}}}function g(e){return/^\??(.*)$/.exec(e)[1].split("&").reduce(function(e,t){return t=/^(.+)=(.*)$/.exec(t),t&&(e[t[1]]=t[2]),e},{})}function y(){return{hash:function(e,t){t=v({hexOutput:!0,textInput:!0},t);var n=R.SHA256(e);return t.hexOutput?n.toString(R.enc.Hex):n},hmac:function(e,t,n){n=v({hexOutput:!0,textInput:!0},n);var r=R.HmacSHA256(t,e,{asBytes:!0});return n.hexOutput?r.toString(R.enc.Hex):r}}}function v(e){return[].slice.call(arguments,1).forEach(function(t){t&&"object"===(void 0===t?"undefined":M(t))&&Object.keys(t).forEach(function(n){var r=t[n];void 0!==r&&(null!==r&&"object"===(void 0===r?"undefined":M(r))?(e[n]=Array.isArray(r)?[]:{},v(e[n],r)):e[n]=r)})}),e}function m(e,t){if(void 0===e||!e)throw new Error(t)}function w(e){var t=e.telemetryData,n=e.dimensionLookup,r=void 0===n?{}:n,i=e.excludeKeys,o=void 0===i?[]:i;return Object.keys(t).filter(function(e){return!o.includes(e)}).map(function(e){return r[e]?{key:S(r,e),value:t[e]}:{key:e,value:k(t,e)}}).reduce(function(e,t){var n=t.key,r=t.value;return e[n]=r,e},{})}function k(e,t){return"json"===t?e[t]?JSON.stringify(e[t]):"null":void 0===e[t]?"null":e[t].toString()}function S(e,t){return"dimension"+e[t]}function b(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).filter(function(e){return t[e]||G.includes(e)}).map(function(n){return t[n]?{key:_(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 _(e,t){return"metric"+e[t]}function T(e){var t=e.event,n=e.session,r=n.id,i=n.startTimestamp,o=e.dimensionLookup,s=void 0===o?{}:o,a=e.metricLookup,u=void 0===a?{}:a,c=b(t,u),l=w({telemetryData:t,dimensionLookup:s,excludeKeys:["workflow"].concat(Y(Object.keys(c)),Y(Object.keys(u)))});return{eventType:t.eventType||"other",timestamp:(new Date).toISOString(),session:{id:r,startTimestamp:i},attributes:J({referrer:document.referrer,hostname:window.location.hostname,path:window.location.pathname},l),metrics:c}}function x(e){var t=e.page,n=e.session;n=void 0===n?{}:n;var r=n.id,i=n.startTimestamp,o=e.previousPage,s=void 0===o?{}:o,a=e.options,u=void 0===a?{}:a,c=e.dimensionLookup,l=void 0===c?{}:c,h=e.metricLookup,f=void 0===h?{}:h,d=b(u,f),p=w({telemetryData:u,dimensionLookup:l,excludeKeys:["workflow"].concat(Y(Object.keys(d)),Y(Object.keys(f)))}),g=document||{},y=g.referrer,v=g.title,m=window&&window.location?window.location:{},k=m.hostname,S=m.pathname;return{eventType:"pageView",timestamp:(new Date).toISOString(),session:{id:r,startTimestamp:i},attributes:J({referrer:y,hostname:k,path:t||S,pageUrl:t||S,pageName:v,previousPageUrl:s.pageUrl,previousPageName:s.pageName},p),metrics:d}}function O(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1],n={region:"us-east-1",service:"mobileanalytics",accessKeyId:e.AccessKeyId,secretAccessKey:e.SecretKey,sessionToken:e.SessionToken};return new V(n).sign(t)}function I(e,t){return JSON.stringify({client:{client_id:e,app_title:t.name,app_version_name:t.version||"unknown"},services:{mobile_analytics:{app_id:t.id}}})}function A(n,r,i,o){var s=t();n=Array.isArray(n)?n:[n];var a=E(n);return e(r).then(function(e){try{a.headers=O(e,a),a.headers["x-amz-Client-Context"]=I(s.id,i)}catch(e){return void console.error(e)}return fetch(X,a)}).then(function(e){if(e.ok)return{success:!0};throw new Error("Telemetry failed. "+e.status+", "+e.statusText)}).catch(function(e){console.error(e.message)})}function E(e){return{url:arguments.length>1&&void 0!==arguments[1]?arguments[1]:X,method:"POST",body:JSON.stringify({events:e})}}function P(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:z(i,e),value:n[e]}:s[e]?{key:L(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 z(e,t){return"dimension"+e[t]}function L(e,t){return"metric"+e[t]}function C(e){window.ga?window.ga(function(){e(window.ga.getAll())}):console.log(new Error("Google Analytics trackers not available"))}function H(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=P({customTelemetryData:t,dimensionLookup:n,metricLookup:r});return J({},i,o)}function W(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=P({customTelemetryData:e,dimensionLookup:t,metricLookup:n});return J({},r,i)}var j={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]}}},q="TELEMETRY_COGNITO_CREDENTIALS",D="https://cognito-identity.us-east-1.amazonaws.com/",B=18e5,K="TELEMETRY_SESSION",U="TELEMETRY_CLIENT_ID",R=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)))}},h=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=h.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.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 f.HMAC.init(e,n).finalize(t)}}});var f=n.algo={};return n}(Math);!function(e){for(var t=R,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 h=e.sqrt(l),f=2;f<=h;f++)if(!(l%f)){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],h=n[7],f=0;f<64;f++){if(f<16)d[f]=0|e[t+f];else{var p=d[f-15],g=d[f-2];d[f]=((p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3)+d[f-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+d[f-16]}p=h+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[f]+d[f],g=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),h=l,l=c,c=u,u=a+p|0,a=o,o=i,i=r,r=p+g|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]+h|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=R,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 M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},N=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},F=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}}(),J=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},Y=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)},$={region:"eu-west-1",service:"execute-api",defaultContentType:"application/json",defaultAcceptType:"application/json",payloadSerializerFactory:d,uriParserFactory:p,hasherFactory:y},V=function(){function e(t){N(this,e),this.config=v({},$,t),this.payloadSerializer=this.config.payloadSerializer||this.config.payloadSerializerFactory(),this.uriParser=this.config.uriParserFactory(),this.hasher=this.config.hasherFactory(),m(this.config.accessKeyId,"AwsSigner requires AWS AccessKeyID"),m(this.config.secretAccessKey,"AwsSigner requires AWS SecretAccessKey")}return F(e,[{key:"sign",value:function(e,t){var n={request:v({},e),signDate:t||new Date,uri:this.uriParser(e.url)};return a(this,n),u(this,n),c(this,n),l(this,n),h(this,n),{Accept:n.request.headers.accept,Authorization:n.authorization,"Content-Type":n.request.headers["content-type"],"x-amz-date":n.request.headers["x-amz-date"],"x-amz-security-token":this.config.sessionToken||void 0}}}]),e}(),G=["size","duration","position","number","count"],X="https://mobileanalytics.us-east-1.amazonaws.com/2014-06-05/events",Q=function(){function e(n){N(this,e),this.name="amazon",J(this,n),t().session.new&&!n.test&&this.logEvent({eventType:"_session.start"}).catch(function(e){console.error("Failed to log _session.start: "+e.message)})}return F(e,[{key:"logPageView",value:function(e,n){var r=t().session,i=x({page:e,session:r,previousPage:this.previousPage,options:n,dimensionLookup:this.dimensions,metricLookup:this.metrics});return this.previousPage=i.attributes,A(i,this.userPoolID,this.app)}},{key:"logEvent",value:function(e){return A(T({event:e,session:t().session,dimensionLookup:this.dimensions,metricLookup:this.metrics}),this.userPoolID,this.app)}}]),e}(),Z=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};N(this,e),this.name="google",J(this,t)}return F(e,[{key:"logPageView",value:function(e,t){var n=H(e,t,this.dimensions,this.metrics);C(function(e){e.forEach(function(e){e.send(n)})})}},{key:"logEvent",value:function(e){var t=W(e,this.dimensions,this.metrics);C(function(e){e.forEach(function(e){e.send(t)})})}}]),e}(),ee=function(e){if(e)return R.SHA256(e).toString(R.enc.Hex)},te=["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"],ne=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){N(this,e);try{if(this.trackers=[],this.workflows={},this.test=t.test,this.debug=t.debug,this.disabled=!ne(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 F(e,[{key:"_initTrackers",value:function(e){if(e.amazon){var t=new Q(e.amazon);this.trackers.push(t)}if(e.google){var n=new Z(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=te.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=J({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=J({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=J({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=J({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=J({name:e,step:"cancel"},t);this._logWorkflow(n)}},{key:"getWorkflow",value:function(e){var t=j.get("TELEMETRY-WORKFLOW:"+e);if(t){if(Date.now()-t.start<18e5)return t;this._deleteWorkflow(t)}}},{key:"_saveWorkflow",value:function(e){j.set("TELEMETRY-WORKFLOW:"+e.name,e)}},{key:"_deleteWorkflow",value:function(e){j.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=J(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:ee(this.user.username),org:ee(this.user.orgId),lastLogin:this.user.lastLogin,userSince:this.user.created,internalUser:this.user.internalUser||!1,accountType:this.user.accountType}),J({},e,t)}}]),e}()});
//# sourceMappingURL=telemetry.min.js.map
{
"name": "@esri/telemetry",
"version": "1.5.1-beta.0",
"version": "1.5.1-beta.1",
"description": "A JavaScript Implementation of the ArcGIS Telemetry Specification",

@@ -5,0 +5,0 @@ "main": "dist/telemetry.js",

@@ -5,12 +5,6 @@ import Storage from '../helpers/storage'

const COGNITO_URL = 'https://cognito-identity.us-east-1.amazonaws.com/'
const defaults = {
method: 'POST',
headers: {
'Content-type': 'application/x-amz-json-1.1'
}
}
export function getCredentials (IdentityPoolId, callback) {
export function getCredentials (IdentityPoolId) {
let cached = Storage.get(COGNITO_KEY)
if (cached && Date.now() / 1000 < cached.Expiration) return callback(cached)
if (cached && Date.now() / 1000 < cached.Expiration) return cached

@@ -17,0 +11,0 @@ const options = {

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc