Advanced Setup
User tracking
By default, each user will be identified with a unique guid and marked as anonymous. The identifier property on the RaygunUserInformation class is what separates one user from another. Be sure to set it with something unique, for example a database id, username or email address. If the user changes, for instance when logging in or out, be sure to update the user information on the shared Raygun client each time. You can assign user information as described below.
Objective-C:
RaygunUserInformation *userInfo = [[RaygunUserInformation alloc] initWithIdentifier:@"user@raygun.com"
withEmail:@"user@raygun.com"
withFullName:@"Test User"
withFirstName:@"Test"];
RaygunClient.sharedInstance.userInformation = userInfo;
Swift:
let userInformation = RaygunUserInformation(identifier: "user@raygun.com", email: "user@raygun.com", fullName: "Test User", firstName: "Test")
RaygunClient.sharedInstance().userInformation = userInformation
Automatic network performance monitoring
The provider has the ability to automatically record the time it took to complete network requests. Use the following snippet to enable this feature. Network performance monitoring can only be enabled after enabling Real User Monitoring on the client.
Details about all automatically and manually logged network calls can be found on the Performance tab of your Real User Monitoring for mobile dashboard.
Objective-C:
[RaygunClient.sharedInstance enableNetworkPerformanceMonitoring];
Swift:
RaygunClient.sharedInstance().enableNetworkPerformanceMonitoring()
The provider will track the performance of network calls made with the following methods:
// NSURLSession methods
dataTaskWithURL:
dataTaskWithURL:completionHandler:
dataTaskWithRequest:
dataTaskWithRequest:completionHandler:
downloadTaskWithURL:
downloadTaskWithURL:completionHandler:
downloadTaskWithRequest:
downloadTaskWithRequest:completionHandler:
uploadTaskWithRequest:fromData:
uploadTaskWithRequest:fromData:completionHandler:
uploadTaskWithRequest:fromFile:
uploadTaskWithRequest:fromFile:completionHandler:
// NSURLConnection methods
sendAsynchronousRequest:queue:completionHandler
sendSynchronousRequest:returningResponse:error:
Manually report timings
You are able to manually report network timings to Raygun using the following snippet with duration being measured in milliseconds.
Objective-C:
[RaygunClient.sharedInstance sendTimingEvent:RaygunEventTimingTypeNetworkCall withName:@"www.raygun.com/rum" withDuration:120];
Swift:
RaygunClient.sharedInstance().sendTimingEvent(type: RaygunEventTimingType.networkCall, name:"www.raygun.com/rum", duration:120)
Ignoring timings
Since network requests are automatically detected, there may be network request that are not helpful to record and should be ignored. The following snippet can be used to stop the provider from sending timing events for those requests whose URLs contain specific text.
Objective-C:
[RaygunClient.sharedInstance ignoreURLs:@[@"raygun.com"]];
Swift:
RaygunClient.sharedInstance().ignoreURLs(["raygun.com"])
Version tracking
Raygun4Apple supports tracking the version of your application by setting the applicationVersion
property of the Raygun client.
// Instantiate a new Raygun client
RaygunClient *raygunClient = [RaygunClient sharedInstanceWithApiKey:@"paste_your_api_key_here"];
// Set the application version
raygunClient.applicationVersion = @"1.0.0";
The applications version will then be tracked in Real User Monitoring allowing you to see how many users are using each version of your application.