Merge pull request #46 from loki-project/mixpanel

Analytics
pull/47/head
gmbnt 6 years ago committed by GitHub
commit e0a4b982ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -62,7 +62,6 @@ def shared_pods
pod 'PureLayout', :inhibit_warnings => true
pod 'Reachability', :inhibit_warnings => true
pod 'YYImage', :inhibit_warnings => true
pod 'CryptoSwift', :inhibit_warnings => true
pod 'IGIdenticon', :inhibit_warnings => true
end
@ -72,8 +71,10 @@ target 'Signal' do
pod 'SSZipArchive', :inhibit_warnings => true
# Loki
pod 'GCDWebServer', '~> 3.0'
pod 'FeedKit', '~> 8.1'
pod 'GCDWebServer', '~> 3.0', :inhibit_warnings => true
pod 'FeedKit', '~> 8.1', :inhibit_warnings => true
pod 'CryptoSwift', '~> 1.0', :inhibit_warnings => true
pod 'Mixpanel', '~> 3.4', :inhibit_warnings => true
target 'SignalTests' do
inherit! :search_paths

@ -52,6 +52,7 @@ PODS:
- Mantle (2.1.0):
- Mantle/extobjc (= 2.1.0)
- Mantle/extobjc (2.1.0)
- Mixpanel (3.4.7)
- PromiseKit (6.5.3):
- PromiseKit/CorePromise (= 6.5.3)
- PromiseKit/Foundation (= 6.5.3)
@ -196,7 +197,7 @@ DEPENDENCIES:
- AFNetworking
- AxolotlKit (from `https://github.com/signalapp/SignalProtocolKit.git`, branch `master`)
- AxolotlKit/Tests (from `https://github.com/signalapp/SignalProtocolKit.git`, branch `master`)
- CryptoSwift
- CryptoSwift (~> 1.0)
- Curve25519Kit (from `https://github.com/signalapp/Curve25519Kit`)
- Curve25519Kit/Tests (from `https://github.com/signalapp/Curve25519Kit`)
- FeedKit (~> 8.1)
@ -206,6 +207,7 @@ DEPENDENCIES:
- HKDFKit/Tests (from `https://github.com/signalapp/HKDFKit.git`)
- IGIdenticon
- Mantle (from `https://github.com/signalapp/Mantle`, branch `signal-master`)
- Mixpanel (~> 3.4)
- PromiseKit (= 6.5.3)
- PureLayout
- Reachability
@ -230,6 +232,7 @@ SPEC REPOS:
- GCDWebServer
- IGIdenticon
- libPhoneNumber-iOS
- Mixpanel
- PromiseKit
- PureLayout
- Reachability
@ -307,6 +310,7 @@ SPEC CHECKSUMS:
IGIdenticon: 5790befde4fe56296927c72c0efed3d07b21de8e
libPhoneNumber-iOS: e444379ac18bbfbdefad571da735b2cd7e096caa
Mantle: 2fa750afa478cd625a94230fbf1c13462f29395b
Mixpanel: 696e0a1c7f2685aa06bb23829b7a58ab7203d6c7
PromiseKit: c609029bdd801f792551a504c695c7d3098b42cd
PureLayout: f08c01b8dec00bb14a1fefa3de4c7d9c265df85e
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
@ -321,6 +325,6 @@ SPEC CHECKSUMS:
YapDatabase: b418a4baa6906e8028748938f9159807fd039af4
YYImage: 1e1b62a9997399593e4b9c4ecfbbabbf1d3f3b54
PODFILE CHECKSUM: 95f41137d4fe8c5b8a27de951b328f8c9531d166
PODFILE CHECKSUM: 0666e8fade5ac5ba48d0b3c9cb83b2095d1b3cef
COCOAPODS: 1.5.3

@ -1 +1 @@
Subproject commit 8b30c2d91fe7f9743350dd30521b5ca74e78766c
Subproject commit eea56e7a7f25a5a9e282c742cf1c618765ca5ca8

@ -3291,6 +3291,7 @@
"${BUILT_PRODUCTS_DIR}/HKDFKit/HKDFKit.framework",
"${BUILT_PRODUCTS_DIR}/IGIdenticon/IGIdenticon.framework",
"${BUILT_PRODUCTS_DIR}/Mantle/Mantle.framework",
"${BUILT_PRODUCTS_DIR}/Mixpanel/Mixpanel.framework",
"${BUILT_PRODUCTS_DIR}/PromiseKit/PromiseKit.framework",
"${BUILT_PRODUCTS_DIR}/PureLayout/PureLayout.framework",
"${BUILT_PRODUCTS_DIR}/Reachability/Reachability.framework",
@ -3319,6 +3320,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/HKDFKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/IGIdenticon.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Mantle.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Mixpanel.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PromiseKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PureLayout.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Reachability.framework",

@ -46,6 +46,7 @@
#import <SignalServiceKit/TSSocketManager.h>
#import <YapDatabase/YapDatabaseCryptoUtils.h>
#import <sys/utsname.h>
#import <Mixpanel/Mixpanel.h>
@import WebRTC;
@import Intents;
@ -348,6 +349,13 @@ static NSTimeInterval launchStartedAt;
// NSLog(@"[Loki] Failed to start P2P server.");
// }
// Loki - Set up beta analytics
[Mixpanel sharedInstanceWithToken:@"0410357303b7b6b45b740e6f0e6d34be"];
LKAnalytics.shared.trackImplementation = ^(NSString *event) {
NSDictionary *properties = @{ @"configuration" : LKBuildConfiguration.current };
[Mixpanel.sharedInstance track:event properties:properties];
};
return YES;
}

