Skip to content

Commit

Permalink
Use the Tracks Sentry integration
Browse files Browse the repository at this point in the history
  • Loading branch information
jkmassel authored Jul 4, 2019
1 parent c202dd4 commit 7a00a14
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 165 deletions.
11 changes: 9 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def shared_with_all_pods
pod 'CocoaLumberjack', '3.5.2'
pod 'FormatterKit/TimeIntervalFormatter', '1.8.2'
pod 'NSObject-SafeExpectations', '0.0.3'
pod 'Sentry', '4.3.1'
end

def shared_with_networking_pods
Expand Down Expand Up @@ -147,7 +146,7 @@ target 'WordPress' do
##

# Production
pod 'Automattic-Tracks-iOS', '0.3.5'
pod 'Automattic-Tracks-iOS', '~> 0.4'
# While in PR
# pod 'Automattic-Tracks-iOS', :git => 'https://github.com/Automattic/Automattic-Tracks-iOS.git', :commit => 'a15db91a24499913affae84243d45be0e353472a'

Expand Down Expand Up @@ -351,6 +350,14 @@ pre_install do |installer|
static = []
dynamic = []
installer.pod_targets.each do |pod|

# Statically linking Sentry results in a conflict with `NSDictionary.objectAtKeyPath`, but dynamically
# linking it resolves this.
if pod.name == "Sentry"
dynamic << pod
next
end

# If this pod is a dependency of one of our shared targets, it must be linked dynamically
if pod.target_definitions.any? { |t| shared_targets.include? t.name }
dynamic << pod
Expand Down
18 changes: 9 additions & 9 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ PODS:
- Alamofire (4.7.3)
- AlamofireNetworkActivityIndicator (2.3.0):
- Alamofire (~> 4.7)
- Automattic-Tracks-iOS (0.3.5):
- Automattic-Tracks-iOS (0.4.0):
- CocoaLumberjack (~> 3.5.2)
- Reachability (~> 3.1)
- Sentry (~> 4)
- UIDeviceIdentifier (~> 1.1.4)
- boost-for-react-native (1.63.0)
- Charts (3.2.2):
Expand Down Expand Up @@ -170,9 +171,9 @@ PODS:
- RNTAztecView (1.8.0):
- React
- WordPress-Aztec-iOS
- Sentry (4.3.1):
- Sentry/Core (= 4.3.1)
- Sentry/Core (4.3.1)
- Sentry (4.3.4):
- Sentry/Core (= 4.3.4)
- Sentry/Core (4.3.4)
- SimulatorStatusMagic (2.4.1)
- Starscream (3.0.6)
- SVProgressHUD (2.2.5)
Expand Down Expand Up @@ -222,7 +223,7 @@ DEPENDENCIES:
- 1PasswordExtension (= 1.8.5)
- Alamofire (= 4.7.3)
- AlamofireNetworkActivityIndicator (~> 2.3)
- Automattic-Tracks-iOS (= 0.3.5)
- Automattic-Tracks-iOS (~> 0.4)
- Charts (~> 3.2.2)
- CocoaLumberjack (= 3.5.2)
- Down (~> 0.6.6)
Expand All @@ -249,7 +250,6 @@ DEPENDENCIES:
- react-native-video (from `https://github.com/wordpress-mobile/gutenberg-mobile/v1.8.0/react-native-gutenberg-bridge/third-party-podspecs/react-native-video.podspec.json`)
- RNSVG (from `https://github.com/wordpress-mobile/react-native-svg.git`, tag `9.3.3-gb`)
- RNTAztecView (from `http://github.com/wordpress-mobile/gutenberg-mobile/`, tag `v1.8.0`)
- Sentry (= 4.3.1)
- SimulatorStatusMagic
- Starscream (= 3.0.6)
- SVProgressHUD (= 2.2.5)
Expand Down Expand Up @@ -358,7 +358,7 @@ SPEC CHECKSUMS:
1PasswordExtension: 0e95bdea64ec8ff2f4f693be5467a09fac42a83d
Alamofire: c7287b6e5d7da964a70935e5db17046b7fde6568
AlamofireNetworkActivityIndicator: 18346ff6d770d9513d0ac6f2d99706f40f93dbaa
Automattic-Tracks-iOS: 1ba339ac16d6aff577b7f0ec16546be2a7ccd64a
Automattic-Tracks-iOS: f7a8284999a5ce2f4e768717d86a640a32f43b7c
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
Charts: f69cf0518b6d1d62608ca504248f1bbe0b6ae77e
CocoaLumberjack: 118bf4a820efc641f79fa487b75ed928dccfae23
Expand Down Expand Up @@ -391,7 +391,7 @@ SPEC CHECKSUMS:
react-native-video: 9aecbfc4628128838187df9d9c9f630670cfb1d1
RNSVG: 978db19eaef499d9ebffb74a091ca0abf209c8c1
RNTAztecView: 885d5497b894ab20a5200f1d9b958792f52bb244
Sentry: 5267d493a398663538317e4dcc438c12c66202ed
Sentry: 26f0e6492b103e87434d1a5eea2d241a36f2c2a2
SimulatorStatusMagic: 28d4a9d1a500ac7cea0b2b5a43c1c6ddb40ba56c
Starscream: ef3ece99d765eeccb67de105bfa143f929026cf5
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
Expand All @@ -409,6 +409,6 @@ SPEC CHECKSUMS:
ZendeskSDK: cbd49d65efb2f2cdbdcaac84e618896ae87b861e
ZIPFoundation: 89df685c971926b0323087952320bdfee9f0b6ef

PODFILE CHECKSUM: f8981f1bdd327ec35f0017bb0d85d715baa3c42c
PODFILE CHECKSUM: 9500c157b4a0ffc32da7461e3a21e5c43271e50e

