Error Tracking
Generates: Events (Log Records)
Report non-fatal errors — handled exceptions, failed API calls, validation failures — that you catch and want to track without crashing the app.
Report by Error Name
For errors you define as strings or enum cases:
Pulse.shared.trackNonFatal(
name: "api_timeout",
observedTimeStampInMs: Int64(Date().timeIntervalSince1970 * 1000),
params: [
"endpoint": "/api/v1/feed",
"timeout_ms": 5000,
"retry": false,
]
)
Report a Swift Error
For caught Error instances — the SDK extracts the type name and message automatically:
do {
let data = try await api.fetchProfile(userId: userId)
processProfile(data)
} catch let error as NetworkError {
Pulse.shared.trackNonFatal(
error: error,
observedTimeStampInMs: Int64(Date().timeIntervalSince1970 * 1000),
params: [
"user.id": userId,
"endpoint": "/api/v1/profile",
]
)
} catch {
Pulse.shared.trackNonFatal(
error: error,
observedTimeStampInMs: Int64(Date().timeIntervalSince1970 * 1000),
params: ["context": "profile_fetch"]
)
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name / error | String / Error | Yes | Error name or a caught Swift Error instance |
observedTimeStampInMs | Int64 | Yes | Timestamp in epoch milliseconds |
params | [String: Any?] | No | Context attributes — add anything useful for debugging |
Generated Telemetry
Type: Log Record (Event)
Body: Error name or error type string
pulse.type: non_fatal
Scope Name: com.pulse.ios.sdk
Attributes
| Attribute | Description | Example | Always Present |
|---|---|---|---|
pulse.type | Instrumentation type | "non_fatal" | ✅ Yes |
exception.type | Error name or Swift type name | "api_timeout", "NetworkError" | ✅ Yes |
exception.message | Error description | "The request timed out." | ✅ Yes |
exception.stacktrace | Stack trace at call site | Multi-line string | ✅ Yes |
session.id | Current session identifier | "f40364c92b85ec0c19c35a65be42b97f" | ✅ Yes |
screen.name | Active UIViewController | "FeedViewController" | ⚠️ If available |
| (your params) | Custom context attributes | — | ⚠️ As provided |
Sample Payload
{
"body": "NetworkError",
"attributes": {
"pulse.type": "non_fatal",
"exception.type": "NetworkError",
"exception.message": "The network connection was lost.",
"exception.stacktrace": "0 MyApp FeedViewController.loadFeed() + 128\n1 MyApp FeedViewController.viewDidLoad() + 64\n...",
"endpoint": "/api/v1/feed",
"session.id": "f40364c92b85ec0c19c35a65be42b97f",
"screen.name": "FeedViewController"
},
"scope_name": "com.pulse.ios.sdk"
}
Difference from Crash Reporting
| Non-Fatal Errors | Crashes | |
|---|---|---|
| App continues running | ✅ Yes | ❌ No |
| Reported | Immediately at call site | On next app launch |
| Triggered by | You, explicitly | Any unhandled exception or signal |
| Use for | Handled errors you want to track | Any crash |