From 646ed556229d39d959df7d582fc756f7ecd8e601 Mon Sep 17 00:00:00 2001 From: mike-dydx Date: Tue, 5 Mar 2024 16:52:12 -0500 Subject: [PATCH] address comments --- .../PlatformRouting.xcodeproj/project.pbxproj | 4 - .../Resources/_UIKit/routing_shared.json | 2 +- .../_iOS/_Transitions/PointsRating.swift | 43 +++++++ .../_iOS/_Transitions/RatingService.swift | 17 +++ Shared/CommonAppDelegate.swift | 2 +- Utilities/Utilities.xcodeproj/project.pbxproj | 32 ----- .../dydxPresenters.xcodeproj/project.pbxproj | 4 + .../_Features/routing_swiftui.json | 2 +- .../_v4/Actions/dydxShareActionBuilder.swift | 13 +- .../Workers/dydxRatingsWorker.swift | 8 +- .../_v4/Profile/dydxProfileViewBuilder.swift | 2 +- .../_v4/Rating/dydxRateAppViewBuilder.swift | 3 +- .../project.pbxproj | 20 ++++ .../Rating/dydxPointsRating.swift | 112 ++++++++++-------- .../Rating/dydxRatingService.swift | 9 +- .../dydxPointsRatingTests.swift | 50 ++++---- dydxV4/dydxV4.xcodeproj/project.pbxproj | 12 -- .../xcshareddata/xcschemes/dydxV4.xcscheme | 10 ++ dydxV4/dydxV4/_Rating/dydxRatingService.swift | 22 ---- 19 files changed, 205 insertions(+), 162 deletions(-) create mode 100644 PlatformRouting/PlatformRouting/_iOS/_Transitions/PointsRating.swift create mode 100644 PlatformRouting/PlatformRouting/_iOS/_Transitions/RatingService.swift rename PlatformRouting/PlatformRouting/_Actions/ShareAction.swift => dydx/dydxPresenters/dydxPresenters/_v4/Actions/dydxShareActionBuilder.swift (86%) rename Utilities/Utilities/_Rating/PointsRating.swift => dydx/dydxStateManager/dydxStateManager/Rating/dydxPointsRating.swift (64%) rename Utilities/Utilities/_Rating/RatingService.swift => dydx/dydxStateManager/dydxStateManager/Rating/dydxRatingService.swift (78%) rename Utilities/UtilitiesTests/PointsRatingTests.swift => dydx/dydxStateManager/dydxStateManagerTests/dydxPointsRatingTests.swift (93%) delete mode 100644 dydxV4/dydxV4/_Rating/dydxRatingService.swift diff --git a/PlatformRouting/PlatformRouting.xcodeproj/project.pbxproj b/PlatformRouting/PlatformRouting.xcodeproj/project.pbxproj index bcfc19567..dc2caa742 100644 --- a/PlatformRouting/PlatformRouting.xcodeproj/project.pbxproj +++ b/PlatformRouting/PlatformRouting.xcodeproj/project.pbxproj @@ -11,7 +11,6 @@ 278A4EDE2B92C639003898EB /* TransitionDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 278A4EDD2B92C639003898EB /* TransitionDelegate.swift */; }; 310CDBAD21C6FA44009665CF /* UIToolkits.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 313EBC0D21BB7B7E00BEF926 /* UIToolkits.framework */; }; 311BAFEB255083C1004331D8 /* Mail.xib in Resources */ = {isa = PBXBuildFile; fileRef = 311BAFDE255083C1004331D8 /* Mail.xib */; }; - 311BB0182550843C004331D8 /* ShareAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 311BB0172550843C004331D8 /* ShareAction.swift */; }; 311BB01F2550845A004331D8 /* Share.xib in Resources */ = {isa = PBXBuildFile; fileRef = 311BB01E2550845A004331D8 /* Share.xib */; }; 311D6FA92176F04900655040 /* Utilities.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 311D6F702176EF7B00655040 /* Utilities.framework */; }; 311D6FAA2176F04900655040 /* RoutingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 311D6F5E2176EF6E00655040 /* RoutingKit.framework */; }; @@ -322,7 +321,6 @@ 278A4EDD2B92C639003898EB /* TransitionDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransitionDelegate.swift; sourceTree = ""; }; 306E17287D7FE48D8EEA3648 /* Pods-iOS-PlatformRouting.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iOS-PlatformRouting.debug.xcconfig"; path = "Target Support Files/Pods-iOS-PlatformRouting/Pods-iOS-PlatformRouting.debug.xcconfig"; sourceTree = ""; }; 311BAFDE255083C1004331D8 /* Mail.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = Mail.xib; sourceTree = ""; }; - 311BB0172550843C004331D8 /* ShareAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareAction.swift; sourceTree = ""; }; 311BB01E2550845A004331D8 /* Share.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = Share.xib; sourceTree = ""; }; 311D6F582176EF6E00655040 /* RoutingKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RoutingKit.xcodeproj; path = ../RoutingKit/RoutingKit.xcodeproj; sourceTree = ""; }; 311D6F612176EF7500655040 /* UIToolkits.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = UIToolkits.xcodeproj; path = ../UIToolkits/UIToolkits.xcodeproj; sourceTree = ""; }; @@ -692,7 +690,6 @@ isa = PBXGroup; children = ( 314C35B524C7C29600695F7E /* DebugEnableAction.swift */, - 311BB0172550843C004331D8 /* ShareAction.swift */, ); path = _Actions; sourceTree = ""; @@ -1289,7 +1286,6 @@ buildActionMask = 2147483647; files = ( 314B627823DCCE8900139EB3 /* RoutingEmbeddingController.swift in Sources */, - 311BB0182550843C004331D8 /* ShareAction.swift in Sources */, 314B627D23DCCE8900139EB3 /* TelAction.swift in Sources */, 314B628223DCCE8900139EB3 /* MappedUIKitAppRouter.swift in Sources */, 314B626D23DCCE8900139EB3 /* RoutingDrawerController.swift in Sources */, diff --git a/PlatformRouting/PlatformRouting/Resources/_UIKit/routing_shared.json b/PlatformRouting/PlatformRouting/Resources/_UIKit/routing_shared.json index 3884785fa..1123953fe 100644 --- a/PlatformRouting/PlatformRouting/Resources/_UIKit/routing_shared.json +++ b/PlatformRouting/PlatformRouting/Resources/_UIKit/routing_shared.json @@ -32,7 +32,7 @@ "destination":"Refresh.xib" }, "/action/share":{ - "destination":"PlatformRouting.ShareActionBuilder" + "destination":"dydxPresenters.dydxShareActionBuilder" }, "/action/wallet":{ "destination":"Wallet.xib" diff --git a/PlatformRouting/PlatformRouting/_iOS/_Transitions/PointsRating.swift b/PlatformRouting/PlatformRouting/_iOS/_Transitions/PointsRating.swift new file mode 100644 index 000000000..e68cfce93 --- /dev/null +++ b/PlatformRouting/PlatformRouting/_iOS/_Transitions/PointsRating.swift @@ -0,0 +1,43 @@ +// +// PointedRating.swift +// Utilities +// +// Created by Qiang Huang on 9/19/19. +// Copyright © 2019 dYdX. All rights reserved. +// + +import Foundation + +open class PointsRating: NSObject, RatingProtocol { + public func add(points: Int) { + self.points = self.points + points + } + + private var pointsKey: String { + return "\(String(describing: className)).points" + } + + private var threshold: Int + + open var points: Int { + get { + return UserDefaults.standard.integer(forKey: pointsKey) + } + set { + if newValue >= threshold { + promptForRating() + UserDefaults.standard.set(0, forKey: pointsKey) + } else { + UserDefaults.standard.set(newValue, forKey: pointsKey) + } + } + } + + public init(threshold: Int) { + self.threshold = threshold + super.init() + } + + open func promptForRating() { + } +} diff --git a/PlatformRouting/PlatformRouting/_iOS/_Transitions/RatingService.swift b/PlatformRouting/PlatformRouting/_iOS/_Transitions/RatingService.swift new file mode 100644 index 000000000..cf7bcb37d --- /dev/null +++ b/PlatformRouting/PlatformRouting/_iOS/_Transitions/RatingService.swift @@ -0,0 +1,17 @@ +// +// RatingService.swift +// Utilities +// +// Created by Qiang Huang on 9/19/19. +// Copyright © 2019 dYdX. All rights reserved. +// + +import Foundation + +public protocol RatingProtocol: NSObjectProtocol { + func add(points: Int) +} + +public class RatingService { + public static var shared: RatingProtocol? +} diff --git a/Shared/CommonAppDelegate.swift b/Shared/CommonAppDelegate.swift index 9da87a787..1ace5ba76 100644 --- a/Shared/CommonAppDelegate.swift +++ b/Shared/CommonAppDelegate.swift @@ -170,7 +170,7 @@ open class CommonAppDelegate: ParticlesAppDelegate { open override func applicationDidBecomeActive(_ application: UIApplication) { super.applicationDidBecomeActive(application) Tracking.shared?.log(event: "AppStart", data: nil) - RatingService.shared?.launchedApp() + dydxRatingService.shared?.launchedApp() } open func injectNotification() { diff --git a/Utilities/Utilities.xcodeproj/project.pbxproj b/Utilities/Utilities.xcodeproj/project.pbxproj index 95e8dd24d..829970985 100644 --- a/Utilities/Utilities.xcodeproj/project.pbxproj +++ b/Utilities/Utilities.xcodeproj/project.pbxproj @@ -29,7 +29,6 @@ 02EE90552829A95600225B56 /* NSObject+ObservingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02EE90542829A95600225B56 /* NSObject+ObservingTests.swift */; }; 02F958032A18278B00828F9A /* SecureStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F958022A18278B00828F9A /* SecureStore.swift */; }; 02F958052A182BC400828F9A /* SecureStoreProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F958042A182BC400828F9A /* SecureStoreProtocol.swift */; }; - 278A4DEA2B915D82003898EB /* PointsRatingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 278A4DE92B915D82003898EB /* PointsRatingTests.swift */; }; 3101F94725112C4100AC4010 /* AuthProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3101F94625112C4100AC4010 /* AuthProtocol.swift */; }; 3101F94A25112C5900AC4010 /* AuthService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3101F94925112C5900AC4010 /* AuthService.swift */; }; 310E61E9216C0F910043BB33 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 310E61E8216C0F910043BB33 /* Security.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; @@ -52,12 +51,6 @@ 31471F7024BA2F1E00057221 /* UserAgent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31471F6F24BA2F1E00057221 /* UserAgent.swift */; }; 31471F7124BA2F1E00057221 /* UserAgent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31471F6F24BA2F1E00057221 /* UserAgent.swift */; }; 31471F7224BA2F1E00057221 /* UserAgent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31471F6F24BA2F1E00057221 /* UserAgent.swift */; }; - 314B63E023DCCF0200139EB3 /* PointsRating.swift in Sources */ = {isa = PBXBuildFile; fileRef = 314B638523DCCF0100139EB3 /* PointsRating.swift */; }; - 314B63E123DCCF0200139EB3 /* PointsRating.swift in Sources */ = {isa = PBXBuildFile; fileRef = 314B638523DCCF0100139EB3 /* PointsRating.swift */; }; - 314B63E223DCCF0200139EB3 /* PointsRating.swift in Sources */ = {isa = PBXBuildFile; fileRef = 314B638523DCCF0100139EB3 /* PointsRating.swift */; }; - 314B63E423DCCF0200139EB3 /* RatingService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 314B638623DCCF0100139EB3 /* RatingService.swift */; }; - 314B63E523DCCF0200139EB3 /* RatingService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 314B638623DCCF0100139EB3 /* RatingService.swift */; }; - 314B63E623DCCF0200139EB3 /* RatingService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 314B638623DCCF0100139EB3 /* RatingService.swift */; }; 314B63E823DCCF0200139EB3 /* Directory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 314B638823DCCF0100139EB3 /* Directory.swift */; }; 314B63E923DCCF0200139EB3 /* Directory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 314B638823DCCF0100139EB3 /* Directory.swift */; }; 314B63EA23DCCF0200139EB3 /* Directory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 314B638823DCCF0100139EB3 /* Directory.swift */; }; @@ -258,7 +251,6 @@ 31CB2B53256DB261008A26A7 /* LocalizerBuffer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31CB2B52256DB261008A26A7 /* LocalizerBuffer.swift */; }; 31DEFEAC277543E8009BEBF6 /* ExportProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31DEFEAB277543E8009BEBF6 /* ExportProtocol.swift */; }; 31E65AC3216BC9C9008ABEE9 /* Utilities.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 31E65AB9216BC9C9008ABEE9 /* Utilities.framework */; }; - 31E65AC8216BC9C9008ABEE9 /* UtilitiesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31E65AC7216BC9C9008ABEE9 /* UtilitiesTests.swift */; }; 31E65ACA216BC9C9008ABEE9 /* Utilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 31E65ABC216BC9C9008ABEE9 /* Utilities.h */; settings = {ATTRIBUTES = (Public, ); }; }; 35EE5B244960774B9B6D4D55 /* Pods_iOS_UtilitiesTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF030595A23E85168A3AD589 /* Pods_iOS_UtilitiesTests.framework */; }; 4EDE0B13DB89059A45D982F2 /* Pods_iOS_Utilities.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A32AA5C7AC3D4879568CFBD /* Pods_iOS_Utilities.framework */; }; @@ -306,7 +298,6 @@ 02EE90542829A95600225B56 /* NSObject+ObservingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSObject+ObservingTests.swift"; sourceTree = ""; }; 02F958022A18278B00828F9A /* SecureStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureStore.swift; sourceTree = ""; }; 02F958042A182BC400828F9A /* SecureStoreProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureStoreProtocol.swift; sourceTree = ""; }; - 278A4DE92B915D82003898EB /* PointsRatingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PointsRatingTests.swift; sourceTree = ""; }; 3101F94625112C4100AC4010 /* AuthProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthProtocol.swift; sourceTree = ""; }; 3101F94925112C5900AC4010 /* AuthService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthService.swift; sourceTree = ""; }; 310E61E8216C0F910043BB33 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; @@ -324,8 +315,6 @@ 313A537421B9805F00A92D62 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 313B1AA625CB08CE006D369F /* Sequence+Reduce.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Sequence+Reduce.swift"; sourceTree = ""; }; 31471F6F24BA2F1E00057221 /* UserAgent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserAgent.swift; sourceTree = ""; }; - 314B638523DCCF0100139EB3 /* PointsRating.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PointsRating.swift; sourceTree = ""; }; - 314B638623DCCF0100139EB3 /* RatingService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RatingService.swift; sourceTree = ""; }; 314B638823DCCF0100139EB3 /* Directory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Directory.swift; sourceTree = ""; }; 314B638923DCCF0100139EB3 /* File.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = File.swift; sourceTree = ""; }; 314B638B23DCCF0100139EB3 /* UrlHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UrlHandler.swift; sourceTree = ""; }; @@ -409,7 +398,6 @@ 31E65ABC216BC9C9008ABEE9 /* Utilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Utilities.h; sourceTree = ""; }; 31E65ABD216BC9C9008ABEE9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31E65AC2216BC9C9008ABEE9 /* UtilitiesTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UtilitiesTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 31E65AC7216BC9C9008ABEE9 /* UtilitiesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UtilitiesTests.swift; sourceTree = ""; }; 31E65AC9216BC9C9008ABEE9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 3A32AA5C7AC3D4879568CFBD /* Pods_iOS_Utilities.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iOS_Utilities.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 439FD4525821BD140CEE8DB1 /* Pods-iOS-UtilitiesTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iOS-UtilitiesTests.release.xcconfig"; path = "Target Support Files/Pods-iOS-UtilitiesTests/Pods-iOS-UtilitiesTests.release.xcconfig"; sourceTree = ""; }; @@ -566,15 +554,6 @@ path = _UserAgent; sourceTree = ""; }; - 314B638423DCCF0100139EB3 /* _Rating */ = { - isa = PBXGroup; - children = ( - 314B638523DCCF0100139EB3 /* PointsRating.swift */, - 314B638623DCCF0100139EB3 /* RatingService.swift */, - ); - path = _Rating; - sourceTree = ""; - }; 314B638723DCCF0100139EB3 /* _Files */ = { isa = PBXGroup; children = ( @@ -858,7 +837,6 @@ 3162C00D24C3781D00DE648C /* _Permissions */, 3162C00424C377BF00DE648C /* _Prompter */, 314B63D823DCCF0100139EB3 /* _Protocols */, - 314B638423DCCF0100139EB3 /* _Rating */, 314B63CE23DCCF0100139EB3 /* _Time */, 314B63D123DCCF0100139EB3 /* _Tracker */, 314B638A23DCCF0100139EB3 /* _URL */, @@ -876,9 +854,7 @@ children = ( 02EE90532829A93400225B56 /* _Extensions */, 02EE8FDF2828305C00225B56 /* _Observing */, - 31E65AC7216BC9C9008ABEE9 /* UtilitiesTests.swift */, 31E65AC9216BC9C9008ABEE9 /* Info.plist */, - 278A4DE92B915D82003898EB /* PointsRatingTests.swift */, ); path = UtilitiesTests; sourceTree = ""; @@ -1208,7 +1184,6 @@ 314B64DA23DCCF0200139EB3 /* Tracking.swift in Sources */, 314B64A223DCCF0200139EB3 /* Collection+Random.swift in Sources */, 314B647223DCCF0200139EB3 /* Weak.swift in Sources */, - 314B63E623DCCF0200139EB3 /* RatingService.swift in Sources */, 314B649E23DCCF0200139EB3 /* DispatchQueue+Utils.swift in Sources */, 3162C00C24C377EF00DE648C /* PrompterFactory.swift in Sources */, 314B646223DCCF0200139EB3 /* JsonWriter.swift in Sources */, @@ -1231,7 +1206,6 @@ 314B644223DCCF0200139EB3 /* FeatureService.swift in Sources */, 314B644623DCCF0200139EB3 /* LoadingStatus.swift in Sources */, 313B1AA925CB08CE006D369F /* Sequence+Reduce.swift in Sources */, - 314B63E223DCCF0200139EB3 /* PointsRating.swift in Sources */, 312CE38E2630A38700C519C0 /* JavascriptRunner.swift in Sources */, 314B64EA23DCCF0200139EB3 /* ProgressProtocol.swift in Sources */, 314B64CA23DCCF0200139EB3 /* Date+Utils.swift in Sources */, @@ -1287,7 +1261,6 @@ 314B64D923DCCF0200139EB3 /* Tracking.swift in Sources */, 314B64A123DCCF0200139EB3 /* Collection+Random.swift in Sources */, 314B647123DCCF0200139EB3 /* Weak.swift in Sources */, - 314B63E523DCCF0200139EB3 /* RatingService.swift in Sources */, 314B649D23DCCF0200139EB3 /* DispatchQueue+Utils.swift in Sources */, 314B646123DCCF0200139EB3 /* JsonWriter.swift in Sources */, 3162C00B24C377EF00DE648C /* PrompterFactory.swift in Sources */, @@ -1312,7 +1285,6 @@ 314B644123DCCF0200139EB3 /* FeatureService.swift in Sources */, 314B644523DCCF0200139EB3 /* LoadingStatus.swift in Sources */, 317F16E12572CF5B00D178B8 /* Double+String.swift in Sources */, - 314B63E123DCCF0200139EB3 /* PointsRating.swift in Sources */, 314B64E923DCCF0200139EB3 /* ProgressProtocol.swift in Sources */, 314B64C923DCCF0200139EB3 /* Date+Utils.swift in Sources */, 314B649123DCCF0200139EB3 /* Bundle+UIBundle.swift in Sources */, @@ -1373,7 +1345,6 @@ 314B647023DCCF0200139EB3 /* Weak.swift in Sources */, 3162B55126E18183000209E1 /* WebCrypto.swift in Sources */, 3112B53B25264670009D19B6 /* NotificationBridge.swift in Sources */, - 314B63E423DCCF0200139EB3 /* RatingService.swift in Sources */, 314B649C23DCCF0200139EB3 /* DispatchQueue+Utils.swift in Sources */, 02ABF37D2AD72314005D799B /* AttributedString+Ext.swift in Sources */, 023FA97028A2C5B4008352E3 /* UIColor+Hex.swift in Sources */, @@ -1416,7 +1387,6 @@ 02F958032A18278B00828F9A /* SecureStore.swift in Sources */, 314B644423DCCF0200139EB3 /* LoadingStatus.swift in Sources */, 0253CEC42AA009D70033F064 /* DebugEnabled.swift in Sources */, - 314B63E023DCCF0200139EB3 /* PointsRating.swift in Sources */, 312CE39A2630A48B00C519C0 /* StringLoader.swift in Sources */, 020F758C298806F600DA2D87 /* AsyncEvent.swift in Sources */, 318A5C07272DD357000DA46C /* HapticFeedbackProtocol.swift in Sources */, @@ -1462,10 +1432,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 31E65AC8216BC9C9008ABEE9 /* UtilitiesTests.swift in Sources */, 02EE90552829A95600225B56 /* NSObject+ObservingTests.swift in Sources */, 02EE8FE12828307900225B56 /* CombineObservingTests.swift in Sources */, - 278A4DEA2B915D82003898EB /* PointsRatingTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/dydx/dydxPresenters/dydxPresenters.xcodeproj/project.pbxproj b/dydx/dydxPresenters/dydxPresenters.xcodeproj/project.pbxproj index 38fd7b7a9..8dbea7eeb 100644 --- a/dydx/dydxPresenters/dydxPresenters.xcodeproj/project.pbxproj +++ b/dydx/dydxPresenters/dydxPresenters.xcodeproj/project.pbxproj @@ -137,6 +137,7 @@ 278A4D1E2B8EA95A003898EB /* dydxCollectFeedbackActionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 278A4D1D2B8EA95A003898EB /* dydxCollectFeedbackActionBuilder.swift */; }; 278A4D932B8FA5E8003898EB /* dydxRateAppViewBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 278A4D922B8FA5E8003898EB /* dydxRateAppViewBuilder.swift */; }; 278A4DA42B8FDD9D003898EB /* dydxRatingsWorker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 278A4DA32B8FDD9D003898EB /* dydxRatingsWorker.swift */; }; + 27B957ED2B97C07400EF9304 /* dydxShareActionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27B957EC2B97C07400EF9304 /* dydxShareActionBuilder.swift */; }; 27C027532AFD761300E92CCB /* dydxSettingsHelpRowViewPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27C027522AFD761300E92CCB /* dydxSettingsHelpRowViewPresenter.swift */; }; 27DB2EA32AC1E7B20047BC39 /* dydxTradeRestrictedViewPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27DB2EA22AC1E7B20047BC39 /* dydxTradeRestrictedViewPresenter.swift */; }; 314BBDE9F332ECA910BC414E /* Pods_iOS_dydxPresenters.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F1551C00FFF41C29CFC5BD94 /* Pods_iOS_dydxPresenters.framework */; }; @@ -482,6 +483,7 @@ 278A4D1D2B8EA95A003898EB /* dydxCollectFeedbackActionBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxCollectFeedbackActionBuilder.swift; sourceTree = ""; }; 278A4D922B8FA5E8003898EB /* dydxRateAppViewBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxRateAppViewBuilder.swift; sourceTree = ""; }; 278A4DA32B8FDD9D003898EB /* dydxRatingsWorker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxRatingsWorker.swift; sourceTree = ""; }; + 27B957EC2B97C07400EF9304 /* dydxShareActionBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = dydxShareActionBuilder.swift; sourceTree = ""; }; 27C027522AFD761300E92CCB /* dydxSettingsHelpRowViewPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxSettingsHelpRowViewPresenter.swift; sourceTree = ""; }; 27DB2EA22AC1E7B20047BC39 /* dydxTradeRestrictedViewPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxTradeRestrictedViewPresenter.swift; sourceTree = ""; }; 64487FFE2AA248340068DD87 /* dydxAlertsWorker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = dydxAlertsWorker.swift; sourceTree = ""; }; @@ -740,6 +742,7 @@ children = ( 0243A76029BE572C00A083FE /* dydxCancelOrderActionBuilder.swift */, 0262F2D429DB4891009889E2 /* WalletAction.swift */, + 27B957EC2B97C07400EF9304 /* dydxShareActionBuilder.swift */, 278A4D1D2B8EA95A003898EB /* dydxCollectFeedbackActionBuilder.swift */, ); path = Actions; @@ -1801,6 +1804,7 @@ 02A134C129A5A14700B13E83 /* dydxClosePositionHeaderViewPresenter.swift in Sources */, 02FA5B7E2A12FB280045F2F5 /* dydxTransferWithdrawalViewPresenter.swift in Sources */, 02A565B22A5E32790035469F /* dydxSystemAlertsProvider.swift in Sources */, + 27B957ED2B97C07400EF9304 /* dydxShareActionBuilder.swift in Sources */, 024FEB412ACB60690087A55E /* dydxMarketOrderbookPresenter.swift in Sources */, 270E7E242A5F6B1B00136793 /* dydxTradeInputSideViewPresenter.swift in Sources */, 278A4D1E2B8EA95A003898EB /* dydxCollectFeedbackActionBuilder.swift in Sources */, diff --git a/dydx/dydxPresenters/dydxPresenters/_Features/routing_swiftui.json b/dydx/dydxPresenters/dydxPresenters/_Features/routing_swiftui.json index 1cbe3b121..a80703bec 100644 --- a/dydx/dydxPresenters/dydxPresenters/_Features/routing_swiftui.json +++ b/dydx/dydxPresenters/dydxPresenters/_Features/routing_swiftui.json @@ -64,7 +64,7 @@ "destination":"dydxPresenters.dydxCancelOrderActionBuilder" }, "/action/share": { - "destination":"PlatformRouting.ShareActionBuilder" + "destination":"dydxPresenters.dydxShareActionBuilder" }, "/action/collect_feedback": { "destination":"dydxPresenters.dydxCollectFeedbackActionBuilder" diff --git a/PlatformRouting/PlatformRouting/_Actions/ShareAction.swift b/dydx/dydxPresenters/dydxPresenters/_v4/Actions/dydxShareActionBuilder.swift similarity index 86% rename from PlatformRouting/PlatformRouting/_Actions/ShareAction.swift rename to dydx/dydxPresenters/dydxPresenters/_v4/Actions/dydxShareActionBuilder.swift index b630113bf..bde7d2c79 100644 --- a/PlatformRouting/PlatformRouting/_Actions/ShareAction.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/Actions/dydxShareActionBuilder.swift @@ -1,5 +1,5 @@ // -// ShareAction.swift +// dydxShareActionBuilder.swift // PlatformRouting // // Created by Qiang Huang on 11/2/20. @@ -9,15 +9,16 @@ import RoutingKit import Utilities import UIToolkits +import dydxStateManager public class ShareActionBuilder: NSObject, ObjectBuilderProtocol { public func build() -> T? { - let action = ShareAction() + let action = dydxShareAction() return action as? T } } -open class ShareAction: NSObject, NavigableProtocol { +open class dydxShareAction: NSObject, NavigableProtocol { private var completion: RoutingCompletionBlock? open func navigate(to request: RoutingRequest?, animated: Bool, completion: RoutingCompletionBlock?) { switch request?.path { @@ -27,13 +28,13 @@ open class ShareAction: NSObject, NavigableProtocol { let activityVC = UIActivityViewController(activityItems: toShare, applicationActivities: nil) activityVC.excludedActivityTypes = [ UIActivity.ActivityType.airDrop, - UIActivity.ActivityType.addToReadingList, + UIActivity.ActivityType.addToReadingList ] activityVC.popoverPresentationController?.sourceView = UserInteraction.shared.sender as? UIView activityVC.popoverPresentationController?.barButtonItem = UserInteraction.shared.sender as? UIBarButtonItem UIViewController.topmost()?.present(activityVC, animated: true, completion: nil) - + let data: [String: String]? if let shareSource = request?.params?["share_source"] as? String { data = ["share_source": shareSource] @@ -41,7 +42,7 @@ open class ShareAction: NSObject, NavigableProtocol { data = nil } Tracking.shared?.log(event: "ShareDialogDisplayed", data: data) - RatingService.shared?.capturedScreenshotOrShare() + dydxRatingService.shared?.capturedScreenshotOrShare() completion?(nil, true) } else { completion?(nil, false) diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxRatingsWorker.swift b/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxRatingsWorker.swift index 06b786dc6..fe04ad093 100644 --- a/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxRatingsWorker.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxRatingsWorker.swift @@ -21,7 +21,7 @@ public final class dydxRatingsWorker: BaseWorker { .compactMap { $0 } .removeDuplicates() .sink { _ in - RatingService.shared?.connectedWallet() + dydxRatingService.shared?.connectedWallet() } .store(in: &self.subscriptions) @@ -30,7 +30,7 @@ public final class dydxRatingsWorker: BaseWorker { .removeDuplicates() .sink { transfers in for transfer in transfers { - RatingService.shared?.transferCreated(transferId: transfer.id, transferCreatedTimestampMillis: transfer.updatedAtMilliseconds) + dydxRatingService.shared?.transferCreated(transferId: transfer.id, transferCreatedTimestampMillis: transfer.updatedAtMilliseconds) } } .store(in: &self.subscriptions) @@ -39,7 +39,7 @@ public final class dydxRatingsWorker: BaseWorker { .sink { fills in for fill in fills { guard let orderId = fill.orderId else { return } - RatingService.shared?.orderCreated(orderId: orderId, orderCreatedTimestampMillis: fill.createdAtMilliseconds) + dydxRatingService.shared?.orderCreated(orderId: orderId, orderCreatedTimestampMillis: fill.createdAtMilliseconds) } } .store(in: &self.subscriptions) @@ -47,7 +47,7 @@ public final class dydxRatingsWorker: BaseWorker { NotificationCenter.default.publisher(for: UIApplication.userDidTakeScreenshotNotification) .compactMap { $0 } .sink { _ in - RatingService.shared?.capturedScreenshotOrShare() + dydxRatingService.shared?.capturedScreenshotOrShare() } .store(in: &self.subscriptions) diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/Profile/dydxProfileViewBuilder.swift b/dydx/dydxPresenters/dydxPresenters/_v4/Profile/dydxProfileViewBuilder.swift index 1229a324e..82102177e 100644 --- a/dydx/dydxPresenters/dydxPresenters/_v4/Profile/dydxProfileViewBuilder.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/Profile/dydxProfileViewBuilder.swift @@ -31,7 +31,7 @@ private class dydxProfileViewController: HostingViewController() -> T? { @@ -53,7 +54,7 @@ private class dydxRateAppViewBuilderPresenter: HostedViewPresenter secondsInADay { uniqueDayAppOpensCount += 1 lastAppOpenTimestamp = now.timeIntervalSince1970 } } - + public func orderCreated(orderId: String, orderCreatedTimestampMillis: TimeInterval) { if orderCreatedTimestampMillis / 1000 > lastPromptedTimestamp { ordersCreatedSinceLastPrompt.insert(orderId) } } - + public func transferCreated(transferId: String, transferCreatedTimestampMillis: TimeInterval) { if transferCreatedTimestampMillis / 1000 > lastPromptedTimestamp { - ordersCreatedSinceLastPrompt.insert(transferId) + transfersCreatedSinceLastPrompt.insert(transferId) } } - + public func disablePrompting() { shouldStopPrompting = true } - - var transfersCreatedSinceLastPromptKey: String { "\(String(describing: className)).transfersCreatedSinceLastPromptKey" } - var ordersCreatedSinceLastPromptKey: String { "\(String(describing: className)).ordersCreatedSinceLastPromptKey" } - var uniqueDayAppOpensCountKey: String { "\(String(describing: className)).uniqueDayAppOpensCountKey" } - var lastAppOpenTimestampKey: String { "\(String(describing: className)).lastAppOpenTimestampKey" } - var lastPromptedTimestampKey: String { "\(String(describing: className)).lastPromptedTimestampKey" } - var hasEverConnectedWalletKey: String { "\(String(describing: className)).hasEverConnectedWallet" } - var hasSharedOrScreenshottedSinceLastPromptKey: String { "\(String(describing: className)).hasSharedOrScreenshottedKey" } - var shouldStopPromptingKey: String { "\(String(describing: className)).shouldStopPromptingKey" } /// this is maintained as a set for easier order count de-duping var ordersCreatedSinceLastPrompt: Set { - get { Set(UserDefaults.standard.array(forKey: ordersCreatedSinceLastPromptKey) as? [String] ?? []) } - set { UserDefaults.standard.set(Array(newValue), forKey: ordersCreatedSinceLastPromptKey) } + get { Set(UserDefaults.standard.array(forKey: Key.ordersCreatedSinceLastPrompt.storeKey) as? [String] ?? []) } + set { UserDefaults.standard.set(Array(newValue), forKey: Key.ordersCreatedSinceLastPrompt.storeKey) } } - + /// this is maintained as a set for easier order count de-duping var transfersCreatedSinceLastPrompt: Set { - get { Set(UserDefaults.standard.array(forKey: transfersCreatedSinceLastPromptKey) as? [String] ?? []) } - set { UserDefaults.standard.set(Array(newValue), forKey: transfersCreatedSinceLastPromptKey) } + get { Set(UserDefaults.standard.array(forKey: Key.transfersCreatedSinceLastPrompt.storeKey) as? [String] ?? []) } + set { UserDefaults.standard.set(Array(newValue), forKey: Key.transfersCreatedSinceLastPrompt.storeKey) } } - + /// the number of unique days the app was opened. If the app is opened Mon at 10am, Monday 10:30am, and Tuesday 10:30am, this count would be 2, counting the Mon at 10am and Tuesday 10:30am since they are more than 24hrs apart var uniqueDayAppOpensCount: Int { - get { UserDefaults.standard.integer(forKey: uniqueDayAppOpensCountKey) } - set { UserDefaults.standard.set(newValue, forKey: uniqueDayAppOpensCountKey) } + get { UserDefaults.standard.integer(forKey: Key.uniqueDayAppOpensCount.storeKey) } + set { UserDefaults.standard.set(newValue, forKey: Key.uniqueDayAppOpensCount.storeKey) } } - + /// this value represents the last time the app was opened, but it should only be reset if it's current value is further than 24hrs away var lastAppOpenTimestamp: TimeInterval { - get { UserDefaults.standard.double(forKey: lastAppOpenTimestampKey) } - set { UserDefaults.standard.set(newValue, forKey: lastAppOpenTimestampKey) } + get { UserDefaults.standard.double(forKey: Key.lastAppOpenTimestamp.storeKey) } + set { UserDefaults.standard.set(newValue, forKey: Key.lastAppOpenTimestamp.storeKey) } } - + var lastPromptedTimestamp: TimeInterval { - get { UserDefaults.standard.double(forKey: lastPromptedTimestampKey) } - set { UserDefaults.standard.set(newValue, forKey: lastPromptedTimestampKey) } + get { UserDefaults.standard.double(forKey: Key.lastPromptedTimestamp.storeKey) } + set { UserDefaults.standard.set(newValue, forKey: Key.lastPromptedTimestamp.storeKey) } } - + var hasSharedOrScreenshottedSinceLastPrompt: Bool { - get { UserDefaults.standard.bool(forKey: hasSharedOrScreenshottedSinceLastPromptKey) } - set { UserDefaults.standard.set(newValue, forKey: hasSharedOrScreenshottedSinceLastPromptKey) } + get { UserDefaults.standard.bool(forKey: Key.hasSharedOrScreenshottedSinceLastPrompt.storeKey) } + set { UserDefaults.standard.set(newValue, forKey: Key.hasSharedOrScreenshottedSinceLastPrompt.storeKey) } } - + var hasEverConnectedWallet: Bool { - get { UserDefaults.standard.bool(forKey: hasEverConnectedWalletKey) } - set { UserDefaults.standard.set(newValue, forKey: hasEverConnectedWalletKey) } + get { UserDefaults.standard.bool(forKey: Key.hasEverConnectedWallet.storeKey) } + set { UserDefaults.standard.set(newValue, forKey: Key.hasEverConnectedWallet.storeKey) } } - + /// whether the user has continued to app store review after pre-prompt var shouldStopPrompting: Bool { - get { UserDefaults.standard.bool(forKey: shouldStopPromptingKey) } - set { UserDefaults.standard.set(newValue, forKey: shouldStopPromptingKey) } + get { UserDefaults.standard.bool(forKey: Key.shouldStopPrompting.storeKey) } + set { UserDefaults.standard.set(newValue, forKey: Key.shouldStopPrompting.storeKey) } } - - open func promptForRating() { + + public func promptForRating() { + // feature flag in case the prompt has issues + if dydxBoolFeatureFlag.disable_app_rating.isEnabled { return } + Tracking.shared?.log(event: "PrepromptedForRating", data: stateData) + Router.shared?.navigate(to: RoutingRequest(path: "/rate_app"), animated: true, completion: nil) + #if DEBUG Console.shared.log("mock prompt for rating") #else @@ -139,7 +156,6 @@ open class PointsRating: NSObject, RatingProtocol { /// - C /// - trader has opened the app 8 unique days or more since last prompt, resetting with each prompt /// - trader has opened the app 3 unique days or more since last prompt **AND** one of the below - /// - ~~trader portfolio is positive (up 5% or more in total)~~ this was not work the effort /// - trader has shared a screenshot or the app /// - trader has created 8 or more orders open func tryPromptForRating() { @@ -153,7 +169,7 @@ open class PointsRating: NSObject, RatingProtocol { reset() } } - + func reset() { let now = Date() uniqueDayAppOpensCount = 0 diff --git a/Utilities/Utilities/_Rating/RatingService.swift b/dydx/dydxStateManager/dydxStateManager/Rating/dydxRatingService.swift similarity index 78% rename from Utilities/Utilities/_Rating/RatingService.swift rename to dydx/dydxStateManager/dydxStateManager/Rating/dydxRatingService.swift index 5916fc433..b5dd921da 100644 --- a/Utilities/Utilities/_Rating/RatingService.swift +++ b/dydx/dydxStateManager/dydxStateManager/Rating/dydxRatingService.swift @@ -7,19 +7,20 @@ // import Foundation +import Utilities -public protocol RatingProtocol: NSObjectProtocol { +public protocol dydxRatingProtocol { func connectedWallet() func launchedApp() func orderCreated(orderId: String, orderCreatedTimestampMillis: TimeInterval) func transferCreated(transferId: String, transferCreatedTimestampMillis: TimeInterval) func capturedScreenshotOrShare() func disablePrompting() - + func promptForRating() func tryPromptForRating() } -public class RatingService { - public static var shared: RatingProtocol? +public class dydxRatingService { + public static var shared: dydxRatingProtocol? } diff --git a/Utilities/UtilitiesTests/PointsRatingTests.swift b/dydx/dydxStateManager/dydxStateManagerTests/dydxPointsRatingTests.swift similarity index 93% rename from Utilities/UtilitiesTests/PointsRatingTests.swift rename to dydx/dydxStateManager/dydxStateManagerTests/dydxPointsRatingTests.swift index 0d2478ed5..8f3fa5073 100644 --- a/Utilities/UtilitiesTests/PointsRatingTests.swift +++ b/dydx/dydxStateManager/dydxStateManagerTests/dydxPointsRatingTests.swift @@ -1,36 +1,36 @@ // -// PointsRatingTests.swift -// UtilitiesTests +// dydxPointsRatingTests.swift +// dydxStateManagerTests // // Created by Michael Maguire on 2/29/24. // Copyright © 2024 dYdX Trading Inc. All rights reserved. // import XCTest -@testable import Utilities +@testable import dydxStateManager -private class TestPointsRating: PointsRating { +private class TestPointsRating: dydxPointsRating { override var secondsInADay: TimeInterval { 0.05 } - + var promptWasReached: Bool = false - + override func promptForRating() { promptWasReached = true } - + } -final class PointsRatingTests: XCTestCase { - +final class dydxPointsRatingTests: XCTestCase { + private var testStartMillis: TimeInterval! private var testPointRating: TestPointsRating! - + override func setUpWithError() throws { UserDefaults.standard.removePersistentDomain(forName: Bundle.main.bundleIdentifier!) testPointRating = TestPointsRating() testStartMillis = Date.now.timeIntervalSince1970 } - + func testSingleAppLaunch() throws { testPointRating.launchedApp() print("mmm: lastAppOpenTimestamp \(testPointRating.lastAppOpenTimestamp)") @@ -39,7 +39,7 @@ final class PointsRatingTests: XCTestCase { XCTAssertLessThan(testStartMillis, testPointRating.lastAppOpenTimestamp) XCTAssertLessThan(testPointRating.lastAppOpenTimestamp, Date.now.timeIntervalSince1970) } - + func testMultipleAppLaunches() { for _ in 1..<4 { Thread.sleep(forTimeInterval: testPointRating.secondsInADay) @@ -47,21 +47,21 @@ final class PointsRatingTests: XCTestCase { } testPointRating.tryPromptForRating() XCTAssertEqual(testPointRating.promptWasReached, false) - + Thread.sleep(forTimeInterval: testPointRating.secondsInADay) testPointRating.launchedApp() testPointRating.tryPromptForRating() XCTAssertEqual(testPointRating.promptWasReached, true) } - + func testConnectedWalletAndSingleAppLaunch() { testPointRating.launchedApp() testPointRating.connectedWallet() testPointRating.tryPromptForRating() XCTAssertEqual(testPointRating.promptWasReached, false) } - + func testConnectedWalletAndMultipleAppLaunchesAndDisablePrompting() { testPointRating.connectedWallet() for i in 1...8 { @@ -79,7 +79,7 @@ final class PointsRatingTests: XCTestCase { XCTAssertEqual(testPointRating.promptWasReached, i == 8 ? true : false) } testPointRating.promptWasReached = false - + testPointRating.disablePrompting() for i in 1...8 { Thread.sleep(forTimeInterval: testPointRating.secondsInADay) @@ -88,48 +88,48 @@ final class PointsRatingTests: XCTestCase { XCTAssertEqual(testPointRating.promptWasReached, false) } } - + func testConnectedWalletAndScreenshotOrCapture() { testPointRating.capturedScreenshotOrShare() testPointRating.tryPromptForRating() XCTAssertEqual(testPointRating.promptWasReached, true) } - + func testConnectedWalletAndOrders() { testPointRating.connectedWallet() testPointRating.tryPromptForRating() XCTAssertEqual(testPointRating.promptWasReached, false) - + for i in 1...8 { testPointRating.orderCreated(orderId: "\(i)", orderCreatedTimestampMillis: testPointRating.lastPromptedTimestamp + Double(i)) testPointRating.tryPromptForRating() XCTAssertEqual(testPointRating.promptWasReached, i == 8 ? true : false) } testPointRating.promptWasReached = false - + for i in 1...8 { testPointRating.orderCreated(orderId: "\(i)\(i)", orderCreatedTimestampMillis: testPointRating.lastPromptedTimestamp * 1000 + Double(i)) testPointRating.tryPromptForRating() XCTAssertEqual(testPointRating.promptWasReached, i == 8 ? true : false) } } - + func testConnectedWalletAndTransfers() { testPointRating.connectedWallet() testPointRating.tryPromptForRating() XCTAssertEqual(testPointRating.promptWasReached, false) - + for i in 1...2 { testPointRating.transferCreated(transferId: "\(i)", transferCreatedTimestampMillis: testPointRating.lastPromptedTimestamp * 1000 + Double(i)) testPointRating.tryPromptForRating() - XCTAssertEqual(testPointRating.promptWasReached, i == 8 ? true : false) + XCTAssertEqual(testPointRating.promptWasReached, i == 2 ? true : false) } testPointRating.promptWasReached = false - + for i in 1...2 { testPointRating.transferCreated(transferId: "\(i)\(i)", transferCreatedTimestampMillis: testPointRating.lastPromptedTimestamp * 1000 + Double(i)) testPointRating.tryPromptForRating() - XCTAssertEqual(testPointRating.promptWasReached, i == 8 ? true : false) + XCTAssertEqual(testPointRating.promptWasReached, i == 2 ? true : false) } } diff --git a/dydxV4/dydxV4.xcodeproj/project.pbxproj b/dydxV4/dydxV4.xcodeproj/project.pbxproj index 225f48f26..b196c103d 100644 --- a/dydxV4/dydxV4.xcodeproj/project.pbxproj +++ b/dydxV4/dydxV4.xcodeproj/project.pbxproj @@ -28,7 +28,6 @@ 02FF092E29ADBD9900781EDA /* dydxFormatter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 028420CF29AD77F400C0E7CC /* dydxFormatter.framework */; }; 02FF092F29ADBD9F00781EDA /* dydxChart.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 029E11EB29ADB9BC00FE271C /* dydxChart.framework */; }; 02FF093029ADBDA300781EDA /* dydxPresenters.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0293B66528CE94E200DDB103 /* dydxPresenters.framework */; }; - 278A4D822B8FA3DA003898EB /* dydxRatingService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 278A4D812B8FA3DA003898EB /* dydxRatingService.swift */; }; 27A7967B2A620BF6007C3D04 /* dydxSettingsStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27A7967A2A620BF6007C3D04 /* dydxSettingsStore.swift */; }; 27D41AF12A8E9214009A2F37 /* UIApplication+URLHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27D41AF02A8E9214009A2F37 /* UIApplication+URLHandler.swift */; }; 27DBDD222A8FF5B2002383C6 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 27DBDCED2A8FF5B2002383C6 /* GoogleService-Info.plist */; }; @@ -807,7 +806,6 @@ 02C7262A29D793C90098AFBC /* dydxCompositeTracking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxCompositeTracking.swift; sourceTree = ""; }; 02E7DD9A28CFB31000727949 /* dydxStateManager.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = dydxStateManager.xcodeproj; path = ../dydx/dydxStateManager/dydxStateManager.xcodeproj; sourceTree = ""; }; 171807B0CCAE5C86B5D65793 /* Pods_iOS_dydxV4.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iOS_dydxV4.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 278A4D812B8FA3DA003898EB /* dydxRatingService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxRatingService.swift; sourceTree = ""; }; 27A7967A2A620BF6007C3D04 /* dydxSettingsStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxSettingsStore.swift; sourceTree = ""; }; 27D41AF02A8E9214009A2F37 /* UIApplication+URLHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIApplication+URLHandler.swift"; sourceTree = ""; }; 27DBDCED2A8FF5B2002383C6 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; @@ -1054,14 +1052,6 @@ name = Frameworks; sourceTree = ""; }; - 278A4D502B8FA3C3003898EB /* _Rating */ = { - isa = PBXGroup; - children = ( - 278A4D812B8FA3DA003898EB /* dydxRatingService.swift */, - ); - path = _Rating; - sourceTree = ""; - }; 27A796482A620BE4007C3D04 /* _Settings */ = { isa = PBXGroup; children = ( @@ -1096,7 +1086,6 @@ 3112F461216BBF8400708927 /* dydx */ = { isa = PBXGroup; children = ( - 278A4D502B8FA3C3003898EB /* _Rating */, 27A796482A620BE4007C3D04 /* _Settings */, 0262F07429DB3989009889E2 /* _Localizer */, 0217A07D29D78B10007F31C5 /* _Security */, @@ -2259,7 +2248,6 @@ buildActionMask = 2147483647; files = ( 27A7967B2A620BF6007C3D04 /* dydxSettingsStore.swift in Sources */, - 278A4D822B8FA3DA003898EB /* dydxRatingService.swift in Sources */, 02C7262B29D793C90098AFBC /* dydxCompositeTracking.swift in Sources */, 27D41AF12A8E9214009A2F37 /* UIApplication+URLHandler.swift in Sources */, 02756A6A287CA33E00803741 /* dydxNotificationHandlerDelegate.swift in Sources */, diff --git a/dydxV4/dydxV4.xcodeproj/xcshareddata/xcschemes/dydxV4.xcscheme b/dydxV4/dydxV4.xcodeproj/xcshareddata/xcschemes/dydxV4.xcscheme index f26717645..bbf6cc59c 100644 --- a/dydxV4/dydxV4.xcodeproj/xcshareddata/xcschemes/dydxV4.xcscheme +++ b/dydxV4/dydxV4.xcodeproj/xcshareddata/xcschemes/dydxV4.xcscheme @@ -170,6 +170,16 @@ ReferencedContainer = "container:dydxV4.xcodeproj"> + + + +