Troubleshooting¶
This document provides basic troubleshooting entry points for HarmonyOS SDK initialization and reporting exceptions.
Initialization Failure¶
If SDK initialization fails, it is recommended to first check:
- Whether
datakitUrl,datawayUrl, andclientTokenare correctly configured according to the deployment method. - Whether
ft_sdk.harandft_native.harhave been correctly placed in thelibsdirectory, declared as@guancecloud/ft_sdkand@guancecloud/ft_nativerespectively inoh-package.json5, andohpm installhas been executed. - Whether the application has completed the dependency declaration in
oh-package.json5as per the documentation. - Whether SDK initialization occurs during the application startup phase.
No Data Reporting¶
It is recommended to troubleshoot in the following order:
- Confirm that the prerequisites have been completed, especially the DataKit and RUM collector configurations.
- Confirm that the application device can access
datakitUrlordatawayUrl. - Enable
setDebug(true)and check the initialization and reporting logs. - Confirm that RUM has executed
installRUMConfigand at least one collection item that needs verification is enabled.
HttpInterceptorChain Not Effective¶
If automatic collection using @kit.NetworkKit's HttpInterceptorChain is not effective, it is recommended to first check:
- Whether the current device or compilation target is HarmonyOS API 22 or higher; this capability is not supported below API 22.
- Whether
ft_sdk.harandft_sdk_ext.harhave been installed in the project, declared as@guancecloud/ft_sdkand@guancecloud/ft_sdk_extinoh-package.json5, andohpm installhas been completed. - Whether
setEnableTraceUserResource(true)has been enabled; if automatic injection of Trace Headers is required, also enablesetEnableAutoTrace(true)in the Trace configuration. - It is known that in concurrent request scenarios using
@kit.NetworkKit, even if independentHttpRequestandHttpInterceptorChainare created for each request, an exception may still be triggered:{"code":2300003,"message":"Invalid URL format or missing URL"}. - If encountering the above error, it is recommended to first downgrade to serial verification for validation; in concurrent scenarios, consider switching to RCP or Axios compatibility mode, or temporarily avoid using
HttpInterceptorChainin high-concurrency chains.
Resource Not Collected¶
If an HTTP request has been created and an automatic collection interceptor has been mounted, but SDK initialization and RUM configuration are executed later, it is possible that the request succeeds but Resource data is not generated.
It is recommended to first check:
- Whether
HttpRequestwas created first,createFTHttpInterceptorChain()orapplyFTHttpTrack()was called, and thenFTSDK.installRUMConfig()was executed later. - Whether
setEnableTraceUserResource(true)has been enabled in the RUM configuration.
Reason Explanation:
- When
HttpInterceptorChainis created, it immediately reads the current RUM configuration to decide whether to enable automatic Resource collection. - If this step occurs before
FTSDK.installRUMConfig(), the default value read by the SDK isfalse. - Subsequently, even after SDK initialization is completed, the already created automatic collection interceptor instance will not automatically refresh to an enabled state, and therefore will not generate
Resource.
Recommended Handling Methods:
- Complete
FTSDK.install()andFTSDK.installRUMConfig()first, then createHttpRequestand mountHttpInterceptorChain. - If the request object or interceptor chain has been created in advance, it needs to be recreated and remounted after SDK initialization is complete.
- If it is indeed necessary to create automatic collection objects before SDK initialization, explicitly pass the switch during creation to avoid relying on default configuration values.
Optional Writing Example:
applyFTAxiosTrack(client, {
enableTraceInterceptor: true,
enableResourceInterceptor: true
});
sdk.init();
Note:
- Explicitly passing
enableTraceInterceptorandenableResourceInterceptoronly ensures that the automatic collection mechanism itself is enabled. - Requests already sent before SDK initialization is complete may still fail to generate or complete
Resourcedata because the RUM context has not yet been initialized. - Therefore, the more recommended approach is still to complete SDK initialization first, then create and use automatic collection objects.
Similar handling methods also apply to RCP and HttpInterceptorChain:
- Axios:
applyFTAxiosTrack(client, { enableTraceInterceptor: true, enableResourceInterceptor: true }) - RCP:
createFTRCPInterceptors(true, true)orcreateFTRCPTrackConfig({ enableTraceInterceptor: true, enableResourceInterceptor: true }) - HTTP:
createFTHttpInterceptorChain({ enableTraceInterceptor: true, enableResourceInterceptor: true })orapplyFTHttpTrack(request, { enableTraceInterceptor: true, enableResourceInterceptor: true })
Caching and Synchronization¶
- If automatic synchronization is disabled, i.e.,
autoSync = false, you need to manually callFTSDK.flushSyncData()from the SDK Initialization. - If local cache is abnormal, you can use
FTSDK.clearAllData()to clean up unreported data and then re-verify.
Related Documents¶
- Installation and Entry Page: See Application Access.
- Initialization Parameters: See SDK Initialization.
- RUM Network Collection: See RUM Configuration.
- Trace Chain Tracking: See Trace Configuration.