Custom Tags and BridgeContext¶
Get MobileAgent¶
Import from GC-UniPlugin for standard uni-app projects, and from GC-JSPlugin for uni mini programs:
// Standard uni-app
import { mobileAgent } from '@/uni_modules/GC-UniPlugin';
// For uni mini programs, replace the import above with the one below
// import { mobileAgent } from '@/uni_modules/GC-JSPlugin';
Set Global Tags at Initialization¶
For standard uni-app, you can pass custom tags via globalContext in sdkConfig or rum.setConfig:
mobileAgent.sdkConfig({
datakitUrl: 'YOUR_DATAKIT_URL',
globalContext: {
custom_key: 'custom value'
}
});
For uni mini programs, the SDK is not re‑initialized. The host app sets the initial global tags in the Native SDK configuration.
Add Custom Tags at Runtime¶
mobileAgent.appendGlobalContext({
ft_global_key: 'ft_global_value'
});
mobileAgent.appendRUMGlobalContext({
ft_global_rum_key: 'ft_global_rum_value'
});
mobileAgent.appendLogGlobalContext({
ft_global_log_key: 'ft_global_log_value'
});
| API | Description |
|---|---|
| appendGlobalContext(object) | Adds global parameters that apply to both RUM and Log |
| appendRUMGlobalContext(object) | Adds global parameters that apply only to RUM |
| appendLogGlobalContext(object) | Adds global parameters that apply only to Log |
Add BridgeContext¶
appendBridgeContext only injects RUM and Log data collected by the uni-app or uni mini program JS side. It does not affect data collected natively by the host app. This is useful for distinguishing data sources between the host app and different uni mini programs.
| Field | Type | Required | Description |
|---|---|---|---|
| None | object | Yes | Environment parameters for uni-app or uni mini program |