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 use the AE Debug feature for real-time debugging. To use the Debug feature, complete the following two steps:
- Use DebugConsumer
The following sample code uses DebugConsumer:
%% Configure the data receiving URL
ServerUrl = "server_url",
%% Configure app_id
AppID = "app_id",
%% Configure whether to write data to the database
IsWrite = true,
%% Configure device_id, which is used to view reported data in the AE backend in real time
DeviceId = "123456789",
%% init consumer
Consumer = td_debug_consumer:init_with_config(ServerUrl, AppID, IsWrite, DeviceId),
%% init SDK with consumer
TE_SDK = td_analytics:init_with_consumer(Consumer),
AccountId0 = "account_id_Erlang_0",
%% ordinary event
td_analytics:track_instance(TE_SDK, AccountId0, "distinct_logbus", "ViewProduct", #{"#key_1" => "🚓🦽🦼🚲🚜🚜🦽", "key_2" => 2.2, "key_array" => ["🚌", "🏍", "😚😊"]}),
%% Call this when you shut down the SDK. To start the SDK again after it's shut down, you must rerun the initialization code above.
td_analytics:close_instance(TE_SDK).
- Add a Debug device in the AE backend
To prevent Debug mode from going live in the production environment, Debug mode can only be enabled on specified devices. Debug mode can be enabled only on devices that have Debug mode enabled on the client and whose device IDs have been added on the Data → Tracking → Debugger page in the AE backend. 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.

