All Products
Document Center

Weex access configuration

Last Updated: Apr 11, 2018

This topic explains the integration configuration of cloud browser monitoring in Weex environment.

WeexLogger usage

Import the npm package

In Weex, use the dedicated WeexLogger module to report logs. Import the alife-logger npm package into the project before the integration.

npm install alife-logger --save


At the Weex application entry, run the singleton(props) static method for initialization and set the configurations in the imported props. For more information, see Common APIs.

// in app.js
import WeexLogger from 'alife-logger/weex';

    pid: 'your-project-id',
    uid: 'zhangsan', // Login uid, for UV report
    page: 'Lazada | Home', // Initial page name, if passed, SDK will send a PV log after Initialization completed
    imgUrl: '' // Set the log upload path. If it is deployed in Singapore, set it to ``


In the premise that WeexLogger has been initialized, run singleton() in the service module to obtain the instance and use the instance to call the corresponding report method for report.

// in some biz module
import WeexLogger from 'alife-logger/weex';

const wxLogger = WeexLogger.singleton();

wxLogger.api('/', true, 233, 'SUCCESS');

Common APIs

@static singleton() for single-instance object

In the static method, a single-instance object is returned. Here is the instruction on how to use props (only valid for the first call):

Call parameter description: WeexLogger.singleton(props)

Attribute Type Description Required Default value
pid String Site ID Yes -
page String Initialized Page Name No -
uid String User ID Yes -
imgUrl String Log uploading URL that ends with “?” No -

You can use this method to initialize SDK at the application entry and obtain the instance during each invocation. For examples, see Initialization.

setPage() for setting the Page Name of the current page

Set the Page Name and report the PV log for once (default).

Call parameter description:

const wxLogger = WeexLogger.singleton();
// ...
Parameter Type Description Required Default value
nextPage String Page Name Yes -

setConfig() for modifying configuration items

It is used to modify part of configurations after SDK is initialized. The configuration method is the same as singleton().

Call parameter description:

const wxLogger = WeexLogger.singleton();
// ...
Parameter Type Description Required Default value
next Object The configuration item to be modified and its value Yes -

Log reporting API

For more information, see "Log reporting API" in API user guide.