COCOAPODS: 1.6.1
1 change: 1 addition & 0 deletions WordPress/Classes/Services/BlogService.m
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ - (void)updateBlog:(Blog *)blog withRemoteBlog:(RemoteBlog *)remoteBlog
- (Blog *)migrateRemoteJetpackBlog:(RemoteBlog *)remoteBlog
forAccount:(WPAccount *)account
{
assert(remoteBlog.xmlrpc != nil);
NSURL *xmlrpcURL = [NSURL URLWithString:remoteBlog.xmlrpc];
NSURLComponents *components = [NSURLComponents componentsWithURL:xmlrpcURL resolvingAgainstBaseURL:NO];
if ([components.scheme isEqualToString:@"https"]) {
Expand Down
3 changes: 2 additions & 1 deletion WordPress/Classes/System/WordPressAppDelegate+openURL.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import WordPressAuthenticator
import AutomatticTracks

@objc extension WordPressAppDelegate {
internal func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
Expand Down Expand Up @@ -111,7 +112,7 @@ import WordPressAuthenticator
}

if debugKey == ApiCredentials.debuggingKey(), debugType == "force_crash" {
WPCrashLogging.crash()
CrashLogging.crash()
}

return true
Expand Down
9 changes: 4 additions & 5 deletions WordPress/Classes/System/WordPressAppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class WordPressAppDelegate: UIResponder, UIApplicationDelegate {

var analytics: WPAppAnalytics?
var hockey: HockeyManager?
private lazy var crashLoggingProvider: WPCrashLoggingProvider = {
return WPCrashLoggingProvider()
}()

@objc var logger: WPLogger?
@objc var internetReachability: Reachability?
Expand Down Expand Up @@ -190,7 +193,7 @@ class WordPressAppDelegate: UIResponder, UIApplicationDelegate {

logger = WPLogger()

WPCrashLogging.start()
CrashLogging.start(withDataProvider: crashLoggingProvider)

configureHockeySDK()
configureAppRatingUtility()
Expand Down Expand Up @@ -337,10 +340,6 @@ extension WordPressAppDelegate {
})
}

@objc func configureCrashLogging() {
WPCrashLogging.start()
}

@objc func configureHockeySDK() {
hockey = HockeyManager()
hockey?.configure()
Expand Down
135 changes: 0 additions & 135 deletions WordPress/Classes/Utility/Logging/WPCrashLogging.swift

This file was deleted.

26 changes: 26 additions & 0 deletions WordPress/Classes/Utility/Logging/WPCrashLoggingProvider.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Foundation
import AutomatticTracks

fileprivate let UserOptedOutKey = "crashlytics_opt_out"

class WPCrashLoggingProvider: CrashLoggingDataProvider {

var sentryDSN: String = ApiCredentials.sentryDSN()

var buildType: String = BuildConfiguration.current.rawValue

var userHasOptedOut: Bool {
return UserDefaults.standard.bool(forKey: UserOptedOutKey)
}

var currentUser: TracksUser? {

let context = ContextManager.sharedInstance().mainContext
let service = AccountService(managedObjectContext: context)
guard let account = service.defaultWordPressComAccount() else {
return nil
}

return TracksUser(userID: account.userID.stringValue, email: account.email, username: account.username)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import WordPressEditor
import WPMediaPicker
import AVKit
import MobileCoreServices

import AutomatticTracks

// MARK: - Aztec's Native Editor!
//
Expand Down Expand Up @@ -1030,7 +1030,7 @@ extension AztecPostViewController {
guard let action = self.postEditorStateContext.secondaryPublishButtonAction else {
// If the user tapped on the secondary publish action button, it means we should have a secondary publish action.
let error = NSError(domain: errorDomain, code: ErrorCode.expectedSecondaryAction.rawValue, userInfo: nil)
WPCrashLogging.logError(error)
CrashLogging.logError(error)
return
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import AutomatticTracks

/// This extension handles the "more" actions triggered by the top right
/// navigation bar button of Gutenberg editor.
Expand Down Expand Up @@ -68,7 +69,7 @@ extension GutenbergViewController {
guard let action = self.postEditorStateContext.secondaryPublishButtonAction else {
// If the user tapped on the secondary publish action button, it means we should have a secondary publish action.
let error = NSError(domain: errorDomain, code: ErrorCode.expectedSecondaryAction.rawValue, userInfo: nil)
WPCrashLogging.logError(error)
CrashLogging.logError(error)
return
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Gridicons
import UIKit
import AutomatticTracks

class PrivacySettingsViewController: UITableViewController {
fileprivate var handler: ImmuTableViewHandler!
Expand Down Expand Up @@ -113,7 +114,7 @@ class PrivacySettingsViewController: UITableViewController {
let accountService = AccountService(managedObjectContext: ContextManager.sharedInstance().mainContext)
AccountSettingsHelper(accountService: accountService).updateTracksOptOutSetting(!enabled)

WPCrashLogging.userHasOptedOut = !enabled
CrashLogging.setNeedsDataRefresh()
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import AutomatticTracks

@objc
protocol PostPreviewGeneratorDelegate {
Expand Down Expand Up @@ -39,7 +40,7 @@ class PostPreviewGenerator: NSObject {
@objc func previewRequestFailed(reason: String) {
let message = "Preview failed"
let properties = ["reason": reason]
WPCrashLogging.logMessage(message, properties: properties)
CrashLogging.logMessage(message, properties: properties)
delegate?.previewFailed(self, message: NSLocalizedString("There has been an error while trying to reach your site.", comment: "An error message."))
}

Expand Down
Loading

0 comments on commit 7a00a14

Please sign in to comment.