Skip to content

Commit 3eb3da9

Browse files
committed
Switch to old amplitude version due to leaking
1 parent 1c5c9f5 commit 3eb3da9

File tree

6 files changed

+70
-69
lines changed

6 files changed

+70
-69
lines changed

ForPDA.xcodeproj/project.pbxproj

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
B8001CDA2A1AA0FE00E7A8A8 /* CookiesService.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8001CD92A1AA0FE00E7A8A8 /* CookiesService.swift */; };
1919
B8001CDC2A1ADD4000E7A8A8 /* Cookie.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8001CDB2A1ADD4000E7A8A8 /* Cookie.swift */; };
2020
B8001CDF2A1B01D000E7A8A8 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8001CDE2A1B01D000E7A8A8 /* User.swift */; };
21+
B802964F2AACE50C00D5B413 /* Amplitude in Frameworks */ = {isa = PBXBuildFile; productRef = B802964E2AACE50C00D5B413 /* Amplitude */; };
2122
B809925B293CBF5C0053202C /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = B809925A293CBF5C0053202C /* SnapKit */; };
2223
B82B2EB32A87D58D00CB067C /* Sentry in Frameworks */ = {isa = PBXBuildFile; productRef = B82B2EB22A87D58D00CB067C /* Sentry */; };
23-
B82B2EB62A87D5F200CB067C /* AmplitudeSwift in Frameworks */ = {isa = PBXBuildFile; productRef = B82B2EB52A87D5F200CB067C /* AmplitudeSwift */; };
2424
B82B2EBE2A89016300CB067C /* Secrets.swift in Sources */ = {isa = PBXBuildFile; fileRef = B82B2EBD2A89016300CB067C /* Secrets.swift */; };
2525
B82B2EC12A89059C00CB067C /* AppScheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = B82B2EC02A89059C00CB067C /* AppScheme.swift */; };
2626
B82EFA252A896CBD00C8B2AC /* RouteComposer in Frameworks */ = {isa = PBXBuildFile; productRef = B82EFA242A896CBD00C8B2AC /* RouteComposer */; };
@@ -301,14 +301,14 @@
301301
B8D3521B293CBE46008A84EA /* SwiftSoup in Frameworks */,
302302
B83E8AC5294A75DA000D59E7 /* SwiftyGif in Frameworks */,
303303
B8BD2D79293E1C3F00E12E29 /* MarqueeLabel in Frameworks */,
304-
B82B2EB62A87D5F200CB067C /* AmplitudeSwift in Frameworks */,
305304
B8BD2D85293E242200E12E29 /* SwipeCellKit in Frameworks */,
306305
B82EFA252A896CBD00C8B2AC /* RouteComposer in Frameworks */,
307306
B89301192947CF5500D14141 /* SwiftRichString in Frameworks */,
308307
B8495D42294CCE1E00F60171 /* SwiftMessages in Frameworks */,
309308
B82B2EB32A87D58D00CB067C /* Sentry in Frameworks */,
310309
B84CCC52294A6EDA0001EB24 /* Nuke in Frameworks */,
311310
B88D3F592A098C600061C6C4 /* SFSafeSymbols in Frameworks */,
311+
B802964F2AACE50C00D5B413 /* Amplitude in Frameworks */,
312312
B8B55B022A07C948008C93D3 /* Factory in Frameworks */,
313313
);
314314
runOnlyForDeploymentPostprocessing = 0;
@@ -815,8 +815,8 @@
815815
B8B55B012A07C948008C93D3 /* Factory */,
816816
B88D3F582A098C600061C6C4 /* SFSafeSymbols */,
817817
B82B2EB22A87D58D00CB067C /* Sentry */,
818-
B82B2EB52A87D5F200CB067C /* AmplitudeSwift */,
819818
B82EFA242A896CBD00C8B2AC /* RouteComposer */,
819+
B802964E2AACE50C00D5B413 /* Amplitude */,
820820
);
821821
productName = ForPDA;
822822
productReference = B8D351F5293CABB6008A84EA /* ForPDA.app */;
@@ -867,8 +867,8 @@
867867
B8B55B002A07C948008C93D3 /* XCRemoteSwiftPackageReference "Factory" */,
868868
B88D3F572A098C600061C6C4 /* XCRemoteSwiftPackageReference "SFSafeSymbols" */,
869869
B82B2EB12A87D58D00CB067C /* XCRemoteSwiftPackageReference "sentry-cocoa" */,
870-
B82B2EB42A87D5F200CB067C /* XCRemoteSwiftPackageReference "Amplitude-Swift" */,
871870
B82EFA232A896CBD00C8B2AC /* XCRemoteSwiftPackageReference "route-composer" */,
871+
B802964D2AACE50C00D5B413 /* XCRemoteSwiftPackageReference "Amplitude-iOS" */,
872872
);
873873
productRefGroup = B8D351F6293CABB6008A84EA /* Products */;
874874
projectDirPath = "";
@@ -1477,6 +1477,14 @@
14771477
/* End XCConfigurationList section */
14781478

