Release Notes
function changeURLArg(url,arg,arg_val) {var pattern=arg+' = ([^&]*)';var replaceText = arg+'='+arg_val;if (url.match(pattern)) {var tmp = '/('+ arg+'=)([^&]*)/gi';tmp = url.replace(eval(tmp),replaceText);return tmp;}return url;}const aegis = new Aegis({id: 'pGUVFTCZyewxxxxx',onBeforeRequest(log) {if (log.type === 'performance') {// Page speed test. Here, you can modify the content of `log`; for example, you can modify the `platform` for page speed testlog.url = changeURLArg(log.url, 'platform', type)}return log}});// SEND_TYPE {// LOG = 'log', // Log// SPEED = 'speed', // API and static resource speed test// PERFORMANCE = 'performance', // Page speed test// OFFLINE = 'offline', // Offline log upload// WHITE_LIST = 'whiteList', // Allowlist// VITALS = 'vitals', // Web Vitals// PV = 'pv', // Custom PV// EVENT = 'event', // Custom event// CUSTOM = 'custom', // Custom speed test// SDK_ERROR = 'sdkError', // SDK error// }
/collect? API); for example:const aegis = new Aegis({id: 'pGUVFTCZyewxxxxx',beforeReport(log) {// Listen on the reported error belowconsole.log(log); // {level: "4", msg: "An error occurred."}return log;}});throw new Error('An error occurred.');
log will have the following fields: level: log level. For example, '4' indicates error log. msg: log content.{ level: '1', name: 'API request log (allowed log)' }{ level: '2', name: 'General log (aegis.info or aegis.infoAll)' }{ level: '4', name: 'JavaScript execution error' }{ level: '8', name: 'Promise error' }{ level: '16', name: 'Ajax request exception' }{ level: '32', name: 'JavaScript loading exception' }{ level: '64', name: 'Image loading exception' }{ level: '128', name: 'CSS loading exception' }{ level: '256', name: 'console.error (reserved)' }{ level: '512', name: 'Audio/Video resource exception' }{ level: '1024', name: 'retcode exception' }{ level: '2048', name: 'aegis report' }{ level: 4096, name: 'PV' }{ level: 8192, name: 'Custom event' }false, the log won't be reported. This feature can be used to filter out errors that don't need to be reported; for example:const aegis = new Aegis({id: 'pGUVFTCZyewxxxxx',beforeReport(log) {if (log.level === '4' && log.msg && log.msg.indexOf('An error that doesn't need to be reported') !== -1) {return false}return log;}});throw new Error('An error that doesn't need to be reported'); // This error will not be reported
An error that doesn't need to be reported keywords, it won't be reported to the RUM backend.beforeReport. Their only difference is that all parameters received by this hook are of an already reported log, but the parameters received by beforeReport are of a log to be reported./speed?); for example:const aegis = new Aegis({id: 'pGUVFTCZyewxxxxx',reportApiSpeed: true,reportAssetSpeed: true,beforeReportSpeed(msg) {console.log(msg); // {url: "https://localhost:3001/example.e31bb0bc.js", method: "get", duration: 7.4, status: 200, type: "static"}return msg}});
msg will have the following fields: url: request address of this resource. type: resource type. Valid values: fetch: Aegis will report the resource as an API request; static: Aegis will report the resource as a static resource. duration: resource request duration. method: http method used when the resource is requested. status: status code returned by the server. payload: complete resource request information provided to you (this field won't be reported to the Aegis backend and can be manipulated by you)The complete data structure is as follows:payload.type: resource request type, which is used to distinguish between the original request types. Valid values: 'fetch' and 'xhr'. payload.sourceURL: complete URL request connection. payload.status: request status code. payload.headers: all request headers, whose values are all strings. payload.data: complete request resource, which you can customize. If the request type is fetch, it is the response object; if the request type is xhr, it is the XMLHttpRequest object.msg returned above) as parameters to call the beforeReportSpeed hook.const aegis = new Aegis({id: 'pGUVFTCZyewxxxxx',reportApiSpeed: true,reportAssetSpeed: true,beforeReportSpeed(msg) {msg.type = 'static';return msg;}});
msg.type parameters are set to static, indicating that all resources, even API requests, will be reported as static resources.3. You can use this hook to correct the Aegis type and judge incorrect requests. https://example.com/api whose response header Content-Type is text/html. In normal case, RUM will report this API as a static resource; however, it must be reported as an API request in your business. Then, you can configure Aegis with following hook for correction:const aegis = new Aegis({id: 'pGUVFTCZyewxxxxx',reportApiSpeed: true,reportAssetSpeed: true,beforeReportSpeed(msg) {if (msg.url === 'https://example.com/api') {msg.type = 'fetch';}}});
const aegis = new Aegis({id: 'pGUVFTCZyewxxxxx',reportApiSpeed: true,reportAssetSpeed: true,beforeReportSpeed(msg) {// Speed test logs for resources whose address contains `https://example.com/api` will not be reportedif (msg.url.indexOf('https://example.com/api') !== -1) {// If `false` is returned, the reporting of the speed test log will be blockedreturn false}}});
const aegis = new Aegis({id: 'pGUVFTCZyewxxxxx',beforeRequest: function(msg) {if (msg.logs && msg.logs.level === '4' && msg.logs.msg && msg.logs.msg.indexOf('An error that doesn't need to be reported') !== -1) {return false}return msg;}});
msg will have the following fields:logType is 'custom', logs will be in the format of {name: "white screen time", duration: 3015.7000000178814, ext1: '', ext2: '', ext3: ''}.logType is 'event', logs will be in the format of {name: "ios", ext1: "", ext2: "", ext3: ""}.logType is 'performance', logs will be in the format of {contentDownload: 2, dnsLookup: 0, domParse: 501, firstScreenTiming: 2315, resourceDownload: 2660, ssl: 4, tcp: 4, ttfb: 5}.logType is 'speed', logs will be in the format of {connectTime: 0, domainLookup: 0, duration: 508.2, isHttps: true, method: "get", status: 200, type: "static", url: "https://xxxxxx", urlQuery: "max_age=1296000"}.logType is 'vitals', logs will be in the format of {delta: 1100, entries: [PerformancePaintTiming], id: "v1-1629344653118-4916457684758", name: "LCP", value: 1100}.logType is 'log', logs will be in the format of {msg: "log details", level: '4', ext1: '', ext2: '', ext3: '', trace: ''}.level:{ level: '1', name: 'API request log (allowed log)' }{ level: '2', name: 'General log (aegis.info or aegis.infoAll)' }{ level: '4', name: 'JavaScript execution error' }{ level: '8', name: 'Promise error' }{ level: '16', name: 'Ajax request exception' }{ level: '32', name: 'JavaScript loading exception' }{ level: '64', name: 'Image loading exception' }{ level: '128', name: 'CSS loading exception' }{ level: '256', name: 'console.error (reserved)' }{ level: '512', name: 'Audio/Video resource exception' }{ level: '1024', name: 'retcode exception' }{ level: '2048', name: 'aegis report' }{ level: 4096, name: 'PV' }{ level: 8192, name: 'Custom event' }false, the log won't be reported. This feature can be used to filter out errors and logs that don't need to be reported.const aegis = new Aegis({id: "pGUVFTCZyewxxxxx",afterRequest: function(msg) {// {isErr: false, result: Array(1), logType: "log", logs: Array(4)}console.log(msg);}});
msg will have the following fields:logType in beforeRequest.Esta página foi útil?
Você também pode entrar em contato com a Equipe de vendas ou Enviar um tíquete em caso de ajuda.
comentários