이 페이지에서

For AI agents: a documentation index is available at /docs/llms.txt. Append .md to any page URL for markdown, or send Accept: text/markdown.

세션 리플레이 iOS 플러그인

이 문서에서는 iOS 플러그인을 사용하여 세션 리플레이를 설치하는 방법을 설명합니다. 앱에서 이미 Amplitude iOS Swift SDK 또는 기존 Amplitude iOS SDK를 사용하는 경우 이 옵션을 사용하십시오.

Analytics-Swift SDK 및 Amplitude(액션) 목적지를 통해 세그먼트를 사용하는 경우 세그먼트 플러그인을 선택하십시오.

제품 내 분석을 위해 Amplitude 이외의 공급자를 사용하는 경우, 독립형 구현을 선택하십시오.

Unified SDK

다른 Amplitude 제품(분석, 실험)과 함께 세션 리플레이를 이용하려면 Swift용 Unified SDK를 설치하십시오. 통합 SDK는 모든 Amplitude 기능을 위한 단일 진입점을 제공하며 모든 구성 요소의 초기화 및 구성을 처리함으로써 통합을 단순화합니다.

Session Replay and performance

Amplitude built Session Replay to minimize impact on the performance of the iOS apps in which it's installed by:

  • Asynchronously processing replay data, to avoid blocking the main user interface thread. The main thread must be used to interact with the view hierarchy, but all processing is performed on a background queue.
  • Using batching and lightweight compression to reduce the number of network connections and bandwidth.
  • Optimizing view hierarchy processing. Contact Amplitude if you experience issues with hierarchy processing.

세션 리플레이는 기본 뷰와 모든 하위 뷰를 포함하여 앱의 뷰 트리에 대한 변경 사항을 재귀적으로 캡처합니다. 그런 다음 세션 리플레이는 이러한 변경 사항을 재생하여 비디오와 유사한 재생을 구성합니다. 세션이 시작될 때 세션 리플레이는 앱의 뷰 트리의 전체 스냅샷을 캡처합니다. 사용자가 앱과 상호작용할 때 세션 리플레이는 각 뷰 변경을 차이로 캡처합니다. 세션의 재생을 시청할 때 세션 리플레이는 각 차이를 순차적으로 원본 뷰 트리에 다시 적용하여 재생을 구성합니다. 세션 리플레이에는 최대 길이가 없습니다.

문제 리포트

iOS용 세션 리플레이와 관련된 문제를 리포트하려면 AmplitudeSessionReplay-ios GitHub 저장소로 이동하십시오.

시작하기 전에

사용하는 방법은 사용하는 Amplitude iOS SDK의 버전에 따라 다릅니다.

세션 리플레이 iOS 플러그인을 사용하려면 다음이 필요합니다.

  1. 애플리케이션은 iOS 또는 iPadOS에서 실행됩니다.
  2. iOS Swift SDK 이상을 1.9.0사용하고 있습니다.

Supported iOS versions

Session Replay supports a minimum target version of iOS 13.

빠른 시작

최신 버전의 플러그인을 프로젝트 종속성에 추가합니다.

Swift 패키지 관리자

세션 리플레이를 Package.swift 파일이나 Xcode의 패키지 목록에 의존성으로 추가하십시오.

swift
dependencies: [
    .package(url: "https://github.com/amplitude/AmplitudeSessionReplay-iOS", from: "0.12.8")
]

Amplitude-Swift와의 통합을 위해 AmplitudeSwiftSessionReplayPlugin 타겟을 사용하십시오.

swift
.product(name: "AmplitudeSwiftSessionReplayPlugin", package: "AmplitudeSessionReplay")

CocoaPods

코어 라이브러리와 플러그인을 사용자의 Podfile에 추가하십시오.

plaintext
pod 'AmplitudeSessionReplay', :git => 'https://github.com/amplitude/AmplitudeSessionReplay-iOS.git', :tag => 'v0.12.8'
pod 'AmplitudeSwiftSessionReplayPlugin', :git => 'https://github.com/amplitude/AmplitudeSessionReplay-iOS.git', :tag => 'v0.12.8'

애플리케이션 코드 구성

swift
import AmplitudeSwift
import AmplitudeSwiftSessionReplayPlugin
// Initialize Amplitude Analytics SDK instance
let amplitude = Amplitude(configuration: Configuration(apiKey: API_KEY))
// Create and Install Session Replay Plugin
// Recording will be handled automatically
amplitude.add(plugin: AmplitudeSwiftSessionReplayPlugin(sampleRate: 1.0))