14791479
/* Begin XCRemoteSwiftPackageReference section */
1480+
B802964D2AACE50C00D5B413 /* XCRemoteSwiftPackageReference "Amplitude-iOS" */ = {
1481+
isa = XCRemoteSwiftPackageReference;
1482+
repositoryURL = "https://github.com/amplitude/Amplitude-iOS";
1483+
requirement = {
1484+
kind = upToNextMajorVersion;
1485+
minimumVersion = 8.17.1;
1486+
};
1487+
};
14801488
B8099259293CBF5C0053202C /* XCRemoteSwiftPackageReference "SnapKit" */ = {
14811489
isa = XCRemoteSwiftPackageReference;
14821490
repositoryURL = "https://github.com/SnapKit/SnapKit.git";
@@ -1493,14 +1501,6 @@
14931501
minimumVersion = 8.9.4;
14941502
};
14951503
};
1496-
B82B2EB42A87D5F200CB067C /* XCRemoteSwiftPackageReference "Amplitude-Swift" */ = {
1497-
isa = XCRemoteSwiftPackageReference;
1498-
repositoryURL = "https://github.com/amplitude/Amplitude-Swift.git";
1499-
requirement = {
1500-
kind = upToNextMajorVersion;
1501-
minimumVersion = 0.4.11;
1502-
};
1503-
};
15041504
B82EFA232A896CBD00C8B2AC /* XCRemoteSwiftPackageReference "route-composer" */ = {
15051505
isa = XCRemoteSwiftPackageReference;
15061506
repositoryURL = "https://github.com/ekazaev/route-composer";
@@ -1600,6 +1600,11 @@
16001600
/* End XCRemoteSwiftPackageReference section */
16011601

16021602
/* Begin XCSwiftPackageProductDependency section */
1603+
B802964E2AACE50C00D5B413 /* Amplitude */ = {
1604+
isa = XCSwiftPackageProductDependency;
1605+
package = B802964D2AACE50C00D5B413 /* XCRemoteSwiftPackageReference "Amplitude-iOS" */;
1606+
productName = Amplitude;
1607+
};
16031608
B809925A293CBF5C0053202C /* SnapKit */ = {
16041609
isa = XCSwiftPackageProductDependency;
16051610
package = B8099259293CBF5C0053202C /* XCRemoteSwiftPackageReference "SnapKit" */;
@@ -1610,11 +1615,6 @@
16101615
package = B82B2EB12A87D58D00CB067C /* XCRemoteSwiftPackageReference "sentry-cocoa" */;
16111616
productName = Sentry;
16121617
};
1613-
B82B2EB52A87D5F200CB067C /* AmplitudeSwift */ = {
1614-
isa = XCSwiftPackageProductDependency;
1615-
package = B82B2EB42A87D5F200CB067C /* XCRemoteSwiftPackageReference "Amplitude-Swift" */;
1616-
productName = AmplitudeSwift;
1617-
};
16181618
B82EFA242A896CBD00C8B2AC /* RouteComposer */ = {
16191619
isa = XCSwiftPackageProductDependency;
16201620
package = B82EFA232A896CBD00C8B2AC /* XCRemoteSwiftPackageReference "route-composer" */;

ForPDA.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 13 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ForPDA.xcodeproj/xcshareddata/xcschemes/ForPDA.xcscheme

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,29 +68,11 @@
6868
ReferencedContainer = "container:ForPDA.xcodeproj">
6969
</BuildableReference>
7070
</BuildableProductRunnable>
71-
<CommandLineArguments>
72-
<CommandLineArgument
73-
argument = "-FIRAnalyticsDebugEnabled"
74-
isEnabled = "NO">
75-
</CommandLineArgument>
76-
<CommandLineArgument
77-
argument = "-FIRDebugEnabled"
78-
isEnabled = "NO">
79-
</CommandLineArgument>
80-
<CommandLineArgument
81-
argument = "-FIRAnalyticsDebugDisabled"
82-
isEnabled = "NO">
83-
</CommandLineArgument>
84-
<CommandLineArgument
85-
argument = "-FIRDebugDisabled"
86-
isEnabled = "NO">
87-
</CommandLineArgument>
88-
</CommandLineArguments>
8971
<EnvironmentVariables>
9072
<EnvironmentVariable
9173
key = "OS_ACTIVITY_MODE"
9274
value = "${DEBUG_ACTIVITY_MODE}"
93-
isEnabled = "YES">
75+
isEnabled = "NO">
9476
</EnvironmentVariable>
9577
</EnvironmentVariables>
9678
</LaunchAction>

ForPDA/Sources/Application/AppDelegate.swift

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,21 @@
88
import UIKit
99
import SnapKit
1010
import Factory
11+
import Amplitude
1112
import Sentry
1213
import Nuke
1314
import RouteComposer
1415

1516
@main
1617
class AppDelegate: UIResponder, UIApplicationDelegate {
1718

18-
@Injected(\.networkService) private var networkService
1919
@Injected(\.settingsService) private var settingsService
2020

2121
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
22-
23-
SentrySDK.start { options in
24-
options.dsn = Secrets.for(key: .SENTRY_DSN)
25-
options.debug = AppScheme.isDebug
26-
options.enabled = !AppScheme.isDebug
27-
options.tracesSampleRate = 1.0
28-
options.diagnosticLevel = .warning
29-
options.attachScreenshot = true
30-
}
31-
32-
ImagePipeline.shared = ImagePipeline(configuration: .withDataCache)
3322

23+
configureAmplitude()
24+
configureSentry()
25+
configureNuke()
3426
configureCookies()
3527

3628
return true
@@ -44,10 +36,38 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
4436

4537
}
4638

47-
// MARK: - Cookies
39+
// MARK: - Configuration
4840

4941
extension AppDelegate {
5042

43+
// MARK: Amplitude
44+
45+
private func configureAmplitude() {
46+
Amplitude.instance().defaultTracking.sessions = true
47+
Amplitude.instance().initializeApiKey(Secrets.for(key: .AMPLITUDE_TOKEN))
48+
}
49+
50+
// MARK: Sentry
51+
52+
private func configureSentry() {
53+
SentrySDK.start { options in
54+
options.dsn = Secrets.for(key: .SENTRY_DSN)
55+
options.debug = AppScheme.isDebug
56+
options.enabled = !AppScheme.isDebug
57+
options.tracesSampleRate = 1.0
58+
options.diagnosticLevel = .warning
59+
options.attachScreenshot = true
60+
}
61+
}
62+
63+
// MARK: Nuke
64+
65+
private func configureNuke() {
66+
ImagePipeline.shared = ImagePipeline(configuration: .withDataCache)
67+
}
68+
69+
// MARK: Cookies
70+
5171
func configureCookies() {
5272
// We need 3 cookies to authorize: anonymous, member_id, pass_hash
5373
// There's also __fixmid cookie, but it lasts for a second and then removed

ForPDA/Sources/Services/Analytics/AnalyticsService.swift

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,27 @@
77
// swiftlint:disable nesting
88

99
import Foundation
10-
import AmplitudeSwift
10+
import Amplitude
1111

1212
final class AnalyticsService {
1313

1414
typealias EventDictionary = [String: String]
1515

16-
private let amplitude = Amplitude(configuration: Configuration(
17-
apiKey: Secrets.for(key: .AMPLITUDE_TOKEN),
18-
logLevel: .WARN,
19-
serverZone: .EU
20-
))
21-
2216
let isDebug: Bool
2317

2418
init(isDebug: Bool = false) {
2519
self.isDebug = isDebug
26-
amplitude.configuration.optOut = isDebug
2720
}
2821

2922
// MARK: - Generic Event
3023

3124
private func event(_ name: AnalyticsEvent, parameters: EventDictionary?) {
3225
guard !isDebug else { return }
33-
let event = BaseEvent(
34-
eventType: name.rawValue,
35-
eventProperties: parameters
36-
)
3726

38-
amplitude.track(event: event)
27+
Amplitude.instance().logEvent(
28+
name.rawValue,
29+
withEventProperties: parameters
30+
)
3931
}
4032

4133
// MARK: - Parameters Cases

ForPDA/Sources/Services/Container.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ extension Container {
2020
}
2121

2222
var analyticsService: Factory<AnalyticsService> {
23-
Factory(self) { AnalyticsService() }
24-
.onDebug { AnalyticsService(isDebug: AppScheme.isDebug) }
25-
.singleton
23+
Factory(self) { AnalyticsService(isDebug: AppScheme.isDebug) }
2624
}
2725

2826
var settingsService: Factory<SettingsService> {

0 commit comments

Comments
 (0)