Basic integration
1. Domain settings
Before calling the pre-initialization method, developers need to call the setTrackDomain API to set the data collection endpoint of the privatization environment before calling any other API of the SDK.
import { setTrackDomain } from '@quicktracking/analytics';
/**
* Set the primary and alternate domain for uploading statistics logs.
* The SDK will first report the statistics to the primary domain. If it fails, it will try to report the data to the alternate domain again.
* The primary domain primaryDomain or null or an empty string cannot be specified. If null or an empty string is specified, the SDK will print "The domain cannot be empty. Please check the domain settings!" "Exception log.
* You can specify null or an empty string for the alternate domain. In this case, the SDK considers that the alternate domain is exactly the same as the primary domain. After the SDK fails to upload data, the data is reported to the primary domain for the second time.
* The incoming domain parameter should contain the "https://" prefix.
*/
function setTrackDomain(primaryDomain: string, standaryDomain?: string)Value | Description |
primaryDomain | The address of the primary data collection endpoint for uploading logs. |
standaryDomain | The address of the alternate data collection endpoint for uploading logs. |
Note: Only HTTP and HTTPS prefixes are supported. If you do not specify a protocol prefix, HTTPS is used by default.
2. Compliance initialization
Due to the compliance requirements of the Ministry of Industry and Information Technology (MIIT), applications cannot obtain any personal information before users agree to the privacy policy. Therefore, the SDK of QuickTracking Next is divided into two steps: pre-initialization and initialization. To complete the compliance initialization, perform the following operations:
You need to ensure that the app has a Privacy Policy and that the Privacy Policy pops up and the user's consent is obtained when the user starts the app for the first time.
You must inform the user that you choose QuickTrackingSDK collection service. Please add the following reference clause to the Privacy Policy: "Our products integrate QuickTracking SDK. QuickTracking SDK needs to collect your OAID /Huawei AAID/SIM card IMSI information /hardware serial number /MCC (mobile country code) and MNC (mobile network number) to provide statistical analysis service.
You can initialize the QuickTracking SDK only after you agree to the privacy policy.
2.1. Pre-initialization API
Call the SDK pre-initialization API. The pre-initialization API call does not track device information or report data to the QuickTracking collection service.
2.1.1. API description
import { preInit } from '@quicktracking/analytics';
function preInit(cfg: UMConfig):void2.1.2. Parameter description
Option | Parameter | Description | Required |
context | common.ApplicationContext | Application environment context variables | Yes |
appKey | string | The unique identifier of the application. The appkey of the input parameter must be the same as that of the QT backend. The appKey is reported along with each event log and is used to identify the application platform data of QT. | Yes |
plugins | BasePlugin | BasePlugin[] | Currently open plug-ins | Yes |
channel | string | The channel in which the application is released. For more information, see Upgrade Channel in System Properties. | No |
enableLog | boolean | Whether to enable debug logging. Default value: false. | No |
enableJSBridge | boolean | Specifies whether to enable H5 bridging. Default value: false. | No |
enableAutoTrackApplication | boolean | Specifies whether to enable automatic EDAS application lifecycle tracking. Default value: true. | No |
enableAutoTrackPage | boolean | Indicates whether the automatic tracking page is enabled. Default value: true. | No |
2.2. Initialize the API init
After the user agrees to the privacy agreement, the SDK initialization API is called. The log tracking and transmission starts only after the init method is called.
2.2.1. API description
import { init } from '@quicktracking/analytics';
function init():Promise<void>2.3. Call the SDK to initialize the API
In the application module directory, add the abilityStage project file, for example, entry/src/main/ets/abilityStage/MyAbilityStage.ets. The screenshot of the specific location is as follows

Add srcEntry to the module.json5 file to point to the address of the abilityStage file

2.3.1. Complete call example
import AbilityStage from '@ohos.app.ability.AbilityStage';
import { preInit, InternalPlugin, setLogEnabled, init, setTrackDomain } from '@quicktracking/analytics';
setLogEnabled(true); // Enable debug logging.
setTrackDomain("Primary data collection endpoin", "sub-data collection endpoin"); // Set the collection domain.
export default class MyAbilityStage extends AbilityStage {
onCreate() {
preInit({
appKey: 'Your AppKey'
context: this.context.getApplicationContext(),
enableJSBridge: true,
enableAutoTrackApplication: true,
enableAutoTrackPage: true,
plugins: [new InternalPlugin()]
});
init();
}
}attention:! ! !. After the preInit method is called, log tracking and transmission are started only after the init method is called and the user is authorized to agree to the privacy policy.
3. Log printing
sdk log can be enabled or disabled by actively calling setLogEnable apis
import { setLogEnabled } from '@quicktracking/analytics';
function setLogEnabled(enable: boolean):voidValue | Description |
enable | whether to enable sdk log. by default, false is disabled. |
Note:
If you view the LOG during initialization, be sure to turn on the LOG switch before calling the initialization method.
Logs are divided into three levels
error Print error messages about SDK integration or run time
warn to print the warning message of the sdk
info to print the prompt information of the sdk