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. 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. |
const aegis = new Aegis({id: 'pGUVFTCZyewxxxxx',uin: '777'})
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 obtainedaegis.setConfig({uin: '6666'})
info
, infoAll
, error
, and report
// `info` can report any string, number, array, and object, but it reports data only when the user opening the page is in the allowlistaegis.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 caseaegis.info({msg: 'test',ext1: 'ext1',ext2: 'ext2',ext3: 'ext3',trace: 'trace',});// Different from `info`, `infoAll` reports full dataaegis.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 exceptionsaegis.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 typeaegis.report({msg: 'This is an Ajax error log',level: Aegis.LogType.AJAX_ERROR,ext1: 'ext1',ext2: 'ext2',ext3: 'ext3',trace: 'trace',});
reportEvent
supports the string and object data types for the parameters to be reported.aegis.reportEvent('The XXX request succeeded');
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', // Requiredext1: 'Additional parameter 1',ext2: 'Additional parameter 2',ext3: 'Additional parameter 3',})
ext1
, ext2
, and ext3
currently.// Suppose the time of `onload` is 1 secondaegis.reportTime('onload', 1000);
ext1
, ext2
, and ext3
.aegis.reportTime({name: 'onload', // Custom speed test nameduration: 1000, // Custom speed test duration. Value range: 0–60000ext1: 'test1',ext2: 'test2',ext3: 'test3',});
onload
can be renamed.time
and timeEnd
aegis.time('complexOperation');/*** .* .* After complicated operations are performed for a long time* .* .*/aegis.timeEnd('complexOperation'); /** At this point, the log has been reported**/
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. aegis.destroy();
Was this page helpful?