tencent cloud

DocumentaçãoTencent Cloud Observability Platform

Configuration Documentation

Baixar
Modo Foco
Tamanho da Fonte
Última atualização: 2026-10-20 11:59:59
Traduzido por IA

Configuration Instructions

The configuration items in the configuration document are described as follows:
Configuration
Description
id
Required, string, no default value. Application ID assigned by RUM (reporting ID).
uin
Recommended, string, no default value. Unique identifier of the current user. During allowlist reporting, whether the user is in the allowlist is determined based on this field. The field supports only alphanumeric characters and @=._-, with the regular expression: /^[@=.0-9a-zA-Z_-]{1,60}$/.
aid
Optional, boolean or string, default true. Whether the current instance generates aid. In the RN environment, aid is persisted through AsyncStorage (key AEGIS_ID) to distinguish user devices and calculate uv. When @react-native-async-storage/async-storage (optional peerDependency) is not installed, it degrades to a non-persistent aid.
onError
Optional, boolean, default true. Whether the current instance needs error monitoring to obtain error logs (JS execution errors, Promise errors, API request exceptions, and retcode exceptions).
env
Optional, enum, default Aegis.environment.production. Environment where the current application runs.
version
Optional, string, default SDK version number. Current reporting version. When the application has offline packages, it can be used to determine which version of code the current report comes from. Only alphanumeric characters and .,:_- are supported, with a maximum length of 60 characters /^[0-9a-zA-Z.,:_-]{1,60}$/.
delay
Optional, number, default 1000ms. Reporting throttling interval, during which reports are merged into a single reporting request.
repeat
Optional, number, default 60. Repeat reporting frequency limit (the same error / speed test is not reported after exceeding the specified number of times). If 0 is passed in, no limit is applied.
random
Optional, number, default 1. Sampling rate from 0 to 1, where 0 means no data is reported.
speedSample
Optional, boolean, default true. Whether speed test logs are sampled (limits each url to reporting only one speed test log).
pageUrl
Optional, default -. Modifies the page URL in report data (the from field), allowing developers to proactively aggregate data and reduce dimensions.
urlHandler
Optional, Function. Custom function for calculating the page URL (the from field), with a maximum return value length of 2048.
hostUrl
Optional, default https://rumt-zh.com. host address that affects all report data (rumt-zh.com for China, rumt-sg.com for Singapore, rumt-us.com for Silicon Valley).
api
Optional, object, default {}. Related configurations:
apiDetail: Optional. boolean. Default value: false. Specifies whether to report the request parameters and return values of an API when API information is reported.
retCodeHandler: Function(data: String, url: String, xhr: Object): {isErr: boolean, code: string}. A hook function for reporting return codes. The API response data, request url, and xhr object are passed to this function. For details, see the example api.retCodeHandler.
reqParamHandler: Function(data: any, url: String). A handler for reporting request parameters, which facilitates filtering the information of reported request parameters.
resBodyHandler: Function(data: any, url: String). A handler for reporting the body returned in the response, which reports only key information.
resourceTypeHandler: Function. A hook function for correcting the request resource type. The API url is passed to this function, and the return value is static or fetch.
reportRequest: boolean. Default value: false. After it is enabled, aegis.info reports all data without the need for allowlist configuration, and reports information of all APIs. To report APIs, reportApiSpeed must be enabled.
reqHeaders / resHeaders: Array. A list of HTTP request/response headers to be reported.
beforeRequest
Optional, Function. Hook executed before log reporting. Returning false blocks the report, and returning modified data reports the modified content.
afterRequest
Optional, Function. Hook executed after data reporting.
device
Optional, boolean, default true. Whether to collect device information (platform / vp / sr / netType; brand and model are reported through User-Agent).
ext1 - ext3
Optional, string. Custom additional dimension for reporting, which can be overwritten during reporting. The length limit is 1024, and content exceeding 1024 will be truncated.
ext4 - ext10
Optional, string. Custom additional dimension for reporting. Before use, upload a custom field enumeration table in the RUM > Application Management > Field Mapping Configuration module; reported content not in the enumeration table will be rewritten to undefined.
reportApiSpeed
Optional, boolean, default false. Whether to enable API speed testing (also collects static resource speed tests by Content-Type). After enabling, add users to the allowlist on the Allowlist Management page so that collected normal API requests are recorded in logs; otherwise, they are only aggregated and consumed in the metric analysis module.
beforeReportSpeed
Optional, Function. Filter hook before speed test log reporting. Returning false prevents this speed test from being reported.
enableAppStart
Optional, boolean or AppStartConfig, default true. Whether to enable cold/hot startup monitoring. Configuration in object form:
maxDurationMs: Optional. number. Default value: 180000. The maximum valid duration (ms) of the startup metric. If duration reaches this value, it is considered abnormal and discarded.
appLoadedTimeoutMs: Optional. number. Default value: 3000. The maximum time to wait for the application to call appLoaded() as the startup completion point. If the timeout expires, the system falls back to first-frame.
enablePreWarmedAppStartTracing: Optional. boolean. Default value: false. Specifies whether to report cold start data triggered by iOS system prewarming (ActivePrewarm). Android does not have this mechanism, so this switch affects iOS only.
enablePagePerf
Optional, boolean, default true. Whether to enable basic page performance context collection (providing a unified context for TTID/TTFD/route switching). No context is generated when route start/end points are not integrated.
enableRouteSwitch
Optional, boolean or RouteSwitchConfig, default true. Whether to enable route switch latency monitoring. Configuration in object form:
maxDurationMs: Optional. number. Default value: 5000. The maximum valid duration (ms) for route switching. If the duration exceeds this value, the route switch is discarded.
ignoreBackNavigation: Optional. boolean. Default value: true. Specifies whether to ignore the route switching speed test when a user returns to a previously visited page.
enableTTID
Optional, boolean or PageDisplayConfig, default true. Whether to enable page-level TTID (first frame)/TTFD (full display) monitoring. Configuration in object form:
maxDurationMs: Optional. number. Default value: 60000. The maximum valid duration (ms) of the page display metric. If the value exceeds this limit or is negative, it is discarded.
includeAppStartTTID: Optional. boolean. Default value: true. Specifies whether to report the first screen of cold/hot start as the page TTID.
includeAppStartTTFD: Optional. boolean. Default value: true. Specifies whether to include the App Start duration in the cold start first-screen TTFD.
reportSeenRoutes: Optional. boolean. Default value: false. Specifies whether to report TTID/TTFD for previously visited routes. Returning to a previously visited page is skipped by default.
aggregateTimeoutMs: Optional. number. Default value: 10000. The waiting time (ms) for aggregate reporting. If TTFD is not received within this time after the page loads, aggregate reporting is automatically triggered using the collected metrics. Set this value to 0 to report immediately. Valid range: [0, 60000].
spa
Optional, boolean, default false. Whether to enable page flow monitoring (PV reporting). After enabling, use it together with aegis.reportPageView(), useAegisPageView, or route framework integration.

