Features
- Access to OpenTelemetry APIs
- Network Monitoring
- Crash Reporting
- AppLifecycle Instrumentation
- Slow Rendering Detection
- WebView Instrumentation
- Api for sending custom errors & record exceptions
- Custom logging
- Session Recording
Setup
Add the following line in Package.swift in dependencies
.package(url: "https://github.com/middleware-labs/middleware-ios", from: "1.0.6"),
Using Cocoapods
pod "MiddlewareRum", "~> 1.0.6"
Initialization of Middleware iOS sdk
import SwiftUI import MiddlewareRum @main struct YourApp: App { init() { MiddlewareRumBuilder() .globalAttributes(["customerId" : "123456"]) .target("<target>") .serviceName("Mobile-SDK-iOS") .projectName("Mobile-SDK-iOS") .rumAccessToken("<account-key>") .deploymentEnvironment("PROD") .build() } var body: some Scene { WindowGroup { ContentView() } } }
Documentation
Configurations
Methods that can be used for setting instrumentation & configure your application.
| Option | Description |
.rumAccessToken(String)
|
Sets the RUM account access token to authorize client to send telemetry data to Middleware |
.target(String)
|
Sets the target URL to which you want to send telemetry data. For example - Unified Observability Platform | Middleware |
.serviceName(String)
|
Sets the service name for your application. This can be used further for filtering by service name. |
.projectName(String)
|
Sets the project name for your application. |
.deploymentEnvironment(String)
|
Sets the environment attribute on the spans that are generated by the instrumentation. For Example - PROD | DEV |
.disableCrashReportingInstrumentation()
|
Disable crash reporting. By default it is enabled. |
.disableNetworkMonitoring()
|
Disable HTTP Instrumentation. By default it is enabled. |
.disableSlowRenderingDetection()
|
Disable slow or frozen frame renders. By default it is enabled. |
.slowFrameDetectionThresholdMs(Double)
|
Sets the default polling for slow render detection. Default value in milliseconds is 16.7 |
.frozenFrameDetectionThresholdMs(Double)
|
Sets the default polling for slow render detection. Default value in milliseconds is 700 |
Logging using Middleware API
MiddlewareRum.info("Some information") MiddlewareRum.debug("Some information") MiddlewareRum.trace("Some information") MiddlewareRum.warning("Some information") MiddlewareRum.error("Some information") MiddlewareRum.critical("Some information")
Adding custom error to trace
MiddlewareRum.addError("Unable to process I am error")
Custom Exception
MiddlewareRum.addException(e: NSException(name: NSExceptionName(rawValue: "RuntimeException"), reason: "I am custom exception"))
Set screen name
MiddlewareRum.setScreenName("WebView")
Set Global Attributes
MiddlewareRum.setGlobalAttributes(["some": "value"])
WebView Instrumentation
MiddlewareRum.integrateWebViewWithBrowserRum(view: webView)
Enable Session Recording
By default session recording is enabled, to disable call .disableRecording() :
MiddlewareRumBuilder() .globalAttributes(["customerId" : "123456"]) .target("<target>") .serviceName("Mobile-SDK-iOS") .projectName("Mobile-SDK-iOS") .rumAccessToken("<account-key>") .deploymentEnvironment("PROD") .disableRecording() .build()
Sensitive views (View will get blurred)
//SwiftUI Text("Very important sensitive text").sensitive() // UIKit MiddlewareRum.addIgnoredView(view)