Skip to content

Custom Tag Usage

Static Usage

You can create multiple Configurations and use preprocessor directives to set values:

  1. Create multiple Configurations

  1. Set preset attributes to distinguish different Configurations

  1. Use preprocessor directives
// Target -> Build Settings -> GCC_PREPROCESSOR_DEFINITIONS to configure preset definitions
#if PRE
#define Track_id       @"0000000001"
#define STATIC_TAG     @"preprod"
#elif  DEVELOP
#define Track_id       @"0000000002"
#define STATIC_TAG     @"common"
#else
#define Track_id       @"0000000003"
#define STATIC_TAG     @"prod"
#endif

FTRumConfig *rumConfig = [[FTRumConfig alloc] init];
rumConfig.globalContext = @{@"track_id":Track_id,@"static_tag":STATIC_TAG};
... // Other setup operations
[[FTSDKAgent sharedInstance] startRumWithConfigOptions:rumConfig];

Dynamic Usage

Since the globalContext set after RUM starts will not take effect, users can save it locally and set it to take effect the next time the application starts.

  1. Save locally via file storage, such as NSUserDefaults. When configuring the SDK, add code to retrieve tag data in the configuration section.
NSString *dynamicTag = [[NSUserDefaults standardUserDefaults] valueForKey:@"DYNAMIC_TAG"] ?: @"NO_VALUE";

FTRumConfig *rumConfig = [[FTRumConfig alloc] init];
rumConfig.globalContext = @{@"dynamic_tag":dynamicTag};
... // Other setup operations
[[FTSDKAgent sharedInstance] startRumWithConfigOptions:rumConfig];
  1. Add a method to change file data anywhere.
[[NSUserDefaults standardUserDefaults] setValue:@"dynamic_tags" forKey:@"DYNAMIC_TAG"];
  1. Finally, restart the application for it to take effect.

Notes

  1. Special key: track_id (configured in RUM, used for tracking functionality)
  2. When a user adds a custom tag via globalContext that is the same as an SDK's own tag, the SDK tag will override the user-set value. It is recommended to add a project abbreviation prefix to tag names, e.g., custom_tag_name
  3. The globalContext must be set before calling the -startRumWithConfigOptions method to start RUM for it to take effect
  4. Custom tags configured in FTSDKConfig will be added to all types of data

For more detailed information, refer to the SDK Demo.

Feedback

Is this page helpful? ×