Configuration
Complete reference for all Pulse.shared.initialize(...) parameters. If you just need a quick working setup, see Installation.
The SDK ignores subsequent initialize() calls. Call it once, as early as possible.
Required
| Parameter | Description |
|---|---|
endpointBaseUrl | OTLP base URL for your Pulse backend |
apiKey | Project API key |
Endpoints & Headers
| Parameter | Default | Description |
|---|---|---|
configEndpointUrl | Auto-derived | URL to fetch remote SDK config. Omit unless your backend serves config from a different host — see Remote Config. |
customEventCollectorUrl | nil | Override delivery URL for custom events only |
endpointHeaders | nil | Extra HTTP headers on all outbound requests. |
Telemetry Enrichment
globalAttributes
Key/value pairs attached to every span and log. Supported types: .string, .int, .double, .bool, and array variants.
globalAttributes: [
"environment": AttributeValue.string("production"),
"app.version": AttributeValue.string("2.1.0"),
]
See Global Attributes for the full list of what the SDK auto-attaches alongside your values.
resource
Override OpenTelemetry resource attributes (device model, OS, service name). Your values win over SDK defaults.
resource: { attributes in
attributes["service.name"] = .string("MyApp-iOS")
attributes["deployment.environment"] = .string("staging")
}
SDK Behavior
configuration
Controls which attribute groups are injected into every span and log. All are on by default.
| Method | When called |
|---|---|
disableScreenAttributes() | Stop injecting screen.name |
disableNetworkAttributes() | Stop injecting network.connection.type / subtype |
disableGlobalAttributes() | Stop injecting your custom globalAttributes |
configuration: { config in
config.disableScreenAttributes() // don't inject screen.name into every signal
}
dataCollectionState
| Value | Behavior |
|---|---|
.allowed (default) | Telemetry collected and exported |
.pending / .denied | SDK skips initialization — nothing collected |
Pulse.shared.initialize(
endpointBaseUrl: "https://your-backend.com",
apiKey: "your-api-key",
dataCollectionState: .pending // wait for user consent before collecting
)
Use .pending to gate collection behind a user consent prompt. See Data Collection Consent.
Instrumentations
Configure individual instrumentations via the instrumentations closure. Each has a dedicated guide with all available options.
On by default:
| Instrumentation | DSL key | Guide |
|---|---|---|
| URLSession | urlSession { } | Network |
| Crash reporting | crash { } | Crashes |
| Screen lifecycle | screenLifecycle { } | Screen Lifecycle |
| Session management | sessions { } | Sessions |
| App startup timing | appStartup { } | App Startup |
| App lifecycle events | appLifecycle { } | App Lifecycle |
| User flow tracking | interaction { } | Interaction |
Needs extra setup:
| Instrumentation | What's needed | Guide |
|---|---|---|
| Session replay | Enable from Pulse Dashboard | Session Replay |
| UIKit tap | Enable from Pulse Dashboard | UIKit Tap |
| Geo attributes | ACCESS_COARSE_LOCATION permission | Location |
Use the instrumentations block to disable or configure any default instrumentation:
instrumentations: { config in
// disable a default instrumentation
config.crash { $0.enabled(false) }
}
Each instrumentation has its own guide with all available options linked in the table above.
Before-Send Callbacks
Inspect, modify, or drop any signal before it is exported. Return nil to drop.
| Parameter | Signature | Use |
|---|---|---|
beforeSendSpan | (ReadableSpan) -> ReadableSpan? | Filter or annotate spans |
beforeSendLog | (ReadableLogRecord) -> ReadableLogRecord? | Filter or annotate logs |
beforeSendMetric | (MetricData) -> MetricData? | Filter metrics |
beforeSendSpan: { span in
span.name.contains("/health") ? nil : span // drop health-check spans
},
beforeSendLog: { log in
log.attributes["log.level"]?.description == "debug" ? nil : log
}
Advanced OpenTelemetry
Direct access to the OTel pipeline for custom processors or exporters:
tracerProviderCustomizer: { builder in
builder.add(spanProcessor: MyCustomSpanProcessor())
return builder
},
loggerProviderCustomizer: { processors in
[MyCustomLogProcessor()] + processors // prepend before Pulse's own processors
}
Remote Config
The SDK fetches a server-side config from your Pulse backend on every launch — in the background, non-blocking. The fetched config is persisted on device and applied on the next launch, so mid-session behavior stays consistent.
The config URL is auto-derived from endpointBaseUrl. Only set configEndpointUrl explicitly if your backend serves config from a different host.
Everything below can be changed from the Pulse dashboard without shipping an app update:
- Enable or disable instrumentations — turn crash reporting, network, session replay, tap tracking, or interaction on/off
- Set a default sampling rate — e.g. collect telemetry from 10% of all sessions globally
- Rule-based sampling — override the default rate for specific OS versions, app versions, countries or platforms (e.g. 100% sampling on iOS 16, 10% on all others)
- Drop attributes — remove sensitive or noisy attributes from all matching signals without touching app code
- Add attributes — inject computed or static key/value pairs into matching signals
Shutdown
Permanently shuts down the SDK. All subsequent API calls are no-ops and cannot be reversed in the same process.
Pulse.shared.shutdown()
Uninstalls all instrumentations and swizzles, flushes and shuts down processors, deletes persisted telemetry, and clears session data from UserDefaults.
Next Steps
Now that the SDK is configured, explore what you can do with it:
| I want to… | Go to |
|---|---|
| Configure a specific instrumentation | Instrumentation guides |
| Track business events | Custom Events |
| Report handled errors | Error Tracking |
| Measure operation durations | Custom Spans |
| Attach user identity to telemetry | User Identification |
| Add global metadata to all signals | Global Attributes |
| Gate collection behind consent | Data Collection Consent |
| Browse all public methods | API Reference |
| Upload symbol file | Upload Symbols |