Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to destinations to match ExampleDestination #64

Merged
merged 6 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

let configuration = Configuration(writeKey: "WRITE_KEY")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prob don't want a write key in here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, missed that cause of the merge conflict

let configuration = Configuration(writeKey: "8XpdAWa7qJVBJMK8V4FfXQOrnvCzu3Ie")
.trackApplicationLifecycleEvents(true)
.flushInterval(1)

Expand Down
22 changes: 11 additions & 11 deletions Examples/destination_plugins/AdjustDestination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,14 @@ 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()
let type = PluginType.destination
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.
Expand Down Expand Up @@ -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?
}
14 changes: 7 additions & 7 deletions Examples/destination_plugins/AppsFlyerDestination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -346,3 +340,9 @@ extension AppsFlyerDestination: DeepLinkDelegate, UIApplicationDelegate {
// return nil
// }
//}

private struct AppsFlyerSettings: Codable {
let appsFlyerDevKey: String
let appleAppID: String
let trackAttributionData: Bool?
}
74 changes: 40 additions & 34 deletions Examples/destination_plugins/FirebaseDestination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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]

}
12 changes: 5 additions & 7 deletions Examples/destination_plugins/FlurryDestination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -126,3 +119,8 @@ extension FlurryDestination {
}
}

private struct FlurrySettings: Codable {
let apiKey: String
let sessionContinueSeconds: Int?
let screenTracksEvents: Bool?
}