Recording Sessions

Control when and how sessions are recorded in your app.

Automatic Recording

By default, PipeKit starts recording automatically when your app launches (if autoStart: true in config). Recording continues until the app goes to background or you manually stop it.

Session Lifecycle

  1. 1App launches → Recording starts automatically
  2. 2App goes to background → Recording pauses, session saves
  3. 3App returns to foreground → New session starts
  4. 4Session uploads in background when WiFi available

Manual Control

For more control, disable auto-start and manage recording manually:

Manual Recording
// Disable auto-start in config
let config = PipeKitConfig(autoStart: false)
PipeKit.shared.configure(apiKey: "your_key", config: config)
// Start recording when ready
PipeKit.shared.startRecording()
// Stop recording
PipeKit.shared.stopRecording()
// Check if currently recording
if PipeKit.shared.isRecording {
print("Recording in progress...")
}

Conditional Recording

Record only specific user flows or conditions:

Conditional Recording
// Record only specific screens
class CheckoutViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
PipeKit.shared.startRecording()
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
PipeKit.shared.stopRecording()
}
}
// Record based on user consent
func userDidConsentToRecording() {
PipeKit.shared.startRecording()
}
// Record only for specific user segments
if user.isBetaTester {
PipeKit.shared.startRecording()
}

Custom Events & Markers

Add custom events to mark important moments in your sessions:

swift
// Log a message with attributes
PipeKit.log("purchase_completed", attributes: [
"product_id": "12345",
"amount": "29.99"
])
// Log a warning
PipeKit.warning("Low memory detected")
// Log an error with attributes
PipeKit.error("Payment processing failed", attributes: [
"gateway": "stripe",
"code": "card_declined"
])

Upload Control

Sessions are uploaded automatically, but you can also trigger manual uploads:

swift
// Upload current session immediately
PipeKit.shared.uploadCurrentSession { result in
switch result {
case .success(let response):
print("Session uploaded: \(response.sessionId)")
case .failure(let error):
print("Upload failed: \(error)")
}
}
// Upload all pending sessions
SessionUploader.shared.uploadAllPendingSessions { results in
print("Uploaded \(results.count) sessions")
}

Upload Timing

Sessions are automatically uploaded when the app goes to background or when you callstopRecording(). Manual upload is useful for ensuring critical sessions are saved immediately.

Next: User Identification

Learn how to link sessions to your users for easier debugging.

Continue to User Identification →