tencent cloud

Tencent Cloud Observability Platform

Release Notes and Announcements
Release Notes
Product Introduction
Overview
Strengths
Basic Features
Basic Concepts
Use Cases
Use Limits
Purchase Guide
Tencent Cloud Product Monitoring
Application Performance Management
Mobile App Performance Monitoring
Real User Monitoring
Cloud Automated Testing
Prometheus Monitoring
Grafana
EventBridge
PTS
Quick Start
Monitoring Overview
Instance Group
Tencent Cloud Product Monitoring
Application Performance Management
Real User Monitoring
Cloud Automated Testing
Performance Testing Service
Prometheus Getting Started
Grafana
Dashboard Creation
EventBridge
Alarm Service
Cloud Product Monitoring
Tencent Cloud Service Metrics
Operation Guide
CVM Agents
Cloud Product Monitoring Integration with Grafana
Troubleshooting
Practical Tutorial
Application Performance Management
Product Introduction
Access Guide
Operation Guide
Practical Tutorial
Parameter Information
FAQs
Mobile App Performance Monitoring
Overview
Operation Guide
Access Guide
Practical Tutorial
Tencent Cloud Real User Monitoring
Product Introduction
Operation Guide
Connection Guide
FAQs
Cloud Automated Testing
Product Introduction
Operation Guide
FAQs
Performance Testing Service
Overview
Operation Guide
Practice Tutorial
JavaScript API List
FAQs
Prometheus Monitoring
Product Introduction
Access Guide
Operation Guide
Practical Tutorial
Terraform
FAQs
Grafana
Product Introduction
Operation Guide
Guide on Grafana Common Features
FAQs
Dashboard
Overview
Operation Guide
Alarm Management
Console Operation Guide
Troubleshooting
FAQs
EventBridge
Product Introduction
Operation Guide
Practical Tutorial
FAQs
Report Management
FAQs
General
Alarm Service
Concepts
Monitoring Charts
CVM Agents
Dynamic Alarm Threshold
CM Connection to Grafana
Documentation Guide
Related Agreements
Application Performance Management Service Level Agreement
APM Privacy Policy
APM Data Processing And Security Agreement
RUM Service Level Agreement
Mobile Performance Monitoring Service Level Agreement
Cloud Automated Testing Service Level Agreement
Prometheus Service Level Agreement
TCMG Service Level Agreements
PTS Service Level Agreement
PTS Use Limits
Cloud Monitor Service Level Agreement
API Documentation
History
Introduction
API Category
Making API Requests
Monitoring Data Query APIs
Alarm APIs
Legacy Alert APIs
Notification Template APIs
TMP APIs
Grafana Service APIs
Event Center APIs
TencentCloud Managed Service for Prometheus APIs
Monitoring APIs
Data Types
Error Codes
Glossary

Instance Methods

PDF
Modo Foco
Tamanho da Fonte
Última atualização: 2024-11-01 19:45:35
RUM provides various instance methods for data reporting. You can use them to modify the instance configuration and customize the events and resources for speed test to be reported.
Currently, RUM provides the following Aegis instance methods:
Parameter
Description
setConfig
Passes in the configuration object, which contains information such as user ID and UIN.
info
Is a main reporting field to report allowlist logs. A log will be reported to the backend only in the following cases:
1. The user who opens the page is in the allowlist.
2. The page has an error.
infoAll
Is a main reporting field to report allowlist logs. The only difference between it and info is as follows:
info reports the logs of only specified users, while infoAll reports the logs of all users.
error
Is a main reporting field to report the error information.
report
Reports the information of a log in any type.
reportEvent
Reports a custom event.
reportTime
Reports a custom resource for speed test.
time
Reports a custom resource for speed test and is used together with timeEnd to calculate and report data between two time points.
timeEnd
Reports a custom resource for speed test and is used together with time to calculate and report data between two time points.
destroy
Terminates the Aegis instance.

Prerequisites

Install and initialize the Aegis SDK in any method as detailed in Installation and Initialization.

Instance Methods

setConfig

