@esri/telemetry-amazon 6.0.0-beta.1 → 6.0.0-beta.2
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.
- package/dist/esm/index.js +5 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.test.js +21 -7
- package/dist/esm/index.test.js.map +1 -1
- package/dist/esm/plugins/esri.js +77 -30
- package/dist/esm/plugins/esri.js.map +1 -1
- package/dist/esm/plugins/esri.test.js +80 -13
- package/dist/esm/plugins/esri.test.js.map +1 -1
- package/dist/node/index.js +5 -5
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.test.js +21 -7
- package/dist/node/index.test.js.map +1 -1
- package/dist/node/plugins/esri.js +77 -30
- package/dist/node/plugins/esri.js.map +1 -1
- package/dist/node/plugins/esri.test.js +80 -13
- package/dist/node/plugins/esri.test.js.map +1 -1
- package/dist/types/plugins/esri.d.ts +4 -3
- package/dist/types/types.d.ts +9 -7
- package/dist/umd/telemetry-amazon.js +80 -35
- package/dist/umd/telemetry-amazon.js.map +1 -1
- package/dist/umd/telemetry-amazon.min.js +80 -35
- package/dist/umd/telemetry-amazon.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1795,12 +1795,10 @@
|
|
|
1795
1795
|
};
|
|
1796
1796
|
}
|
|
1797
1797
|
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
return String(value);
|
|
1803
|
-
}
|
|
1798
|
+
const ESRI_SIGNING_SERVICE = 'execute-api';
|
|
1799
|
+
const ESRI_SIGNING_REGION = 'us-east-1';
|
|
1800
|
+
const ESRI_ENDPOINT_URL = (appId) => `https://tedev.arcgis.com/v1/apps/${appId}/events`;
|
|
1801
|
+
/** Converts a string to a number, guarded against invalid values */
|
|
1804
1802
|
function getNumber(value, fallback = 0) {
|
|
1805
1803
|
const numeric = Number(value);
|
|
1806
1804
|
return Number.isFinite(numeric) ? numeric : fallback;
|
|
@@ -1842,6 +1840,7 @@
|
|
|
1842
1840
|
};
|
|
1843
1841
|
}
|
|
1844
1842
|
function buildBatchEventPayload({ eventName, payload, trackerName, appName, appVersion, }) {
|
|
1843
|
+
var _a, _b, _c, _d;
|
|
1845
1844
|
const endpointId = getEndpointId$1();
|
|
1846
1845
|
const sessionId = `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
1847
1846
|
const timestamp = new Date().toISOString();
|
|
@@ -1851,19 +1850,19 @@
|
|
|
1851
1850
|
Endpoint: {
|
|
1852
1851
|
Id: endpointId,
|
|
1853
1852
|
Device: {
|
|
1854
|
-
Make:
|
|
1855
|
-
Model:
|
|
1853
|
+
Make: (payload === null || payload === void 0 ? void 0 : payload.deviceMake) || '',
|
|
1854
|
+
Model: (payload === null || payload === void 0 ? void 0 : payload.deviceModel) || '',
|
|
1856
1855
|
},
|
|
1857
1856
|
Location: {
|
|
1858
|
-
City:
|
|
1859
|
-
Country:
|
|
1857
|
+
City: (payload === null || payload === void 0 ? void 0 : payload.city) || '',
|
|
1858
|
+
Country: (payload === null || payload === void 0 ? void 0 : payload.country) || '',
|
|
1860
1859
|
Lat: getNumber(payload === null || payload === void 0 ? void 0 : payload.lat),
|
|
1861
1860
|
Lon: getNumber(payload === null || payload === void 0 ? void 0 : payload.lon),
|
|
1862
1861
|
},
|
|
1863
1862
|
Application: {
|
|
1864
|
-
AppTitle:
|
|
1865
|
-
AppVersion:
|
|
1866
|
-
ClientSdkVersion:
|
|
1863
|
+
AppTitle: (_b = (_a = payload === null || payload === void 0 ? void 0 : payload.appTitle) !== null && _a !== void 0 ? _a : appName) !== null && _b !== void 0 ? _b : trackerName,
|
|
1864
|
+
AppVersion: (_c = payload === null || payload === void 0 ? void 0 : payload.appVersion) !== null && _c !== void 0 ? _c : appVersion,
|
|
1865
|
+
ClientSdkVersion: (_d = payload === null || payload === void 0 ? void 0 : payload.clientSdkVersion) !== null && _d !== void 0 ? _d : trackerName,
|
|
1867
1866
|
},
|
|
1868
1867
|
},
|
|
1869
1868
|
Events: [
|
|
@@ -1883,36 +1882,81 @@
|
|
|
1883
1882
|
},
|
|
1884
1883
|
};
|
|
1885
1884
|
}
|
|
1886
|
-
function createEsriPlugin({
|
|
1885
|
+
function createEsriPlugin({ trackerName, appName, appId, appVersion, userPoolID, fips, }) {
|
|
1886
|
+
const url = ESRI_ENDPOINT_URL(appId);
|
|
1887
|
+
let isDisabled = false;
|
|
1888
|
+
let hasWarned = false;
|
|
1889
|
+
const warnOnce = (message, details) => {
|
|
1890
|
+
if (hasWarned) {
|
|
1891
|
+
return;
|
|
1892
|
+
}
|
|
1893
|
+
hasWarned = true;
|
|
1894
|
+
warnLog$1(message, details);
|
|
1895
|
+
};
|
|
1887
1896
|
debugLog$1('createEsriPlugin initialized', {
|
|
1888
1897
|
trackerName,
|
|
1889
1898
|
hasUrl: Boolean(url),
|
|
1890
|
-
headerCount: Object.keys(headers).length,
|
|
1891
1899
|
});
|
|
1900
|
+
if (!url) {
|
|
1901
|
+
isDisabled = true;
|
|
1902
|
+
warnOnce('Esri telemetry disabled due to missing internal endpoint URL', {
|
|
1903
|
+
trackerName,
|
|
1904
|
+
});
|
|
1905
|
+
}
|
|
1906
|
+
if (!userPoolID) {
|
|
1907
|
+
isDisabled = true;
|
|
1908
|
+
warnOnce('Esri telemetry disabled due to missing userPoolID', {
|
|
1909
|
+
trackerName,
|
|
1910
|
+
});
|
|
1911
|
+
}
|
|
1912
|
+
if (typeof fetch !== 'function') {
|
|
1913
|
+
isDisabled = true;
|
|
1914
|
+
warnOnce('Esri telemetry disabled because fetch is unavailable', {
|
|
1915
|
+
trackerName,
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1892
1918
|
return {
|
|
1893
1919
|
track: (eventName, payload) => {
|
|
1894
|
-
if (!url ||
|
|
1895
|
-
debugLog$1('Skipping
|
|
1920
|
+
if (isDisabled || !url || !userPoolID) {
|
|
1921
|
+
debugLog$1('Skipping esri track call', {
|
|
1896
1922
|
eventName,
|
|
1897
|
-
reason:
|
|
1923
|
+
reason: 'plugin-disabled',
|
|
1898
1924
|
});
|
|
1899
1925
|
return false;
|
|
1900
1926
|
}
|
|
1901
|
-
debugLog$1('Sending endpoint event', {
|
|
1927
|
+
debugLog$1('Sending esri endpoint event', {
|
|
1902
1928
|
eventName,
|
|
1903
1929
|
trackerName,
|
|
1904
1930
|
url,
|
|
1905
1931
|
});
|
|
1906
|
-
void
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1932
|
+
void getCredentials(userPoolID, { fips })
|
|
1933
|
+
.then((credentials) => {
|
|
1934
|
+
const accessKeyId = (credentials === null || credentials === void 0 ? void 0 : credentials.AccessKeyId) || (credentials === null || credentials === void 0 ? void 0 : credentials.accessKeyId);
|
|
1935
|
+
const secretAccessKey = (credentials === null || credentials === void 0 ? void 0 : credentials.SecretKey) || (credentials === null || credentials === void 0 ? void 0 : credentials.secretAccessKey);
|
|
1936
|
+
const sessionToken = (credentials === null || credentials === void 0 ? void 0 : credentials.SessionToken) || (credentials === null || credentials === void 0 ? void 0 : credentials.sessionToken);
|
|
1937
|
+
if (!accessKeyId || !secretAccessKey) {
|
|
1938
|
+
throw new Error('Signed endpoint credentials are missing required key fields.');
|
|
1939
|
+
}
|
|
1940
|
+
const client = new AwsClient({
|
|
1941
|
+
accessKeyId,
|
|
1942
|
+
secretAccessKey,
|
|
1943
|
+
sessionToken,
|
|
1944
|
+
service: ESRI_SIGNING_SERVICE,
|
|
1945
|
+
region: ESRI_SIGNING_REGION,
|
|
1946
|
+
});
|
|
1947
|
+
return client.fetch(url, {
|
|
1948
|
+
method: 'POST',
|
|
1949
|
+
headers: {
|
|
1950
|
+
'Content-Type': 'application/json',
|
|
1951
|
+
},
|
|
1952
|
+
body: JSON.stringify(buildBatchEventPayload({
|
|
1953
|
+
eventName,
|
|
1954
|
+
payload: payload,
|
|
1955
|
+
trackerName,
|
|
1956
|
+
appName,
|
|
1957
|
+
appVersion,
|
|
1958
|
+
})),
|
|
1959
|
+
});
|
|
1916
1960
|
})
|
|
1917
1961
|
.then(() => {
|
|
1918
1962
|
debugLog$1('Endpoint event sent', {
|
|
@@ -1921,7 +1965,8 @@
|
|
|
1921
1965
|
});
|
|
1922
1966
|
})
|
|
1923
1967
|
.catch((error) => {
|
|
1924
|
-
|
|
1968
|
+
isDisabled = true;
|
|
1969
|
+
warnOnce('Esri telemetry disabled after endpoint track failure', {
|
|
1925
1970
|
eventName,
|
|
1926
1971
|
trackerName,
|
|
1927
1972
|
message: (error === null || error === void 0 ? void 0 : error.message) || String(error),
|
|
@@ -1941,9 +1986,8 @@
|
|
|
1941
1986
|
this.name = 'amazon';
|
|
1942
1987
|
this.previousPage = {};
|
|
1943
1988
|
this.isInitialized = false;
|
|
1944
|
-
|
|
1945
|
-
const { app = {},
|
|
1946
|
-
const { url = 'https://bh1xqvcevk.execute-api.us-east-1.amazonaws.com/akira/v1/apps/1e9a61d8a1e74aa5a6faa9112fd63d70/events', headers = {}, } = endpoint;
|
|
1989
|
+
// default to `esri` mode if not specified
|
|
1990
|
+
const { app = {}, fips, userPoolID, mode = 'esri' } = options;
|
|
1947
1991
|
this.mode = mode;
|
|
1948
1992
|
if (this.mode === 'pinpoint') {
|
|
1949
1993
|
this.analytics = createPinpointPlugin({
|
|
@@ -1956,11 +2000,12 @@
|
|
|
1956
2000
|
}
|
|
1957
2001
|
else {
|
|
1958
2002
|
this.analytics = createEsriPlugin({
|
|
1959
|
-
url,
|
|
1960
|
-
headers,
|
|
1961
2003
|
trackerName: this.name,
|
|
1962
2004
|
appName: app.name,
|
|
1963
2005
|
appVersion: app.version,
|
|
2006
|
+
appId: app.id,
|
|
2007
|
+
userPoolID,
|
|
2008
|
+
fips,
|
|
1964
2009
|
});
|
|
1965
2010
|
}
|
|
1966
2011
|
Object.assign(this, options);
|