Pulse for tvOS
Integrate Pulse with Sentry to capture and send structured logs.
The SentryPulse package provides a Pulse integration that automatically forwards log entries to Sentry's structured logging system. Once started, all Pulse log messages are captured and sent to Sentry with full context, including metadata, source location, and log levels.
- Sentry Cocoa SDK
9.27.0or above - Pulse
5.0.0or above
Add the package via Swift Package Manager:
dependencies: [
.package(url: "https://github.com/getsentry/sentry-apple-pulse", from: "9.0.0")
]
dependencies: [
.package(url: "https://github.com/getsentry/sentry-apple-pulse", from: "9.0.0")
]
Or add it in Xcode via File > Add Package Dependencies using the URL https://github.com/getsentry/sentry-apple-pulse.
By default, the integration uses precompiled Sentry binary xcframeworks. If you need to build Sentry from source, enable the SentryFromSource trait:
dependencies: [
.package(url: "https://github.com/getsentry/sentry-apple-pulse", from: "9.0.0", traits: ["SentryFromSource"])
]
dependencies: [
.package(url: "https://github.com/getsentry/sentry-apple-pulse", from: "9.0.0", traits: ["SentryFromSource"])
]
Initialize the Sentry SDK, then start the Pulse integration. SDK 9.27.0+ doesn't require an enable flag for logs forwarded by this integration:
import Sentry
import Pulse
import SentryPulse
SentrySDK.start { options in
options.dsn = "___PUBLIC_DSN___"
}
SentryPulse.start()
import Sentry
import Pulse
import SentryPulse
SentrySDK.start { options in
options.dsn = "___PUBLIC_DSN___"
}
SentryPulse.start()
By default, SentryPulse.start() observes LoggerStore.shared. You can pass a custom store:
let customStore = try LoggerStore(storeURL: customURL, options: [.inMemory])
SentryPulse.start(loggerStore: customStore)
let customStore = try LoggerStore(storeURL: customURL, options: [.inMemory])
SentryPulse.start(loggerStore: customStore)
You can stop and restart the integration at any time:
SentryPulse.stop() // Stop forwarding Pulse logs to Sentry
SentryPulse.start() // Re-enable the integration
SentryPulse.stop() // Stop forwarding Pulse logs to Sentry
SentryPulse.start() // Re-enable the integration
Calling start() multiple times has no effect — the integration is started only once.
import Pulse
let logger = LoggerStore.shared.makeLogger(label: "com.example.app")
logger.info("User logged in", metadata: ["userId": "12345"])
logger.error("Payment failed", metadata: ["errorCode": "500"])
import Pulse
let logger = LoggerStore.shared.makeLogger(label: "com.example.app")
logger.info("User logged in", metadata: ["userId": "12345"])
logger.error("Payment failed", metadata: ["errorCode": "500"])
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 |
All Pulse metadata is automatically forwarded to Sentry with the pulse. prefix:
logger.info("User action", metadata: [
"userId": "12345",
"action": "purchase"
])
// Produces attributes: pulse.userId, pulse.action
logger.info("User action", metadata: [
"userId": "12345",
"action": "purchase"
])
// Produces attributes: pulse.userId, pulse.action
The integration automatically includes the following attributes with every log entry:
| Attribute | Description |
|---|---|
sentry.origin | "auto.logging.pulse" |
pulse.level | The original Pulse level name |
pulse.label | The logger label |
code.file.path | The source file path (if available) |
code.function.name | The function name (if available) |
code.line.number | The line number |
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").