- 访问OpenTelemetry API
- 网络监控
- 崩溃报告
- App生命周期 instrumentation
- 慢速渲染检测
- WebView instrumentation
- 发送自定义错误与记录异常的API
- 自定义日志记录
- 会话录制
.package(url: "https://github.com/middleware-labs/middleware-ios", from: "1.0.3"),
pod "MiddlewareRum", "~> 1.0.3"
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()
}
}
}
可用于设置instrumentation和配置应用程序的方法。
选项 | 描述 |
.rumAccessToken(String)
|
设置RUM账户访问令牌,授权客户端向Middleware发送遥测数据 |
.target(String)
|
设置要发送遥测数据的目标URL。例如 - 统一可观测性平台 | Middleware |
.serviceName(String)
|
设置应用程序的服务名称。这可以进一步用于按服务名称进行过滤。 |
.projectName(String)
|
设置应用程序的项目名称。 |
.deploymentEnvironment(String)
|
设置由instrumentation生成的spans的环境属性。例如 - PROD | DEV |
.disableCrashReportingInstrumentation()
|
禁用崩溃报告。默认情况下是启用的。 |
.disableNetworkMonitoring()
|
禁用HTTP instrumentation。默认情况下是启用的。 |
.disableSlowRenderingDetection()
|
禁用慢速或冻结的帧渲染。默认情况下是启用的。 |
.slowFrameDetectionThresholdMs(Double)
|
设置默认轮询以检测慢速渲染的时间间隔。默认值(以毫秒为单位)为16.7 |
.frozenFrameDetectionThresholdMs(Double)
|
设置默认轮询以检测慢速渲染的时间间隔。默认值(以毫秒为单位)为700 |
MiddlewareRum.info("Some information")
MiddlewareRum.debug("Some information")
MiddlewareRum.trace("Some information")
MiddlewareRum.warning("Some information")
MiddlewareRum.error("Some information")
MiddlewareRum.critical("Some information")
MiddlewareRum.addError("Unable to process I am error")
MiddlewareRum.addException(e: NSException(name: NSExceptionName(rawValue: "RuntimeException"), reason: "I am custom exception"))
MiddlewareRum.setScreenName("WebView")
MiddlewareRum.setGlobalAttributes(["some": "value"])
MiddlewareRum.integrateWebViewWithBrowserRum(view: webView)
默认情况下会话录制是启用的,要禁用,请调用.disableRecording()
MiddlewareRumBuilder()
.globalAttributes(["customerId" : "123456"])
.target("<target>")
.serviceName("Mobile-SDK-iOS")
.projectName("Mobile-SDK-iOS")
.rumAccessToken("<account-key>")
.deploymentEnvironment("PROD")
.disableRecording()
.build()
//SwiftUI
Text("Very important sensitive text").sensitive()
// UIKit
MiddlewareRum.addIgnoredView(view)