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

Add branch provider #2

Merged
merged 5 commits into from Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
105 changes: 105 additions & 0 deletions Analytical/Classes/Provider/BranchProvider.swift
@@ -0,0 +1,105 @@
//
// BranchProvider.swift
// Analytical_Example
//
// Created by Erik Drobne on 17/10/2019.
// Copyright © 2019 Unified Sense. All rights reserved.
//

import Analytical
import Branch

public class BranchProvider : BaseProvider<Branch>, AnalyticalProvider {

public static let ShouldUseTestKey = false
public static let IsDebugEnabled = false
public static let ShouldStartSession = true

private var launchOptions = [UIApplication.LaunchOptionsKey: Any]?

public func setup(with properties: Properties?) {
launchOptions = properties?[Property.Launch.options.rawValue] as? [UIApplication.LaunchOptionsKey: Any]

if let shouldUseTestKey = properties?[BranchProvider.ShouldUseTestKey] as? Bool {
Branch.setUseTestBranchKey(shouldUseTestKey)
}

instance = Branch.getInstance()

if properties?[BranchProvider.IsDebugEnabled] as? Bool ?? false {
instance.setDebug()
}

if let shouldStartSession = properties?[BranchProvider.ShouldStartSession] as? Bool, shouldStartSession {
initSession()
}
}

public func initSession() {
instance.initSession(launchOptions: launchOptions, andRegisterDeepLinkHandler: { params, error in

})
}

public func flush() {

}

public func reset() {

}

public func identify(userId: String, properties: Properties?) {
instance.setIdentity(userId)
}

public func alias(userId: String, forId: String) {

}

public func set(properties: Properties) {

}

public func increment(property: String, by number: NSDecimalNumber) {

}

public override func update(event: AnalyticalEvent) -> AnalyticalEvent? {
guard let event = super.update(event: event) else {
return nil
}

return event
}

public override func event(_ event: AnalyticalEvent) {
guard let event = update(event: event) else {
return
}

guard let defaultName = DefaultEvent(rawValue: event.name), let branchEvent = branchEvent(for: defaultName) else {
return
}

BranchEvent.standardEvent(branchEvent).logEvent()
delegate?.analyticalProviderDidSendEvent(self, event: event)
}

public override func activate() {

}

private func branchEvent(for name: DefaultEvent) -> BranchStandardEvent? {
switch name {
case .startTrial:
return .startTrial
case .addedToCart:
return .addToCart
case .spendCredits:
return .spendCredits
default:
return nil
}
}
}
6 changes: 6 additions & 0 deletions Example/Analytical.xcodeproj/project.pbxproj
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
03DCAD1D1667A68F9860610E /* Pods_Analytical_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B3DA68DF1C06AE4134E311DA /* Pods_Analytical_Example.framework */; };
1718C419235877FA00367ED3 /* BranchProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1718C418235877FA00367ED3 /* BranchProvider.swift */; };
2C4C7B7BA5876132D0E84091 /* Pods_Analytical_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D08A02826BA7B956043C6F80 /* Pods_Analytical_Tests.framework */; };
3808454A1D8AF708007E1D2D /* Analytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 380845491D8AF708007E1D2D /* Analytics.swift */; };
38363CCA1FCE3D1400449ED0 /* AppsFlyerProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38363CC91FCE3D1300449ED0 /* AppsFlyerProvider.swift */; };
Expand Down Expand Up @@ -36,6 +37,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
1718C418235877FA00367ED3 /* BranchProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = BranchProvider.swift; path = ../Analytical/Classes/Provider/BranchProvider.swift; sourceTree = "<group>"; };
380845471D8AF6D8007E1D2D /* GoogleProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GoogleProvider.swift; path = ../Analytical/Classes/Provider/GoogleProvider.swift; sourceTree = "<group>"; };
380845491D8AF708007E1D2D /* Analytics.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Analytics.swift; sourceTree = "<group>"; };
3808454B1D8AF759007E1D2D /* Analytical-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Analytical-Bridging-Header.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -98,6 +100,7 @@
38989E571F6D8FA900611303 /* FirebaseProvider.swift */,
380845471D8AF6D8007E1D2D /* GoogleProvider.swift */,
3853CE4D2281A70C0040729A /* SmartlookProvider.swift */,
1718C418235877FA00367ED3 /* BranchProvider.swift */,
);
name = Analytical;
sourceTree = "<group>";
Expand Down Expand Up @@ -335,6 +338,7 @@
"${BUILT_PRODUCTS_DIR}/Adjust/Adjust.framework",
"${BUILT_PRODUCTS_DIR}/Analytical/Analytical.framework",
"${BUILT_PRODUCTS_DIR}/Analytics/Analytics.framework",
"${BUILT_PRODUCTS_DIR}/Branch/Branch.framework",
"${BUILT_PRODUCTS_DIR}/FBSDKCoreKit/FBSDKCoreKit.framework",
"${BUILT_PRODUCTS_DIR}/Flurry-iOS-SDK/Flurry_iOS_SDK.framework",
"${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework",
Expand All @@ -346,6 +350,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Adjust.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Analytical.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Analytics.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Branch.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBSDKCoreKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flurry_iOS_SDK.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework",
Expand Down Expand Up @@ -388,6 +393,7 @@
3808454A1D8AF708007E1D2D /* Analytics.swift in Sources */,
38F4CE771DE316E700B93EC0 /* SecondViewController.swift in Sources */,
386B52E620C14F5E007101C4 /* AdjustProvider.swift in Sources */,
1718C419235877FA00367ED3 /* BranchProvider.swift in Sources */,
3853CE4E2281A70C0040729A /* SmartlookProvider.swift in Sources */,
38829E211EDDCD3B0061173B /* AnswersProvider.swift in Sources */,
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions Example/Podfile
Expand Up @@ -22,6 +22,7 @@ target 'Analytical_Example' do

