@cloudcare/browser-core 3.1.3 → 3.1.6
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/cjs/browser/cookie.js +18 -2
- package/cjs/browser/cookie.js.map +1 -1
- package/cjs/configuration/configuration.js +18 -0
- package/cjs/configuration/configuration.js.map +1 -1
- package/cjs/configuration/transportConfiguration.js +15 -6
- package/cjs/configuration/transportConfiguration.js.map +1 -1
- package/cjs/dataMap.js +2 -2
- package/cjs/dataMap.js.map +1 -1
- package/cjs/helper/deviceInfo.js +23 -21
- package/cjs/helper/deviceInfo.js.map +1 -1
- package/cjs/helper/tools.js +66 -18
- package/cjs/helper/tools.js.map +1 -1
- package/esm/browser/cookie.js +17 -3
- package/esm/browser/cookie.js.map +1 -1
- package/esm/configuration/configuration.js +17 -0
- package/esm/configuration/configuration.js.map +1 -1
- package/esm/configuration/transportConfiguration.js +15 -6
- package/esm/configuration/transportConfiguration.js.map +1 -1
- package/esm/dataMap.js +2 -2
- package/esm/dataMap.js.map +1 -1
- package/esm/helper/deviceInfo.js +23 -21
- package/esm/helper/deviceInfo.js.map +1 -1
- package/esm/helper/tools.js +62 -17
- package/esm/helper/tools.js.map +1 -1
- package/package.json +2 -2
- package/src/browser/cookie.js +22 -3
- package/src/configuration/configuration.js +27 -1
- package/src/configuration/transportConfiguration.js +19 -13
- package/src/dataMap.js +2 -2
- package/src/helper/deviceInfo.js +23 -20
- package/src/helper/tools.js +70 -18
- package/src/.DS_Store +0 -0
package/cjs/browser/cookie.js
CHANGED
|
@@ -8,6 +8,8 @@ exports.areCookiesAuthorized = areCookiesAuthorized;
|
|
|
8
8
|
exports.deleteCookie = deleteCookie;
|
|
9
9
|
exports.getCookie = getCookie;
|
|
10
10
|
exports.getCurrentSite = getCurrentSite;
|
|
11
|
+
exports.getInitCookie = getInitCookie;
|
|
12
|
+
exports.resetInitCookies = resetInitCookies;
|
|
11
13
|
exports.setCookie = setCookie;
|
|
12
14
|
var _tools = require("../helper/tools");
|
|
13
15
|
var COOKIE_ACCESS_DELAY = _tools.ONE_SECOND;
|
|
@@ -24,6 +26,20 @@ function setCookie(name, value, expireDelay, options) {
|
|
|
24
26
|
function getCookie(name) {
|
|
25
27
|
return (0, _tools.findCommaSeparatedValue)(document.cookie, name);
|
|
26
28
|
}
|
|
29
|
+
var initCookieParsed;
|
|
30
|
+
/**
|
|
31
|
+
* Returns a cached value of the cookie. Use this during SDK initialization (and whenever possible)
|
|
32
|
+
* to avoid accessing document.cookie multiple times.
|
|
33
|
+
*/
|
|
34
|
+
function getInitCookie(name) {
|
|
35
|
+
if (!initCookieParsed) {
|
|
36
|
+
initCookieParsed = (0, _tools.findCommaSeparatedValues)(document.cookie);
|
|
37
|
+
}
|
|
38
|
+
return initCookieParsed.get(name);
|
|
39
|
+
}
|
|
40
|
+
function resetInitCookies() {
|
|
41
|
+
initCookieParsed = undefined;
|
|
42
|
+
}
|
|
27
43
|
function deleteCookie(name, options) {
|
|
28
44
|
setCookie(name, '', 0, options);
|
|
29
45
|
}
|
|
@@ -34,7 +50,7 @@ function areCookiesAuthorized(options) {
|
|
|
34
50
|
try {
|
|
35
51
|
// Use a unique cookie name to avoid issues when the SDK is initialized multiple times during
|
|
36
52
|
// the test cookie lifetime
|
|
37
|
-
var testCookieName = "
|
|
53
|
+
var testCookieName = "gc_cookie_test_".concat((0, _tools.UUID)());
|
|
38
54
|
var testCookieValue = 'test';
|
|
39
55
|
setCookie(testCookieName, testCookieValue, _tools.ONE_SECOND, options);
|
|
40
56
|
return getCookie(testCookieName) === testCookieValue;
|
|
@@ -53,7 +69,7 @@ function getCurrentSite() {
|
|
|
53
69
|
if (getCurrentSiteCache === undefined) {
|
|
54
70
|
// Use a unique cookie name to avoid issues when the SDK is initialized multiple times during
|
|
55
71
|
// the test cookie lifetime
|
|
56
|
-
var testCookieName = "
|
|
72
|
+
var testCookieName = "gc_site_test_".concat((0, _tools.UUID)());
|
|
57
73
|
var testCookieValue = 'test';
|
|
58
74
|
var domainLevels = window.location.hostname.split('.');
|
|
59
75
|
var candidateDomain = domainLevels.pop();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie.js","names":["_tools","require","COOKIE_ACCESS_DELAY","ONE_SECOND","exports","setCookie","name","value","expireDelay","options","date","Date","setTime","getTime","expires","toUTCString","sameSite","crossSite","domain","secure","document","cookie","getCookie","findCommaSeparatedValue","
|
|
1
|
+
{"version":3,"file":"cookie.js","names":["_tools","require","COOKIE_ACCESS_DELAY","ONE_SECOND","exports","setCookie","name","value","expireDelay","options","date","Date","setTime","getTime","expires","toUTCString","sameSite","crossSite","domain","secure","document","cookie","getCookie","findCommaSeparatedValue","initCookieParsed","getInitCookie","findCommaSeparatedValues","get","resetInitCookies","undefined","deleteCookie","areCookiesAuthorized","testCookieName","concat","UUID","testCookieValue","error","getCurrentSiteCache","getCurrentSite","domainLevels","window","location","hostname","split","candidateDomain","pop","length"],"sources":["../../src/browser/cookie.js"],"sourcesContent":["import {\n findCommaSeparatedValue,\n UUID,\n ONE_SECOND,\n findCommaSeparatedValues\n} from '../helper/tools'\nexport var COOKIE_ACCESS_DELAY = ONE_SECOND\n\nexport function setCookie(name, value, expireDelay, options) {\n var date = new Date()\n date.setTime(date.getTime() + expireDelay)\n var expires = 'expires=' + date.toUTCString()\n var sameSite = options && options.crossSite ? 'none' : 'strict'\n var domain = options && options.domain ? ';domain=' + options.domain : ''\n var secure = options && options.secure ? ';secure' : ''\n document.cookie =\n name +\n '=' +\n value +\n ';' +\n expires +\n ';path=/;samesite=' +\n sameSite +\n domain +\n secure\n}\n\nexport function getCookie(name) {\n return findCommaSeparatedValue(document.cookie, name)\n}\nvar initCookieParsed\n/**\n * Returns a cached value of the cookie. Use this during SDK initialization (and whenever possible)\n * to avoid accessing document.cookie multiple times.\n */\nexport function getInitCookie(name) {\n if (!initCookieParsed) {\n initCookieParsed = findCommaSeparatedValues(document.cookie)\n }\n return initCookieParsed.get(name)\n}\n\nexport function resetInitCookies() {\n initCookieParsed = undefined\n}\nexport function deleteCookie(name, options) {\n setCookie(name, '', 0, options)\n}\n\nexport function areCookiesAuthorized(options) {\n if (document.cookie === undefined || document.cookie === null) {\n return false\n }\n try {\n // Use a unique cookie name to avoid issues when the SDK is initialized multiple times during\n // the test cookie lifetime\n var testCookieName = `gc_cookie_test_${UUID()}`\n var testCookieValue = 'test'\n setCookie(testCookieName, testCookieValue, ONE_SECOND, options)\n return getCookie(testCookieName) === testCookieValue\n } catch (error) {\n return false\n }\n}\n\n/**\n * No API to retrieve it, number of levels for subdomain and suffix are unknown\n * strategy: find the minimal domain on which cookies are allowed to be set\n * https://web.dev/same-site-same-origin/#site\n */\nvar getCurrentSiteCache\nexport function getCurrentSite() {\n if (getCurrentSiteCache === undefined) {\n // Use a unique cookie name to avoid issues when the SDK is initialized multiple times during\n // the test cookie lifetime\n var testCookieName = `gc_site_test_${UUID()}`\n var testCookieValue = 'test'\n\n var domainLevels = window.location.hostname.split('.')\n var candidateDomain = domainLevels.pop()\n while (domainLevels.length && !getCookie(testCookieName)) {\n candidateDomain = domainLevels.pop() + '.' + candidateDomain\n setCookie(testCookieName, testCookieValue, ONE_SECOND, {\n domain: candidateDomain\n })\n }\n getCurrentSiteCache = candidateDomain\n }\n return getCurrentSiteCache\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAMO,IAAIC,mBAAmB,GAAGC,iBAAU;AAAAC,OAAA,CAAAF,mBAAA,GAAAA,mBAAA;AAEpC,SAASG,SAASA,CAACC,IAAI,EAAEC,KAAK,EAAEC,WAAW,EAAEC,OAAO,EAAE;EAC3D,IAAIC,IAAI,GAAG,IAAIC,IAAI,CAAC,CAAC;EACrBD,IAAI,CAACE,OAAO,CAACF,IAAI,CAACG,OAAO,CAAC,CAAC,GAAGL,WAAW,CAAC;EAC1C,IAAIM,OAAO,GAAG,UAAU,GAAGJ,IAAI,CAACK,WAAW,CAAC,CAAC;EAC7C,IA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AAIC,eAAe,GAAG,MAAM;IAC5B9B,SAAS,CAAC2B,cAAc,EAAEG,eAAe,EAAEhC,iBAAU,EAAEM,OAAO,CAAC;IAC/D,OAAOa,SAAS,CAACU,cAAc,CAAC,KAAKG,eAAe;EACtD,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,OAAO,KAAK;EACd;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAIC,mBAAmB;AAChB,SAASC,cAAcA,CAAA,EAAG;EAC/B,IAAID,mBAAmB,KAAKR,SAAS,EAAE;IACrC;IACA;IACA,IAAIG,cAAc,mBAAAC,MAAA,CAAmB,IAAAC,WAAI,EAAC,CAAC,CAAE;IAC7C,IAAIC,eAAe,GAAG,MAAM;IAE5B,IAAII,YAAY,GAAGC,MAAM,CAACC,QAAQ,CAACC,QAAQ,CAACC,KAAK,CAAC,GAAG,CAAC;IACtD,IAAIC,eAAe,GAAGL,YAAY,CAACM,GAAG,CAAC,CAAC;IACxC,OAAON,YAAY,CAACO,MAAM,IAAI,CAACxB,SAAS,CAACU,cAAc,CAAC,EAAE;MACxDY,eAAe,GAAGL,YAAY,CAACM,GAAG,CAAC,CAAC,GAAG,GAAG,GAAGD,eAAe;MAC5DvC,SAAS,CAAC2B,cAAc,EAAEG,eAAe,EAAEhC,iBAAU,EAAE;QACrDe,MAAM,EAAE0B;MACV,CAAC,CAAC;IACJ;IACAP,mBAAmB,GAAGO,eAAe;EACvC;EACA,OAAOP,mBAAmB;AAC5B"}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.DefaultPrivacyLevel = void 0;
|
|
7
7
|
exports.buildCookieOptions = buildCookieOptions;
|
|
8
8
|
exports.validateAndBuildConfiguration = validateAndBuildConfiguration;
|
|
9
|
+
exports.validatePostRequestRequireParamsConfiguration = validatePostRequestRequireParamsConfiguration;
|
|
9
10
|
var _cookie = require("../browser/cookie");
|
|
10
11
|
var _catchUserErrors = require("../helper/catchUserErrors");
|
|
11
12
|
var _display = require("../helper/display");
|
|
@@ -64,6 +65,23 @@ function validateAndBuildConfiguration(initConfiguration) {
|
|
|
64
65
|
sendContentTypeByJson: !!initConfiguration.sendContentTypeByJson
|
|
65
66
|
}, (0, _transportConfiguration.computeTransportConfiguration)(initConfiguration));
|
|
66
67
|
}
|
|
68
|
+
function validatePostRequestRequireParamsConfiguration(initConfiguration) {
|
|
69
|
+
if (!initConfiguration.site && !initConfiguration.datakitOrigin && !initConfiguration.datakitUrl) {
|
|
70
|
+
_display.display.error('datakitOrigin or site is not configured, no RUM data will be collected.');
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
// if (!initConfiguration.datakitUrl && !initConfiguration.datakitOrigin) {
|
|
74
|
+
// display.error(
|
|
75
|
+
// 'datakitOrigin is not configured, no RUM data will be collected.'
|
|
76
|
+
// )
|
|
77
|
+
// return false
|
|
78
|
+
// }
|
|
79
|
+
if (initConfiguration.site && !initConfiguration.clientToken) {
|
|
80
|
+
_display.display.error('clientToken is not configured, no RUM data will be collected.');
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
67
85
|
function buildCookieOptions(initConfiguration) {
|
|
68
86
|
var cookieOptions = {};
|
|
69
87
|
cookieOptions.secure = mustUseSecureCookie(initConfiguration);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","names":["_cookie","require","_catchUserErrors","_display","_tools","_byteUtils","_transportConfiguration","DefaultPrivacyLevel","ALLOW","MASK","MASK_USER_INPUT","exports","validateAndBuildConfiguration","initConfiguration","sampleRate","undefined","isPercentage","display","error","sessionSampleRate","telemetrySampleRate","assign","beforeSend","catchUserErrors","cookieOptions","buildCookieOptions","isNullUndefinedDefaultValue","service","version","env","telemetryEnabled","silentMultipleInit","batchBytesLimit","ONE_KIBI_BYTE","eventRateLimiterThreshold","maxTelemetryEventsPerPage","flushTimeout","ONE_SECOND","batchMessagesLimit","messageBytesLimit","resourceUrlLimit","storeContextsToLocal","sendContentTypeByJson","computeTransportConfiguration","secure","mustUseSecureCookie","crossSite","useCrossSiteSessionCookie","trackSessionAcrossSubdomains","domain","getCurrentSite","useSecureSessionCookie"],"sources":["../../src/configuration/configuration.js"],"sourcesContent":["import { getCurrentSite } from '../browser/cookie'\nimport { catchUserErrors } from '../helper/catchUserErrors'\nimport { display } from '../helper/display'\nimport {\n assign,\n isPercentage,\n ONE_SECOND,\n isNullUndefinedDefaultValue\n} from '../helper/tools'\nimport { ONE_KIBI_BYTE } from '../helper/byteUtils'\nimport { computeTransportConfiguration } from './transportConfiguration'\n\nexport var DefaultPrivacyLevel = {\n ALLOW: 'allow',\n MASK: 'mask',\n MASK_USER_INPUT: 'mask-user-input'\n}\nexport function validateAndBuildConfiguration(initConfiguration) {\n if (\n initConfiguration.sampleRate !== undefined &&\n !isPercentage(initConfiguration.sampleRate)\n ) {\n display.error('Sample Rate should be a number between 0 and 100')\n return\n }\n if (\n initConfiguration.sessionSampleRate !== undefined &&\n !isPercentage(initConfiguration.sessionSampleRate)\n ) {\n display.error('Sample Rate should be a number between 0 and 100')\n return\n }\n if (\n initConfiguration.telemetrySampleRate !== undefined &&\n !isPercentage(initConfiguration.telemetrySampleRate)\n ) {\n display.error('Telemetry Sample Rate should be a number between 0 and 100')\n return\n }\n var sessionSampleRate =\n initConfiguration.sessionSampleRate || initConfiguration.sampleRate\n return assign(\n {\n beforeSend:\n initConfiguration.beforeSend &&\n catchUserErrors(\n initConfiguration.beforeSend,\n 'beforeSend threw an error:'\n ),\n cookieOptions: buildCookieOptions(initConfiguration),\n sessionSampleRate: isNullUndefinedDefaultValue(sessionSampleRate, 100),\n service: initConfiguration.service,\n version: initConfiguration.version,\n env: initConfiguration.env,\n telemetrySampleRate: isNullUndefinedDefaultValue(\n initConfiguration.telemetrySampleRate,\n 100\n ),\n telemetryEnabled: isNullUndefinedDefaultValue(\n initConfiguration.telemetryEnabled,\n false\n ),\n silentMultipleInit: !!initConfiguration.silentMultipleInit,\n\n /**\n * beacon payload max queue size implementation is 64kb\n * ensure that we leave room for logs, rum and potential other users\n */\n batchBytesLimit: 16 * ONE_KIBI_BYTE,\n\n eventRateLimiterThreshold: 3000,\n maxTelemetryEventsPerPage: 15,\n\n /**\n * flush automatically, aim to be lower than ALB connection timeout\n * to maximize connection reuse.\n */\n flushTimeout: 30 * ONE_SECOND,\n\n /**\n * Logs intake limit\n */\n batchMessagesLimit: 50,\n messageBytesLimit: 256 * ONE_KIBI_BYTE,\n resourceUrlLimit: 5 * ONE_KIBI_BYTE,\n storeContextsToLocal: !!initConfiguration.storeContextsToLocal,\n sendContentTypeByJson: !!initConfiguration.sendContentTypeByJson\n },\n computeTransportConfiguration(initConfiguration)\n )\n}\n\nexport function buildCookieOptions(initConfiguration) {\n var cookieOptions = {}\n\n cookieOptions.secure = mustUseSecureCookie(initConfiguration)\n cookieOptions.crossSite = !!initConfiguration.useCrossSiteSessionCookie\n\n if (initConfiguration.trackSessionAcrossSubdomains) {\n cookieOptions.domain = getCurrentSite()\n }\n\n return cookieOptions\n}\n\nfunction mustUseSecureCookie(initConfiguration) {\n return (\n !!initConfiguration.useSecureSessionCookie ||\n !!initConfiguration.useCrossSiteSessionCookie\n )\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"configuration.js","names":["_cookie","require","_catchUserErrors","_display","_tools","_byteUtils","_transportConfiguration","DefaultPrivacyLevel","ALLOW","MASK","MASK_USER_INPUT","exports","validateAndBuildConfiguration","initConfiguration","sampleRate","undefined","isPercentage","display","error","sessionSampleRate","telemetrySampleRate","assign","beforeSend","catchUserErrors","cookieOptions","buildCookieOptions","isNullUndefinedDefaultValue","service","version","env","telemetryEnabled","silentMultipleInit","batchBytesLimit","ONE_KIBI_BYTE","eventRateLimiterThreshold","maxTelemetryEventsPerPage","flushTimeout","ONE_SECOND","batchMessagesLimit","messageBytesLimit","resourceUrlLimit","storeContextsToLocal","sendContentTypeByJson","computeTransportConfiguration","validatePostRequestRequireParamsConfiguration","site","datakitOrigin","datakitUrl","clientToken","secure","mustUseSecureCookie","crossSite","useCrossSiteSessionCookie","trackSessionAcrossSubdomains","domain","getCurrentSite","useSecureSessionCookie"],"sources":["../../src/configuration/configuration.js"],"sourcesContent":["import { getCurrentSite } from '../browser/cookie'\nimport { catchUserErrors } from '../helper/catchUserErrors'\nimport { display } from '../helper/display'\nimport {\n assign,\n isPercentage,\n ONE_SECOND,\n isNullUndefinedDefaultValue\n} from '../helper/tools'\nimport { ONE_KIBI_BYTE } from '../helper/byteUtils'\nimport { computeTransportConfiguration } from './transportConfiguration'\n\nexport var DefaultPrivacyLevel = {\n ALLOW: 'allow',\n MASK: 'mask',\n MASK_USER_INPUT: 'mask-user-input'\n}\nexport function validateAndBuildConfiguration(initConfiguration) {\n if (\n initConfiguration.sampleRate !== undefined &&\n !isPercentage(initConfiguration.sampleRate)\n ) {\n display.error('Sample Rate should be a number between 0 and 100')\n return\n }\n if (\n initConfiguration.sessionSampleRate !== undefined &&\n !isPercentage(initConfiguration.sessionSampleRate)\n ) {\n display.error('Sample Rate should be a number between 0 and 100')\n return\n }\n if (\n initConfiguration.telemetrySampleRate !== undefined &&\n !isPercentage(initConfiguration.telemetrySampleRate)\n ) {\n display.error('Telemetry Sample Rate should be a number between 0 and 100')\n return\n }\n var sessionSampleRate =\n initConfiguration.sessionSampleRate || initConfiguration.sampleRate\n return assign(\n {\n beforeSend:\n initConfiguration.beforeSend &&\n catchUserErrors(\n initConfiguration.beforeSend,\n 'beforeSend threw an error:'\n ),\n cookieOptions: buildCookieOptions(initConfiguration),\n sessionSampleRate: isNullUndefinedDefaultValue(sessionSampleRate, 100),\n service: initConfiguration.service,\n version: initConfiguration.version,\n env: initConfiguration.env,\n telemetrySampleRate: isNullUndefinedDefaultValue(\n initConfiguration.telemetrySampleRate,\n 100\n ),\n telemetryEnabled: isNullUndefinedDefaultValue(\n initConfiguration.telemetryEnabled,\n false\n ),\n silentMultipleInit: !!initConfiguration.silentMultipleInit,\n\n /**\n * beacon payload max queue size implementation is 64kb\n * ensure that we leave room for logs, rum and potential other users\n */\n batchBytesLimit: 16 * ONE_KIBI_BYTE,\n\n eventRateLimiterThreshold: 3000,\n maxTelemetryEventsPerPage: 15,\n\n /**\n * flush automatically, aim to be lower than ALB connection timeout\n * to maximize connection reuse.\n */\n flushTimeout: 30 * ONE_SECOND,\n\n /**\n * Logs intake limit\n */\n batchMessagesLimit: 50,\n messageBytesLimit: 256 * ONE_KIBI_BYTE,\n resourceUrlLimit: 5 * ONE_KIBI_BYTE,\n storeContextsToLocal: !!initConfiguration.storeContextsToLocal,\n sendContentTypeByJson: !!initConfiguration.sendContentTypeByJson\n },\n computeTransportConfiguration(initConfiguration)\n )\n}\nexport function validatePostRequestRequireParamsConfiguration(\n initConfiguration\n) {\n if (\n !initConfiguration.site &&\n !initConfiguration.datakitOrigin &&\n !initConfiguration.datakitUrl\n ) {\n display.error(\n 'datakitOrigin or site is not configured, no RUM data will be collected.'\n )\n return false\n }\n // if (!initConfiguration.datakitUrl && !initConfiguration.datakitOrigin) {\n // display.error(\n // 'datakitOrigin is not configured, no RUM data will be collected.'\n // )\n // return false\n // }\n if (initConfiguration.site && !initConfiguration.clientToken) {\n display.error(\n 'clientToken is not configured, no RUM data will be collected.'\n )\n return false\n }\n return true\n}\nexport function buildCookieOptions(initConfiguration) {\n var cookieOptions = {}\n\n cookieOptions.secure = mustUseSecureCookie(initConfiguration)\n cookieOptions.crossSite = !!initConfiguration.useCrossSiteSessionCookie\n\n if (initConfiguration.trackSessionAcrossSubdomains) {\n cookieOptions.domain = getCurrentSite()\n }\n\n return cookieOptions\n}\n\nfunction mustUseSecureCookie(initConfiguration) {\n return (\n !!initConfiguration.useSecureSessionCookie ||\n !!initConfiguration.useCrossSiteSessionCookie\n )\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IA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G,CAAC,CAAC;EAEtBA,aAAa,CAACyB,MAAM,GAAGC,mBAAmB,CAACrC,iBAAiB,CAAC;EAC7DW,aAAa,CAAC2B,SAAS,GAAG,CAAC,CAACtC,iBAAiB,CAACuC,yBAAyB;EAEvE,IAAIvC,iBAAiB,CAACwC,4BAA4B,EAAE;IAClD7B,aAAa,CAAC8B,MAAM,GAAG,IAAAC,sBAAc,EAAC,CAAC;EACzC;EAEA,OAAO/B,aAAa;AACtB;AAEA,SAAS0B,mBAAmBA,CAACrC,iBAAiB,EAAE;EAC9C,OACE,CAAC,CAACA,iBAAiB,CAAC2C,sBAAsB,IAC1C,CAAC,CAAC3C,iBAAiB,CAACuC,yBAAyB;AAEjD"}
|
|
@@ -12,16 +12,25 @@ var typeMap = {
|
|
|
12
12
|
log: '/logging',
|
|
13
13
|
sessionReplay: '/rum/replay'
|
|
14
14
|
};
|
|
15
|
-
function getEndPointUrl(
|
|
15
|
+
function getEndPointUrl(configuration, type) {
|
|
16
16
|
// type: rum, log,replay
|
|
17
17
|
var subUrl = typeMap[type];
|
|
18
18
|
if (!subUrl) return '';
|
|
19
|
+
var url = configuration.datakitOrigin || configuration.datakitUrl || configuration.site;
|
|
19
20
|
if (url.indexOf('/') === 0) {
|
|
20
21
|
// 绝对路径这种 /xxx
|
|
21
22
|
url = location.origin + trim(url);
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
var endpoint = url;
|
|
25
|
+
if (url.lastIndexOf('/') === url.length - 1) {
|
|
26
|
+
endpoint = trim(url) + 'v1/write' + subUrl;
|
|
27
|
+
} else {
|
|
28
|
+
endpoint = trim(url) + '/v1/write' + subUrl;
|
|
29
|
+
}
|
|
30
|
+
if (configuration.site && configuration.clientToken) {
|
|
31
|
+
endpoint = endpoint + '?token=' + configuration.clientToken + '&to_headless=true';
|
|
32
|
+
}
|
|
33
|
+
return endpoint;
|
|
25
34
|
}
|
|
26
35
|
function trim(str) {
|
|
27
36
|
return str.replace(TRIM_REGIX, '');
|
|
@@ -40,9 +49,9 @@ function computeTransportConfiguration(initConfiguration) {
|
|
|
40
49
|
isServerError = initConfiguration.isServerError;
|
|
41
50
|
}
|
|
42
51
|
return {
|
|
43
|
-
rumEndpoint: getEndPointUrl(initConfiguration
|
|
44
|
-
logsEndpoint: getEndPointUrl(initConfiguration
|
|
45
|
-
sessionReplayEndPoint: getEndPointUrl(initConfiguration
|
|
52
|
+
rumEndpoint: getEndPointUrl(initConfiguration, 'rum'),
|
|
53
|
+
logsEndpoint: getEndPointUrl(initConfiguration, 'log'),
|
|
54
|
+
sessionReplayEndPoint: getEndPointUrl(initConfiguration, 'sessionReplay'),
|
|
46
55
|
isIntakeUrl: isIntakeUrl,
|
|
47
56
|
isServerError: isServerError
|
|
48
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transportConfiguration.js","names":["_tools","require","TRIM_REGIX","typeMap","rum","log","sessionReplay","getEndPointUrl","
|
|
1
|
+
{"version":3,"file":"transportConfiguration.js","names":["_tools","require","TRIM_REGIX","typeMap","rum","log","sessionReplay","getEndPointUrl","configuration","type","subUrl","url","datakitOrigin","datakitUrl","site","indexOf","location","origin","trim","endpoint","lastIndexOf","length","clientToken","str","replace","computeTransportConfiguration","initConfiguration","isIntakeUrl","isFunction","isBoolean","isServerError","request","rumEndpoint","logsEndpoint","sessionReplayEndPoint","isIntakeRequest","notTakeRequest","push","some","takeUrl"],"sources":["../../src/configuration/transportConfiguration.js"],"sourcesContent":["import { isFunction, isBoolean, some } from '../helper/tools'\nvar TRIM_REGIX = /^\\s+|\\s+$/g\nvar typeMap = {\n rum: '/rum',\n log: '/logging',\n sessionReplay: '/rum/replay'\n}\nfunction getEndPointUrl(configuration, type) {\n // type: rum, log,replay\n var subUrl = typeMap[type]\n if (!subUrl) return ''\n var url =\n configuration.datakitOrigin ||\n configuration.datakitUrl ||\n configuration.site\n if (url.indexOf('/') === 0) {\n // 绝对路径这种 /xxx\n url = location.origin + trim(url)\n }\n var endpoint = url\n if (url.lastIndexOf('/') === url.length - 1) {\n endpoint = trim(url) + 'v1/write' + subUrl\n } else {\n endpoint = trim(url) + '/v1/write' + subUrl\n }\n if (configuration.site && configuration.clientToken) {\n endpoint =\n endpoint + '?token=' + configuration.clientToken + '&to_headless=true'\n }\n return endpoint\n}\n\nfunction trim(str) {\n return str.replace(TRIM_REGIX, '')\n}\n\nexport function computeTransportConfiguration(initConfiguration) {\n var isIntakeUrl = function (url) {\n return false\n }\n if (\n 'isIntakeUrl' in initConfiguration &&\n isFunction(initConfiguration.isIntakeUrl) &&\n isBoolean(initConfiguration.isIntakeUrl())\n ) {\n isIntakeUrl = initConfiguration.isIntakeUrl\n }\n var isServerError = function (request) {\n return false\n }\n if (\n 'isServerError' in initConfiguration &&\n isFunction(initConfiguration.isServerError) &&\n isBoolean(initConfiguration.isServerError())\n ) {\n isServerError = initConfiguration.isServerError\n }\n return {\n rumEndpoint: getEndPointUrl(initConfiguration, 'rum'),\n logsEndpoint: getEndPointUrl(initConfiguration, 'log'),\n sessionReplayEndPoint: getEndPointUrl(initConfiguration, 'sessionReplay'),\n isIntakeUrl: isIntakeUrl,\n isServerError: isServerError\n }\n}\nexport function isIntakeRequest(url, configuration) {\n var notTakeRequest = [configuration.rumEndpoint]\n if (configuration.logsEndpoint) {\n notTakeRequest.push(configuration.logsEndpoint)\n }\n if (configuration.sessionReplayEndPoint) {\n notTakeRequest.push(configuration.sessionReplayEndPoint)\n }\n // datakit 地址,log 地址,以及客户自定义过滤方法定义url\n return (\n some(notTakeRequest, function (takeUrl) {\n return url.indexOf(takeUrl) === 0\n }) || configuration.isIntakeUrl(url)\n )\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAIC,UAAU,GAAG,YAAY;AAC7B,IAAIC,OAAO,GAAG;EACZC,GAAG,EAAE,MAAM;EACXC,GAAG,EAAE,UAAU;EACfC,aAAa,EAAE;AACjB,CAAC;AACD,SAASC,cAAcA,CA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C;IACAA,WAAW,GAAGD,iBAAiB,CAACC,WAAW;EAC7C;EACA,IAAIG,aAAa,GAAG,SAAAA,cAAUC,OAAO,EAAE;IACrC,OAAO,KAAK;EACd,CAAC;EACD,IACE,eAAe,IAAIL,iBAAiB,IACpC,IAAAE,iBAAU,EAACF,iBAAiB,CAACI,aAAa,CAAC,IAC3C,IAAAD,gBAAS,EAACH,iBAAiB,CAACI,aAAa,CAAC,CAAC,CAAC,EAC5C;IACAA,aAAa,GAAGJ,iBAAiB,CAACI,aAAa;EACjD;EACA,OAAO;IACLE,WAAW,EAAEzB,cAAc,CAACmB,iBAAiB,EAAE,KAAK,CAAC;IACrDO,YAAY,EAAE1B,cAAc,CAACmB,iBAAiB,EAAE,KAAK,CAAC;IACtDQ,qBAAqB,EAAE3B,cAAc,CAACmB,iBAAiB,EAAE,eAAe,CAAC;IACzEC,WAAW,EAAEA,WAAW;IACxBG,aAAa,EAAEA;EACjB,CAAC;AACH;AACO,SAASK,eAAeA,CAACxB,GAAG,EAAEH,aAAa,EAAE;EAClD,IAAI4B,cAAc,GAAG,CAAC5B,aAAa,CAACwB,WAAW,CAAC;EAChD,IAAIxB,aAAa,CAACyB,YAAY,EAAE;IAC9BG,cAAc,CAACC,IAAI,CAAC7B,aAAa,CAACyB,YAAY,CAAC;EACjD;EACA,IAAIzB,aAAa,CAAC0B,qBAAqB,EAAE;IACvCE,cAAc,CAACC,IAAI,CAAC7B,aAAa,CAAC0B,qBAAqB,CAAC;EAC1D;EACA;EACA,OACE,IAAAI,WAAI,EAACF,cAAc,EAAE,UAAUG,OAAO,EAAE;IACtC,OAAO5B,GAAG,CAACI,OAAO,CAACwB,OAAO,CAAC,KAAK,CAAC;EACnC,CAAC,CAAC,IAAI/B,aAAa,CAACmB,WAAW,CAAChB,GAAG,CAAC;AAExC"}
|
package/cjs/dataMap.js
CHANGED
|
@@ -35,11 +35,11 @@ var commonTags = {
|
|
|
35
35
|
view_path: 'view.path',
|
|
36
36
|
view_name: 'view.path',
|
|
37
37
|
// 冗余一个字段
|
|
38
|
-
view_path_group: 'view.path_group'
|
|
39
|
-
view_url_query: 'view.url_query'
|
|
38
|
+
view_path_group: 'view.path_group'
|
|
40
39
|
};
|
|
41
40
|
exports.commonTags = commonTags;
|
|
42
41
|
var commonFields = {
|
|
42
|
+
view_url_query: 'view.url_query',
|
|
43
43
|
action_id: 'action.id',
|
|
44
44
|
action_ids: 'action.ids',
|
|
45
45
|
view_in_foreground: 'view.in_foreground',
|
package/cjs/dataMap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataMap.js","names":["_enums","require","commonTags","sdk_name","sdk_version","app_id","env","service","version","userid","user_email","user_name","session_id","session_type","session_sampling","is_signin","os","os_version","os_version_major","browser","browser_version","browser_version_major","screen_size","network_type","device","view_id","view_referrer","view_url","view_host","view_path","view_name","view_path_group","view_url_query","exports","commonFields","action_id","action_ids","view_in_foreground","display","session_has_replay","is_login","page_states","dataMap","view","type","RumEventType","VIEW","tags","view_loading_type","view_apdex_level","view_privacy_replay_level","fields","is_active","session_replay_stats","session_is_active","view_error_count","view_resource_count","view_long_task_count","view_action_count","first_contentful_paint","largest_contentful_paint","largest_contentful_paint_element_selector","cumulative_layout_shift","cumulative_layout_shift_target_selector","first_input_delay","loading_time","dom_interactive","dom_content_loaded","dom_complete","load_event","first_input_time","first_input_target_selector","first_paint_time","interaction_to_next_paint","interaction_to_next_paint_target_selector","resource_load_time","time_to_interactive","dom","dom_ready","time_spent","first_byte","frustration_count","custom_timings","resource","RESOURCE","trace_id","span_id","resource_url","resource_url_host","resource_url_path","resource_url_path_group","resource_url_query","resource_type","resource_status","resource_status_group","resource_method","duration","resource_size","resource_encode_size","resource_render_blocking_status","resource_dns","resource_tcp","resource_ssl","resource_ttfb","resource_trans","resource_redirect","resource_first_byte","resource_dns_time","resource_download_time","resource_first_byte_time","resource_connect_time","resource_ssl_time","resource_redirect_time","error","ERROR","error_id","error_source","error_type","error_handling","error_message","error_stack","error_causes","long_task","LONG_TASK","long_task_id","action","ACTION","action_type","action_name","action_error_count","action_resource_count","action_frustration_types","action_long_task_count","action_target","action_position","telemetry","status","message","error_kind","browser_log","LOGGER","error_resource_url","error_resource_url_host","error_resource_url_path","error_resource_url_path_group","error_resource_status","error_resource_status_group","error_resource_method"],"sources":["../src/dataMap.js"],"sourcesContent":["import { RumEventType } from './helper/enums'\nexport var commonTags = {\n sdk_name: '_gc.sdk_name',\n sdk_version: '_gc.sdk_version',\n app_id: 'application.id',\n env: 'env',\n service: 'service',\n version: 'version',\n userid: 'user.id',\n user_email: 'user.email',\n user_name: 'user.name',\n session_id: 'session.id',\n session_type: 'session.type',\n session_sampling: 'session.is_sampling',\n is_signin: 'user.is_signin',\n os: 'device.os',\n os_version: 'device.os_version',\n os_version_major: 'device.os_version_major',\n browser: 'device.browser',\n browser_version: 'device.browser_version',\n browser_version_major: 'device.browser_version_major',\n screen_size: 'device.screen_size',\n network_type: 'device.network_type',\n device: 'device.device',\n view_id: 'view.id',\n view_referrer: 'view.referrer',\n view_url: 'view.url',\n view_host: 'view.host',\n view_path: 'view.path',\n view_name: 'view.path', // 冗余一个字段\n view_path_group: 'view.path_group',\n view_url_query: 'view.url_query'\n}\nexport var commonFields = {\n action_id: 'action.id',\n action_ids: 'action.ids',\n view_in_foreground: 'view.in_foreground',\n display: 'display',\n session_has_replay: 'session.has_replay',\n is_login: 'user.is_login',\n page_states: '_gc.page_states'\n}\n// 需要用双引号将字符串类型的field value括起来, 这里有数组标示[string, path]\nexport var dataMap = {\n view: {\n type: RumEventType.VIEW,\n tags: {\n view_loading_type: 'view.loading_type',\n view_apdex_level: 'view.apdex_level',\n view_privacy_replay_level: 'privacy.replay_level'\n },\n fields: {\n is_active: 'view.is_active',\n session_replay_stats: '_gc.replay_stats',\n session_is_active: 'session.is_active',\n view_error_count: 'view.error.count',\n view_resource_count: 'view.resource.count',\n view_long_task_count: 'view.long_task.count',\n view_action_count: 'view.action.count',\n first_contentful_paint: 'view.first_contentful_paint',\n largest_contentful_paint: 'view.largest_contentful_paint',\n largest_contentful_paint_element_selector:\n 'view.largest_contentful_paint_element_selector',\n cumulative_layout_shift: 'view.cumulative_layout_shift',\n cumulative_layout_shift_target_selector:\n 'view.cumulative_layout_shift_target_selector',\n first_input_delay: 'view.first_input_delay',\n loading_time: 'view.loading_time',\n dom_interactive: 'view.dom_interactive',\n dom_content_loaded: 'view.dom_content_loaded',\n dom_complete: 'view.dom_complete',\n load_event: 'view.load_event',\n first_input_time: 'view.first_input_time',\n first_input_target_selector: 'view.first_input_target_selector',\n first_paint_time: 'view.fpt',\n interaction_to_next_paint: 'view.interaction_to_next_paint',\n interaction_to_next_paint_target_selector:\n 'view.interaction_to_next_paint_target_selector',\n resource_load_time: 'view.resource_load_time',\n time_to_interactive: 'view.tti',\n dom: 'view.dom',\n dom_ready: 'view.dom_ready',\n time_spent: 'view.time_spent',\n first_byte: 'view.first_byte',\n frustration_count: 'view.frustration.count',\n custom_timings: 'view.custom_timings'\n }\n },\n resource: {\n type: RumEventType.RESOURCE,\n tags: {\n trace_id: '_gc.trace_id',\n span_id: '_gc.span_id',\n resource_url: 'resource.url',\n resource_url_host: 'resource.url_host',\n resource_url_path: 'resource.url_path',\n resource_url_path_group: 'resource.url_path_group',\n resource_url_query: 'resource.url_query',\n resource_type: 'resource.type',\n resource_status: 'resource.status',\n resource_status_group: 'resource.status_group',\n resource_method: 'resource.method'\n },\n fields: {\n duration: 'resource.duration',\n resource_size: 'resource.size',\n resource_encode_size: 'resource.encode_size',\n resource_render_blocking_status: 'resource.render_blocking_status',\n resource_dns: 'resource.dns',\n resource_tcp: 'resource.tcp',\n resource_ssl: 'resource.ssl',\n resource_ttfb: 'resource.ttfb',\n resource_trans: 'resource.trans',\n resource_redirect: 'resource.redirect',\n resource_first_byte: 'resource.firstbyte',\n resource_dns_time: 'resource.dns_time',\n resource_download_time: 'resource.download_time',\n resource_first_byte_time: 'resource.first_byte_time',\n resource_connect_time: 'resource.connect_time',\n resource_ssl_time: 'resource.ssl_time',\n resource_redirect_time: 'resource.redirect_time'\n }\n },\n error: {\n type: RumEventType.ERROR,\n tags: {\n error_id: 'error.id',\n trace_id: '_gc.trace_id',\n span_id: '_gc.span_id',\n error_source: 'error.source',\n error_type: 'error.type',\n error_handling: 'error.handling'\n // resource_url: 'error.resource.url',\n // resource_url_host: 'error.resource.url_host',\n // resource_url_path: 'error.resource.url_path',\n // resource_url_path_group: 'error.resource.url_path_group',\n // resource_status: 'error.resource.status',\n // resource_status_group: 'error.resource.status_group',\n // resource_method: 'error.resource.method'\n },\n fields: {\n error_message: ['string', 'error.message'],\n error_stack: ['string', 'error.stack'],\n error_causes: ['string', 'error.causes']\n }\n },\n long_task: {\n type: RumEventType.LONG_TASK,\n tags: {\n long_task_id: 'long_task.id'\n },\n fields: {\n duration: 'long_task.duration'\n }\n },\n action: {\n type: RumEventType.ACTION,\n tags: {\n action_type: 'action.type'\n },\n fields: {\n action_name: 'action.target.name',\n duration: 'action.loading_time',\n action_error_count: 'action.error.count',\n action_resource_count: 'action.resource.count',\n action_frustration_types: 'action.frustration.type',\n action_long_task_count: 'action.long_task.count',\n action_target: '_gc.action.target',\n action_position: '_gc.action.position'\n }\n },\n telemetry: {\n type: 'telemetry',\n fields: {\n status: 'telemetry.status',\n message: ['string', 'telemetry.message'],\n type: 'telemetry.type',\n error_stack: ['string', 'telemetry.error.stack'],\n error_kind: ['string', 'telemetry.error.kind']\n }\n },\n browser_log: {\n type: RumEventType.LOGGER,\n tags: {\n error_source: 'error.source',\n error_type: 'error.type',\n error_resource_url: 'http.url',\n error_resource_url_host: 'http.url_host',\n error_resource_url_path: 'http.url_path',\n error_resource_url_path_group: 'http.url_path_group',\n error_resource_status: 'http.status_code',\n error_resource_status_group: 'http.status_group',\n error_resource_method: 'http.method',\n action_id: 'user_action.id',\n service: 'service',\n status: 'status'\n },\n fields: {\n message: ['string', 'message']\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GA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AAC;IACDrF,MAAM,EAAE;MACNsF,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS;IAC/B;EACF;AACF,CAAC;AAAAxG,OAAA,CAAAS,OAAA,GAAAA,OAAA"}
|
|
1
|
+
{"version":3,"file":"dataMap.js","names":["_enums","require","commonTags","sdk_name","sdk_version","app_id","env","service","version","userid","user_email","user_name","session_id","session_type","session_sampling","is_signin","os","os_version","os_version_major","browser","browser_version","browser_version_major","screen_size","network_type","device","view_id","view_referrer","view_url","view_host","view_path","view_name","view_path_group","exports","commonFields","view_url_query","action_id","action_ids","view_in_foreground","display","session_has_replay","is_login","page_states","dataMap","view","type","RumEventType","VIEW","tags","view_loading_type","view_apdex_level","view_privacy_replay_level","fields","is_active","session_replay_stats","session_is_active","view_error_count","view_resource_count","view_long_task_count","view_action_count","first_contentful_paint","largest_contentful_paint","largest_contentful_paint_element_selector","cumulative_layout_shift","cumulative_layout_shift_target_selector","first_input_delay","loading_time","dom_interactive","dom_content_loaded","dom_complete","load_event","first_input_time","first_input_target_selector","first_paint_time","interaction_to_next_paint","interaction_to_next_paint_target_selector","resource_load_time","time_to_interactive","dom","dom_ready","time_spent","first_byte","frustration_count","custom_timings","resource","RESOURCE","trace_id","span_id","resource_url","resource_url_host","resource_url_path","resource_url_path_group","resource_url_query","resource_type","resource_status","resource_status_group","resource_method","duration","resource_size","resource_encode_size","resource_render_blocking_status","resource_dns","resource_tcp","resource_ssl","resource_ttfb","resource_trans","resource_redirect","resource_first_byte","resource_dns_time","resource_download_time","resource_first_byte_time","resource_connect_time","resource_ssl_time","resource_redirect_time","error","ERROR","error_id","error_source","error_type","error_handling","error_message","error_stack","error_causes","long_task","LONG_TASK","long_task_id","action","ACTION","action_type","action_name","action_error_count","action_resource_count","action_frustration_types","action_long_task_count","action_target","action_position","telemetry","status","message","error_kind","browser_log","LOGGER","error_resource_url","error_resource_url_host","error_resource_url_path","error_resource_url_path_group","error_resource_status","error_resource_status_group","error_resource_method"],"sources":["../src/dataMap.js"],"sourcesContent":["import { RumEventType } from './helper/enums'\nexport var commonTags = {\n sdk_name: '_gc.sdk_name',\n sdk_version: '_gc.sdk_version',\n app_id: 'application.id',\n env: 'env',\n service: 'service',\n version: 'version',\n userid: 'user.id',\n user_email: 'user.email',\n user_name: 'user.name',\n session_id: 'session.id',\n session_type: 'session.type',\n session_sampling: 'session.is_sampling',\n is_signin: 'user.is_signin',\n os: 'device.os',\n os_version: 'device.os_version',\n os_version_major: 'device.os_version_major',\n browser: 'device.browser',\n browser_version: 'device.browser_version',\n browser_version_major: 'device.browser_version_major',\n screen_size: 'device.screen_size',\n network_type: 'device.network_type',\n device: 'device.device',\n view_id: 'view.id',\n view_referrer: 'view.referrer',\n view_url: 'view.url',\n view_host: 'view.host',\n view_path: 'view.path',\n view_name: 'view.path', // 冗余一个字段\n view_path_group: 'view.path_group'\n}\nexport var commonFields = {\n view_url_query: 'view.url_query',\n action_id: 'action.id',\n action_ids: 'action.ids',\n view_in_foreground: 'view.in_foreground',\n display: 'display',\n session_has_replay: 'session.has_replay',\n is_login: 'user.is_login',\n page_states: '_gc.page_states'\n}\n// 需要用双引号将字符串类型的field value括起来, 这里有数组标示[string, path]\nexport var dataMap = {\n view: {\n type: RumEventType.VIEW,\n tags: {\n view_loading_type: 'view.loading_type',\n view_apdex_level: 'view.apdex_level',\n view_privacy_replay_level: 'privacy.replay_level'\n },\n fields: {\n is_active: 'view.is_active',\n session_replay_stats: '_gc.replay_stats',\n session_is_active: 'session.is_active',\n view_error_count: 'view.error.count',\n view_resource_count: 'view.resource.count',\n view_long_task_count: 'view.long_task.count',\n view_action_count: 'view.action.count',\n first_contentful_paint: 'view.first_contentful_paint',\n largest_contentful_paint: 'view.largest_contentful_paint',\n largest_contentful_paint_element_selector:\n 'view.largest_contentful_paint_element_selector',\n cumulative_layout_shift: 'view.cumulative_layout_shift',\n cumulative_layout_shift_target_selector:\n 'view.cumulative_layout_shift_target_selector',\n first_input_delay: 'view.first_input_delay',\n loading_time: 'view.loading_time',\n dom_interactive: 'view.dom_interactive',\n dom_content_loaded: 'view.dom_content_loaded',\n dom_complete: 'view.dom_complete',\n load_event: 'view.load_event',\n first_input_time: 'view.first_input_time',\n first_input_target_selector: 'view.first_input_target_selector',\n first_paint_time: 'view.fpt',\n interaction_to_next_paint: 'view.interaction_to_next_paint',\n interaction_to_next_paint_target_selector:\n 'view.interaction_to_next_paint_target_selector',\n resource_load_time: 'view.resource_load_time',\n time_to_interactive: 'view.tti',\n dom: 'view.dom',\n dom_ready: 'view.dom_ready',\n time_spent: 'view.time_spent',\n first_byte: 'view.first_byte',\n frustration_count: 'view.frustration.count',\n custom_timings: 'view.custom_timings'\n }\n },\n resource: {\n type: RumEventType.RESOURCE,\n tags: {\n trace_id: '_gc.trace_id',\n span_id: '_gc.span_id',\n resource_url: 'resource.url',\n resource_url_host: 'resource.url_host',\n resource_url_path: 'resource.url_path',\n resource_url_path_group: 'resource.url_path_group',\n resource_url_query: 'resource.url_query',\n resource_type: 'resource.type',\n resource_status: 'resource.status',\n resource_status_group: 'resource.status_group',\n resource_method: 'resource.method'\n },\n fields: {\n duration: 'resource.duration',\n resource_size: 'resource.size',\n resource_encode_size: 'resource.encode_size',\n resource_render_blocking_status: 'resource.render_blocking_status',\n resource_dns: 'resource.dns',\n resource_tcp: 'resource.tcp',\n resource_ssl: 'resource.ssl',\n resource_ttfb: 'resource.ttfb',\n resource_trans: 'resource.trans',\n resource_redirect: 'resource.redirect',\n resource_first_byte: 'resource.firstbyte',\n resource_dns_time: 'resource.dns_time',\n resource_download_time: 'resource.download_time',\n resource_first_byte_time: 'resource.first_byte_time',\n resource_connect_time: 'resource.connect_time',\n resource_ssl_time: 'resource.ssl_time',\n resource_redirect_time: 'resource.redirect_time'\n }\n },\n error: {\n type: RumEventType.ERROR,\n tags: {\n error_id: 'error.id',\n trace_id: '_gc.trace_id',\n span_id: '_gc.span_id',\n error_source: 'error.source',\n error_type: 'error.type',\n error_handling: 'error.handling'\n // resource_url: 'error.resource.url',\n // resource_url_host: 'error.resource.url_host',\n // resource_url_path: 'error.resource.url_path',\n // resource_url_path_group: 'error.resource.url_path_group',\n // resource_status: 'error.resource.status',\n // resource_status_group: 'error.resource.status_group',\n // resource_method: 'error.resource.method'\n },\n fields: {\n error_message: ['string', 'error.message'],\n error_stack: ['string', 'error.stack'],\n error_causes: ['string', 'error.causes']\n }\n },\n long_task: {\n type: RumEventType.LONG_TASK,\n tags: {\n long_task_id: 'long_task.id'\n },\n fields: {\n duration: 'long_task.duration'\n }\n },\n action: {\n type: RumEventType.ACTION,\n tags: {\n action_type: 'action.type'\n },\n fields: {\n action_name: 'action.target.name',\n duration: 'action.loading_time',\n action_error_count: 'action.error.count',\n action_resource_count: 'action.resource.count',\n action_frustration_types: 'action.frustration.type',\n action_long_task_count: 'action.long_task.count',\n action_target: '_gc.action.target',\n action_position: '_gc.action.position'\n }\n },\n telemetry: {\n type: 'telemetry',\n fields: {\n status: 'telemetry.status',\n message: ['string', 'telemetry.message'],\n type: 'telemetry.type',\n error_stack: ['string', 'telemetry.error.stack'],\n error_kind: ['string', 'telemetry.error.kind']\n }\n },\n browser_log: {\n type: RumEventType.LOGGER,\n tags: {\n error_source: 'error.source',\n error_type: 'error.type',\n error_resource_url: 'http.url',\n error_resource_url_host: 'http.url_host',\n error_resource_url_path: 'http.url_path',\n error_resource_url_path_group: 'http.url_path_group',\n error_resource_status: 'http.status_code',\n error_resource_status_group: 'http.status_group',\n error_resource_method: 'http.method',\n action_id: 'user_action.id',\n service: 'service',\n status: 'status'\n },\n fields: {\n message: ['string', 'message']\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACO,IAAIC,UAAU,GAAG;EACtBC,QAAQ,EAAE,cAAc;EACxBC,WAAW,EAAE,iBAAiB;EAC9BC,MAAM,EAAE,gBAAgB;EACxBC,GAAG,EAAE,KAAK;EACVC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,SAAS;EAClBC,MAAM,EAAE,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
|
|
5
5
|
});
|
|
6
6
|
exports.deviceInfo = void 0;
|
|
7
7
|
var _display = require("../helper/display");
|
|
8
|
+
var _monitor = require("../helper/monitor");
|
|
8
9
|
var VariableLibrary = {
|
|
9
10
|
navigator: typeof window !== 'undefined' && typeof window.navigator != 'undefined' ? window.navigator : {},
|
|
10
11
|
// 信息map
|
|
@@ -18,7 +19,7 @@ var VariableLibrary = {
|
|
|
18
19
|
// 方法库
|
|
19
20
|
var MethodLibrary = {
|
|
20
21
|
// 获取匹配库
|
|
21
|
-
getMatchMap: function
|
|
22
|
+
getMatchMap: (0, _monitor.monitor)(function (u) {
|
|
22
23
|
return {
|
|
23
24
|
// 内核
|
|
24
25
|
Trident: u.indexOf('Trident') > -1 || u.indexOf('NET CLR') > -1,
|
|
@@ -88,9 +89,9 @@ var MethodLibrary = {
|
|
|
88
89
|
Tablet: u.indexOf('Tablet') > -1 || u.indexOf('Nexus 7') > -1,
|
|
89
90
|
iPad: u.indexOf('iPad') > -1
|
|
90
91
|
};
|
|
91
|
-
},
|
|
92
|
+
}),
|
|
92
93
|
// 在信息map和匹配库中进行匹配
|
|
93
|
-
matchInfoMap: function
|
|
94
|
+
matchInfoMap: (0, _monitor.monitor)(function (_this) {
|
|
94
95
|
var u = VariableLibrary.navigator.userAgent || '';
|
|
95
96
|
var match = MethodLibrary.getMatchMap(u);
|
|
96
97
|
for (var s in VariableLibrary.infoMap) {
|
|
@@ -101,15 +102,15 @@ var MethodLibrary = {
|
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
|
-
},
|
|
105
|
+
}),
|
|
105
106
|
// 获取当前操作系统
|
|
106
|
-
getOS: function
|
|
107
|
+
getOS: (0, _monitor.monitor)(function () {
|
|
107
108
|
var _this = this;
|
|
108
109
|
MethodLibrary.matchInfoMap(_this);
|
|
109
110
|
return _this.os || 'Unknown';
|
|
110
|
-
},
|
|
111
|
+
}),
|
|
111
112
|
// 获取操作系统版本
|
|
112
|
-
getOSVersion: function
|
|
113
|
+
getOSVersion: (0, _monitor.monitor)(function () {
|
|
113
114
|
var _this = this;
|
|
114
115
|
var u = VariableLibrary.navigator.userAgent || '';
|
|
115
116
|
_this.osVersion = '';
|
|
@@ -162,9 +163,9 @@ var MethodLibrary = {
|
|
|
162
163
|
version: _this.osVersion,
|
|
163
164
|
osMajor: _this.osMajor
|
|
164
165
|
};
|
|
165
|
-
},
|
|
166
|
+
}),
|
|
166
167
|
// 获取横竖屏状态
|
|
167
|
-
getOrientationStatu: function
|
|
168
|
+
getOrientationStatu: (0, _monitor.monitor)(function () {
|
|
168
169
|
var orientationStatus = '';
|
|
169
170
|
var orientation = window.matchMedia('(orientation: portrait)');
|
|
170
171
|
if (orientation.matches) {
|
|
@@ -173,16 +174,16 @@ var MethodLibrary = {
|
|
|
173
174
|
orientationStatus = '横屏';
|
|
174
175
|
}
|
|
175
176
|
return orientationStatus;
|
|
176
|
-
},
|
|
177
|
+
}),
|
|
177
178
|
// 获取设备类型
|
|
178
|
-
getDeviceType: function
|
|
179
|
+
getDeviceType: (0, _monitor.monitor)(function () {
|
|
179
180
|
var _this = this;
|
|
180
181
|
_this.device = 'PC';
|
|
181
182
|
MethodLibrary.matchInfoMap(_this);
|
|
182
183
|
return _this.device;
|
|
183
|
-
},
|
|
184
|
+
}),
|
|
184
185
|
// 获取网络状态
|
|
185
|
-
getNetwork: function
|
|
186
|
+
getNetwork: (0, _monitor.monitor)(function () {
|
|
186
187
|
var connection = window.navigator.connection || window.navigator.mozConnection || window.navigator.webkitConnection;
|
|
187
188
|
var result = 'unknown';
|
|
188
189
|
var type = connection ? connection.type || connection.effectiveType : null;
|
|
@@ -219,9 +220,9 @@ var MethodLibrary = {
|
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
222
|
return result;
|
|
222
|
-
},
|
|
223
|
+
}),
|
|
223
224
|
// 获取当前语言
|
|
224
|
-
getLanguage: function
|
|
225
|
+
getLanguage: (0, _monitor.monitor)(function () {
|
|
225
226
|
var _this = this;
|
|
226
227
|
_this.language = function () {
|
|
227
228
|
var language = VariableLibrary.navigator.browserLanguage || VariableLibrary.navigator.language || '';
|
|
@@ -232,9 +233,9 @@ var MethodLibrary = {
|
|
|
232
233
|
return arr.join('_');
|
|
233
234
|
}();
|
|
234
235
|
return _this.language;
|
|
235
|
-
},
|
|
236
|
+
}),
|
|
236
237
|
// 浏览器信息
|
|
237
|
-
getBrowserInfo: function
|
|
238
|
+
getBrowserInfo: (0, _monitor.monitor)(function () {
|
|
238
239
|
var _this = this;
|
|
239
240
|
MethodLibrary.matchInfoMap(_this);
|
|
240
241
|
var u = VariableLibrary.navigator.userAgent || '';
|
|
@@ -266,7 +267,7 @@ var MethodLibrary = {
|
|
|
266
267
|
if (is360) {
|
|
267
268
|
if (_mime('type', 'application/gameplugin')) {
|
|
268
269
|
match['360SE'] = true;
|
|
269
|
-
} else if (VariableLibrary.navigator && typeof VariableLibrary.navigator['connection']['saveData'] == 'undefined') {
|
|
270
|
+
} else if (VariableLibrary.navigator && VariableLibrary.navigator.connection && typeof VariableLibrary.navigator['connection']['saveData'] == 'undefined') {
|
|
270
271
|
match['360SE'] = true;
|
|
271
272
|
} else {
|
|
272
273
|
match['360EE'] = true;
|
|
@@ -505,9 +506,9 @@ var MethodLibrary = {
|
|
|
505
506
|
engine: _this.engine,
|
|
506
507
|
browserMajor: _this.browserMajor
|
|
507
508
|
};
|
|
508
|
-
},
|
|
509
|
+
}),
|
|
509
510
|
// 获取地理位置
|
|
510
|
-
getGeoPostion: function
|
|
511
|
+
getGeoPostion: (0, _monitor.monitor)(function (callback) {
|
|
511
512
|
navigator && navigator.geolocation && navigator.geolocation.getCurrentPosition(
|
|
512
513
|
// 位置获取成功
|
|
513
514
|
function (position) {
|
|
@@ -517,12 +518,13 @@ var MethodLibrary = {
|
|
|
517
518
|
function (error) {
|
|
518
519
|
_display.display.warn(error);
|
|
519
520
|
});
|
|
520
|
-
}
|
|
521
|
+
})
|
|
521
522
|
};
|
|
522
523
|
var _deviceInfo = {};
|
|
523
524
|
if (typeof window !== 'undefined') {
|
|
524
525
|
_deviceInfo = {
|
|
525
526
|
os: MethodLibrary.getOS(),
|
|
527
|
+
MethodLibrary: MethodLibrary,
|
|
526
528
|
osVersion: MethodLibrary.getOSVersion().version,
|
|
527
529
|
osVersionMajor: MethodLibrary.getOSVersion().osMajor,
|
|
528
530
|
browser: MethodLibrary.getBrowserInfo().browser,
|