구성

세션 리플레이 플러그인을 초기화할 때 다음 옵션을 전달하십시오.

사용자 지정 세션 ID

iOS 버전 0.11.2 이상용 세션 리플레이는 customSessionId속성을 통해 문자열 세션 ID(예: UUID)를 지원합니다. 프로젝트에서 Amplitude 대신 사용자 정의 이벤트 속성을 사용하여 세션을 정의하는 경우 사용자 정의 세션 ID를 사용하십시오session_id.

customSessionId를 설정하면 이 값이 플러그인이 Amplitude SDK에서 데이터 동기화하는 세션 ID보다 우선합니다. Amplitude 세션 ID를 사용하여 재개하도록 속성을 nil로 설정하십시오.

swift
// Keep a reference to the plugin to set the custom session ID
let sessionReplayPlugin = AmplitudeSwiftSessionReplayPlugin(sampleRate: 1.0)
sessionReplayPlugin.customSessionId = "ef197fc7-a46f-4e6c-a77f-8d90c17065c0"
amplitude.add(plugin: sessionReplayPlugin)
// Whenever your custom session changes
sessionReplayPlugin.customSessionId = NEW_CUSTOM_SESSION_ID

세션 리플레이가 사용자 정의 세션을 안정적으로 일치시키려면 사용자 정의 세션 ID가 다음 제약 조건을 따라야 합니다.

  • 이 값은 /을 포함할 수 없습니다. 세션 리플레이는 /을 세션 리플레이 ID의 구분 기호로 사용하며, 형식은 <deviceId>/<sessionId>입니다.
  • 값에는 a-z A-Z 0-9 _ - . | @ : = 문자만 포함할 수 있습니다.
  • 이 값은 이벤트에 대해 Amplitude로 전송하는 세션 정의 속성과 일치해야 합니다. 자세한 내용은 세션 일치를 참조하십시오.

런타임 시 마스킹 변경

앱이 실행되는 동안 자동 마스킹 수준이 변경되도록 플러그인에 privacyConfig을 설정합니다. 플러그인을 Amplitude에 추가하기 전이나 후에 설정하십시오.

swift
sessionReplayPlugin.privacyConfig = PrivacyConfig(maskLevel: .conservative)

원격 구성에서 마스킹 수준을 제공하는 경우 해당 수준이 우선합니다. 플러그인은 로컬 privacyConfig 값을 유지하며 원격 구성에서 마스킹 수준을 제공하지 않거나 원격 구성을 비활성화할 때 이 값을 적용합니다.

Remote configuration

Enable remote configuration to set Sample Rate and Masking Level in Amplitude.

Remote configuration and testing

With enableRemoteConfig set to true, settings you define in Amplitude take precedence over settings you define locally in the SDK. For this reason, while testing your application, you should disable remote configuration to ensure you can set sampleRate to 1, and ensure you capture test sessions.

Block on-screen data

Session Replay supports three ways to block sensitive on-screen data. Masking setting for WebViews is in the Web view support section.

Mask level

Session Replay for iOS supports three levels of masking, configurable with the maskLevel option.

Use this option in the Session Replay configuration.

Privacy methods for UIKit

Session Replay provides an extension on UIView to manage privacy. Import the Session Replay library to access it.

swift
import AmplitudeSessionReplay

Privacy Modifiers for SwiftUI

Session Replay provides an extension on View to manage privacy. Import the Session Replay Library to access it.

swift
import AmplitudeSessionReplay

사용자 옵트아웃

세션 리플레이 플러그인은 Amplitude-Swift SDK의 optOut설정을 따르며, 사용자 옵트아웃을 자체적으로 지원하지 않습니다.

swift
// Set optOut on the Amplitude SDK
let amplitude = Amplitude(configuration: Configuration(apiKey: API_KEY,
                                                           optOut: true,
                                                           /* other configuration */))
amplitude.add(plugin: AmplitudeSwiftSessionReplayPlugin(/* session replay options */))

EU data residency

Session Replay is available to Amplitude Customers who use the EU data center. Set the serverZone configuration option to EU during initialization. For example:

swift
// Set serverZone on the Amplitude SDK
let amplitude = Amplitude(configuration: Configuration(apiKey: API_KEY,
                                                           serverZone: .EU,
                                                           /* other configuration */))
