This is Amplitude's latest version of the Session Replay SDK for iOS.
AmplitudeSessionReplay integrates via plugin to your core analytics library.
To Start, import the library via your preferred package manager.
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.
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.
-
Use target/subspec:
AmplitudeSwiftSessionReplayPlugin
-
Import the framework:
import AmplitudeSwiftSessionReplayPlugin
- Add the plugin to your Amplitude instance:
amplitude.add(plugin: AmplitudeSwiftSessionReplayPlugin())
-
Use target/subspec:
AmplitudeiOSSessionReplayMiddleware
-
Import the framework:
import AmplitudeiOSSessionReplayMiddleware
- Add the plugin to your Amplitude instance:
amplitude.addEventMiddleware(AmplitudeiOSSessionReplayMiddleware())
-
Use target/subspec:
AmplitudeSegmentSessionReplayPlugin
-
Import the framework:
import AmplitudeSegmentSessionReplayPlugin
- 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"))
-
Use target/subspec:
AmplitudeSessionReplay
-
Import the framework:
import AmplitudeSegmentSessionReplayPlugin
- Initialize
AmplitudeSessionReplay
, and make sure to retain a copy of the instance:
let sessionReplay = SessionReplay(apiKey: "API_KEY")
- Set
deviceId
andsessionId
on theSessionReplay
instance, equivalent to that set on your analytics client.
sessionReplay.deviceId = deviceId
sessionReplay.sessionId = sessionId
- 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
- Call start:
sessionReplay.start()
If you have any issues using our SDK, feel free to create a GitHub issue or submit a request on Amplitude Help.