Example

api.retCodeHandler

If the backend returns the following data:
{
body: {
code: 200,
retCode: 0,
data: {
// xxx
}
}
}
Business requirement: If code is not 200 or retCode is not 0, the request is considered failed. In this case, you only need to perform the following configuration:
new Aegis({
id: 'pGUVFTCZyewhxxxxxx',
reportApiSpeed: true, // This must be enabled, otherwise no return code will be reported.
api: {
retCodeHandler(data, url, xhr) {
// data is of string type. If you need an object, parse it manually.
// url is the request url.
// xhr response. You can get the complete backend response through xhr.response.
try {
data = JSON.parse(data)
} catch(e) {}
return {
// If isErr is true, a log with an abnormal retcode is reported.
isErr: data.body.code !== 200 || data.body.retCode !== 0,
code: data.body.code
}
}
}
})

api.resourceTypeHandler

If the API is http://example.com/test-api and the returned Content-Type is text/html, Aegis will consider the response as a static resource. You can fix this issue by using the following method:
new Aegis({
id: 'pGUVFTCZyewhxxxxxx',
reportApiSpeed: true,
api: {
resourceTypeHandler(url) {
if (url?.indexOf('http://example.com/test-api') != -1) {
return 'fetch';
}
}
}
})

urlHandler (restful Page URL Aggregation)

If your page routes follow the restful style, such as /user/1000 and /user/1001, you need to aggregate these page addresses when reporting them:
new Aegis({
id: 'pGUVFTCZyewhxxxxxx',
urlHandler() {
const name = /* Obtain the route name from the current route, such as getCurrentRoute().name */;
if (/^\\/user\\/\\d*/.test(name)) {
return '/user/:id';
}
return name;
}
})

beforeRequest (Reporting Interception/Modification)

const aegis = new Aegis({
id: 'pGUVFTCZyewhxxxxxx',
beforeRequest(data) {
// Data structure of the input parameter data: {logs: {…}, logType: "log"}
if (data.logType === 'log' && data.logs.msg.indexOf('internal.example.com') > -1) {
// Return false to block this report.
return false;
}
// Modify the input parameters and return them. The report is then made based on the modified content.
return data;
}
});


Ajuda e Suporte

Esta página foi útil?

comentários