From bf374b7f9ef784bf432680748ea6b8f220d3ba00 Mon Sep 17 00:00:00 2001 From: Tuan Pham <103537251+phantumcode@users.noreply.github.com> Date: Wed, 3 Jan 2024 20:41:55 +0000 Subject: [PATCH] chore: resolve swiftlint errors and warnings for Analytics plugin (#3445) * chore: resolve swiftlint errors * chore: resolve swiftlint warnings * chore: resolve swiftlint warnings * chore: resolve swiftlint errors and warnings * chore: resolve swiftlint errors and warnings * chore: resolve swiftlint errors and warnings * chore: resolve swiftlint errors and warnings --- ...npointAnalyticsPlugin+ClientBehavior.swift | 2 +- ...AWSPinpointAnalyticsPlugin+Configure.swift | 8 +++---- .../AWSPinpointAnalyticsPlugin+Reset.swift | 2 +- ...PinpointAnalyticsPluginConfiguration.swift | 8 +++---- .../Support/Utils/NetworkMonitor.swift | 4 ++-- .../AWSPinpointBehavior.swift | 6 +++--- .../Analytics/AnalyticsClient.swift | 15 +++++++------ .../Analytics/EventRecorder.swift | 21 +++++++++---------- .../LocalStorage/PinpointEvent+Bindings.swift | 2 +- .../SQLiteLocalStorageAdapter.swift | 2 +- .../Analytics/PinpointEvent.swift | 6 +++--- .../Context/AWSPinpointFactory.swift | 11 +++++----- .../PinpointContext+AWSPinpointBehavior.swift | 8 +++---- .../Context/PinpointContext.swift | 2 +- .../Endpoint/EndpointClient.swift | 2 +- .../Extensions/Data+HexString.swift | 2 +- .../SDKModels+AmplifyStringConvertible.swift | 2 +- .../ActivityTracking/ActivityTracker.swift | 4 ++-- .../ActivityTracking/StateMachine.swift | 2 +- .../Session/SessionClient.swift | 2 +- .../Constants/AWSPinpointErrorConstants.swift | 2 +- .../Utils/AmplifyStringConvertible.swift | 2 +- .../Utils/PinpointRequestsRegistry.swift | 4 ++-- .../Utils/RemoteNotificationsHelper.swift | 1 - 24 files changed, 58 insertions(+), 62 deletions(-) diff --git a/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/AWSPinpointAnalyticsPlugin+ClientBehavior.swift b/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/AWSPinpointAnalyticsPlugin+ClientBehavior.swift index 53b3f4e264..ddc52e2657 100644 --- a/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/AWSPinpointAnalyticsPlugin+ClientBehavior.swift +++ b/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/AWSPinpointAnalyticsPlugin+ClientBehavior.swift @@ -135,7 +135,7 @@ extension AWSPinpointAnalyticsPlugin { globalProperties.removeAll() return } - + for key in keys { if let value = globalProperties[key] { await pinpoint.removeGlobalProperty(value, forKey: key) diff --git a/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/AWSPinpointAnalyticsPlugin+Configure.swift b/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/AWSPinpointAnalyticsPlugin+Configure.swift index 4430f3bf9a..421c54b7b1 100644 --- a/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/AWSPinpointAnalyticsPlugin+Configure.swift +++ b/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/AWSPinpointAnalyticsPlugin+Configure.swift @@ -37,7 +37,7 @@ extension AWSPinpointAnalyticsPlugin { appId: configuration.appId, region: configuration.region ) - + let interval = TimeInterval(configuration.autoFlushEventsInterval) pinpoint.setAutomaticSubmitEventsInterval(interval) { result in switch result { @@ -47,7 +47,7 @@ extension AWSPinpointAnalyticsPlugin { Amplify.Hub.dispatchFlushEvents(AnalyticsErrorHelper.getDefaultError(error)) } } - + if configuration.trackAppSessions { let sessionBackgroundTimeout: TimeInterval if configuration.autoSessionTrackingInterval == .max { @@ -55,10 +55,10 @@ extension AWSPinpointAnalyticsPlugin { } else { sessionBackgroundTimeout = TimeInterval(configuration.autoSessionTrackingInterval) } - + pinpoint.startTrackingSessions(backgroundTimeout: sessionBackgroundTimeout) } - + let networkMonitor = NWPathMonitor() networkMonitor.startMonitoring( using: DispatchQueue( diff --git a/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/AWSPinpointAnalyticsPlugin+Reset.swift b/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/AWSPinpointAnalyticsPlugin+Reset.swift index a86fdb0ffa..4d29463c05 100644 --- a/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/AWSPinpointAnalyticsPlugin+Reset.swift +++ b/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/AWSPinpointAnalyticsPlugin+Reset.swift @@ -23,7 +23,7 @@ extension AWSPinpointAnalyticsPlugin { if isEnabled != nil { isEnabled = nil } - + if networkMonitor != nil { networkMonitor.stopMonitoring() networkMonitor = nil diff --git a/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/Configuration/AWSPinpointAnalyticsPluginConfiguration.swift b/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/Configuration/AWSPinpointAnalyticsPluginConfiguration.swift index 38ee22a95f..06db245ea7 100644 --- a/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/Configuration/AWSPinpointAnalyticsPluginConfiguration.swift +++ b/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/Configuration/AWSPinpointAnalyticsPluginConfiguration.swift @@ -35,7 +35,7 @@ public struct AWSPinpointAnalyticsPluginConfiguration { let autoFlushEventsInterval: Int let trackAppSessions: Bool let autoSessionTrackingInterval: Int - + private static let logger = Amplify.Logging.logger(forCategory: CategoryType.analytics.displayName, forNamespace: String(describing: Self.self)) init(_ configuration: JSONValue) throws { @@ -52,13 +52,13 @@ public struct AWSPinpointAnalyticsPluginConfiguration { AnalyticsPluginErrorConstant.missingPinpointAnalyicsConfiguration.recoverySuggestion ) } - + let pluginConfiguration = try AWSPinpointPluginConfiguration(pinpointAnalyticsConfig) - + let autoFlushEventsInterval = try Self.getAutoFlushEventsInterval(configObject) let trackAppSessions = try Self.getTrackAppSessions(configObject) let autoSessionTrackingInterval = try Self.getAutoSessionTrackingInterval(configObject) - + // Warn users in case they set different regions between pinpointTargeting and pinpointAnalytics if let pinpointTargetingJson = configObject[Self.pinpointTargetingConfigKey], let pinpointTargetingConfig = try? AWSPinpointPluginConfiguration(pinpointTargetingJson), diff --git a/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/Support/Utils/NetworkMonitor.swift b/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/Support/Utils/NetworkMonitor.swift index 1517b7394a..c14182f492 100644 --- a/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/Support/Utils/NetworkMonitor.swift +++ b/AmplifyPlugins/Analytics/Sources/AWSPinpointAnalyticsPlugin/Support/Utils/NetworkMonitor.swift @@ -18,11 +18,11 @@ extension NWPathMonitor: NetworkMonitor { var isOnline: Bool { currentPath.status == .satisfied } - + func startMonitoring(using queue: DispatchQueue) { start(queue: queue) } - + func stopMonitoring() { cancel() } diff --git a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/AWSPinpointBehavior.swift b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/AWSPinpointBehavior.swift index 6a98e3b4dc..9f4c7d5d7a 100644 --- a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/AWSPinpointBehavior.swift +++ b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/AWSPinpointBehavior.swift @@ -41,19 +41,19 @@ public protocol AWSPinpointBehavior { /// Records the specified `PinpointEvent` to the local storage. /// - Parameter event: The `PinpointEvent` to persist func record(_ event: PinpointEvent) async throws - + /// Sets the interval for the automatic submission of event. If set to `TimeInterval.zero`, /// the automatic submission is disabled /// - Parameter interval: How much to wait between submissions /// - Parameter onSubmit: An optional callback to be run after each submission happens func setAutomaticSubmitEventsInterval(_ interval: TimeInterval, onSubmit: AnalyticsClientBehaviour.SubmitResult?) - + // MARK: Session /// Beings automatically tracking session activity in the device. /// - Parameter backgroundTimeout: How much to wait after the device goes to the background before stopping the session func startTrackingSessions(backgroundTimeout: TimeInterval) - + /// Submits all recorded events to Pinpoint. /// Events are automatically submitted when the application goes into the background. /// - Returns: An array of successfully submitted events. diff --git a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/AnalyticsClient.swift b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/AnalyticsClient.swift index 6ed75f1ab6..51fb69a888 100644 --- a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/AnalyticsClient.swift +++ b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/AnalyticsClient.swift @@ -71,21 +71,20 @@ actor AnalyticsClient: AnalyticsClientBehaviour { self.eventRecorder = eventRecorder self.sessionProvider = sessionProvider } - + // Actors no longer use 'convenience' for inits. This is a warning in swift 5.7 and an error in swift 6+. // However, 'convenience' is required to build with swift <5.7 #if swift(>=5.7) init(applicationId: String, pinpointClient: PinpointClientProtocol, endpointClient: EndpointClientBehaviour, - sessionProvider: @escaping SessionProvider) throws - { + sessionProvider: @escaping SessionProvider) throws { let dbAdapter = try SQLiteLocalStorageAdapter(prefixPath: Constants.eventRecorderStoragePathPrefix, databaseName: applicationId) let eventRecorder = try EventRecorder(appId: applicationId, storage: AnalyticsEventSQLStorage(dbAdapter: dbAdapter), pinpointClient: pinpointClient, endpointClient: endpointClient) - + self.init(eventRecorder: eventRecorder, sessionProvider: sessionProvider) } #else @@ -98,11 +97,11 @@ actor AnalyticsClient: AnalyticsClientBehaviour { let eventRecorder = try EventRecorder(appId: applicationId, storage: AnalyticsEventSQLStorage(dbAdapter: dbAdapter), pinpointClient: pinpointClient, endpointClient: endpointClient) - + self.init(eventRecorder: eventRecorder, sessionProvider: sessionProvider) } #endif - + nonisolated var pinpointClient: PinpointClientProtocol { return eventRecorder.pinpointClient } @@ -278,7 +277,7 @@ actor AnalyticsClient: AnalyticsClientBehaviour { automaticSubmitEventsTimer = nil return } - + log.info("Enabling Automatic Submission of Events after \(interval) seconds.") automaticSubmitEventsTimer = RepeatingTimer.createRepeatingTimer( timeInterval: automaticSubmitEventsInterval, @@ -302,7 +301,7 @@ extension AnalyticsClient: DefaultLogger { public static var log: Logger { Amplify.Logging.logger(forCategory: CategoryType.analytics.displayName, forNamespace: String(describing: self)) } - + public nonisolated var log: Logger { Self.log } diff --git a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/EventRecorder.swift b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/EventRecorder.swift index 61563d86fc..0beb869b77 100644 --- a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/EventRecorder.swift +++ b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/EventRecorder.swift @@ -88,11 +88,11 @@ actor EventRecorder: AnalyticsEventRecording { _ = try? await submissionTask?.value submittedEvents = [] let eventsBatch = try getBatchRecords() - if eventsBatch.count > 0 { + if eventsBatch.isEmpty { + log.verbose("No events to submit") + } else { let endpointProfile = await endpointClient.currentEndpointProfile() try await processBatch(eventsBatch, endpointProfile: endpointProfile) - } else { - log.verbose("No events to submit") } return submittedEvents } @@ -115,7 +115,7 @@ actor EventRecorder: AnalyticsEventRecording { } try storage.removeFailedEvents() let nextEventsBatch = try getBatchRecords() - if nextEventsBatch.count > 0 { + if !nextEventsBatch.isEmpty { try await processBatch(nextEventsBatch, endpointProfile: endpointProfile) } } @@ -231,7 +231,7 @@ actor EventRecorder: AnalyticsEventRecording { throw error } } - + private func handleError(_ error: Error, for pinpointEvents: [PinpointEvent]) { if isConnectivityError(error) { // Connectivity errors should be retried indefinitely, so we won't update the database @@ -256,7 +256,7 @@ actor EventRecorder: AnalyticsEventRecording { } return type(of: modeledError).isRetryable } - + private func errorDescription(_ error: Error) -> String { if isConnectivityError(error) { return AWSPinpointErrorConstants.deviceOffline.errorDescription @@ -273,7 +273,7 @@ actor EventRecorder: AnalyticsEventRecording { return error.localizedDescription } } - + private func isConnectivityError(_ error: Error) -> Bool { switch error { case let error as CommonRunTimeError: @@ -291,7 +291,7 @@ actor EventRecorder: AnalyticsEventRecording { return false } } - + private func deleteEvent(eventId: String) { retry(onErrorMessage: "Unable to delete event with id \(eventId).") { try storage.deleteEvent(eventId: eventId) @@ -303,18 +303,17 @@ actor EventRecorder: AnalyticsEventRecording { try storage.setDirtyEvent(eventId: eventId) } } - + private func markEventsAsDirty(_ events: [PinpointEvent]) { events.forEach { setDirtyEvent(eventId: $0.id) } } - private func incrementEventRetry(eventId: String) { retry(onErrorMessage: "Unable to update retry count for event with id \(eventId).") { try storage.incrementEventRetry(eventId: eventId) } } - + private func incrementRetryCounter(for events: [PinpointEvent]) { events.forEach { incrementEventRetry(eventId: $0.id) } } diff --git a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/LocalStorage/PinpointEvent+Bindings.swift b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/LocalStorage/PinpointEvent+Bindings.swift index 1105240b69..571d60b41d 100644 --- a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/LocalStorage/PinpointEvent+Bindings.swift +++ b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/LocalStorage/PinpointEvent+Bindings.swift @@ -75,7 +75,7 @@ extension PinpointEvent { guard let eventId = element[EventPropertyIndex.id] as? String else { return nil } - + var retryCount = 0 if let retryCountInt = element[EventPropertyIndex.retryCount] as? Int64 { retryCount = Int(retryCountInt) diff --git a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/LocalStorage/SQLiteLocalStorageAdapter.swift b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/LocalStorage/SQLiteLocalStorageAdapter.swift index 433c8b51fa..ae32ef37fd 100644 --- a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/LocalStorage/SQLiteLocalStorageAdapter.swift +++ b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/LocalStorage/SQLiteLocalStorageAdapter.swift @@ -111,7 +111,7 @@ extension SQLiteLocalStorageAdapter: DefaultLogger { public static var log: Logger { Amplify.Logging.logger(forCategory: CategoryType.analytics.displayName, forNamespace: String(describing: self)) } - + public var log: Logger { Self.log } diff --git a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/PinpointEvent.swift b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/PinpointEvent.swift index 0d50342efb..a8296abaed 100644 --- a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/PinpointEvent.swift +++ b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Analytics/PinpointEvent.swift @@ -93,7 +93,7 @@ extension PinpointEvent: DefaultLogger { public static var log: Logger { Amplify.Logging.logger(forCategory: CategoryType.analytics.displayName, forNamespace: String(describing: self)) } - + public var log: Logger { Self.log } @@ -117,12 +117,12 @@ extension PinpointEvent: CustomStringConvertible { """ return string } - + private func string(from dictionary: AnalyticsProperties) -> String { if dictionary.isEmpty { return "[:]" } - + var string = "" for (key, value) in dictionary.sorted(by: { $0.key < $1.key}) { string += "\n\t\t\"\(key)\": \"\(value)\"" diff --git a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Context/AWSPinpointFactory.swift b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Context/AWSPinpointFactory.swift index bae79890c2..05f64ea9e1 100644 --- a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Context/AWSPinpointFactory.swift +++ b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Context/AWSPinpointFactory.swift @@ -15,15 +15,15 @@ public class AWSPinpointFactory { let appId: String let region: String } - + private static var instances: AtomicDictionary = [:] - + private init() {} - + static var credentialsProvider = AWSAuthService().getCredentialsProvider() static var provisioningProfileReader: ProvisioningProfileReader = .default - + public static func sharedPinpoint(appId: String, region: String) throws -> AWSPinpointBehavior { let key = PinpointContextKey(appId: appId, region: region) @@ -49,10 +49,9 @@ public class AWSPinpointFactory { credentialsProvider: credentialsProvider, isDebug: isDebug ) - + let pinpointContext = try PinpointContext(with: configuration) instances[key] = pinpointContext return pinpointContext } } - diff --git a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Context/PinpointContext+AWSPinpointBehavior.swift b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Context/PinpointContext+AWSPinpointBehavior.swift index 30a26275d9..30fe00f951 100644 --- a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Context/PinpointContext+AWSPinpointBehavior.swift +++ b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Context/PinpointContext+AWSPinpointBehavior.swift @@ -44,7 +44,7 @@ extension PinpointContext: AWSPinpointBehavior { await analyticsClient.removeGlobalMetric(forKey: forKey) } } - + func addGlobalProperty(_ value: AnalyticsPropertyValue, forKey: String) async { if let value = value as? String { await analyticsClient.addGlobalAttribute(value, forKey: forKey) @@ -57,17 +57,17 @@ extension PinpointContext: AWSPinpointBehavior { } } - func setRemoteGlobalAttributes(_ attributes: [String : String]) async { + func setRemoteGlobalAttributes(_ attributes: [String: String]) async { await analyticsClient.setRemoteGlobalAttributes(attributes) } - + func setAutomaticSubmitEventsInterval(_ interval: TimeInterval, onSubmit: AnalyticsClientBehaviour.SubmitResult?) { Task { await analyticsClient.setAutomaticSubmitEventsInterval(interval, onSubmit: onSubmit) } } - + func startTrackingSessions(backgroundTimeout: TimeInterval) { sessionClient.startTrackingSessions(backgroundTimeout: backgroundTimeout) } diff --git a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Context/PinpointContext.swift b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Context/PinpointContext.swift index 70303f278e..ceeeab6cec 100644 --- a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Context/PinpointContext.swift +++ b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Context/PinpointContext.swift @@ -47,7 +47,7 @@ extension FileManager: FileManagerBehaviour, DefaultLogger { public var log: Logger { Self.log } - + func createDirectory(atPath path: String, withIntermediateDirectories createIntermediates: Bool) throws { try createDirectory(atPath: path, withIntermediateDirectories: createIntermediates, diff --git a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Endpoint/EndpointClient.swift b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Endpoint/EndpointClient.swift index 57954e552b..ac034e3653 100644 --- a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Endpoint/EndpointClient.swift +++ b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Endpoint/EndpointClient.swift @@ -207,7 +207,7 @@ actor EndpointClient: EndpointClientBehaviour { log.error("Unable to migrate Analytics key-value store for key \(Constants.endpointProfileKey)") } } - + let keychainTokenData = try? keychain._getData(Constants.deviceTokenKey) if let tokenData = userDefaults.data(forKey: Constants.deviceTokenKey), keychainTokenData == nil { do { diff --git a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Extensions/Data+HexString.swift b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Extensions/Data+HexString.swift index 66363af0fd..0681f85c91 100644 --- a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Extensions/Data+HexString.swift +++ b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Extensions/Data+HexString.swift @@ -18,7 +18,7 @@ extension Data { .map { String(chars[$0]) + String(chars[$0 + 1]) } .compactMap { UInt8($0, radix: 16) } - guard bytes.count > 0, hexString.count / bytes.count == 2 else { + guard !bytes.isEmpty, hexString.count / bytes.count == 2 else { return nil } diff --git a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Extensions/SDKModels+AmplifyStringConvertible.swift b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Extensions/SDKModels+AmplifyStringConvertible.swift index 33274a5a25..3421574914 100644 --- a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Extensions/SDKModels+AmplifyStringConvertible.swift +++ b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Extensions/SDKModels+AmplifyStringConvertible.swift @@ -14,7 +14,7 @@ extension PutEventsOutput: AmplifyStringConvertible { enum CodingKeys: Swift.String, Swift.CodingKey { case eventsResponse = "EventsResponse" } - + public func encode(to encoder: Encoder) throws { var encodeContainer = encoder.container(keyedBy: CodingKeys.self) if let eventsResponse = self.eventsResponse { diff --git a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Session/ActivityTracking/ActivityTracker.swift b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Session/ActivityTracking/ActivityTracker.swift index 20692be11e..1b64474a61 100644 --- a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Session/ActivityTracking/ActivityTracker.swift +++ b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Session/ActivityTracking/ActivityTracker.swift @@ -55,14 +55,14 @@ extension ApplicationState: DefaultLogger { public static var log: Logger { Amplify.Logging.logger(forCategory: CategoryType.analytics.displayName, forNamespace: String(describing: self)) } - + public var log: Logger { Self.log } } protocol ActivityTrackerBehaviour: AnyObject { - var backgroundTrackingTimeout: TimeInterval { set get } + var backgroundTrackingTimeout: TimeInterval { get set } func beginActivityTracking(_ listener: @escaping (ApplicationState) -> Void) } diff --git a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Session/ActivityTracking/StateMachine.swift b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Session/ActivityTracking/StateMachine.swift index 6d3cbcf876..58bbe66676 100644 --- a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Session/ActivityTracking/StateMachine.swift +++ b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Session/ActivityTracking/StateMachine.swift @@ -111,7 +111,7 @@ extension StateMachine: DefaultLogger { public static var log: Logger { Amplify.Logging.logger(forCategory: CategoryType.analytics.displayName, forNamespace: String(describing: self)) } - + public var log: Logger { Self.log } diff --git a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Session/SessionClient.swift b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Session/SessionClient.swift index 1837fd7487..4f653d69d1 100644 --- a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Session/SessionClient.swift +++ b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Session/SessionClient.swift @@ -72,7 +72,7 @@ class SessionClient: SessionClientBehaviour { startNewSession() } } - + func startTrackingSessions(backgroundTimeout: TimeInterval) { sessionBackgroundTimeout = backgroundTimeout activityTracker.backgroundTrackingTimeout = backgroundTimeout diff --git a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Support/Constants/AWSPinpointErrorConstants.swift b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Support/Constants/AWSPinpointErrorConstants.swift index 16019e6c5c..0eaeb915fd 100644 --- a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Support/Constants/AWSPinpointErrorConstants.swift +++ b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Support/Constants/AWSPinpointErrorConstants.swift @@ -45,7 +45,7 @@ public struct AWSPinpointErrorConstants { "Region is empty", "Ensure should not be empty" ) - + public static let deviceOffline: AWSPinpointErrorString = ( "The device does not have internet access. Please ensure the device is online and try again.", "" diff --git a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Support/Utils/AmplifyStringConvertible.swift b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Support/Utils/AmplifyStringConvertible.swift index fede14232a..6f12af8567 100644 --- a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Support/Utils/AmplifyStringConvertible.swift +++ b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Support/Utils/AmplifyStringConvertible.swift @@ -16,7 +16,7 @@ extension AmplifyStringConvertible { encoder.dateEncodingStrategy = .iso8601 return encoder } - + public var description: String { if let data = try? Self.jsonEncoder.encode(self), let result = String(data: data, encoding: .utf8) { diff --git a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Support/Utils/PinpointRequestsRegistry.swift b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Support/Utils/PinpointRequestsRegistry.swift index 6c0b33dc99..55e42943ce 100644 --- a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Support/Utils/PinpointRequestsRegistry.swift +++ b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Support/Utils/PinpointRequestsRegistry.swift @@ -29,11 +29,11 @@ import AWSPluginsCore ) } - fileprivate func sources(for api: API) -> Set { + func sources(for api: API) -> Set { return pendingRequests[api, default: []] } - fileprivate func unregisterSources(for api: API) { + func unregisterSources(for api: API) { pendingRequests[api] = nil } diff --git a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Support/Utils/RemoteNotificationsHelper.swift b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Support/Utils/RemoteNotificationsHelper.swift index e09c675571..514ec7e7fb 100644 --- a/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Support/Utils/RemoteNotificationsHelper.swift +++ b/AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Support/Utils/RemoteNotificationsHelper.swift @@ -52,4 +52,3 @@ public struct AmplifyRemoteNotificationsHelper: RemoteNotificationsBehaviour { await AUNotificationPermissions.registerForRemoteNotifications() } } -