Harmonyos Next deployment
Environmental demand
The minimum supports API 11 (Harmonyos Next Developer Preview2))
Install SDK
Enter the root derivative of the project and execute the following command
ohpm install @tingyun/sdk-core
Initialize SDK
At the entrance Ability onCreate
Methods initialized SDK
import tingyun from '@tingyun/sdk-core'
import axios from '@ohos/axios'
export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
tingyun.init({
// redirect Server address, obtained from the console settings page
redirectHost: '<Redirect server address>',
// appKey, obtained from the console settings page
appKey: '<AppKey>',
// context
context: this.context,
// If using axios, you can pass in the axios object to collect the network requests sent by axios
axios: axios
})
}
// ...
}
Confirm that the project is compatible with the HAR package in bytecode format
The SDK HAR package is in bytecode format, it is necessary to set useNormalizedOHMUrl
to true in the project-level build-profile.json5
.
{
"app": {
"products": [
{
"buildOption": {
"strictMode": {
"useNormalizedOHMUrl": true
}
}
}
]
}
}
Set user ID (optional)
import tingyun from '@tingyun/sdk-core'
tingyun.init({
// ...
})
// Set the user ID for the application
tingyun.setUserId('<userId>')
Rights Profile
Permission name | Use | Whether it is necessary |
---|---|---|
ohos.permission.internet | SDK sends data. It cannot be started without configured SDK | yes |
ohos.permission.get_network_info | Get network connection information. After configuration, you can obtain network type and connection method information | no |
Verification data report
After the embryo is completed, start the app and open the log in the IDE-> Hilog menu, select the corresponding app, view logs, detect existence init success
After the log of keywords, the data report is successful.
SDK configuration option
import common from '@ohos.app.ability.common'
export enum LogLevel {
DEBUG,
INFO,
WARN,
ERROR,
NONE
}
export type RecordRule = {
// You need to configure the domain/URL for this parameter collection. Collection will only occur if the target URL is included in this configuration; if not configured, this rule will apply to all URLs
url?: string
// Obtain all request headers, default is empty
reqHeaders?: string[]
// Request body configuration, default is empty
reqBody?: string[]
// Obtain all response headers, default is empty
resHeaders?: string[]
// Response body configuration, default is empty
resBody?: string[]
}
export type NetworkConfig = {
// Network request collection switch, default is false
enabled?: boolean;
// Cross-application tracking switch, default is false
trackingEnabled?: boolean;
// Data collection whitelist
recordConfig?: RecordRule[];
// Data collection blacklist
recordBlockConfig?: RecordRule[];
// Body collection maximum size, unit is KB
bodyMaxSize?: number;
// Third-party APM request header support
apms?: string[];
// Trace propagators
propagators?: string[];
};
export type CrashConfig = {
// Crash collection master switch, default is true
enabled?: boolean;
// JavaScript crash collection switch, default is true
jsCrashEnabled?: boolean;
// C++ crash collection switch, default is true
cppCrashEnabled?: boolean;
};
export type FreezeConfig = {
// Freeze monitoring switch, default is false
enabled?: boolean;
};
export type UserExperienceConfig = {
// Master switch for user experience, default is false
enabled?: boolean;
// Launch user experience switch, default is true
launchEnabled?: boolean;
};
/**
* Application configuration
*/
export type InitConfig = {
// Redirect server address
redirectHost: string;
// Application appKey
appKey: string;
// Context
context: common.Context;
// Log level, default is LogLevel.INFO
logLevel?: LogLevel;
// Whether to use HTTP to send data, default is false, using HTTPS to send data
httpEnabled?: boolean;
// Axios object, it needs to be passed in when intercepting axios
axios?: any;
// Maximum stack depth obtained
stackDepth?: number;
// Whether to use the historical data protocol for reporting, default is false
legacyDataProtocol?: boolean;
// Network request collection configuration
network?: NetworkConfig;
// Crash monitoring configuration
crash?: CrashConfig;
// AppFreeze monitoring configuration
freeze?: FreezeConfig;
// User experience configuration
ue?: UserExperienceConfig;
}
Note: The configuration of the init is the initial configuration of the SDK. After communication with the server, the configuration issued by the server will be preferred.
Functional support list
Module | Support | Data collection | Non -support type |
---|---|---|---|
Collapse | 1. ARKTS collapse 2. C /C ++ collapse | 1. Stack 2. Thread information 3. System log | 1. Tracks 2. Customized additional information 3. Add information (CPU, memory, etc.) |
Stuck and stopped | 1. App freeze | 1. Stack 2. Thread information 3. System log 4. Add information (CPU, memory, etc.) | 1. Tracks 2. Customized additional information |
Network module | 1. Axios (@ohos /axios) 2. SDK packaging interface based on@ohos.net.http | 1. Response time 2. Transmission bytes 3. Cross -application and APMS 4. Status code 5. HTTP error and network error 6. Request content collection 7. Trace Propagators | 1. DNS time 2. TCP time 3. SSL time 4. First package time 5. Remaining time 6. TCPPING 7 . 2.0 Application 8. 2.0 CDNNAME 9. Black and White List |
basic information | 1. Equipment model 2. Equipment manufacturer 3. Application name 4. Operator 5. Network type 6. Connection type 7. System version | 1. Latitude and Longitude |