Skip to content

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:

  1. Create a macOS application in RUM and obtain the RUM App ID
  2. Confirm the reporting address and authentication method
  3. Local environment deployment: Prepare datakitUrl
  4. Public DataWay: Prepare datawayUrl and clientToken
  5. Confirm that the project has completed SDK installation, supporting CocoaPods or Swift Package Manager

Integration Steps

  1. Install FTMacOSSDK in the project
  2. Initialize FTSDKConfig before the application launches
  3. Initialize FTRumConfig and enable View, Action, Resource, crash, and freeze collection
  4. Keep debug logs enabled, run the application, and trigger a window switch or network request
  5. 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.swift file first and delete @main or @NSApplicationMain in AppDelegate.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

  1. Keep enableSDKDebugLog = YES/true enabled and run the application
  2. Open a window or initiate a URLSession network request
  3. Confirm in the Xcode console that logs related to SDK initialization and data synchronization appear
  4. 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