Skip to content

Commit

Permalink
Merge pull request #2323 from CruGlobal/GT-fix-swiftui-preview
Browse files Browse the repository at this point in the history
GT fix swiftui preview
  • Loading branch information
levieggertcru authored Nov 5, 2024
2 parents 023f02f + 06c4c34 commit 19f7ec0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,18 @@ import Combine

struct DashboardView_Previews: PreviewProvider {

private static let diContainer: AppDiContainer = SwiftUIPreviewDiContainer().getAppDiContainer()
private static let flowDelegate: FlowDelegate = MockFlowDelegate()
private static let dashboardDependencies: DashboardPresentationLayerDependencies = DashboardPresentationLayerDependencies(appDiContainer: Self.diContainer, flowDelegate: Self.flowDelegate)

static func getDashboardViewModel() -> DashboardViewModel {

let appDiContainer: AppDiContainer = SwiftUIPreviewDiContainer().getAppDiContainer()
let appDiContainer: AppDiContainer = Self.diContainer

let viewModel = DashboardViewModel(
startingTab: .favorites,
flowDelegate: MockFlowDelegate(),
dashboardPresentationLayerDependencies: DashboardPresentationLayerDependencies(appDiContainer: appDiContainer, flowDelegate: MockFlowDelegate()),
flowDelegate: Self.flowDelegate,
dashboardPresentationLayerDependencies: Self.dashboardDependencies,
getCurrentAppLanguageUseCase: appDiContainer.feature.appLanguage.domainLayer.getCurrentAppLanguageUseCase(),
viewDashboardUseCase: appDiContainer.feature.dashboard.domainLayer.getViewDashboardUseCase(),
dashboardTabObserver: CurrentValueSubject(.favorites)
Expand All @@ -118,6 +122,6 @@ struct DashboardView_Previews: PreviewProvider {

static var previews: some View {

DashboardView(viewModel: DashboardView_Previews.getDashboardViewModel())
DashboardView(viewModel: Self.getDashboardViewModel())
}
}
14 changes: 2 additions & 12 deletions godtools/App/Services/Analytics/AppsFlyer/AppsFlyerAnalytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ class AppsFlyerAnalytics: NSObject {
func trackAppLaunch() {

serialQueue.async { [weak self] in

self?.assertFailureIfNotConfigured()


self?.appsFlyer.appsFlyerLib.start()

self?.log(method: "trackAppLaunch()", label: nil, labelValue: nil, data: nil)
Expand All @@ -60,20 +58,12 @@ class AppsFlyerAnalytics: NSObject {
func trackAction(actionName: String, data: [String: Any]?) {

serialQueue.async { [weak self] in

self?.assertFailureIfNotConfigured()


self?.appsFlyer.appsFlyerLib.logEvent(actionName, withValues: data)
self?.log(method: "trackEvent()", label: "eventName", labelValue: actionName, data: data)
}
}

private func assertFailureIfNotConfigured() {
if !isConfigured {
assertionFailure("AppsFlyer has not been configured. Call configure() on application didFinishLaunching.")
}
}

private func log(method: String, label: String?, labelValue: String?, data: [String: Any]?) {

if loggingEnabled {
Expand Down
12 changes: 1 addition & 11 deletions godtools/App/Services/Analytics/Firebase/FirebaseAnalytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class FirebaseAnalytics {
}

func setLoggedInStateUserProperties(isLoggedIn: Bool, loggedInUserProperties: FirebaseAnalyticsLoggedInUserProperties?) {
assertFailureIfNotConfigured()

let userId: String? = loggedInUserProperties?.grMasterPersonId ?? loggedInUserProperties?.ssoguid

Expand Down Expand Up @@ -104,16 +103,8 @@ class FirebaseAnalytics {
)
}

private func assertFailureIfNotConfigured() {
if !isConfigured {
assertionFailure("FirebaseAnalytics has not been configured. Call configure() on application didFinishLaunching.")
}
}

private func internalTrackEvent(screenName: String?, siteSection: String?, siteSubSection: String?, appLanguage: String?, contentLanguage: String?, secondaryContentLanguage: String?, previousScreenName: String, eventName: String, data: [String: Any]?) {

assertFailureIfNotConfigured()


DispatchQueue.global().async { [weak self] in

guard let firebaseAnalytics = self else {
Expand Down Expand Up @@ -176,7 +167,6 @@ class FirebaseAnalytics {
}

private func createBaseProperties(screenName: String?, siteSection: String?, siteSubSection: String?, appLanguage: String?, contentLanguage: String?, secondaryContentLanguage: String?, previousScreenName: String?) -> [String: String] {
assertFailureIfNotConfigured()

var properties: [String: String] = [:]

Expand Down
7 changes: 0 additions & 7 deletions godtools/App/Share/Data/AppsFlyer/AppsFlyer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,9 @@ class AppsFlyer {
}

var appsFlyerLib: AppsFlyerLib {
assertFailureIfNotConfigured()
return sharedAppsFlyerLib
}

private func assertFailureIfNotConfigured() {
if !isConfigured {
assertionFailure("AppsFlyer has not been configured. Be sure to call configure on application didFinishLaunching.")
}
}

func configure(configuration: AppsFlyerConfiguration, deepLinkDelegate: DeepLinkDelegate) {

guard !isConfigured else {
Expand Down

0 comments on commit 19f7ec0

Please sign in to comment.