This method is used to modify the instance configuration in the following use cases:
1. You can get the user UIN and pass in two instance objects of user ID and UIN at the same time for instantiation:
const aegis = new Aegis({
id: 'pGUVFTCZyewxxxxx',
uin: '777'
})
2. Generally, the uin cannot be directly obtained in the beginning. If instantiation cannot be completed during the period when uin is obtained, RUM cannot listen on the errors occurring in this period. To solve this, you can pass in the ID first for instantiation and then import setConfig to pass in uin as follows:
const aegis = new Aegis({
id: 'pGUVFTCZyewxxxxx'
})

// After `uin` is obtained
aegis.setConfig({
uin: '6666'
})

info, infoAll, error, and report

These are the main reporting methods provided by RUM.
// `info` can report any string, number, array, and object, but it reports data only when the user opening the page is in the allowlist
aegis.info('test');
aegis.info('test', 123, ['a', 'b', 'c', 1], {a: '123'});

// You can also report a specified object and pass in the `ext` and `trace` parameters
// You must pass in the `msg` field in this case
aegis.info({
msg: 'test',
ext1: 'ext1',
ext2: 'ext2',
ext3: 'ext3',
trace: 'trace',
});

// Different from `info`, `infoAll` reports full data
aegis.infoAll({
msg: 'test',
ext1: 'ext1',
ext2: 'ext2',
ext3: 'ext3',
trace: 'trace',
});

// `error` indicates a JavaScript error log, whose full data will also be reported. Generally, it is used to actively get and report JavaScript exceptions
aegis.error({
msg: 'test',
ext1: 'ext1',
ext2: 'ext2',
ext3: 'ext3',
trace: 'trace',
});
aegis.error(new Error('Actively report an error'));

// The default log type of `aegis.report` is `report`, but currently you can pass in any log type
aegis.report({
msg: 'This is an Ajax error log',
level: ['1'], #Log level. For specific values, see Log Level.
ext1: 'ext1',
ext2: 'ext2',
ext3: 'ext3',
trace: 'trace',
});

reportEvent

This method can be used to report a custom event, and the system will automatically collect the metrics of the reported event, such as PV and platform distribution. reportEvent supports the string and object data types for the parameters to be reported.

String data type

aegis.reportEvent('The XXX request succeeded');

Object data type

ext1, ext2, and ext3 use the parameters passed in when you use new Aegis. During custom event reporting, you can overwrite their default values.
aegis.reportEvent({
name: 'The XXX request succeeded', // Required
ext1: 'Additional parameter 1',
ext2: 'Additional parameter 2',
ext3: 'Additional parameter 3',
})
Note:
The keys of the three additional parameters are fixed, which can only be ext1, ext2, and ext3 currently.

reportTime

This method can be used to report custom speed test as follows:
// Suppose the time of `onload` is 1 second
aegis.reportTime('onload', 1000);
If you want to use additional parameters, you can pass them in by using the object type, and they will overwrite the default values of ext1, ext2, and ext3.
aegis.reportTime({
name: 'onload', // Custom speed test name
duration: 1000, // Custom speed test duration. Value range: 0–60000
ext1: 'test1',
ext2: 'test2',
ext3: 'test3',
});
Note:
onload can be renamed.

time and timeEnd

These methods can be used to report a custom resource for speed test and are suitable for calculating and reporting a duration between two time points.
aegis.time('complexOperation');
/**
* .
* .
* After complicated operations are performed for a long time
* .
* .
*/
aegis.timeEnd('complexOperation'); /** At this point, the log has been reported**/
Note:
complexOperation can be renamed. In custom speed test, you can report any values, and the server will collect and calculate them. As the server cannot process dirty data, we recommend you restrict the statistics values passed in to prevent the system from being affected by dirty data. Currently, Aegis can calculate values only between 0 and 60000. If you use a greater value, we recommend you adjust it reasonably.

destroy

This method is used to terminate the instance process, after which no data will be reported, and Aegis will stop collecting user data.
aegis.destroy();

Log Level

Key (level)
Value (name)
1
'Allowlist Logs'
2
'General Logs'
4
'Error Logs'
8
'Promise Error'
16
'Ajax Request Exception'
32
'JavaScript Loading Exception'
64
'Image Loading Exception'
128
'css Loading Exception'
256
'console.error'
512
'Audio/Video Resource Exception'
1024
'retcode Exception'
2048
'aegis report'
4096
'PV'
8192
'Custom Event'
16384
'Mini Program Page Not Found'
32768
'webSocket Error'
65536
'js bridge Error'


Ajuda e Suporte

Esta página foi útil?

comentários