This Application Programming Interface (API) is the primary interface for frontend instrumentation.
Use the remoteLog API
AlipayJSBridge.call('remoteLog', {
bizType: "Nebula", // Business type
logLevel: 1, // 1 - high, 2 - medium, 3 - low
actionId: "event", // Instrumentation type. Set to "event".
seedId: "Login", // Unique instrumentation identifier
param1: "",
param2: "",
param3: "",
param4: {key1:"value1",key2:"value2"}, // Custom parameters
});To add a custom instrumentation parameter, add it to
param4in thekey:"value"format. For example,key1:"value1".To add multiple custom instrumentation parameters, use the following format for the
param4parameter:param4: "key1:"value1",key2:"value2",key3:"value3".
Code sample
<h1>Clicking the button records relevant information</h1>
<a href="javascript:void(0)" class="btn read">Click</a>
<script>
function ready(callback) {
// If jsbridge is already injected, call it directly.
if (window.AlipayJSBridge) {
callback && callback();
} else {
// If it is not injected, listen for the injection event.
document.addEventListener('AlipayJSBridgeReady', callback, false);
}
}
ready(function() {
document.querySelector('.read').addEventListener('click', function() {
AlipayJSBridge.call('remoteLog', {
type: "behavior",
bizType: "Nebula",
spmId: "a1.b2",
logLevel: 1, // 1 - high, 2 - medium, 3 - low
actionId: "event"
seedId: "xxx",
param1: "xxx",
param2: "xxx",
param3: "xxx",
param4: "xxx",
});
});
});
</script>API reference
AlipayJSBridge.call('remoteLog', {
type, seedId, ucId, bizType, logLevel,
actionId, spmId, param1, param2, param3, param4
});Input parameters
Property | Type | Description | Required | Default |
type | string | Instrumentation type:
| N | "monitor" |
seedId | string | Instrumentation ID. | Yes | "" |
bizType | float | Business type identifier. When a value is passed for this parameter, a separate log file is generated. | No | - |
logLevel | int | 1 - high 2 - medium 3 - low. Low-level logs may be subject to throttling. | N | - |
actionId | string | Instrumentation type. Set to event. | Yes | "" |
spmId | string | SPM code. If `spmId` is specified, `seedId` is ignored. | Yes | "" |
param1 | string | Instrumentation parameter 1. | N | "" |
param2 | string | Instrumentation parameter 2. | N | "" |
param3 | string | Instrumentation parameter 3. | N | "" |
param4 | string | Instrumentation parameter 4. | N | "" |