1. Install the Raygun4Apple package
Download the latest package installer from here. Run the installer and follow the on-screen instructions.
2. Reference Raygun4Apple in your project
To use the framework in an app project, you will need to first select the Project in the Project Navigator. Then select the Target for the Project and scroll down to the Embedded Binaries section.
Next, in Finder, open the Library > Frameworks > raygun4apple directory. Open the folder corresponding to the platform your Target is currently supporting. Select the raygun4apple.framework file and drag it into the Embedded Binaries section.
3. Add the import dependency
For Swift projects you must create an Objective-C bridging header to be able to import the provider's umbrella header file. You can find out how to do this by visiting Apple's documentation for more details.
In your AppDelegate's source file or Objective-C bridging header file, import the umbrella header for your target platform.
4. Enable Real User Monitoring
In your AppDelegate's application function, add the following code to start the Raygun crash reporter. Your app API key is displayed when you create a new application in your Raygun account, or can be viewed in the application settings.
RaygunClient *raygunClient = [RaygunClient sharedInstanceWithApiKey:@"YOUR_APP_API_KEY"];
let raygunClient = RaygunClient.sharedInstance(apiKey:"YOUR_APP_API_KEY")
Unique 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.
RaygunUserInformation *userInfo = [[RaygunUserInformation alloc] initWithIdentifier:@"firstname.lastname@example.org"
RaygunClient.sharedInstance.userInformation = userInfo;
let userInformation = RaygunUserInformation(identifier: "email@example.com", email: "firstname.lastname@example.org", fullName: "Test User", firstName: "Test")
RaygunClient.sharedInstance().userInformation = userInformation
Automatic view performance monitoring
The provider will automatically record the time it took for views to load during a user's session. This information will appear on the Views tab of your Real User Monitoring for mobile dashboard and also when inspecting a user's session.
Manually report timings
You are able to manually report view timing events that will appear with the current session. This can be helpful to provide additional information around a user's experience.
[RaygunClient.sharedInstance sendTimingEvent:RaygunEventTimingTypeViewLoaded withName:@"MyAppViewController" withDuration:300];
RaygunClient.sharedInstance().sendTimingEvent(type: RaygunEventTimingType.viewLoaded, name:"MyAppViewController", duration:300)
Since views are automatically detected, there may be views 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 views whose name matches.
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.
The provider will track the performance of network calls made with the following methods:
// NSURLSession methods
// NSURLConnection methods
Manually report timings
You are able to manually report network timings to Raygun using the following snippet with duration being measured in milliseconds.
[RaygunClient.sharedInstance sendTimingEvent:RaygunEventTimingTypeNetworkCall withName:@"www.raygun.com/rum" withDuration:120];
RaygunClient.sharedInstance().sendTimingEvent(type: RaygunEventTimingType.networkCall, name:"www.raygun.com/rum", duration:120)
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.