How to Integrate Alibaba Cloud RUM SDK for HarmonyOS Native Apps
This guide explains the background of HarmonyOS NEXT, introduces Alibaba Cloud ARMS Real User Monitoring SDK for native HarmonyOS apps, details its page, resource, exception, and custom data collection features, and provides step‑by‑step integration instructions with code examples.
Background
On October 22, 2024 Huawei officially released HarmonyOS NEXT, a fully self‑developed native operating system with significant improvements in smoothness, performance, and security. Over 15,000 native HarmonyOS apps and services are already available. To further optimize user experience and developer efficiency, Alibaba Cloud ARMS Real User Monitoring (RUM) launched an SDK for monitoring native HarmonyOS applications.
Feature Overview
ARMS RUM supports browsers, mini‑programs, apps, and PC clients, observing and analyzing user behavior and page performance. The HarmonyOS SDK, built with ArkTS, provides comprehensive data collection for full‑stack monitoring of HarmonyOS apps.
Page Collection
The SDK supports both native pages and WebView pages. It records metrics such as page views, average load time, slow‑load ratio, average stay time, and user count, and aggregates them by region, app version, network type, device, OS, and carrier. Detailed page views display device brand, model, access time, IP address, and events like clicks, resource loads, and exceptions. For WebView pages, RUM also captures errors, requests, and route changes.
Resource Loading Collection
The SDK captures all resource loading types, including static resources (image, script, CSS, navigation) and dynamic resources (socket, WebSocket, API). It supports network request collection for RCP, HTTP, WebSocket, TCPSocket, and UDPSocket. Metrics such as load count, average load time, error count, error rate, and request method are reported, and the resource detail page shows DNS lookup, TCP connection, SSL handshake, response, content transfer, DOM parsing, and other performance indicators.
Exception Collection
Exception monitoring covers JS crashes, CPP crashes, app freezes, and lag. The SDK reports exception count, crash rate, affected sessions, affected users, and distribution. It provides a top‑50 list of affected users, detailed stack traces, and an exception analysis feature. After uploading the corresponding sourcemap or symbol files, developers can parse stack traces to locate the source of the issue.
Custom Collection
Developers can define custom events and logs, configuring event names, groups, attribute values, and custom properties, as well as log types, content, and custom attributes.
Integration Steps
3.1 Install SDK
cd path/to/your/project</code><code>ohpm config set registry https://ohpm.openharmony.cn/ohpm/</code><code>ohpm install @alibabacloud_rum/harmony_sdk3.2 Rebuild Project
Rebuild the project to ensure the configuration takes effect.
3.3 Configure Permissions
ohos.permission.INTERNET // Send network data</code><code>ohos.permission.GET_NETWORK_INFO // Get network status information3.4 Enable Normalized OHM URL
{</code><code> "app" : {</code><code> "products": [{</code><code> "buildOption": {</code><code> "strictMode": {</code><code> "useNormalizedOHMUrl": true</code><code> }</code><code> }</code><code> }] </code><code> }</code><code>}3.5 Initialize SDK
AlibabaCloudRum.withAppID("<your appid>") // AppID obtained when creating a RUM app</code><code> .withConfigAddress("<your config address>") // ConfigAddress obtained when creating a RUM app</code><code> .start(this.context.getApplicationContext());Example:
onCreate(): void {</code><code> this.initAlibabaCloudRumSdk();</code><code>}</code><code></code><code>private initAlibabaCloudRumSdk() {</code><code> AlibabaCloudRum.withAppID("<your appid>")</code><code> .withConfigAddress("<your config address>")</code><code> .start(this.context.getApplicationContext());</code><code>}For detailed configuration, refer to the official integration documentation, API reference, and SDK version notes.
Conclusion
HarmonyOS is China’s first fully self‑developed stack operating system, breaking through core OS technologies and achieving true autonomy. In this context, the RUM SDK offers developers a convenient tool to comprehensively analyze and track key user‑experience metrics for HarmonyOS applications.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Alibaba Cloud Observability
Driving continuous progress in observability technology!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
