mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Merge pull request #7401 from vector-im/andy/analytics
Use SwiftPM for AnalyticsEvents instead of CocoaPods
This commit is contained in:
commit
0a95389a31
17 changed files with 44 additions and 77 deletions
2
Podfile
2
Podfile
|
@ -72,8 +72,6 @@ abstract_target 'RiotPods' do
|
|||
# PostHog for analytics
|
||||
pod 'PostHog', '~> 2.0.0'
|
||||
pod 'Sentry', '~> 7.15.0'
|
||||
pod 'AnalyticsEvents', :git => 'https://github.com/matrix-org/matrix-analytics-events.git', :branch => 'release/swift', :inhibit_warnings => false
|
||||
# pod 'AnalyticsEvents', :path => '../matrix-analytics-events/AnalyticsEvents.podspec'
|
||||
|
||||
pod 'OLMKit'
|
||||
pod 'zxcvbn-ios'
|
||||
|
|
15
Podfile.lock
15
Podfile.lock
|
@ -14,7 +14,6 @@ PODS:
|
|||
- AFNetworking/Serialization (4.0.1)
|
||||
- AFNetworking/UIKit (4.0.1):
|
||||
- AFNetworking/NSURLSession
|
||||
- AnalyticsEvents (0.1.0)
|
||||
- BlueCryptor (1.0.32)
|
||||
- BlueECC (1.2.5)
|
||||
- BlueRSA (1.0.200)
|
||||
|
@ -91,7 +90,6 @@ PODS:
|
|||
- ZXingObjC/All (3.6.5)
|
||||
|
||||
DEPENDENCIES:
|
||||
- AnalyticsEvents (from `https://github.com/matrix-org/matrix-analytics-events.git`, branch `release/swift`)
|
||||
- Down (~> 0.11.0)
|
||||
- DSBottomSheet (~> 0.3)
|
||||
- DSWaveformImage (~> 6.1.1)
|
||||
|
@ -164,19 +162,8 @@ SPEC REPOS:
|
|||
- zxcvbn-ios
|
||||
- ZXingObjC
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
AnalyticsEvents:
|
||||
:branch: release/swift
|
||||
:git: https://github.com/matrix-org/matrix-analytics-events.git
|
||||
|
||||
CHECKOUT OPTIONS:
|
||||
AnalyticsEvents:
|
||||
:commit: 53ad46ba1ea1ee8f21139dda3c351890846a202f
|
||||
:git: https://github.com/matrix-org/matrix-analytics-events.git
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
AFNetworking: 3bd23d814e976cd148d7d44c3ab78017b744cd58
|
||||
AnalyticsEvents: 0cc8cf52da2fd464a2f39b788a295988151116ce
|
||||
BlueCryptor: b0aee3d9b8f367b49b30de11cda90e1735571c24
|
||||
BlueECC: 0d18e93347d3ec6d41416de21c1ffa4d4cd3c2cc
|
||||
BlueRSA: dfeef51db96bcc4edec654956c1581adbda4e6a3
|
||||
|
@ -217,6 +204,6 @@ SPEC CHECKSUMS:
|
|||
zxcvbn-ios: fef98b7c80f1512ff0eec47ac1fa399fc00f7e3c
|
||||
ZXingObjC: fdbb269f25dd2032da343e06f10224d62f537bdb
|
||||
|
||||
PODFILE CHECKSUM: a160b10da6c4728f70275f07b53ef1502c794d4e
|
||||
PODFILE CHECKSUM: b95e7964fe3b77759768daa7d9e4988f80210056
|
||||
|
||||
COCOAPODS: 1.11.3
|
||||
|
|
|
@ -36,6 +36,15 @@
|
|||
"version" : "5.12.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "matrix-analytics-events",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/matrix-org/matrix-analytics-events",
|
||||
"state" : {
|
||||
"revision" : "2f5fa5f1e2f6c6ae1a47c33d953a3ce289167eb0",
|
||||
"version" : "0.5.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "matrix-wysiwyg-composer-swift",
|
||||
"kind" : "remoteSourceControl",
|
||||
|
|
|
@ -24,17 +24,8 @@ import AnalyticsEvents
|
|||
/// non-fatal issues and performance. `Analytics` class serves as a façade
|
||||
/// to all these use cases.
|
||||
///
|
||||
/// ## Creating Analytics Events
|
||||
///
|
||||
/// Events are managed in a shared repo for all Element clients https://github.com/matrix-org/matrix-analytics-events
|
||||
/// To add a new event create a PR to that repo with the new/updated schema. Element's Podfile has
|
||||
/// a local version of the pod (commented out) for development purposes.
|
||||
/// Once merged into `main`, follow the steps below to integrate the changes into the project:
|
||||
/// 1. Check if `main` contains any source breaking changes to the events. If so, please
|
||||
/// wait until you are ready to merge your work into element-ios.
|
||||
/// 2. Merge `main` into the `release/swift` branch.
|
||||
/// 3. Run `bundle exec pod update AnalyticsEvents` to update the pod.
|
||||
/// 4. Make sure to commit `Podfile.lock` with the new commit hash.
|
||||
/// Events are managed in a shared repo for all Element clients
|
||||
/// https://github.com/matrix-org/matrix-analytics-events and integrated via SwiftPM
|
||||
///
|
||||
@objcMembers class Analytics: NSObject {
|
||||
|
||||
|
@ -230,10 +221,10 @@ extension Analytics {
|
|||
///
|
||||
/// Only non-nil properties will be updated when calling this method.
|
||||
func updateUserProperties(ftueUseCase: UserSessionProperties.UseCase? = nil, numFavouriteRooms: Int? = nil, numSpaces: Int? = nil, allChatsActiveFilter: UserSessionProperties.AllChatsActiveFilter? = nil) {
|
||||
let userProperties = AnalyticsEvent.UserProperties(ftueUseCaseSelection: ftueUseCase?.analyticsName,
|
||||
let userProperties = AnalyticsEvent.UserProperties(allChatsActiveFilter: allChatsActiveFilter?.analyticsName,
|
||||
ftueUseCaseSelection: ftueUseCase?.analyticsName,
|
||||
numFavouriteRooms: numFavouriteRooms,
|
||||
numSpaces: numSpaces,
|
||||
allChatsActiveFilter: allChatsActiveFilter?.analyticsName)
|
||||
numSpaces: numSpaces)
|
||||
client.updateUserProperties(userProperties)
|
||||
}
|
||||
|
||||
|
@ -281,7 +272,12 @@ extension Analytics {
|
|||
/// - reason: The error that occurred.
|
||||
/// - context: Additional context of the error that occured
|
||||
func trackE2EEError(_ reason: DecryptionFailureReason, context: String) {
|
||||
let event = AnalyticsEvent.Error(context: context, domain: .E2EE, name: reason.errorName)
|
||||
let event = AnalyticsEvent.Error(
|
||||
context: context,
|
||||
cryptoModule: MXSDKOptions.sharedInstance().enableCryptoSDK ? .Rust : .Native,
|
||||
domain: .E2EE,
|
||||
name: reason.errorName
|
||||
)
|
||||
capture(event: event)
|
||||
}
|
||||
|
||||
|
@ -359,7 +355,7 @@ extension Analytics: MXAnalyticsDelegate {
|
|||
|
||||
func trackCallError(with reason: __MXCallHangupReason, video isVideo: Bool, numberOfParticipants: Int, incoming isIncoming: Bool) {
|
||||
let callEvent = AnalyticsEvent.CallError(isVideo: isVideo, numParticipants: numberOfParticipants, placed: !isIncoming)
|
||||
let event = AnalyticsEvent.Error(context: nil, domain: .VOIP, name: reason.errorName)
|
||||
let event = AnalyticsEvent.Error(context: nil, cryptoModule: nil, domain: .VOIP, name: reason.errorName)
|
||||
capture(event: callEvent)
|
||||
capture(event: event)
|
||||
}
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnalyticsEvents
|
||||
|
||||
extension AnalyticsEvent.UserProperties {
|
||||
|
||||
// Initializer for Element. Strips all Web properties.
|
||||
public init(ftueUseCaseSelection: FtueUseCaseSelection?, numFavouriteRooms: Int?, numSpaces: Int?, allChatsActiveFilter: AllChatsActiveFilter?) {
|
||||
self.init(WebMetaSpaceFavouritesEnabled: nil,
|
||||
WebMetaSpaceHomeAllRooms: nil,
|
||||
WebMetaSpaceHomeEnabled: nil,
|
||||
WebMetaSpaceOrphansEnabled: nil,
|
||||
WebMetaSpacePeopleEnabled: nil,
|
||||
allChatsActiveFilter: allChatsActiveFilter,
|
||||
ftueUseCaseSelection: ftueUseCaseSelection,
|
||||
numFavouriteRooms: numFavouriteRooms,
|
||||
numSpaces: numSpaces)
|
||||
}
|
||||
|
||||
}
|
|
@ -81,10 +81,10 @@ class PostHogAnalyticsClient: AnalyticsClientProtocol {
|
|||
}
|
||||
|
||||
// Merge the updated user properties with the existing ones
|
||||
self.pendingUserProperties = AnalyticsEvent.UserProperties(ftueUseCaseSelection: userProperties.ftueUseCaseSelection ?? pendingUserProperties.ftueUseCaseSelection,
|
||||
self.pendingUserProperties = AnalyticsEvent.UserProperties(allChatsActiveFilter: userProperties.allChatsActiveFilter ?? pendingUserProperties.allChatsActiveFilter,
|
||||
ftueUseCaseSelection: userProperties.ftueUseCaseSelection ?? pendingUserProperties.ftueUseCaseSelection,
|
||||
numFavouriteRooms: userProperties.numFavouriteRooms ?? pendingUserProperties.numFavouriteRooms,
|
||||
numSpaces: userProperties.numSpaces ?? pendingUserProperties.numSpaces,
|
||||
allChatsActiveFilter: userProperties.allChatsActiveFilter ?? pendingUserProperties.allChatsActiveFilter)
|
||||
numSpaces: userProperties.numSpaces ?? pendingUserProperties.numSpaces)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
|
|
@ -39,6 +39,7 @@ targets:
|
|||
- target: RiotNSE
|
||||
- target: DesignKit
|
||||
- target: CommonKit
|
||||
- package: AnalyticsEvents
|
||||
- package: Mapbox
|
||||
- package: OrderedCollections
|
||||
- package: SwiftOGG
|
||||
|
|
|
@ -32,6 +32,7 @@ targets:
|
|||
type: app-extension
|
||||
|
||||
dependencies:
|
||||
- package: AnalyticsEvents
|
||||
- package: DeviceKit
|
||||
- package: DTCoreText
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ targets:
|
|||
type: app-extension
|
||||
|
||||
dependencies:
|
||||
- package: AnalyticsEvents
|
||||
- package: DeviceKit
|
||||
- package: DTCoreText
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ targets:
|
|||
platform: iOS
|
||||
dependencies:
|
||||
- target: DesignKit
|
||||
- package: AnalyticsEvents
|
||||
- package: Mapbox
|
||||
- package: WysiwygComposer
|
||||
sources:
|
||||
|
|
|
@ -35,6 +35,7 @@ targets:
|
|||
|
||||
dependencies:
|
||||
- target: RiotSwiftUI
|
||||
- package: AnalyticsEvents
|
||||
- package: WysiwygComposer
|
||||
|
||||
settings:
|
||||
|
|
|
@ -35,6 +35,7 @@ targets:
|
|||
|
||||
dependencies:
|
||||
- target: RiotSwiftUI
|
||||
- package: AnalyticsEvents
|
||||
|
||||
configFiles:
|
||||
Debug: Debug.xcconfig
|
||||
|
|
|
@ -78,7 +78,7 @@ class AnalyticsTests: XCTestCase {
|
|||
XCTAssertNil(client.pendingUserProperties, "No user properties should have been set yet.")
|
||||
|
||||
// When updating the user properties
|
||||
client.updateUserProperties(AnalyticsEvent.UserProperties(ftueUseCaseSelection: .PersonalMessaging, numFavouriteRooms: 4, numSpaces: 5, allChatsActiveFilter: nil))
|
||||
client.updateUserProperties(AnalyticsEvent.UserProperties(allChatsActiveFilter: nil, ftueUseCaseSelection: .PersonalMessaging, numFavouriteRooms: 4, numSpaces: 5))
|
||||
|
||||
// Then the properties should be cached
|
||||
XCTAssertNotNil(client.pendingUserProperties, "The user properties should be cached.")
|
||||
|
@ -90,7 +90,7 @@ class AnalyticsTests: XCTestCase {
|
|||
func testMergingUserProperties() {
|
||||
// Given a client with a cached use case user properties
|
||||
let client = PostHogAnalyticsClient()
|
||||
client.updateUserProperties(AnalyticsEvent.UserProperties(ftueUseCaseSelection: .PersonalMessaging, numFavouriteRooms: nil, numSpaces: nil, allChatsActiveFilter: nil))
|
||||
client.updateUserProperties(AnalyticsEvent.UserProperties(allChatsActiveFilter: nil, ftueUseCaseSelection: .PersonalMessaging, numFavouriteRooms: nil, numSpaces: nil))
|
||||
|
||||
XCTAssertNotNil(client.pendingUserProperties, "The user properties should be cached.")
|
||||
XCTAssertEqual(client.pendingUserProperties?.ftueUseCaseSelection, .PersonalMessaging, "The use case selection should match.")
|
||||
|
@ -98,7 +98,7 @@ class AnalyticsTests: XCTestCase {
|
|||
XCTAssertNil(client.pendingUserProperties?.numSpaces, "The number of spaces should not be set.")
|
||||
|
||||
// When updating the number of spaces
|
||||
client.updateUserProperties(AnalyticsEvent.UserProperties(ftueUseCaseSelection: nil, numFavouriteRooms: 4, numSpaces: 5, allChatsActiveFilter: nil))
|
||||
client.updateUserProperties(AnalyticsEvent.UserProperties(allChatsActiveFilter: nil, ftueUseCaseSelection: nil, numFavouriteRooms: 4, numSpaces: 5))
|
||||
|
||||
// Then the new properties should be updated and the existing properties should remain unchanged
|
||||
XCTAssertNotNil(client.pendingUserProperties, "The user properties should be cached.")
|
||||
|
@ -107,7 +107,7 @@ class AnalyticsTests: XCTestCase {
|
|||
XCTAssertEqual(client.pendingUserProperties?.numSpaces, 5, "The number of spaces should have been updated.")
|
||||
|
||||
// When updating the number of spaces
|
||||
client.updateUserProperties(AnalyticsEvent.UserProperties(ftueUseCaseSelection: nil, numFavouriteRooms: nil, numSpaces: nil, allChatsActiveFilter: .Favourites))
|
||||
client.updateUserProperties(AnalyticsEvent.UserProperties(allChatsActiveFilter: .Favourites, ftueUseCaseSelection: nil, numFavouriteRooms: nil, numSpaces: nil))
|
||||
|
||||
// Then the new properties should be updated and the existing properties should remain unchanged
|
||||
XCTAssertNotNil(client.pendingUserProperties, "The user properties should be cached.")
|
||||
|
@ -120,7 +120,7 @@ class AnalyticsTests: XCTestCase {
|
|||
func testSendingUserProperties() {
|
||||
// Given a client with user properties set
|
||||
let client = PostHogAnalyticsClient()
|
||||
client.updateUserProperties(AnalyticsEvent.UserProperties(ftueUseCaseSelection: .PersonalMessaging, numFavouriteRooms: nil, numSpaces: nil, allChatsActiveFilter: nil))
|
||||
client.updateUserProperties(AnalyticsEvent.UserProperties(allChatsActiveFilter: nil, ftueUseCaseSelection: .PersonalMessaging, numFavouriteRooms: nil, numSpaces: nil))
|
||||
client.start()
|
||||
|
||||
XCTAssertNotNil(client.pendingUserProperties, "The user properties should be cached.")
|
||||
|
@ -136,7 +136,7 @@ class AnalyticsTests: XCTestCase {
|
|||
func testSendingUserPropertiesWithIdentify() {
|
||||
// Given a client with user properties set
|
||||
let client = PostHogAnalyticsClient()
|
||||
client.updateUserProperties(AnalyticsEvent.UserProperties(ftueUseCaseSelection: .PersonalMessaging, numFavouriteRooms: nil, numSpaces: nil, allChatsActiveFilter: nil))
|
||||
client.updateUserProperties(AnalyticsEvent.UserProperties(allChatsActiveFilter: nil, ftueUseCaseSelection: .PersonalMessaging, numFavouriteRooms: nil, numSpaces: nil))
|
||||
client.start()
|
||||
|
||||
XCTAssertNotNil(client.pendingUserProperties, "The user properties should be cached.")
|
||||
|
|
|
@ -35,6 +35,7 @@ targets:
|
|||
|
||||
dependencies:
|
||||
- target: Riot
|
||||
- package: AnalyticsEvents
|
||||
|
||||
configFiles:
|
||||
Debug: Debug.xcconfig
|
||||
|
|
|
@ -33,6 +33,7 @@ targets:
|
|||
|
||||
dependencies:
|
||||
- sdk: Intents.framework
|
||||
- package: AnalyticsEvents
|
||||
- package: DeviceKit
|
||||
- package: DTCoreText
|
||||
|
||||
|
|
1
changelog.d/pr-7401.change
Normal file
1
changelog.d/pr-7401.change
Normal file
|
@ -0,0 +1 @@
|
|||
Analytics: Use SwiftPM for AnalyticsEvents instead of CocoaPods
|
|
@ -40,6 +40,9 @@ include:
|
|||
- path: CommonKit/targetUnitTests.yml
|
||||
|
||||
packages:
|
||||
AnalyticsEvents:
|
||||
url: https://github.com/matrix-org/matrix-analytics-events
|
||||
exactVersion: 0.5.0
|
||||
Mapbox:
|
||||
url: https://github.com/maplibre/maplibre-gl-native-distribution
|
||||
minVersion: 5.12.2
|
||||
|
@ -59,4 +62,4 @@ packages:
|
|||
majorVersion: 4.7.0
|
||||
DTCoreText:
|
||||
url: https://github.com/Cocoanetics/DTCoreText
|
||||
version: 1.6.27
|
||||
version: 1.6.27
|
||||
|
|
Loading…
Reference in a new issue