amplitude.add(plugin: AmplitudeSwiftSessionReplayPlugin(/* session replay options */))

Sampling rate

By default, Session Replay captures 0% of sessions for replay. Use your SDK's sampleRate configuration option to set the proportion of sessions to capture.

For manual and dynamic sampling, quota planning, and quota accounting, go to Configure Session Replay sampling.

swift
// This configuration samples 1% of all sessions
amplitude.add(plugin: AmplitudeSwiftSessionReplayPlugin(sampleRate: 0.01))

레코딩 품질

재생 충실도와 성능 및 저장 공간의 균형을 맞추기 위해 품질 프로파일을 선택하십시오. 프로파일이 낮을수록 캡처 프레임 속도가 낮고 이미지 해상도가 낮습니다. 프로파일이 높을수록 프레임 속도가 높고 해상도가 높아집니다. SDK가 장치에 따라 프로파일을 선택하도록 허용하는 데 사용합니다(예: 최신 장치에서는 높음, 이전 장치에서는 낮음)QualityProfile.automatic.

swift
// Use automatic profile selection based on device
amplitude.add(plugin: AmplitudeSwiftSessionReplayPlugin(
    sampleRate: 0.1,
    quality: .automatic
))
// Or set a fixed profile (low, medium, or high)
amplitude.add(plugin: AmplitudeSwiftSessionReplayPlugin(
    sampleRate: 0.1,
    quality: .medium
))

사용량이 부과되는 네트워크에서 업로드 비활성화

장치가 요금제 기반 네트워크에 있는 동안 세션 리플레이 업로드를 일시 중지하여 사용자의 휴대폰 데이터 사용을 방지하십시오. 세션 리플레이는 여전히 데이터를 로컬로 기록합니다. 기기가 Wi-Fi 또는 다른 종량제 제한이 없는 연결에 다시 연결되면 업로드가 재개됩니다.

swift
// Set uploadConfig through the plugin's Config initializer
let config = AmplitudeSwiftSessionReplayPlugin.Config(
    sampleRate: 0.1,
    uploadConfig: UploadConfig(disableMeteredUploads: true)
)
amplitude.add(plugin: AmplitudeSwiftSessionReplayPlugin(config: config))

리플레이 수집 비활성화

세션 리플레이를 활성화한 후에는 다음 중 하나가 될 때까지 앱에서 실행됩니다.

  • 사용자가 앱을 떠납니다.
  • sessionReplayPlugin.stop()을(를) 호출하십시오.
  • amplitude.remove(plugin: sessionReplayPlugin)를 사용하여 SDK에서 플러그인을 제거합니다.

사용자가 앱의 제한된 영역으로 이동하기 전에 호출하여 사용자가 해당 영역에 있는 동안 재생 수집을 비활성화하십시오sessionReplayPlugin.stop().

참조 유지

이렇게 하려면 SessionReplayPlugin 인스턴스에 대한 참조를 유지해야 합니다 let sessionReplayPlugin = AmplitudeSwiftSessionReplayPlugin(/* session replay options */).

사용자가 앱의 제한되지 않은 영역으로 돌아왔을 때 재생 수집을 다시 활성화하려면 sessionReplayPlugin.start()를 호출하십시오.

특정 화면만 캡처하려면 플러그인이 시작될 때 시작되지 않도록 autoStart: false를 사용하여 초기화한 다음, 사용자가 해당 화면에 들어오거나 나갈 때 start() 및 stop()를 호출하십시오.

swift
// Add the plugin once, without starting capture
let sessionReplayPlugin = AmplitudeSwiftSessionReplayPlugin(sampleRate: 1.0, autoStart: false)
amplitude.add(plugin: sessionReplayPlugin)
// Start capture when the user enters a screen you want to record
sessionReplayPlugin.start()
// Stop capture when the user leaves that screen
sessionReplayPlugin.stop()

또한 Amplitude 실험과 같은 기능 플래그 제품을 사용하여 위치와 같은 기준에 따라 재생 수집을 활성화하거나 비활성화하는 로직을 생성할 수도 있습니다. 예를 들어, 특정 사용자 그룹을 대상으로 하는 기능 플래그를 생성하고 이를 초기화 논리에 추가할 수 있습니다.

swift
import AmplitudeSwift
import AmplitudeSwiftSessionReplayPlugin
// Your existing initialization logic with Amplitude-Swift SDK
let amplitude = Amplitude(configuration: Configuration(apiKey: API_KEY,
                                                           /* other configuration */))
