Real-time debugging
The SDK Debug mode is only for debugging during integration. Never use it in the production environment.
During SDK integration, you can debug in real time by viewing the SDK logs in the IDE console or by using the Debug feature of AE.
1. Print SDK logs
local tdAnalytics = require "ThinkingDataSdk"
-- enable log
TDAnalytics.enableLog(true)
2. Enable Debug mode
Enabling Debug mode takes the following two steps:
- Use DebugConsumer
The following sample code uses DebugConsumer:
-- DebugConsumer: Data is reported one record at a time. Problems are reported to the user through logs and exceptions. Not recommended for the production environment
local tdAnalytics = require "ThinkingDataSdk"
local consumer = tdAnalytics.TDDebugConsumer("SERVER_URL", "APP_ID", false, "DeviceId")
local sdk = tdAnalytics(consumer)
--Set the distinct ID "ABCDEFG123456789"
local distinctId = "ABCDEFG123456789"
--Set the account ID "AE_10001"
local accountId = "AE_10001"
--Set event properties
local properties = {}
--Set the user's IP address. The AE system parses the user's geographic location from the IP address. If you don't set it, it is not reported by default
properties["#ip"] = "192.168.1.1"
properties["#device_id"] = "te_device_id"
--Upload the event with the user's distinct ID and account ID. Note the order of the account ID and the distinct ID. They cannot both be empty
sdk:track(accountId, distinctId, "payment", properties)
- Add a Debug device in the AE backend
To prevent Debug mode from going live in the production environment, only specified devices can enable Debug mode. A device can enable Debug mode only if Debug mode is enabled on the client and the device ID has been added on the Data > Tracking > Debugger page in AE. To add a device, click Add test device in the upper-right corner of the page, click New device in the Select device drawer, and enter the device ID.
Debug mode may affect data collection quality and App stability. Use it only to verify data during integration, and don't use it in the production environment.

