Quick Start¶
This document provides the shortest path to integrate the macOS RUM SDK, helping you complete a verifiable data report with minimal steps.
Prerequisites¶
Before starting, please complete the following preparations:
- Create a macOS application in RUM and obtain the
RUM App ID - Confirm the reporting address and authentication method
- Local environment deployment: Prepare
datakitUrl - Public DataWay: Prepare
datawayUrlandclientToken - Confirm that the project has completed SDK installation, supporting
CocoaPodsorSwift Package Manager
Integration Steps¶
- Install
FTMacOSSDKin the project - Initialize
FTSDKConfigbefore the application launches - Initialize
FTRumConfigand enable View, Action, Resource, crash, and freeze collection - Keep debug logs enabled, run the application, and trigger a window switch or network request
- Confirm in the console and the Guance platform that the data has been successfully reported
Install SDK¶
For installation methods, please refer directly to Application Access.
If you only want to quickly verify, it is recommended to use CocoaPods or Swift Package Manager first.
Minimal Initialization Example¶
Since the first displayed view NSViewController's viewDidLoad method and NSWindowController's windowDidLoad method are called earlier than AppDelegate's applicationDidFinishLaunching, to avoid abnormal lifecycle collection for the first view, it is recommended to perform SDK initialization in main.m or main.swift.
// main.m file
#import "FTMacOSSDK.h"
int main(int argc, const char * argv[]) {
@autoreleasepool {
// For local environment deployment, use [[FTSDKConfig alloc] initWithDatakitUrl:datakitUrl]
FTSDKConfig *config = [[FTSDKConfig alloc] initWithDatawayUrl:datawayUrl clientToken:clientToken];
config.enableSDKDebugLog = YES;
[FTSDKAgent startWithConfigOptions:config];
FTRumConfig *rumConfig = [[FTRumConfig alloc] initWithAppid:appid];
rumConfig.enableTrackAppCrash = YES;
rumConfig.enableTrackAppANR = YES;
rumConfig.enableTrackAppFreeze = YES;
rumConfig.enableTraceUserAction = YES;
rumConfig.enableTraceUserView = YES;
rumConfig.enableTraceUserResource = YES;
rumConfig.errorMonitorType = FTErrorMonitorAll;
rumConfig.deviceMetricsMonitorType = FTDeviceMetricsMonitorAll;
[[FTSDKAgent sharedInstance] startRumWithConfigOptions:rumConfig];
}
return NSApplicationMain(argc, argv);
}
import Cocoa
import FTMacOSSDK
let delegate = AppDelegate()
NSApplication.shared.delegate = delegate
// For local environment deployment, use FTSDKConfig(datakitUrl: datakitUrl)
let config = FTSDKConfig(datawayUrl: datawayUrl, clientToken: clientToken)
config.enableSDKDebugLog = true
FTSDKAgent.start(withConfigOptions: config)
let rumConfig = FTRumConfig(appid: appid)
rumConfig.enableTraceUserAction = true
rumConfig.enableTrackAppANR = true
rumConfig.enableTraceUserView = true
rumConfig.enableTraceUserResource = true
rumConfig.enableTrackAppCrash = true
rumConfig.enableTrackAppFreeze = true
rumConfig.errorMonitorType = .all
rumConfig.deviceMetricsMonitorType = .all
rumConfig.monitorFrequency = .rare
FTSDKAgent.sharedInstance().startRum(withConfigOptions: rumConfig)
_ = NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv)
When using Swift, please create the
main.swiftfile first and delete@mainor@NSApplicationMaininAppDelegate.swift.
Optional: Initialize Log and Trace¶
If you also need log collection or APM, you can continue by adding the following initialization:
FTLoggerConfig *loggerConfig = [[FTLoggerConfig alloc] init];
loggerConfig.enableCustomLog = YES;
loggerConfig.enableLinkRumData = YES;
[[FTSDKAgent sharedInstance] startLoggerWithConfigOptions:loggerConfig];
FTTraceConfig *traceConfig = [[FTTraceConfig alloc] init];
traceConfig.enableAutoTrace = YES;
traceConfig.enableLinkRumData = YES;
[[FTSDKAgent sharedInstance] startTraceWithConfigOptions:traceConfig];
let loggerConfig = FTLoggerConfig()
loggerConfig.enableCustomLog = true
loggerConfig.enableLinkRumData = true
FTSDKAgent.sharedInstance().startLogger(withConfigOptions: loggerConfig)
let traceConfig = FTTraceConfig()
traceConfig.enableAutoTrace = true
traceConfig.enableLinkRumData = true
FTSDKAgent.sharedInstance().startTrace(withConfigOptions: traceConfig)
Verify Integration Success¶
- Keep
enableSDKDebugLog = YES/trueenabled and run the application - Open a window or initiate a
URLSessionnetwork request - Confirm in the Xcode console that logs related to SDK initialization and data synchronization appear
- Return to the Guance console and confirm that corresponding RUM data has appeared in the application
If further troubleshooting is needed, please refer to Troubleshooting.
Next Steps¶
- For complete installation and initialization instructions, continue reading Application Access
- For explanations of all initialization parameters, read SDK Initialization
- For detailed configurations of RUM, Log, and Trace, read RUM Configuration, Log Configuration, Trace Configuration
- If you need to set global tags, read Custom Tag Usage