User Experience Data Related Interfaces
Custom Cold Start Duration
The SDK defaults to calculating the time from the start of the SDK initialization to the end of the first page load as the 'Cold Start Duration'. Developers can change the end point for calculating the 'Cold Start Duration' according to their application needs.
-
Enable Custom Cold Start Duration Control
-
Related Interface
/**
* @enable Pass YES to enable the custom start end function
*/
+ (void)customLaunchEnd:(BOOL)enable; -
Code Example
int main(int argc, char * argv[]) {
@autoreleasepool {
// Set to enable the custom end point function, call before starting the SDK.
[NBSAppAgent customLaunchEnd:YES];
[NBSAppAgent startWithAppID:@"appkey"];
...
}
}
-
-
Set Custom Cold Start Duration End Point
This interface must be used in conjunction with 'customLaunchEnd'. When 'customLaunchEnd' is set to YES, the 'launchFinish' interface setting takes effect.
-
Related Interface
/**
* Custom end time point, call when the start ends.
*/
+ (void)launchFinish:(NSString *)lanuchName; -
Code Example
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[NBSAppAgent launchFinish:@"firstVC"];
}
-
Custom Trace Points
Since TingYun_SDK defaults to monitoring system classes and methods, it cannot monitor the 'business code' for time consumption. Using the 'Custom Trace Point' interface can complement the 'Page Experience Analysis' and 'Operation Experience Analysis' modules' 'Breakdown Chart', helping developers clearly understand the time consumption and call situation of their business code.
- Related Interface
Note: The 'Custom Trace Point' interface must be called in pairs, and should not be used across methods, processes, or in asynchronous loading and recursive calls.
// @String Name is the name of the current method or a custom name, supports Chinese, English, numbers, underscores, but should not contain spaces or other escape characters
beginTracer(@"StringName")
endTracer(@"StringName")
-
Code Example
- (void)doSomething {
// Users can add custom Trace before and after any method after the SDK is initialized
beginTracer(@"TraceName")
// write your code here
endTracer(@"TraceName")
}
Custom Operations
Define a 'Custom Operation' to understand its performance.
- Related Interface
Note: The 'Custom Operation' interface must be called in pairs, actionName cannot be empty, and supports cross-method and cross-thread calls.
+ (void)customActionStart:(NSString *)actionName;
+ (void)customActionEnd:(NSString *)actionName withTag:(NSString *)tag withCustomInfo:(NSDictionary *)customInfo;
-
Code Example
- (void)doSomething {
[NBSAppAgent customActionStart:@"doSomething"];
...
NSDictionary *cust = @{@"key": @"value"};
[NBSAppAgent customActionEnd:@"doSomething" withTag:@"tag" withCustomInfo:cust];
}
Custom Page End
Define a 'Custom Page End' to understand the actual load time of a page and its performance.
- Related Interface
Note: The 'Custom Page End' interface must be called in pairs, pageName cannot be empty, and supports cross-method and cross-thread calls. The view controllers during the app launch do not support customization; you need to pass the customId returned by customPageLoad: into customPageLoadFinish:withPageName: to associate the end. Call customPageLoad: in the viewDidLoad of the view controller you want to customize; call customPageLoadFinish:withPageName: after viewDidAppear in the view controller you want to customize.
/**
* Whether to customize the page end point
* @param enable Whether to customize.
* @result identifier Association end.
*/
+ (NSInteger)customPageLoad:(BOOL)enable;
/**
* Custom page end.
* @param customId Pass the id returned by customPageLoad.
* @param pageName Page name.
*/
+ (void)customPageLoadFinish:(NSInteger)customId withPageName:(NSString *)pageName;
-
Code Example
- (void)viewDidLoad {
[super viewDidLoad];
customId = [NBSAppAgent customPageLoad:YES];
...
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
....
dispatch_async(dispatch_get_main_queue(), ^{
[NBSAppAgent customPageLoadFinish:customId withPageName:@"CustomPage"];
});
}
Set ViewID
After setting the viewId, the platform's 'Operation Analysis' and 'Visual Naming' features will prioritize this attribute for classification.
-
Example
UIView *view = [UIView new];
[view setTingyunAttributesIdentifier:@"TYIdentifier"];
Set ViewName
After setting the ViewName, the platform's 'Operation Analysis' and 'Visual Naming' features will prioritize this attribute for classification.
-
Example
UIView *view = [UIView new];
[view setTingyunAttributesName:@"TYViewName"];
Set PageName 'View Alias'
After setting the PageName, the platform's 'Operation Analysis' and 'Visual Naming' features will prioritize this attribute for classification.
-
Example
ViewController *vc = [ViewController new];
[vc setTingyunAttributesPageName:@"TYPageName"];
Set Page Scan Interval
You can customize the time interval for scanning the View in the page, the default is 50ms.
- Interface
/**
*Set the page load scan interval, unit ms, default 50ms
*/
+ (void)setPageScanInterval:(NSInteger)interval;
- Example
[NBSAppAgent setPageScanInterval:100]; // Scan interval is set to 100ms
Set Scan Timeout
You can customize the timeout for scanning the View in the page, the default is 5s.
- Interface
/**
*Set the page loading timeout, unit is s, default is 5s, maximum can be set to 15s
*/
+ (void)setPageLoadTimeoutSec:(NSInteger)sec;
- Example
[NBSAppAgent setPageLoadTimeoutSec:10]; // Set the scan timeout to 10 seconds
Set View status
**During page loading, SDK scans the status of View in the current page at a certain interval to calculate whether the page is loaded. You can set the View status by setting the View properties isInvalidView and isIgnoredView. SDK will give priority to the set status. **
- Description
///Set the view to invalid first, and then set it to valid after the content rendering is completed. This can solve the problem of inaccurate page loading end point caused by the placeholder image
@property (nonatomic, assign) BOOL isInvalidView;
///Ignore this view. When calculating the page loading completion, this view does not participate in the calculation
@property (nonatomic, assign) BOOL isIgnoredView;
- Example
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(200, 200, 200, 200)];
view.isIgnoredView = YES; // Set the view to invalid first
view.isInvalidView = YES; // Ignore this view. When calculating the page loading completion, this view does not participate in the calculation
...
//Page loading ends
view.isIgnoredView = NO;