Skip to content

Commit

Permalink
feat: Feature Autocapture (#209)
Browse files Browse the repository at this point in the history
* feat: add user interactions capture (#190)

* Fix indentation issue

* feat: add user interactions capture

* fix: fix typo

* fix: remove support for UITextField action message capture

* refactor: add dispatch once for method swizzling

* fix: remove support for UISlider to reduce noise

* feat: add support for UITextField and UISlider event capture

* style: remove return keyword for one line functions

* fix: fix typo

* feat: add support for text field gained/lost focus

* fix: fix lint

* fix: remove tag as textfield title

* refactor: refactor title and shouldTrack

* refactor: add a protocol to track control elements

* feat: add support for uitextview autocapture (#195)

* Fix indentation issue

* feat: add user interactions capture

* fix: fix typo

* fix: remove support for UITextField action message capture

* refactor: add dispatch once for method swizzling

* fix: remove support for UISlider to reduce noise

* feat: add support for UITextField and UISlider event capture

* style: remove return keyword for one line functions

* fix: fix typo

* feat: add support for text field gained/lost focus

* fix: fix lint

* fix: remove tag as textfield title

* refactor: refactor title and shouldTrack

* refactor: add a protocol to track control elements

* refactor: guard on action name

* feat: add support for uitextview capture

* fix: disable action method tracking support for UITextView

* fix: fix lint issue

* style: remove amp_ prefix from objc methods

* feat: add support for gesture recognizer autocapture (#196)

* Fix indentation issue

* feat: add user interactions capture

* fix: fix typo

* fix: remove support for UITextField action message capture

* refactor: add dispatch once for method swizzling

* fix: remove support for UISlider to reduce noise

* feat: add support for UITextField and UISlider event capture

* style: remove return keyword for one line functions

* fix: fix typo

* feat: add support for text field gained/lost focus

* fix: fix lint

* fix: remove tag as textfield title

* refactor: refactor title and shouldTrack

* refactor: add a protocol to track control elements

* refactor: guard on action name

* feat: add support for uitextview capture

* fix: disable action method tracking support for UITextView

* fix: fix lint issue

* style: remove amp_ prefix from objc methods

* feat: add support for gesture recognizers autocapture

* fix: fix lint issue

* fix: exclude unsupported gestures in tvos

* fix: track touchupinside and valuechanged only (#199)

* fix: just track touchupinside and valuechanged for some elements

* fix: fix tvos issue

* feat: capture control events for autocapture (#202)

* fix: just track touchupinside and valuechanged for some elements

* fix: fix tvos issue

* feat: capture control events

* fix: remove row selected event

* fix: track touchUpInside for any element (#203)

* fix: just track touchupinside and valuechanged for some elements

* fix: fix tvos issue

* feat: capture control events

* fix: remove row selected event

* fix: track any touchUpInside

* fix: capture image name as a fallback for buttons title

* fix: deprecate defaultTracking and add autocapture (#204)

* fix: deprecate defaultTracking and add autocapture

* fix: fix schema for the new test

* fix: fix typo

* fix: fix typo

* fix: support optionset for autocapture options

* fix: fix autocaptureoptions test

* fix: fix failing test

* fix: simplified the logic to deprecate defaultTracking

* style: make autocapture options for objc as properties

* fix: disable swiftui support for autocapture (#206)

* fix: disable swiftui support for autocapture

* fix: disable support for swiftui gesture recognizers autocapture

* fix: fix typo

* fix: filter scrolls for scrollable views

* fix: imporve support for swiftui

* fix: track screen name autocapture (#207)

* fix: change element viewController to screenName

* fix: remove title since it's already captured by screenName

* fix: track changes to defaultTracking after initialization (#208)

* fix: track changes to defaultTracking after initialization

* fix: replace defaultTracking with autocapture if changed

* fix: fix typo

* fix: fix nit

* style: rename parameter name
  • Loading branch information
PouriaAmini authored Aug 8, 2024
1 parent df08b88 commit 4ab5673
Show file tree
Hide file tree
Showing 22 changed files with 733 additions and 78 deletions.
28 changes: 24 additions & 4 deletions Amplitude-Swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
4E05BB942BE41AEB009DE475 /* Amplitude+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E05BB932BE41AEB009DE475 /* Amplitude+Extensions.swift */; };
4E2B646B2BA127460010E6F8 /* UIKitScreenViewsPluginTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E2B646A2BA127460010E6F8 /* UIKitScreenViewsPluginTests.swift */; };
4E3871622BB34DBC002890AB /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = B6DF481F2B5B45BE00B3E6AA /* PrivacyInfo.xcprivacy */; };
6C04FC3F2C58973C00EA8667 /* ElementInteractionEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C04FC3E2C58973C00EA8667 /* ElementInteractionEvent.swift */; };
6C04FC412C58974A00EA8667 /* UIKitElementInteractions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C04FC402C58974A00EA8667 /* UIKitElementInteractions.swift */; };
6C04FC432C58976800EA8667 /* ObjCAutocaptureOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C04FC422C58976800EA8667 /* ObjCAutocaptureOptions.swift */; };
6C04FC452C58978900EA8667 /* AutocaptureOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C04FC442C58978900EA8667 /* AutocaptureOptions.swift */; };
6C04FC482C589C8100EA8667 /* AutocaptureOptionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C04FC462C5897AC00EA8667 /* AutocaptureOptionsTests.swift */; };
6C23EF162C38AD31000DC8C8 /* UIKitUserInteractionPluginTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C23EF142C38AC32000DC8C8 /* UIKitUserInteractionPluginTest.swift */; };
8EDEC02B99EE2092B567A61D /* ObjCIngestionMetadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EDEC500EBDA8B813056E2DB /* ObjCIngestionMetadata.swift */; };
8EDEC1073A308B12B5CCD975 /* AnalyticsConnectorPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EDECD39BAA97DD4320C0AA5 /* AnalyticsConnectorPlugin.swift */; };
8EDEC10C56FA7F7DEEB48B6F /* ObjCBaseEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EDECCFD935A0C5A6FE85E87 /* ObjCBaseEvent.swift */; };
Expand Down Expand Up @@ -63,7 +69,6 @@
B6F338A32B685793006179E2 /* NetworkConnectivityCheckerPluginTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6F338A22B685793006179E2 /* NetworkConnectivityCheckerPluginTests.swift */; };
BA0359CA2A51585D007C383B /* legacy_v3.sqlite in Resources */ = {isa = PBXBuildFile; fileRef = BA0359C92A51585D007C383B /* legacy_v3.sqlite */; };
BA0639F62A4DD491000F1CEE /* LegacyDatabaseStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA0639F52A4DD491000F1CEE /* LegacyDatabaseStorage.swift */; };
BA1EC0F42A9F2FC700C2D547 /* DefaultTrackingOptionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA1EC0F32A9F2FC700C2D547 /* DefaultTrackingOptionsTests.swift */; };
BA1EC0F62A9F63FD00C2D547 /* AmplitudeIOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA1EC0F52A9F63FD00C2D547 /* AmplitudeIOSTests.swift */; };
BA34B23C2AA0723A00F88097 /* AnalyticsConnector in Frameworks */ = {isa = PBXBuildFile; productRef = BA34B23B2AA0723A00F88097 /* AnalyticsConnector */; };
BA994B9A2A4F48DE00D0913F /* LegacyDatabaseStorageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA994B992A4F48DE00D0913F /* LegacyDatabaseStorageTests.swift */; };
Expand Down Expand Up @@ -152,6 +157,12 @@
3E281B902B9BCC14009D913B /* DispatchQueueHolder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DispatchQueueHolder.swift; sourceTree = "<group>"; };
4E05BB932BE41AEB009DE475 /* Amplitude+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Amplitude+Extensions.swift"; sourceTree = "<group>"; };
4E2B646A2BA127460010E6F8 /* UIKitScreenViewsPluginTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIKitScreenViewsPluginTests.swift; sourceTree = "<group>"; };
6C04FC3E2C58973C00EA8667 /* ElementInteractionEvent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ElementInteractionEvent.swift; sourceTree = "<group>"; };
6C04FC402C58974A00EA8667 /* UIKitElementInteractions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIKitElementInteractions.swift; sourceTree = "<group>"; };
6C04FC422C58976800EA8667 /* ObjCAutocaptureOptions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ObjCAutocaptureOptions.swift; sourceTree = "<group>"; };
6C04FC442C58978900EA8667 /* AutocaptureOptions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutocaptureOptions.swift; sourceTree = "<group>"; };
6C04FC462C5897AC00EA8667 /* AutocaptureOptionsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutocaptureOptionsTests.swift; sourceTree = "<group>"; };
6C23EF142C38AC32000DC8C8 /* UIKitUserInteractionPluginTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIKitUserInteractionPluginTest.swift; sourceTree = "<group>"; };
8EDEC0630C3B587334275D9B /* AmplitudeSessionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmplitudeSessionTests.swift; sourceTree = "<group>"; };
8EDEC1160D95DC3F0E48DDF7 /* ObjCPlugin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ObjCPlugin.swift; sourceTree = "<group>"; };
8EDEC1576C95A2EB2FEF00A8 /* ObjCAmplitude.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ObjCAmplitude.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -189,7 +200,6 @@
B6F338A22B685793006179E2 /* NetworkConnectivityCheckerPluginTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkConnectivityCheckerPluginTests.swift; sourceTree = "<group>"; };
BA0359C92A51585D007C383B /* legacy_v3.sqlite */ = {isa = PBXFileReference; lastKnownFileType = file; path = legacy_v3.sqlite; sourceTree = "<group>"; };
BA0639F52A4DD491000F1CEE /* LegacyDatabaseStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegacyDatabaseStorage.swift; sourceTree = "<group>"; };
BA1EC0F32A9F2FC700C2D547 /* DefaultTrackingOptionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultTrackingOptionsTests.swift; sourceTree = "<group>"; };
BA1EC0F52A9F63FD00C2D547 /* AmplitudeIOSTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AmplitudeIOSTests.swift; sourceTree = "<group>"; };
BA994B992A4F48DE00D0913F /* LegacyDatabaseStorageTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegacyDatabaseStorageTests.swift; sourceTree = "<group>"; };
BA994B9B2A4F4B7500D0913F /* legacy_v4.sqlite */ = {isa = PBXFileReference; lastKnownFileType = file; path = legacy_v4.sqlite; sourceTree = "<group>"; };
Expand Down Expand Up @@ -293,6 +303,7 @@
8EDECAFD8271434E8DC7BA78 /* ObjC */ = {
isa = PBXGroup;
children = (
6C04FC422C58976800EA8667 /* ObjCAutocaptureOptions.swift */,
B6CCC6CC2B6B14510004B203 /* ObjCNetworkConnectivityCheckerPlugin.swift */,
8EDECEC5AAE15FD05E76359A /* ObjCConfiguration.swift */,
8EDECB1FA2AFF022A19104EE /* ObjCPlan.swift */,
Expand Down Expand Up @@ -329,6 +340,7 @@
B6F3389F2B6854A8006179E2 /* Plugins */ = {
isa = PBXGroup;
children = (
6C23EF142C38AC32000DC8C8 /* UIKitUserInteractionPluginTest.swift */,
B6F338A22B685793006179E2 /* NetworkConnectivityCheckerPluginTests.swift */,
4E2B646A2BA127460010E6F8 /* UIKitScreenViewsPluginTests.swift */,
);
Expand All @@ -338,6 +350,7 @@
OBJ_13 /* Events */ = {
isa = PBXGroup;
children = (
6C04FC3E2C58973C00EA8667 /* ElementInteractionEvent.swift */,
OBJ_14 /* BaseEvent.swift */,
OBJ_15 /* EventOptions.swift */,
OBJ_16 /* GroupIdentifyEvent.swift */,
Expand Down Expand Up @@ -390,6 +403,7 @@
OBJ_32 /* iOS */ = {
isa = PBXGroup;
children = (
6C04FC402C58974A00EA8667 /* UIKitElementInteractions.swift */,
OBJ_33 /* IOSLifecycleMonitor.swift */,
8EDEC650EF79B104DC3C9F4C /* UIKitScreenViews.swift */,
);
Expand Down Expand Up @@ -451,6 +465,7 @@
OBJ_53 /* Tests */ = {
isa = PBXGroup;
children = (
6C04FC462C5897AC00EA8667 /* AutocaptureOptionsTests.swift */,
B6F3389F2B6854A8006179E2 /* Plugins */,
OBJ_54 /* AmplitudeTests.swift */,
OBJ_55 /* ConfigurationTests.swift */,
Expand All @@ -463,7 +478,6 @@
OBJ_70 /* Utilities */,
8EDEC0630C3B587334275D9B /* AmplitudeSessionTests.swift */,
8EDECBC5925DC68913C7CB89 /* Migration */,
BA1EC0F32A9F2FC700C2D547 /* DefaultTrackingOptionsTests.swift */,
BA1EC0F52A9F63FD00C2D547 /* AmplitudeIOSTests.swift */,
4E05BB932BE41AEB009DE475 /* Amplitude+Extensions.swift */,
);
Expand Down Expand Up @@ -503,6 +517,7 @@
OBJ_7 /* Sources */ = {
isa = PBXGroup;
children = (
6C04FC442C58978900EA8667 /* AutocaptureOptions.swift */,
B6DF481F2B5B45BE00B3E6AA /* PrivacyInfo.xcprivacy */,
OBJ_8 /* Amplitude.swift */,
OBJ_9 /* Configuration.swift */,
Expand Down Expand Up @@ -694,7 +709,6 @@
buildActionMask = 0;
files = (
OBJ_142 /* AmplitudeTests.swift in Sources */,
BA1EC0F42A9F2FC700C2D547 /* DefaultTrackingOptionsTests.swift in Sources */,
OBJ_143 /* ConfigurationTests.swift in Sources */,
OBJ_144 /* ConsoleLoggerTests.swift in Sources */,
OBJ_145 /* BaseEventTests.swift in Sources */,
Expand All @@ -706,11 +720,13 @@
OBJ_150 /* RevenueTests.swift in Sources */,
OBJ_151 /* PersistentStorageTests.swift in Sources */,
OBJ_152 /* TestUtilities.swift in Sources */,
6C23EF162C38AD31000DC8C8 /* UIKitUserInteractionPluginTest.swift in Sources */,
OBJ_153 /* TimelineTests.swift in Sources */,
OBJ_154 /* TypesTests.swift in Sources */,
OBJ_155 /* EventPipelineTests.swift in Sources */,
3E281B8E2B96833D009D913B /* DiagnosticsTests.swift in Sources */,
B6F338A32B685793006179E2 /* NetworkConnectivityCheckerPluginTests.swift in Sources */,
6C04FC482C589C8100EA8667 /* AutocaptureOptionsTests.swift in Sources */,
OBJ_156 /* HttpClientTests.swift in Sources */,
D01043612B6C5A8500F8173C /* SandboxHelperTests.swift in Sources */,
OBJ_157 /* PersistentStorageResponseHandlerTests.swift in Sources */,
Expand Down Expand Up @@ -766,6 +782,7 @@
OBJ_116 /* Atomic.swift in Sources */,
OBJ_117 /* CodableExtension.swift in Sources */,
OBJ_118 /* EventPipeline.swift in Sources */,
6C04FC412C58974A00EA8667 /* UIKitElementInteractions.swift in Sources */,
OBJ_119 /* HttpClient.swift in Sources */,
OBJ_120 /* OutputFileStream.swift in Sources */,
OBJ_121 /* PersistentStorageResponseHandler.swift in Sources */,
Expand All @@ -781,6 +798,8 @@
8EDEC3283B812D5D34DADF7B /* AnalyticsConnectorIdentityPlugin.swift in Sources */,
8EDEC4D0C0CE07BF211804CC /* DefaultTrackingOptions.swift in Sources */,
8EDEC30C0075E9D92B1B5210 /* UIKitScreenViews.swift in Sources */,
6C04FC3F2C58973C00EA8667 /* ElementInteractionEvent.swift in Sources */,
6C04FC432C58976800EA8667 /* ObjCAutocaptureOptions.swift in Sources */,
8EDEC43FB30802F70112E577 /* ScreenViewedEvent.swift in Sources */,
8EDEC51F746CC25D27E32F6A /* DeepLinkOpenedEvent.swift in Sources */,
8EDECF81C2B1B38D472FD7EF /* ObjCConfiguration.swift in Sources */,
Expand All @@ -797,6 +816,7 @@
8EDEC74C71FEC9056DC7358F /* ObjCLoggerProvider.swift in Sources */,
8EDECA4DAFA67CD4785D0161 /* ObjCDefaultTrackingOptions.swift in Sources */,
8EDEC43520B2DCF584F1035D /* ObjCScreenViewedEvent.swift in Sources */,
6C04FC452C58978900EA8667 /* AutocaptureOptions.swift in Sources */,
8EDECC1FC97DDF0BEFAA96E7 /* ObjCDeepLinkOpenedEvent.swift in Sources */,
B6EDB4D02B643C8400454B90 /* NetworkConnectivityCheckerPlugin.swift in Sources */,
8EDEC5F7208B1C327C8703D7 /* ObjCStorage.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
AMPConfiguration* configuration = [AMPConfiguration initWithApiKey:apiKey];
configuration.logLevel = AMPLogLevelLOG;
configuration.serverZone = AMPServerZoneUS;
configuration.defaultTracking = AMPDefaultTrackingOptions.ALL;
NSArray<AMPAutocaptureOptions *> *autocaptureOptions = @[
AMPAutocaptureOptions.sessions,
AMPAutocaptureOptions.appLifecycles,
AMPAutocaptureOptions.screenViews
];
configuration.autocapture = [[AMPAutocaptureOptions alloc] initWithOptionsToUnion:autocaptureOptions];
configuration.loggerProvider = ^(NSInteger logLevel, NSString* _Nonnull message) {
NSLog(@"%@", message);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ - (void)testEventProperties {
- (Amplitude *)getAmplitude:(NSString *)instancePrefix {
NSString* instanceName = [NSString stringWithFormat:@"%@-%f", instancePrefix, [[NSDate date] timeIntervalSince1970]];
AMPConfiguration* configuration = [AMPConfiguration initWithApiKey:@"API-KEY" instanceName:instanceName];
configuration.defaultTracking = AMPDefaultTrackingOptions.NONE;
configuration.autocapture = [[AMPAutocaptureOptions alloc] init];
Amplitude *amplitude = [[TestAmplitude alloc] initWithConfiguration:configuration];
return amplitude;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class TestAmplitude: ObjCAmplitude {
enableCoppaControl: config.enableCoppaControl,
flushEventsOnClose: config.flushEventsOnClose,
minTimeBetweenSessionsMillis: config.minTimeBetweenSessionsMillis,
defaultTracking: config.defaultTracking,
autocapture: config.autocapture,
identifyBatchIntervalMillis: config.identifyBatchIntervalMillis,
migrateLegacyData: config.migrateLegacyData,
offline: NetworkConnectivityCheckerPlugin.Disabled)
Expand Down
14 changes: 14 additions & 0 deletions Sources/Amplitude/AutocaptureOptions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Foundation

public struct AutocaptureOptions: OptionSet {
public let rawValue: Int

public init(rawValue: Int) {
self.rawValue = rawValue
}

public static let sessions = AutocaptureOptions(rawValue: 1 << 0)
public static let appLifecycles = AutocaptureOptions(rawValue: 1 << 1)
public static let screenViews = AutocaptureOptions(rawValue: 1 << 2)
public static let elementInteractions = AutocaptureOptions(rawValue: 1 << 3)
}
81 changes: 78 additions & 3 deletions Sources/Amplitude/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,78 @@ public class Configuration {
public var minTimeBetweenSessionsMillis: Int
public var identifyBatchIntervalMillis: Int
public internal(set) var migrateLegacyData: Bool
public var defaultTracking: DefaultTrackingOptions
@available(*, deprecated, renamed: "autocapture", message: "Please use `autocapture` instead.")
public lazy var defaultTracking: DefaultTrackingOptions = {
DefaultTrackingOptions(delegate: self)
}() {
didSet {
defaultTracking.delegate = self
autocapture = defaultTracking.autocaptureOptions
}
}
public internal(set) var autocapture: AutocaptureOptions
public var offline: Bool?
internal let diagonostics: Diagnostics

@available(*, deprecated, message: "Please use the `autocapture` parameter instead.")
public convenience init(
apiKey: String,
flushQueueSize: Int = Constants.Configuration.FLUSH_QUEUE_SIZE,
flushIntervalMillis: Int = Constants.Configuration.FLUSH_INTERVAL_MILLIS,
instanceName: String = "",
optOut: Bool = false,
storageProvider: (any Storage)? = nil,
identifyStorageProvider: (any Storage)? = nil,
logLevel: LogLevelEnum = LogLevelEnum.WARN,
loggerProvider: any Logger = ConsoleLogger(),
minIdLength: Int? = nil,
partnerId: String? = nil,
callback: EventCallback? = nil,
flushMaxRetries: Int = Constants.Configuration.FLUSH_MAX_RETRIES,
useBatch: Bool = false,
serverZone: ServerZone = ServerZone.US,
serverUrl: String? = nil,
plan: Plan? = nil,
ingestionMetadata: IngestionMetadata? = nil,
trackingOptions: TrackingOptions = TrackingOptions(),
enableCoppaControl: Bool = false,
flushEventsOnClose: Bool = true,
minTimeBetweenSessionsMillis: Int = Constants.Configuration.MIN_TIME_BETWEEN_SESSIONS_MILLIS,
// `trackingSessionEvents` has been replaced by `defaultTracking.sessions`
defaultTracking: DefaultTrackingOptions,
identifyBatchIntervalMillis: Int = Constants.Configuration.IDENTIFY_BATCH_INTERVAL_MILLIS,
migrateLegacyData: Bool = true,
offline: Bool? = false
) {
self.init(apiKey: apiKey,
flushQueueSize: flushQueueSize,
flushIntervalMillis: flushIntervalMillis,
instanceName: instanceName,
optOut: optOut,
storageProvider: storageProvider,
identifyStorageProvider: identifyStorageProvider,
logLevel: logLevel,
loggerProvider: loggerProvider,
minIdLength: minIdLength,
partnerId: partnerId,
callback: callback,
flushMaxRetries: flushMaxRetries,
useBatch: useBatch,
serverZone: serverZone,
serverUrl: serverUrl,
plan: plan,
ingestionMetadata: ingestionMetadata,
trackingOptions: trackingOptions,
enableCoppaControl: enableCoppaControl,
flushEventsOnClose: flushEventsOnClose,
minTimeBetweenSessionsMillis: minTimeBetweenSessionsMillis,
autocapture: defaultTracking.autocaptureOptions,
identifyBatchIntervalMillis: identifyBatchIntervalMillis,
migrateLegacyData: migrateLegacyData,
offline: offline)
self.defaultTracking = defaultTracking
}

public init(
apiKey: String,
flushQueueSize: Int = Constants.Configuration.FLUSH_QUEUE_SIZE,
Expand All @@ -60,7 +128,7 @@ public class Configuration {
flushEventsOnClose: Bool = true,
minTimeBetweenSessionsMillis: Int = Constants.Configuration.MIN_TIME_BETWEEN_SESSIONS_MILLIS,
// `trackingSessionEvents` has been replaced by `defaultTracking.sessions`
defaultTracking: DefaultTrackingOptions = DefaultTrackingOptions(),
autocapture: AutocaptureOptions = .sessions,
identifyBatchIntervalMillis: Int = Constants.Configuration.IDENTIFY_BATCH_INTERVAL_MILLIS,
migrateLegacyData: Bool = true,
offline: Bool? = false
Expand Down Expand Up @@ -92,7 +160,7 @@ public class Configuration {
self.enableCoppaControl = enableCoppaControl
self.flushEventsOnClose = flushEventsOnClose
self.minTimeBetweenSessionsMillis = minTimeBetweenSessionsMillis
self.defaultTracking = defaultTracking
self.autocapture = autocapture
self.identifyBatchIntervalMillis = identifyBatchIntervalMillis
self.migrateLegacyData = migrateLegacyData
// Logging is OFF by default
Expand All @@ -114,3 +182,10 @@ public class Configuration {
return Configuration.getNormalizeInstanceName(self.instanceName)
}
}

extension Configuration: DefaultTrackingOptionsDelegate {
@available(*, deprecated)
func didChangeOptions(options: DefaultTrackingOptions) {
autocapture = options.autocaptureOptions
}
}
Loading

0 comments on commit 4ab5673

Please sign in to comment.