if (nonEUCountryFlagEnabled) {
  // Create and Install Session Replay Plugin
  let sessionReplayPlugin = AmplitudeSwiftSessionReplayPlugin(sampleRate: 0.1)
  amplitude.add(plugin: sessionReplayPlugin)
}

Web view support (Beta)

By default, Session Replay blocks web views in a capture. To enable capture of all WebView components, set captureWebViews to true in the Session Replay configuration.

To mask specific WebView components, use the privacy methods described in Block on-screen data.

swift
// UIKit
webView.amp_isBlocked = false

Map View Support (Alpha)

Session Replay supports capturing map views in iOS applications. To enable map view capture, unmask the map view in your implementation.

swift
// UIKit
mapView.amp_isBlocked = false

// SwiftUI
Map().amp_setBlocked(false)

Log Recording

Availability

AmplitudeSessionReplay 0.8.0 and later support log recording.

Session Replay supports recording logs in iOS applications. Configure the limits with recordLogOptions when you initialize the integration, then send log messages through recordLog(level:message:date:).

import AmplitudeSessionReplay

let sessionReplay = SessionReplay(
    apiKey: API_KEY,
    recordLogOptions: .init(logCountThreshold: 2000, maxMessageLength: 4000)
)

sessionReplay.recordLog(level: .error, message: "This is an error log")

If you have implemented a log system, you can make single-point modifications to integrate log recording functionality. See the following examples for more information.

CocoaLumberjack

If you use CocoaLumberjack, you can integrate it with a custom logger provider.

swift
class AmplitudeLogRecordLogger: DDAbstractLogger {

    private weak var plugin: SessionReplayPlugin?

    init(_ plugin: SessionReplayPlugin) {
        self.plugin = plugin
    }

    override func log(message logMessage: DDLogMessage) {
        let recordLevel: RecordLogLevel
        switch logMessage.flag {
        case .error:
            recordLevel = .error
        case .warning:
            recordLevel = .warn
        case .info:
            recordLevel = .log
        default:
            return
        }
        plugin?.recordLog(level: recordLevel,
                          message: logMessage.message,
                          date: logMessage.timestamp)
    }
}

let sessionReplayPlugin = AmplitudeSwiftSessionReplayPlugin()
amplitude.add(plugin: sessionReplayPlugin)

DDLog.add(AmplitudeLogRecordLogger(sessionReplayPlugin))

React Native

If you use console log or react-native-logs with consoleTransport, you can integrate it with RCTAddLogFunction.

swift
RCTAddLogFunction { level, source, fileName, lineNumber, message in
  let recordLevel: RecordLogLevel
  switch level {
  case .error:
    recordLevel = .error
  case .warning:
    recordLevel = .warn
  case .info:
    recordLevel = .log
  case .fatal:
    recordLevel = .error
  case .trace:
    recordLevel = .init("trace")
  default:
    return
  }
  self.sessionReplayPlugin.recordLog(level: recordLevel, message: message)
}

Data retention, deletion, and privacy

Review consent guidance when you implement capture.

Retention period

For native and Flutter SDK retention guidance and the effective date of changes, go to the Session Replay data lifecycle reference.

DSAR API

For replay metadata returned by the DSAR API, go to Session Replay DSAR metadata.

Data deletion

For user and project deletion behavior, go to Session Replay data deletion.

Bot filter

For bot filtering and property-filter restrictions, go to Session Replay bot filtering.

Session Replay storage

If a user opts out tracking in your app, use the optOut configuration option to disable replay collection for that user.

Session Replay temporarily stores replay data data on the file system before it is uploaded. At every initialization, the least recent replays are trimmed to bring the total disk usage down to a maximum size.

Known limitations

Keep the following limitations in mind as you implement Session Replay:

  • Session Replay doesn't stitch together replays from a single user across multiple projects. For example:

    • You instrument multiple apps as separate Amplitude projects with Session Replay enabled in each.
    • A known user begins on one app, and then switch to another.
    • Amplitude captures both sessions.
    • The replay for each session is available for view in the corresponding host project.
  • The User Sessions chart doesn't show session replays if your organization uses a custom session definition.

  • Session Replay cannot capture the following iOS views:

    • Out-of-process iOS views, such as SFSafariViewController
    • AVPlayerLayer backed views

이 내용이 도움이 되었나요?