The SDK provides mobile Telemetry instrumentation that captures:
- HTTP requests, using URLSession instrumentation
- Unhandled exceptions (NSException, NSError, Error)
- Custom Log ()
- Crashes - using PLCrashReporter
- Page navigation (Swift use swizzeling / SwiftUI use modifier)
- User Actions (Clicks - UI elemenets)
- Mobile Vitals (FPS, Application not responding, Cold Start, Warm Start)
Coralogix RUM agent for iOS supports iOS 13 and higher.
The integration requires minimal effort with a few lines of code. To install this package,
import [email protected]:coralogix/cx-ios-sdk
in spm.
Remember to call this as early in your application life cycle as possible.
Ideally in applicationDidFinishLaunching in AppDelegate
import UIKit
import Coralogix
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var coralogixRum: CoralogixRum?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let domain = CoralogixDomain.US2
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY")
self.coralogixRum = CoralogixRum(options: options)
return true
}
Or if you are using swiftUI
import SwiftUI
import Coralogix
@main
struct DemoAppApp: App {
@State private var coralogixRum: CoralogixRum
init() {
let domain = CoralogixDomain.US2
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY")
self.coralogixRum = CoralogixRum(options: options)
}
var body: some Scene {
WindowGroup {
ContentView(coralogixRum: $coralogixRum)
}
}
}
Turn on/off specific instrumentation, default to all trues. Each instrumentation is responsible for which data the SDK will track and collect for you.
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY",
instrumentations: [.navigation: true,
.mobileVitals: false,
.custom: true,
.errors: true,
.userActions: false,
.network: true,
.anr: true,
.lifeCycle: false])
The ignoreErrors option allows you to exclude errors that meet specific criteria. This options accepts a set of strings and regular expressions to match against the event's error message. Use regular expressions for exact matching as strings remove partial matches.
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY",
ignoreErrors: []) //[".*errorcode=.*", "Im cusom Error"]
The ignoreUrls option allows you to exclude network requests that meet specific criteria. This options accepts a set of strings and regular expressions to match against the event's network url. Use regular expressions for exact matching as strings remove partial matches.
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY",
ignoreUrls: []) //[".*\\.il$","https://www.coralogix.com/academy"])
Provide labels based on url or event
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY",
labels: ["item" : "item_number_5", "itemPrice" : 1000])
Determines whether the SDK should collect the user's IP address and corresponding geolocation data. Defaults to true.
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY",
collectIPData: true)
Number between 0-100 as a precentage of SDK should be init.
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY",
sampleRate: 100)
The timeinterval the SDK will run the FPS sampling in an hour. default is every 1 minute.
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY",
mobileVitalsFPSSamplingRate: 60)
Enable event access and modification before sending to Coralogix, supporting content modification.
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY",
beforeSend: { cxRum in
var editableCxRum = cxRum
if var sessionContext = editableCxRum["session_context"] as? [String: Any] {
sessionContext["user_email"] = "[email protected]"
editableCxRum["session_context"] = sessionContext
}
return editableCxRum
})
, and event discarding
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY",
beforeSend: { cxRum in
var editableCxRum = cxRum
if var viewContext = editableCxRum["view_context"] as? [String: Any],
let view = viewContext["view"] {
if view == "DetailsViewController" {
return nil
}
}
})
This project is licensed under the MIT License - see the LICENSE file for details.