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.0 or above
  • Pulse 5.0.0 or above

Add the package via Swift Package Manager:

Copied
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:

Copied
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:

Copied
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:

Copied
let customStore = try LoggerStore(storeURL: customURL, options: [.inMemory])
SentryPulse.start(loggerStore: customStore)

You can stop and restart the integration at any time:

Copied
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.

Copied
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 LevelSentry 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:

Copied
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:

AttributeDescription
sentry.origin"auto.logging.pulse"
pulse.levelThe original Pulse level name
pulse.labelThe logger label
code.file.pathThe source file path (if available)
code.function.nameThe function name (if available)
code.line.numberThe line number
Was this helpful?
Help improve this content
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").