Skip to content

Widget Extension Data Collection

Widget Extension Data Collection

Supported Data Collection Types

  • Logger Custom Logs
  • Trace APM
  • RUM Data Collection

Since HTTP Resource Data is bound to Views, users need to manually collect View Data.

Collection Configuration

Use FTExtensionConfig to configure the automatic switches for Widget Extension data collection and the file sharing Group Identifier. Other configurations use the settings already configured in the main project SDK.

Field Type Required Description
groupIdentifier NSString Yes File Sharing Group Identifier
enableSDKDebugLog BOOL No (Default NO) Sets whether the SDK is allowed to print Debug logs
enableTrackAppCrash BOOL No (Default NO) Sets whether to collect crash logs
enableRUMAutoTraceResource BOOL No (Default NO) Sets whether to track user network requests (only applies to native http)
enableTracerAutoTrace BOOL No (Default NO) Sets whether to enable automatic http APM
memoryMaxCount NSInteger No (Default 1000 entries) Maximum number of data entries saved in the Widget Extension

Widget Extension SDK Usage Example:

let extensionConfig = FTExtensionConfig.init(groupIdentifier: "group.identifier")
extensionConfig.enableTrackAppCrash = true
extensionConfig.enableRUMAutoTraceResource = true
extensionConfig.enableTracerAutoTrace = true
extensionConfig.enableSDKDebugLog = true
FTExtensionManager.start(with: extensionConfig)
FTExternalDataManager.shared().startView(withName: "WidgetDemoEntryView")

Simultaneously, when setting FTMobileConfig in the main project, groupIdentifiers must be set.

// Main Project
 FTMobileConfig *config = [[FTMobileConfig alloc]initWithMetricsUrl:url];
 config.enableSDKDebugLog = YES;
 config.groupIdentifiers = @[@"group.com.ft.widget.demo"];
let config = FTMobileConfig.init(metricsUrl: url)
config.enableSDKDebugLog = true
config.groupIdentifiers = ["group.com.ft.widget.demo"]

Widget Extension Collected Data Upload

The Widget Extension SDK only implements data collection. The data upload logic is handled by the main project's SDK. The timing for synchronizing collected data to the main project is user-defined.

Usage Method

// Call in the main project
/// Track data cached in the App Extension groupIdentifier
/// - Parameters:
///   - groupIdentifier: groupIdentifier
///   - completion: callback after track completion
- (void)trackEventFromExtensionWithGroupIdentifier:(NSString *)groupIdentifier completion:(nullable void (^)(NSString *groupIdentifier, NSArray *events)) completion;
/// Track data cached in the App Extension groupIdentifier
/// - Parameters:
///   - groupIdentifier: groupIdentifier
///   - completion: callback after track completion
open func trackEventFromExtension(withGroupIdentifier groupIdentifier: String, completion: ((String, [Any]) -> Void)? = nil)

Code Example

// In the main project
-(void)applicationDidBecomeActive:(UIApplication *)application{
    [[FTMobileAgent sharedInstance] trackEventFromExtensionWithGroupIdentifier:@"group.identifier" completion:nil];
}
func applicationDidBecomeActive(_ application: UIApplication) {
   FTMobileAgent.sharedInstance().trackEventFromExtension(withGroupIdentifier: "group.identifier" )
}