Skip to content

Latest commit

 

History

History
151 lines (110 loc) · 5.15 KB

README.md

File metadata and controls

151 lines (110 loc) · 5.15 KB


AmplitudeSessionReplay-iOS

This is Amplitude's latest version of the Session Replay SDK for iOS.

Integrations

AmplitudeSessionReplay integrates via plugin to your core analytics library.

SDK support

AmplitudeSessionReplay currently supports iOS 13.0 and above. macOS support in Package.swift is only used for swift command line tools.

Instructions

To Start, import the library via your preferred package manager.

SPM

Use package https://github.com/amplitude/AmplitudeSessionReplay-iOS.git Be careful to only add a single library to your target, based on your core analytics library as detailed below.

Cocoapods

Add pod 'SUB_SPEC', :git => 'https://github.com/amplitude/AmplitudeSessionReplay-iOS.git' to your Podfile, replacing SUB_SPEC with the appropriate subspec for your core analytics library as detailed below.

Amplitude-Swift (Preferred)

  1. Use target/subspec: AmplitudeSwiftSessionReplayPlugin

  2. Import the framework:

import AmplitudeSwiftSessionReplayPlugin
  1. Add the plugin to your Amplitude instance:
amplitude.add(plugin: AmplitudeSwiftSessionReplayPlugin())

Developer docs

Amplitude-iOS

  1. Make sure the Analytics SDK is on version 8.22.0 or higher

  2. Use target/subspec: AmplitudeiOSSessionReplayMiddleware

  3. Import the framework:

import AmplitudeiOSSessionReplayMiddleware
  1. Add the plugin to your Amplitude instance:
amplitude.addEventMiddleware(AmplitudeiOSSessionReplayMiddleware())

Developer docs

Segment (Analytics-Swift, Amplitude (Actions) Destination, SegmentAmplitude Plugin)

  1. Use target/subspec: AmplitudeSegmentSessionReplayPlugin

  2. Import the framework:

import AmplitudeSegmentSessionReplayPlugin
  1. Add the plugin to your Amplitude instance, after adding the AmplitudeSession plugin:
let analytics = Analytics(configuration: config)
// AmplitudeSession MUST be first so AmplitudeSegmentSessionReplayPlugin can pick up the sessionId
analytics.add(plugin: AmplitudeSession())
analytics.add(plugin: AmplitudeSegmentSessionReplayPlugin(amplitudeApiKey: "AMPLITUDE_API_KEY"))

Developer docs

Standalone / Third Party

  1. Use target/subspec: AmplitudeSessionReplay

  2. Import the framework:

import AmplitudeSessionReplay
  1. Initialize AmplitudeSessionReplay, and make sure to retain a copy of the instance:
let sessionReplay = SessionReplay(apiKey: "API_KEY")
  1. Set deviceId and sessionId on the SessionReplay instance, equivalent to that set on your analytics client.
sessionReplay.deviceId = deviceId
sessionReplay.sessionId = sessionId
  1. Add additionalEventProperties as event properties to the events you pass to Amplitude.
var eventProperties = event.eventProperties ?? [:]
eventProperties.merge(sessionReplay.additionalEventProperties) { (current, _) in current }
event.eventProperties = eventProperties
  1. Call start:
sessionReplay.start()

Developer docs

Need Help?

If you have any issues using our SDK, feel free to create a GitHub issue or submit a request on Amplitude Help.

Legacy middleware and plugin options

AmplitudeiOSSessionReplayMiddleware supports the same capture settings as SessionReplayPlugin: sample rate, mask level, quality, remote configuration, WebView mappings/capture, automatic start, log limits, and upload configuration. The existing initializer remains available; init(config:) also accepts the plugin's Config object.

Runtime API Plugin Middleware
Custom session override (nil restores the latest Analytics session) customSessionId customSessionId
Local privacy configuration (remote settings take precedence) privacyConfig privacyConfig
Core client access sessionReplay sessionReplay
Capture and logs start, stop, recordLog start, stop, recordLog
let middleware = AmplitudeiOSSessionReplayMiddleware(
    config: .init(sampleRate: 0.1, captureWebViews: true)
)
middleware.customSessionId = "snowplow-session-id"
amplitude.addEventMiddleware(middleware)
// On each custom-session transition, update customSessionId.
// Set it to nil to resume the latest Analytics SDK session.

Custom IDs override session matching for enrichment, but device IDs must still match. Configure custom session matching in Amplitude and send the same session-defining property on analytics events. Setting an override does not change the Analytics SDK's session ID. Plugin-host lifecycle and interface-signal protocols are specific to the plugin host; middleware uses legacy SDK callbacks.