Skip to content

Commit

Permalink
feat: expose more configuration in plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
crleona committed Oct 2, 2024
1 parent a4abd2d commit 25ed2dc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ public class AmplitudeSegmentSessionReplayPlugin: Plugin {

public init(amplitudeApiKey apiKey: String,
sampleRate: Float = 0.0,
serverZone: ServerZone = .US) {
serverZone: ServerZone = .US,
maskLevel: MaskLevel = .medium,
enableRemoteConfig: Bool = true) {
sessionReplay = SessionReplay(apiKey: apiKey,
sampleRate: sampleRate,
serverZone: serverZone)
serverZone: serverZone,
maskLevel: maskLevel,
enableRemoteConfig: enableRemoteConfig)
}

public func configure(analytics: Analytics) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ import AmplitudeSessionReplay
private static let sessionReplayProperty = "[Amplitude] Session Replay ID"

private let sampleRate: Float
private let maskLevel: MaskLevel
private let enableRemoteConfig: Bool

private var sessionReplay: SessionReplay?

@objc public init(sampleRate: Float = 0.0) {
@objc public init(sampleRate: Float = 0.0,
maskLevel: MaskLevel = .medium,
enableRemoteConfig: Bool = true) {
self.sampleRate = sampleRate
self.maskLevel = maskLevel
self.enableRemoteConfig = enableRemoteConfig
}

public func setup(amplitude: Amplitude) {
Expand All @@ -37,7 +43,9 @@ import AmplitudeSessionReplay
optOut: amplitude.configuration.optOut,
sampleRate: sampleRate,
logger: LoggerWrapper(amplitude.configuration.loggerProvider),
serverZone: serverZone)
serverZone: serverZone,
maskLevel: maskLevel,
enableRemoteConfig: enableRemoteConfig)
sessionReplay?.start()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ import AmplitudeSessionReplay
@objc public class AmplitudeiOSSessionReplayMiddleware: NSObject, AMPMiddleware {

private let sampleRate: Float
private let maskLevel: AmplitudeSessionReplay.MaskLevel
private let enableRemoteConfig: Bool

private var sessionReplay: SessionReplay?

@objc public init(sampleRate: Float = 0.0) {
@objc public init(sampleRate: Float = 0.0,
maskLevel: AmplitudeSessionReplay.MaskLevel = .medium,
enableRemoteConfig: Bool = true) {
self.sampleRate = sampleRate
self.maskLevel = maskLevel
self.enableRemoteConfig = enableRemoteConfig
}

public func amplitudeDidFinishInitializing(_ amplitude: Amplitude) {
Expand All @@ -34,7 +40,9 @@ import AmplitudeSessionReplay
sessionId: amplitude.getSessionId(),
optOut: amplitude.optOut,
sampleRate: sampleRate,
serverZone: serverZone)
serverZone: serverZone,
maskLevel: maskLevel,
enableRemoteConfig: enableRemoteConfig)
sessionReplay?.start()
}

Expand Down

0 comments on commit 25ed2dc

Please sign in to comment.