@ -91,6 +91,7 @@ final class NewConversationViewController : OWSViewController, OWSQRScannerDeleg
}
func controller(_ controller: OWSQRCodeScanningViewController, didDetectQRCodeWith string: String) {
Analytics.shared.track("QR Code Scanned")
let hexEncodedPublicKey = string
startNewConversationIfPossible(with: hexEncodedPublicKey)
}
@ -111,6 +112,7 @@ final class NewConversationViewController : OWSViewController, OWSQRScannerDeleg
presentAlert(alert)
} else {
let thread = TSContactThread.getOrCreateThread(contactId: hexEncodedPublicKey)
Analytics.shared.track("New Conversation Started")
SignalApp.shared().presentConversation(for: thread, action: .compose, animated: false)
presentingViewController!.dismiss(animated: true, completion: nil)
}

@ -207,6 +207,7 @@ final class SeedViewController : OnboardingBaseViewController {
@objc private func registerOrRestore() {
var seed: Data
let mode = self.mode
switch mode {
case .register: seed = self.seed
case .restore:
@ -232,6 +233,10 @@ final class SeedViewController : OnboardingBaseViewController {
accountManager.phoneNumberAwaitingVerification = hexEncodedPublicKey
accountManager.didRegister()
let onSuccess = { [weak self] in
switch mode {
case .register: Analytics.shared.track("Seed Created")
case .restore: Analytics.shared.track("Seed Restored")
}
guard let strongSelf = self else { return }
strongSelf.onboardingController.verificationDidComplete(fromView: strongSelf)
UserDefaults.standard.set(true, forKey: "didUpdateForMainnet")

@ -611,6 +611,16 @@ typedef enum : NSUInteger {
[self loadDraftInCompose];
[self applyTheme];
[self.conversationViewModel viewDidLoad];
if (self.thread.isGroupThread) {
if (self.isRSSFeed) {
[LKAnalytics.shared track:@"RSS Feed Opened"];
} else {
[LKAnalytics.shared track:@"Loki Public Chat Opened"];
}
} else {
[LKAnalytics.shared track:@"Conversation Opened"];
}
}
- (void)createContents

@ -74,6 +74,9 @@ public extension LokiAPI {
return LokiAPITarget(address: "https://\(address)", port: UInt16(port))
})
return randomSnodePool.randomElement()!
}.recover { error -> Promise<LokiAPITarget> in
Analytics.shared.track("Seed Node Failed")
throw error
}
} else {
return Promise<LokiAPITarget> { seal in
@ -126,6 +129,7 @@ internal extension Promise {
let newFailureCount = oldFailureCount + 1
LokiAPI.failureCount[target] = newFailureCount
print("[Loki] Couldn't reach snode at: \(target); setting failure count to \(newFailureCount).")
Analytics.shared.track("Unreachable Snode")
if newFailureCount >= LokiAPI.failureThreshold {
print("[Loki] Failure threshold reached for: \(target); dropping it.")
LokiAPI.dropIfNeeded(target, hexEncodedPublicKey: hexEncodedPublicKey) // Remove it from the swarm cache associated with the given public key
@ -135,6 +139,7 @@ internal extension Promise {
case 421:
// The snode isn't associated with the given public key anymore
print("[Loki] Invalidating swarm for: \(hexEncodedPublicKey).")
Analytics.shared.track("Migrated Snode")
LokiAPI.dropIfNeeded(target, hexEncodedPublicKey: hexEncodedPublicKey)
case 432:
// The PoW difficulty is too low

@ -178,7 +178,13 @@ public final class LokiGroupChatAPI : NSObject {
storage.dbReadWriteConnection.removeObject(forKey: server, inCollection: authTokenCollection)
}
throw error
}.retryingIfNeeded(maxRetryCount: maxRetryCount)
}.retryingIfNeeded(maxRetryCount: maxRetryCount).map { message in
Analytics.shared.track("Group Message Sent")
return message
}.recover { error -> Promise<LokiGroupMessage> in
Analytics.shared.track("Failed to Send Group Message")
throw error
}
}
public static func getDeletedMessageServerIDs(for group: UInt64, on server: String) -> Promise<[UInt64]> {

@ -0,0 +1,11 @@
@objc(LKAnalytics)
public final class Analytics : NSObject {
@objc public var trackImplementation: ((String) -> Void)! // Set in AppDelegate.m
@objc public static let shared = Analytics()
@objc public func track(_ event: String) {
trackImplementation(event)
}
}

@ -1,5 +1,5 @@
public enum BuildConfiguration {
public enum BuildConfiguration : CustomStringConvertible {
case debug, production
public static let current: BuildConfiguration = {
@ -9,4 +9,18 @@ public enum BuildConfiguration {
return .production
#endif
}()
public var description: String {
switch self {
case .debug: return "debug"
case .production: return "production"
}
}
}
@objc public final class LKBuildConfiguration : NSObject {
override private init() { }
@objc public static var current: String { return BuildConfiguration.current.description }
}

@ -1171,6 +1171,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
[promise
.thenOn(OWSDispatch.sendingQueue, ^(id result) {
if (isSuccess) { return; } // Succeed as soon as the first promise succeeds
[LKAnalytics.shared track:@"Sent Message Using Swarm API"];
isSuccess = YES;
if (signalMessage.type == TSFriendRequestMessageType) {
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
@ -1190,6 +1191,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
.catchOn(OWSDispatch.sendingQueue, ^(NSError *error) {
errorCount += 1;
if (errorCount != promiseCount) { return; } // Only error out if all promises failed
[LKAnalytics.shared track:@"Failed to Send Message Using Swarm API"];
handleError(error);
}) retainUntilComplete];
}

Loading…
Cancel
Save