diff --git a/Examples/destination_plugins/AdjustDestination.swift b/Examples/destination_plugins/AdjustDestination.swift index fc59b4f0..10eff5fa 100644 --- a/Examples/destination_plugins/AdjustDestination.swift +++ b/Examples/destination_plugins/AdjustDestination.swift @@ -36,16 +36,6 @@ import Foundation import Segment import Adjust -internal struct AdjustSettings: Codable { - let appToken: String - let setEnvironmentProduction: Bool? - let setEventBufferingEnabled: Bool? - let trackAttributionData: Bool? - let setDelay: Bool? - let customEvents: JSON? - let delayTime: Double? -} - @objc class AdjustDestination: NSObject, DestinationPlugin, RemoteNotifications { let timeline = Timeline() @@ -53,7 +43,7 @@ class AdjustDestination: NSObject, DestinationPlugin, RemoteNotifications { let key = "Adjust" var analytics: Analytics? = nil - internal var settings: AdjustSettings? = nil + private var settings: AdjustSettings? = nil public func update(settings: Settings, type: UpdateType) { // we've already set up this singleton SDK, can't do it again, so skip. @@ -185,3 +175,13 @@ extension AdjustDestination { return result } } + +private struct AdjustSettings: Codable { + let appToken: String + let setEnvironmentProduction: Bool? + let setEventBufferingEnabled: Bool? + let trackAttributionData: Bool? + let setDelay: Bool? + let customEvents: JSON? + let delayTime: Double? +} diff --git a/Examples/destination_plugins/AppsFlyerDestination.swift b/Examples/destination_plugins/AppsFlyerDestination.swift index 3151096e..c0ef30a8 100644 --- a/Examples/destination_plugins/AppsFlyerDestination.swift +++ b/Examples/destination_plugins/AppsFlyerDestination.swift @@ -34,15 +34,9 @@ // *** To Implement Deep Linking functionality reference: https://support.appsflyer.com/hc/en-us/articles/208874366 **** import Foundation +import UIKit import Segment import AppsFlyerLib -import UIKit - -private struct AppsFlyerSettings: Codable { - let appsFlyerDevKey: String - let appleAppID: String - let trackAttributionData: Bool? -} @objc class AppsFlyerDestination: UIResponder, DestinationPlugin { @@ -346,3 +340,9 @@ extension AppsFlyerDestination: DeepLinkDelegate, UIApplicationDelegate { // return nil // } //} + +private struct AppsFlyerSettings: Codable { + let appsFlyerDevKey: String + let appleAppID: String + let trackAttributionData: Bool? +} diff --git a/Examples/destination_plugins/FirebaseDestination.swift b/Examples/destination_plugins/FirebaseDestination.swift index 0cb836da..83037816 100644 --- a/Examples/destination_plugins/FirebaseDestination.swift +++ b/Examples/destination_plugins/FirebaseDestination.swift @@ -43,10 +43,6 @@ import FirebaseAnalytics An implmentation of the Firebase Analytics device mode destination as a plugin. */ -struct FirebaseSettings: Codable { - let deepLinkURLScheme: String? -} - class FirebaseDestination: DestinationPlugin { let timeline = Timeline() let type = PluginType.destination @@ -124,21 +120,7 @@ extension FirebaseDestination { // Maps Segment spec to Firebase constant func formatFirebaseEventNames(_ eventName: String) -> String { - let mappedValues = ["Product Clicked": FirebaseAnalytics.AnalyticsEventSelectContent, - "Product Viewed": FirebaseAnalytics.AnalyticsEventViewItem, - "Product Added": FirebaseAnalytics.AnalyticsEventAddToCart, - "Product Removed": FirebaseAnalytics.AnalyticsEventRemoveFromCart, - "Checkout Started": FirebaseAnalytics.AnalyticsEventBeginCheckout, - "Promotion Viewed": FirebaseAnalytics.AnalyticsEventPresentOffer, - "Payment Info Entered": FirebaseAnalytics.AnalyticsEventAddPaymentInfo, - "Order Completed": FirebaseAnalytics.AnalyticsEventPurchase, - "Order Refunded": FirebaseAnalytics.AnalyticsEventRefund, - "Product List Viewed": FirebaseAnalytics.AnalyticsEventViewItemList, - "Product Added to Wishlist": FirebaseAnalytics.AnalyticsEventAddToWishlist, - "Product Shared": FirebaseAnalytics.AnalyticsEventShare, - "Cart Shared": FirebaseAnalytics.AnalyticsEventShare, - "Products Searched": FirebaseAnalytics.AnalyticsEventSearch] - if let mappedEvent = mappedValues[eventName] { + if let mappedEvent = FirebaseDestination.mappedValues[eventName] { return mappedEvent } else { return (try? formatFirebaseName(eventName)) ?? eventName @@ -162,24 +144,10 @@ extension FirebaseDestination { func returnMappedFirebaseParameters(_ properties: [String: Any]) -> [String: Any] { - let mappedKeys = ["products": FirebaseAnalytics.AnalyticsParameterItems, - "category": FirebaseAnalytics.AnalyticsParameterItemCategory, - "product_id": FirebaseAnalytics.AnalyticsParameterItemID, - "name": FirebaseAnalytics.AnalyticsParameterItemName, - "brand": FirebaseAnalytics.AnalyticsParameterItemBrand, - "price": FirebaseAnalytics.AnalyticsParameterPrice, - "quantity": FirebaseAnalytics.AnalyticsParameterQuantity, - "query": FirebaseAnalytics.AnalyticsParameterSearchTerm, - "shipping": FirebaseAnalytics.AnalyticsParameterShipping, - "tax": FirebaseAnalytics.AnalyticsParameterTax, - "total": FirebaseAnalytics.AnalyticsParameterValue, - "revenue": FirebaseAnalytics.AnalyticsParameterValue, - "order_id": FirebaseAnalytics.AnalyticsParameterTransactionID, - "currency": FirebaseAnalytics.AnalyticsParameterCurrency] var mappedValues = properties - for (key, firebaseKey) in mappedKeys { + for (key, firebaseKey) in FirebaseDestination.mappedKeys { if var data = properties[key] { mappedValues.removeValue(forKey: key) @@ -220,3 +188,41 @@ extension FirebaseDestination { } } + +private struct FirebaseSettings: Codable { + let deepLinkURLScheme: String? +} + +private extension FirebaseDestination { + + static let mappedValues = ["Product Clicked": FirebaseAnalytics.AnalyticsEventSelectContent, + "Product Viewed": FirebaseAnalytics.AnalyticsEventViewItem, + "Product Added": FirebaseAnalytics.AnalyticsEventAddToCart, + "Product Removed": FirebaseAnalytics.AnalyticsEventRemoveFromCart, + "Checkout Started": FirebaseAnalytics.AnalyticsEventBeginCheckout, + "Promotion Viewed": FirebaseAnalytics.AnalyticsEventPresentOffer, + "Payment Info Entered": FirebaseAnalytics.AnalyticsEventAddPaymentInfo, + "Order Completed": FirebaseAnalytics.AnalyticsEventPurchase, + "Order Refunded": FirebaseAnalytics.AnalyticsEventRefund, + "Product List Viewed": FirebaseAnalytics.AnalyticsEventViewItemList, + "Product Added to Wishlist": FirebaseAnalytics.AnalyticsEventAddToWishlist, + "Product Shared": FirebaseAnalytics.AnalyticsEventShare, + "Cart Shared": FirebaseAnalytics.AnalyticsEventShare, + "Products Searched": FirebaseAnalytics.AnalyticsEventSearch] + + static let mappedKeys = ["products": FirebaseAnalytics.AnalyticsParameterItems, + "category": FirebaseAnalytics.AnalyticsParameterItemCategory, + "product_id": FirebaseAnalytics.AnalyticsParameterItemID, + "name": FirebaseAnalytics.AnalyticsParameterItemName, + "brand": FirebaseAnalytics.AnalyticsParameterItemBrand, + "price": FirebaseAnalytics.AnalyticsParameterPrice, + "quantity": FirebaseAnalytics.AnalyticsParameterQuantity, + "query": FirebaseAnalytics.AnalyticsParameterSearchTerm, + "shipping": FirebaseAnalytics.AnalyticsParameterShipping, + "tax": FirebaseAnalytics.AnalyticsParameterTax, + "total": FirebaseAnalytics.AnalyticsParameterValue, + "revenue": FirebaseAnalytics.AnalyticsParameterValue, + "order_id": FirebaseAnalytics.AnalyticsParameterTransactionID, + "currency": FirebaseAnalytics.AnalyticsParameterCurrency] + +} diff --git a/Examples/destination_plugins/FlurryDestination.swift b/Examples/destination_plugins/FlurryDestination.swift index 26f3a840..aad9419d 100644 --- a/Examples/destination_plugins/FlurryDestination.swift +++ b/Examples/destination_plugins/FlurryDestination.swift @@ -42,13 +42,6 @@ import FlurryAnalytics An implementation of the Flurry Analytics device mode destination as a plugin. */ -private struct FlurrySettings: Codable { - let apiKey: String - let sessionContinueSeconds: Int? - let screenTracksEvents: Bool? -} - - class FlurryDestination: DestinationPlugin { let timeline = Timeline() let type = PluginType.destination @@ -126,3 +119,8 @@ extension FlurryDestination { } } +private struct FlurrySettings: Codable { + let apiKey: String + let sessionContinueSeconds: Int? + let screenTracksEvents: Bool? +}