Merge pull request #2159 from fridtjof/matomo-v6

Rename PiwikTracker to MatomoTracker and update to version 6.0.1
This commit is contained in:
manuroe 2019-06-19 15:31:53 +02:00 committed by GitHub
commit 8010133d6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 60 additions and 54 deletions

View file

@ -8,6 +8,7 @@ Improvements:
* Menu actions: Display message time (#2463).
* Reactions Menu: Fix position (#2447).
* Context menu polish (#2466).
* Upgrade Piwik/MatomoTracker (v6.0.1) (#2159).
* Message Editing: Annotate edited messages in timeline (#2400).
* Message Editing: Editing in the timeline (#2404).
* Read receipts: They are now counted at the MatrixKit level.
@ -55,7 +56,7 @@ Changes in 0.8.4 (2019-03-21)
Improvements:
* Upgrade MatrixKit version ([v0.9.8](https://github.com/matrix-org/matrix-ios-kit/releases/tag/v0.9.8)).
* Share extension: Remove image large size resizing choice if output dimension is too high to prevent memory limit exception (PR #2342).
Bug fix:
* Unable to open a file attachment of a room message (#2338).
@ -64,7 +65,7 @@ Changes in 0.8.3 (2019-03-13)
Improvements:
* Upgrade MatrixKit version ([v0.9.7](https://github.com/matrix-org/matrix-ios-kit/releases/tag/v0.9.7)).
Bug fix:
* Widgets: Attempt to re-register for a scalar token if ours is invalid (#2326).
* Widgets: Pass scalar_token only when required.
@ -126,7 +127,7 @@ Improvements:
* Key backup: Update key backup setup UI and UX (PR #2243).
* Key backup: Logout warning (#2245).
* Key backup: new recover method detected (#2230).
Bug fix:
* Use white scroll bar on dark themes (#2158).
* Registration: fix tap gesture on checkboxes in the terms screen.

12
Podfile
View file

@ -63,16 +63,14 @@ abstract_target 'RiotPods' do
pod 'Reusable', '~> 4.0'
# Piwik for analytics
# While https://github.com/matomo-org/matomo-sdk-ios/pull/223 is not released, use the PR branch
pod 'PiwikTracker', :git => 'https://github.com/manuroe/matomo-sdk-ios.git', :branch => 'feature/CustomVariables'
#pod 'PiwikTracker', '~> 4.4.2'
pod 'MatomoTracker', '~> 6.0.1'
# Remove warnings from "bad" pods
pod 'OLMKit', :inhibit_warnings => true
pod 'cmark', :inhibit_warnings => true
pod 'DTCoreText', :inhibit_warnings => true
pod 'zxcvbn-ios'
# Tools
pod 'SwiftGen', '~> 6.1'
pod 'SwiftLint', '~> 0.30.1'
@ -101,13 +99,7 @@ post_install do |installer|
# Plus the app does not enable it
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
# Required for PiwikTracker as `swift_version` is not defined in podspec. Should be removed
if target.name.include? 'PiwikTracker'
config.build_settings['SWIFT_VERSION'] = '4.0'
end
end
end
end

View file

@ -15,6 +15,7 @@ PODS:
- AFNetworking/UIKit (3.2.1):
- AFNetworking/NSURLSession
- cmark (0.24.1)
- DGCollectionViewLeftAlignFlowLayout (1.0.4)
- DTCoreText (1.6.21):
- DTCoreText/Core (= 1.6.21)
- DTFoundation/Core (~> 1.7.5)
@ -45,6 +46,9 @@ PODS:
- JitsiMeetSDK (2.1.0)
- libbase58 (0.1.4)
- libPhoneNumber-iOS (0.9.13)
- MatomoTracker (6.0.1):
- MatomoTracker/Core (= 6.0.1)
- MatomoTracker/Core (6.0.1)
- MatrixKit (0.9.9):
- cmark (~> 0.24.1)
- DTCoreText (~> 1.6.21)
@ -83,9 +87,6 @@ PODS:
- OLMKit/olmcpp (= 3.1.0)
- OLMKit/olmc (3.1.0)
- OLMKit/olmcpp (3.1.0)
- PiwikTracker (4.4.2):
- PiwikTracker/Core (= 4.4.2)
- PiwikTracker/Core (4.4.2)
- Realm (3.13.1):
- Realm/Headers (= 3.13.1)
- Realm/Headers (3.13.1)
@ -100,14 +101,15 @@ PODS:
DEPENDENCIES:
- cmark
- DGCollectionViewLeftAlignFlowLayout (~> 1.0.4)
- DTCoreText
- GBDeviceInfo (~> 5.2.0)
- MatomoTracker (~> 6.0.1)
- MatrixKit (= 0.9.9)
- MatrixKit/AppExtension (= 0.9.9)
- MatrixSDK/JingleCallStack
- MatrixSDK/SwiftSupport
- OLMKit
- PiwikTracker (from `https://github.com/manuroe/matomo-sdk-ios.git`, branch `feature/CustomVariables`)
- Reusable (~> 4.0)
- SwiftGen (~> 6.1)
- SwiftLint (~> 0.30.1)
@ -117,6 +119,7 @@ SPEC REPOS:
https://github.com/cocoapods/specs.git:
- AFNetworking
- cmark
- DGCollectionViewLeftAlignFlowLayout
- DTCoreText
- DTFoundation
- GBDeviceInfo
@ -125,6 +128,7 @@ SPEC REPOS:
- JitsiMeetSDK
- libbase58
- libPhoneNumber-iOS
- MatomoTracker
- MatrixKit
- MatrixSDK
- OLMKit
@ -134,19 +138,10 @@ SPEC REPOS:
- SwiftLint
- zxcvbn-ios
EXTERNAL SOURCES:
PiwikTracker:
:branch: feature/CustomVariables
:git: https://github.com/manuroe/matomo-sdk-ios.git
CHECKOUT OPTIONS:
PiwikTracker:
:commit: dfb048f25f4eefbe13ff7515c3c1c2cad5d94491
:git: https://github.com/manuroe/matomo-sdk-ios.git
SPEC CHECKSUMS:
AFNetworking: b6f891fdfaed196b46c7a83cf209e09697b94057
cmark: ec0275215b504780287b6fca360224e384368af8
DGCollectionViewLeftAlignFlowLayout: a0fa58797373ded039cafba8133e79373d048399
DTCoreText: e5d688cffc9f6a61eddd1a4f94e2046851230de3
DTFoundation: f03be9fd786f11e505bb8fc44e2a3732bf0917df
GBDeviceInfo: 2c65ceb9404f9079264d4c238f5b81916fdfc5e2
@ -155,16 +150,16 @@ SPEC CHECKSUMS:
JitsiMeetSDK: 3e66564af7f38a19142338955dd7f581801852b3
libbase58: 7c040313537b8c44b6e2d15586af8e21f7354efd
libPhoneNumber-iOS: e444379ac18bbfbdefad571da735b2cd7e096caa
MatomoTracker: 3ae4f65a1f5ace8043bda7244888fee28a734de5
MatrixKit: 6f553797e1ad42794b5336afb5cecb975ec69daa
MatrixSDK: ed0d0cee4877955052f19730bb3ee727e01ec948
OLMKit: 4ee0159d63feeb86d836fdcfefe418e163511639
PiwikTracker: 42862c7b13028065c3dfd36b4dc38db8a5765acf
Realm: 50071da38fe079e0735e47c9f2eae738c68c5996
Reusable: 188be1a54ac0691bc66e5bb24ec6eb91971b315b
SwiftGen: f872ca75cbd17bf7103c17f13dcfa0d9a15667b0
SwiftLint: a54bf1fe12b55c68560eb2a7689dfc81458508f7
zxcvbn-ios: fef98b7c80f1512ff0eec47ac1fa399fc00f7e3c
PODFILE CHECKSUM: cfb6be050dfbb227d58b14434629e447ea54554b
PODFILE CHECKSUM: 16b6518b09d4e3af0af46ed9c1338e9df8674aff
COCOAPODS: 1.6.1

View file

@ -3691,10 +3691,10 @@
"${BUILT_PRODUCTS_DIR}/HPGrowingTextView/HPGrowingTextView.framework",
"${PODS_ROOT}/JitsiMeetSDK/Frameworks/JitsiMeet.framework",
"${PODS_ROOT}/JitsiMeetSDK/Frameworks/WebRTC.framework",
"${BUILT_PRODUCTS_DIR}/MatomoTracker/MatomoTracker.framework",
"${BUILT_PRODUCTS_DIR}/MatrixKit/MatrixKit.framework",
"${BUILT_PRODUCTS_DIR}/MatrixSDK.common-JingleCallStack/MatrixSDK.framework",
"${BUILT_PRODUCTS_DIR}/OLMKit/OLMKit.framework",
"${BUILT_PRODUCTS_DIR}/PiwikTracker/PiwikTracker.framework",
"${BUILT_PRODUCTS_DIR}/Realm/Realm.framework",
"${BUILT_PRODUCTS_DIR}/Reusable/Reusable.framework",
"${BUILT_PRODUCTS_DIR}/cmark/cmark.framework",
@ -3717,10 +3717,10 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/HPGrowingTextView.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/JitsiMeet.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/WebRTC.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MatomoTracker.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MatrixKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MatrixSDK.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OLMKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PiwikTracker.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Realm.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Reusable.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/cmark.framework",

View file

@ -31,7 +31,30 @@ NSString *const kAnalyticsE2eCategory = @"E2E";
NSString *const kAnalyticsE2eDecryptionFailureAction = @"Decryption failure";
@import PiwikTracker;
@import MatomoTracker;
@interface MatomoTracker (MatomoTrackerMigration)
+ (MatomoTracker *)shared;
- (void)migrateFromFourPointFourSharedInstance;
@end
@implementation MatomoTracker (MatomoTrackerMigration)
+ (MatomoTracker *)shared
{
NSDictionary *piwikConfig = [[NSUserDefaults standardUserDefaults] objectForKey:@"piwik"];
MatomoTracker *matomoTracker = [[MatomoTracker alloc] initWithSiteId:piwikConfig[@"siteId"] baseURL:[NSURL URLWithString:piwikConfig[@"url"]] userAgent:@"iOSMatomoTracker"];
[matomoTracker migrateFromFourPointFourSharedInstance];
return matomoTracker;
}
- (void)migrateFromFourPointFourSharedInstance
{
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"migratedFromFourPointFourSharedInstance"]) return;
[self copyFromOldSharedInstance];
[[NSUserDefaults standardUserDefaults] setBool:true forKey:@"migratedFromFourPointFourSharedInstance"];
}
@end
@implementation Analytics
@ -49,29 +72,24 @@ NSString *const kAnalyticsE2eDecryptionFailureAction = @"Decryption failure";
- (void)start
{
NSDictionary *piwikConfig = [[NSUserDefaults standardUserDefaults] objectForKey:@"piwik"];
[PiwikTracker configureSharedInstanceWithSiteID:piwikConfig[@"siteId"]
baseURL:[NSURL URLWithString:piwikConfig[@"url"]]
userAgent:@"iOSPiwikTracker"];
// Check whether the user has enabled the sending of crash reports.
if (RiotSettings.shared.enableCrashReport)
{
[PiwikTracker shared].isOptedOut = NO;
[MatomoTracker shared].isOptedOut = NO;
[[PiwikTracker shared] setCustomVariableWithIndex:1 name:@"App Platform" value:@"iOS Platform"];
[[PiwikTracker shared] setCustomVariableWithIndex:2 name:@"App Version" value:[AppDelegate theDelegate].appVersion];
[[MatomoTracker shared] setCustomVariableWithIndex:1 name:@"App Platform" value:@"iOS Platform"];
[[MatomoTracker shared] setCustomVariableWithIndex:2 name:@"App Version" value:[AppDelegate theDelegate].appVersion];
// The language is either the one selected by the user within the app
// or, else, the one configured by the OS
NSString *language = [NSBundle mxk_language] ? [NSBundle mxk_language] : [[NSBundle mainBundle] preferredLocalizations][0];
[[PiwikTracker shared] setCustomVariableWithIndex:4 name:@"Chosen Language" value:language];
[[MatomoTracker shared] setCustomVariableWithIndex:4 name:@"Chosen Language" value:language];
MXKAccount* account = [MXKAccountManager sharedManager].activeAccounts.firstObject;
if (account)
{
[[PiwikTracker shared] setCustomVariableWithIndex:7 name:@"Homeserver URL" value:account.mxCredentials.homeServer];
[[PiwikTracker shared] setCustomVariableWithIndex:8 name:@"Identity Server URL" value:account.identityServerURL];
[[MatomoTracker shared] setCustomVariableWithIndex:7 name:@"Homeserver URL" value:account.mxCredentials.homeServer];
[[MatomoTracker shared] setCustomVariableWithIndex:8 name:@"Identity Server URL" value:account.identityServerURL];
}
// TODO: We should also track device and os version
@ -83,20 +101,20 @@ NSString *const kAnalyticsE2eDecryptionFailureAction = @"Decryption failure";
#ifdef DEBUG
// Disable analytics in debug as it pollutes stats
[PiwikTracker shared].isOptedOut = YES;
[MatomoTracker shared].isOptedOut = YES;
#endif
}
else
{
NSLog(@"[AppDelegate] The user decided to not send analytics");
[PiwikTracker shared].isOptedOut = YES;
[MatomoTracker shared].isOptedOut = YES;
[MXLogger logCrashes:NO];
}
}
- (void)stop
{
[PiwikTracker shared].isOptedOut = YES;
[MatomoTracker shared].isOptedOut = YES;
[MXLogger logCrashes:NO];
}
@ -106,20 +124,20 @@ NSString *const kAnalyticsE2eDecryptionFailureAction = @"Decryption failure";
NSString *appName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"];
NSString *appVersion = [AppDelegate theDelegate].appVersion;
[[PiwikTracker shared] trackWithView:@[@"ios", appName, appVersion, screenName]
[[MatomoTracker shared] trackWithView:@[@"ios", appName, appVersion, screenName]
url:nil];
}
- (void)dispatch
{
[[PiwikTracker shared] dispatch];
[[MatomoTracker shared] dispatch];
}
- (void)trackLaunchScreenDisplayDuration:(NSTimeInterval)seconds
{
NSString *action = [NSString stringWithFormat:kAnalyticsMetricsActionPattern, kMXAnalyticsStartupCategory];
[[PiwikTracker shared] trackWithEventWithCategory:kAnalyticsMetricsCategory
[[MatomoTracker shared] trackWithEventWithCategory:kAnalyticsMetricsCategory
action:action
name:kMXAnalyticsStartupLaunchScreen
number:@(seconds * 1000)
@ -132,7 +150,7 @@ NSString *const kAnalyticsE2eDecryptionFailureAction = @"Decryption failure";
{
NSString *action = [NSString stringWithFormat:kAnalyticsMetricsActionPattern, kMXAnalyticsStartupCategory];
[[PiwikTracker shared] trackWithEventWithCategory:kAnalyticsMetricsCategory
[[MatomoTracker shared] trackWithEventWithCategory:kAnalyticsMetricsCategory
action:action
name:kMXAnalyticsStartupStorePreload
number:@(seconds * 1000)
@ -143,7 +161,7 @@ NSString *const kAnalyticsE2eDecryptionFailureAction = @"Decryption failure";
{
NSString *action = [NSString stringWithFormat:kAnalyticsMetricsActionPattern, kMXAnalyticsStartupCategory];
[[PiwikTracker shared] trackWithEventWithCategory:kAnalyticsMetricsCategory
[[MatomoTracker shared] trackWithEventWithCategory:kAnalyticsMetricsCategory
action:action
name:kMXAnalyticsStartupMountData
number:@(seconds * 1000)
@ -154,7 +172,7 @@ NSString *const kAnalyticsE2eDecryptionFailureAction = @"Decryption failure";
{
NSString *action = [NSString stringWithFormat:kAnalyticsMetricsActionPattern, kMXAnalyticsStartupCategory];
[[PiwikTracker shared] trackWithEventWithCategory:kAnalyticsMetricsCategory
[[MatomoTracker shared] trackWithEventWithCategory:kAnalyticsMetricsCategory
action:action
name:isInitial ? kMXAnalyticsStartupInititialSync : kMXAnalyticsStartupIncrementalSync
number:@(seconds * 1000)
@ -165,7 +183,7 @@ NSString *const kAnalyticsE2eDecryptionFailureAction = @"Decryption failure";
{
NSString *action = [NSString stringWithFormat:kAnalyticsMetricsActionPattern, kMXAnalyticsStatsCategory];
[[PiwikTracker shared] trackWithEventWithCategory:kAnalyticsMetricsCategory
[[MatomoTracker shared] trackWithEventWithCategory:kAnalyticsMetricsCategory
action:action
name:kMXAnalyticsStatsRooms
number:@(roomCount)
@ -178,7 +196,7 @@ NSString *const kAnalyticsE2eDecryptionFailureAction = @"Decryption failure";
{
for (NSString *reason in failuresCounts)
{
[[PiwikTracker shared] trackWithEventWithCategory:kAnalyticsE2eCategory
[[MatomoTracker shared] trackWithEventWithCategory:kAnalyticsE2eCategory
action:kAnalyticsE2eDecryptionFailureAction
name:reason
number:failuresCounts[reason]