pod 'Adjust'
pod 'Smartlook'
pod 'Branch'

target 'Analytical_Tests' do
inherit! :search_paths
Expand Down
15 changes: 11 additions & 4 deletions Example/Podfile.lock
Expand Up @@ -26,6 +26,9 @@ PODS:
- Analytics
- Analytics (3.6.10)
- AppsFlyerFramework (4.9.0)
- Branch (0.29.3):
- Branch/Core (= 0.29.3)
- Branch/Core (0.29.3)
- Crashlytics (3.12.0):
- Fabric (~> 1.9.0)
- Fabric (1.9.0)
Expand Down Expand Up @@ -95,14 +98,15 @@ DEPENDENCIES:
- Adjust
- Analytical (from `../`)
- AppsFlyerFramework
- Branch
- Crashlytics
- Fabric
- Firebase/Core
- Mixpanel-swift (from `https://github.com/mixpanel/mixpanel-swift.git`)
- Smartlook

SPEC REPOS:
https://github.com/cocoapods/specs.git:
https://github.com/CocoaPods/Specs.git:
- Adjust
- Analytics
- AppsFlyerFramework
Expand All @@ -118,6 +122,8 @@ SPEC REPOS:
- GoogleUtilities
- nanopb
- Smartlook
trunk:
- Branch

EXTERNAL SOURCES:
Analytical:
Expand All @@ -135,6 +141,7 @@ SPEC CHECKSUMS:
Analytical: be4bf18fea464a21ba76633a98118dc566ae1b68
Analytics: 63744ad4afa65c3bcdcdb7a94b62515bde5b3900
AppsFlyerFramework: f57e5d590ad3124d3e594a76032a181bc91ec6cd
Branch: 9d40910c3d7f8516376fd166cb73a31cc7f73fcf
Crashlytics: 07fb167b1694128c1c9a5a5cc319b0e9c3ca0933
Fabric: f988e33c97f08930a413e08123064d2e5f68d655
FBSDKCoreKit: ba361d4a9d4dc29ff218822b849b22d4f869c7bb
Expand All @@ -145,10 +152,10 @@ SPEC CHECKSUMS:
Flurry-iOS-SDK: 5d782d740c5e95389c327d38245b3db4bb471fd7
GoogleAppMeasurement: ffe513e90551844a739e7bcbb1d2aca1c28a4338
GoogleUtilities: 04fce34bcd5620c1ee76fb79172105c74a4df335
Mixpanel-swift: eea98bb65fd80e992a9ecb3a0a421eca542ea72f
Mixpanel-swift: 56b19ba6786e24571671d110a16e022d0370cd8e
nanopb: 2901f78ea1b7b4015c860c2fdd1ea2fee1a18d48
Smartlook: f9be8dcb835d390031c10c9ade6caa793afb92f3

PODFILE CHECKSUM: ccfdb79e295b064958ce8dc362ea4e1768fdd230
PODFILE CHECKSUM: ecb3692248a1a543aa51098b31e4e78729356aff

COCOAPODS: 1.6.1
COCOAPODS: 1.8.3