@esri/telemetry-amazon 6.0.0-beta.10 → 6.0.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2052,7 +2052,12 @@
2052
2052
 
2053
2053
  const ESRI_SIGNING_SERVICE = 'execute-api';
2054
2054
  const ESRI_SIGNING_REGION = 'us-east-1';
2055
- const ESRI_ENDPOINT_URL = (appId) => `https://tedev.arcgis.com/v1/apps/${appId}/events`;
2055
+ const ESRI_ENDPOINT_SUBDOMAINS = {
2056
+ production: 'te',
2057
+ qa: 'teqa',
2058
+ dev: 'tedev',
2059
+ };
2060
+ const ESRI_ENDPOINT_URL = (appId, env = 'production') => `https://${ESRI_ENDPOINT_SUBDOMAINS[env || 'production']}.arcgis.com/v1/apps/${appId}/events`;
2056
2061
  const SESSION_START_EVENT = '_session.start';
2057
2062
  const SESSION_STOP_EVENT = '_session.stop';
2058
2063
  const DEFAULT_IDLE_TIMEOUT_MS = 30 * 60 * 1000;
@@ -2165,8 +2170,9 @@
2165
2170
  },
2166
2171
  };
2167
2172
  }
2168
- function createEsriPlugin({ trackerName, appName, appId, appVersion, userPoolID, fips, debounceMs = DEFAULT_DEBOUNCE_MS, }) {
2169
- const url = ESRI_ENDPOINT_URL(appId);
2173
+ function createEsriPlugin({ trackerName, appName, appId, appVersion, userPoolID, fips, debounceMs = DEFAULT_DEBOUNCE_MS, env = 'production', }) {
2174
+ const url = ESRI_ENDPOINT_URL(appId, env);
2175
+ console.log("url set", url);
2170
2176
  let isDisabled = false;
2171
2177
  let hasWarned = false;
2172
2178
  let hasSessionStarted = false;
@@ -2269,7 +2275,7 @@
2269
2275
  service: ESRI_SIGNING_SERVICE,
2270
2276
  region: ESRI_SIGNING_REGION,
2271
2277
  });
2272
- await client.fetch(url, {
2278
+ const response = await client.fetch(url, {
2273
2279
  method: 'POST',
2274
2280
  headers: {
2275
2281
  'Content-Type': 'application/json',
@@ -2281,6 +2287,12 @@
2281
2287
  appVersion,
2282
2288
  })),
2283
2289
  });
2290
+ if (response.status === 403) {
2291
+ warnLog('Response forbidden. Confirm that the configured env matches the the supplied app ID.', { env, url });
2292
+ }
2293
+ if (!response.ok) {
2294
+ throw new Error(`Esri telemetry endpoint returned ${response.status}.`);
2295
+ }
2284
2296
  debugLog('Endpoint event sent', {
2285
2297
  trackerName,
2286
2298
  eventCount: queuedEvents.length,
@@ -2479,7 +2491,7 @@
2479
2491
  this.appConfig = {};
2480
2492
  this.isPinpointRetired = (nowMs = Date.now()) => nowMs >= PINPOINT_RETIREMENT_CUTOFF_UTC_MS;
2481
2493
  // default to `esri` mode if not specified
2482
- const { app = {}, fips, userPoolID, mode = 'esri' } = options;
2494
+ const { app = {}, fips, userPoolID, env, mode = 'esri' } = options;
2483
2495
  Object.assign(this, options);
2484
2496
  this.appConfig = app;
2485
2497
  this.userPoolIDConfig = userPoolID;
@@ -2508,6 +2520,7 @@
2508
2520
  appId: this.appConfig.id,
2509
2521
  userPoolID: this.userPoolIDConfig,
2510
2522
  fips: this.fipsConfig,
2523
+ env,
2511
2524
  });
2512
2525
  }
2513
2526
  init() {