getsentry/sentry-apple-pulse
A Pulse integration that automatically forwards log entries to Sentry's structured logging system, capturing application logs with full context including metadata, source location, and log levels.
Installation
Swift Package Manager
Add the following dependencies to your Package.swift or Xcode package manager:
dependencies: [
.package(url: "https://github.com/getsentry/sentry-apple-pulse", from: "9.0.0")
]Then add the SentryPulse product to your target:
.target(
name: "MyApp",
dependencies: [
.product(name: "SentryPulse", package: "sentry-apple-pulse")
]
)Quick Start
import Sentry
import Pulse
import SentryPulse
SentrySDK.start { options in
options.dsn = "YOUR_DSN"
}
SentryPulse.start()
let logger = LoggerStore.shared.makeLogger(label: "com.example.app")
logger.info("User logged in", metadata: ["userId": "12345"])
logger.error("Payment failed", metadata: ["errorCode": 500])Configuration
Custom LoggerStore
By default, SentryPulse.start() uses LoggerStore.shared. You can specify a custom LoggerStore:
let customStore = try LoggerStore(storeURL: customURL, options: [.inMemory])
SentryPulse.start(loggerStore: customStore)Lifecycle Management
The integration automatically observes Pulse's LoggerStore.events publisher and forwards all .messageStored events to Sentry. You can stop the integration if needed:
SentryPulse.stop()
SentryPulse.start()Calling start() multiple times has no effect - the integration is started only once.
Log Level Mapping
Pulse log levels are automatically mapped to Sentry log levels:
| Pulse Level | Sentry Log Level | | ----------- | ---------------- | | .trace | .trace | | .debug | .debug | | .info | .info | | .notice | .info | | .warning | .warn | | .error | .error | | .critical | .fatal |
Metadata Handling
All Pulse metadata is automatically forwarded to Sentry with the pulse. prefix:
logger.info("User action", metadata: [
"userId": "12345",
"action": "purchase"
])The metadata will appear in Sentry as pulse.userId and pulse.action.
Pulse metadata is already converted to [String: String] format before being forwarded, ensuring compatibility with Sentry's attribute system.
Automatic Attributes
The integration automatically includes the following attributes with every log entry:
sentry.origin:"auto.logging.pulse"pulse.level: The original Pulse level namepulse.label: The logger labelcode.file.path: The source file name (if available)code.function.name: The function name (if available)code.line.number: The line number
All Pulse metadata is prefixed with pulse. in Sentry attributes (e.g., pulse.userId, pulse.action).
Documentation
License
This integration follows the same license as the Sentry Cocoa SDK. See the LICENSE file for details.
Package Metadata
Repository: getsentry/sentry-apple-pulse
Default branch: main
README: README.md