Advanced guide
1. Initialization parameters
The Strategy SDK is initialized through TDStrategySettings. For the Analytics SDK, call TDAnalytics.init(context, appId, serverUrl) first. The TDStrategySettings configuration is described below.
1.1 TDStrategySettings
| Property name | Type | Description |
|---|---|---|
| appId | string | app id of the project created in the AE backend |
| serverUrl | string | server url of the project created in the AE backend |
| mode | TDStrategyMode | Strategy SDK running mode; defaults to NORMAL |
1.2 TDStrategyMode
| Enum values | Description |
|---|---|
| NORMAL | Normal mode. Fetches and triggers tasks according to online rules. |
| DEBUG | Test mode. The device id must be added to the test device list in the AE console. The SDK fetches test tasks more frequently, so you can run channel tests or task tests in the AE Engage module. |
import { TDStrategy, TDStrategyMode, TDStrategySettings } from '@thinkingdata/strategy';
const settings = new TDStrategySettings('AppId', 'ServerUrl');
settings.mode = TDStrategyMode.DEBUG;
TDStrategy.init(context, settings);
2. Set client parameters
When you create a client-triggered task, you can fill in Client-side Conditions. For configuration details, see Create client-triggered tasks
The parameters available in Client-side Conditions come from the environment parameters that the client collects automatically and the client parameters that you set through the TDRemoteConfig SDK. After you SET custom client parameters, you can add them to the Client Parameters module in the AE Engage settings and use them in operation tasks.
Note: The names and types of the parameters you SET on the client must match the client parameters configured in the AE Engage backend.
Add client parameters
import { TDRemoteConfig } from '@thinkingdata/remoteconfig';
// Set client parameters. If you set them multiple times, the union is used
TDRemoteConfig.addClientParams({
'key': 'value',
});
Delete client parameters
TDRemoteConfig.removeClientParam('key');
Get a single client parameter
import { TDRemoteConfig } from '@thinkingdata/remoteconfig';
const value = TDRemoteConfig.getClientParamValueForKey('key');
TDStrategy.addClientParams/TDStrategy.removeClientParamare compatibility APIs that forward calls toTDRemoteConfiginternally. We recommend callingTDRemoteConfigdirectly.
3. Customize fetch timing
3.1 Automatic fetching
The SDK automatically fetches remote configuration data in the following scenarios:
- App cold start
- The app switches between foreground and background more than 6 hours after the previous switch
- The ThinkingSDK account system changes, for example, on login or logout
3.2 Manual fetching
Call the SDK method manually to fetch the remote configuration at any time:
TDStrategy.fetch();
This API has internal rate limiting. Avoid fetching too frequently.
4. Touch funnel events
When you create a client-triggered channel, you can enable the touch funnel settings. For configuration details, see Channel Settings
After you enable the touch funnel, you can configure the event names associated with the funnel steps. You can then view the conversion data of the configured steps on the data details page of operation tasks that use this channel.
Events selected for Delivered and Clicked must meet the following requirements:
- The event must carry Engage-specific parameters. You can get these parameters from the opsProperties property of the
TDStrategyResultobject in the push content, and report them as follows:
import { TDAnalytics } from '@thinkingdata/analytics';
import { TDStrategy, TDStrategyResult, TDStrategyResultListener } from '@thinkingdata/strategy';
TDStrategy.setTriggerListener({
onTriggerResult: (result: TDStrategyResult) => {
TDAnalytics.track({
eventName: 'ops_click',
properties: result.opsProperties,
});
},
});
5. Send Test
To quickly verify the availability of a channel and the validity of a task, the SDK supports a test mode.
import { TDAnalytics } from '@thinkingdata/analytics';
import { TDStrategy, TDStrategyMode, TDStrategySettings } from '@thinkingdata/strategy';
await TDAnalytics.init(context, 'AppId', 'ServerUrl');
const settings = new TDStrategySettings('AppId', 'ServerUrl');
settings.mode = TDStrategyMode.DEBUG;
TDStrategy.init(context, settings);
After you enable debug mode on the client, the client fetches test tasks more frequently. In the AE Engage module, you can create channel tests or task tests. While a task is waiting to be triggered, you can watch the progress nodes on the frontend page.
Related documentation: Send Test for tasks, Send Test for channels
Send tests for client-triggered tasks require test devices. You can select or add test devices in the test device list

