Skip to content

Commit 07194b0

Browse files
authored
Merge pull request #7574 from woocommerce/fix/explat-include-anonid-in-loggedin-requests
Pass anonymous ID to ExPlat configuration for authenticated users
2 parents 3c2feb9 + 8cc1bd6 commit 07194b0

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

Podfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ target 'WooCommerce' do
3636
# ====================
3737
#
3838

39+
pod 'Automattic-Tracks-iOS', '~> 0.12.0-beta.2'
3940
# pod 'Automattic-Tracks-iOS', :git => 'https://github.com/Automattic/Automattic-Tracks-iOS.git', :branch => ''
40-
pod 'Automattic-Tracks-iOS', '~> 0.12.0-beta.1'
41+
# pod 'Automattic-Tracks-iOS', :git => 'https://github.com/Automattic/Automattic-Tracks-iOS.git', :commit => ''
42+
# pod 'Automattic-Tracks-iOS', :path => '../Automattic-Tracks-iOS'
4143

4244
pod 'Gridicons', '~> 1.2.0'
4345

@@ -227,7 +229,10 @@ end
227229
# ==================
228230
#
229231
def experiments_pods
230-
pod 'Automattic-Tracks-iOS', '~> 0.12.0-beta.1'
232+
pod 'Automattic-Tracks-iOS', '~> 0.12.0-beta.2'
233+
# pod 'Automattic-Tracks-iOS', :git => 'https://github.com/Automattic/Automattic-Tracks-iOS.git', :branch => ''
234+
# pod 'Automattic-Tracks-iOS', :git => 'https://github.com/Automattic/Automattic-Tracks-iOS.git', :commit => '7e11e93d6205f51c09aad5d59f4e0679a796a2ef'
235+
# pod 'Automattic-Tracks-iOS', :path => '../Automattic-Tracks-iOS'
231236
pod 'CocoaLumberjack', '~> 3.7.4'
232237
pod 'CocoaLumberjack/Swift', '~> 3.7.4'
233238
end

Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ PODS:
66
- AppAuth/Core (1.5.0)
77
- AppAuth/ExternalUserAgent (1.5.0):
88
- AppAuth/Core
9-
- Automattic-Tracks-iOS (0.12.0-beta.1):
9+
- Automattic-Tracks-iOS (0.12.0-beta.2):
1010
- Sentry (~> 6)
1111
- Sodium (>= 0.9.1)
1212
- UIDeviceIdentifier (~> 2.0)
@@ -83,7 +83,7 @@ PODS:
8383

8484
DEPENDENCIES:
8585
- Alamofire (~> 4.8)
86-
- Automattic-Tracks-iOS (~> 0.12.0-beta.1)
86+
- Automattic-Tracks-iOS (~> 0.12.0-beta.2)
8787
- CocoaLumberjack (~> 3.7.4)
8888
- CocoaLumberjack/Swift (~> 3.7.4)
8989
- Gridicons (~> 1.2.0)
@@ -144,7 +144,7 @@ SPEC REPOS:
144144
SPEC CHECKSUMS:
145145
Alamofire: 3ec537f71edc9804815215393ae2b1a8ea33a844
146146
AppAuth: 80317d99ac7ff2801a2f18ff86b48cd315ed465d
147-
Automattic-Tracks-iOS: b6f9873770a57e54941c5a3ca8296cbc8dd1015b
147+
Automattic-Tracks-iOS: f31213fbf0391968ffcff75e8c1bdad398589261
148148
CocoaLumberjack: 543c79c114dadc3b1aba95641d8738b06b05b646
149149
FormatterKit: 184db51bf120b633693a73624a4cede89ec51a41
150150
GoogleSignIn: fd381840dbe7c1137aa6dc30849a5c3e070c034a
@@ -179,6 +179,6 @@ SPEC CHECKSUMS:
179179
ZendeskSupportProvidersSDK: 2bdf8544f7cd0fd4c002546f5704b813845beb2a
180180
ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba
181181

182-
PODFILE CHECKSUM: e8394e38023e50481a5683373d9efd4e827ba1db
182+
PODFILE CHECKSUM: 9a75e7f419482622cc94acc2a73bd04ebbc4beaf
183183

184184
COCOAPODS: 1.11.2

WooCommerce/Classes/Analytics/TracksProvider.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public extension TracksProvider {
6464
private extension TracksProvider {
6565
func switchTracksUsersIfNeeded() {
6666
let currentAnalyticsUsername = UserDefaults.standard[.analyticsUsername] as? String ?? ""
67+
let anonymousID = ServiceLocator.stores.sessionManager.anonymousUserID
6768
if ServiceLocator.stores.isAuthenticated,
6869
let account = ServiceLocator.stores.sessionManager.defaultAccount,
6970
let credentials = ServiceLocator.stores.sessionManager.defaultCredentials {
@@ -72,25 +73,28 @@ private extension TracksProvider {
7273
UserDefaults.standard[.analyticsUsername] = account.username
7374
tracksService.switchToAuthenticatedUser(withUsername: account.username,
7475
userID: String(account.userID),
76+
anonymousID: anonymousID,
7577
wpComToken: credentials.authToken,
7678
skipAliasEventCreation: false)
7779
} else if currentAnalyticsUsername == account.username {
7880
// Username did not change - just make sure Tracks client has it
7981
tracksService.switchToAuthenticatedUser(withUsername: account.username,
8082
userID: String(account.userID),
83+
anonymousID: anonymousID,
8184
wpComToken: credentials.authToken,
8285
skipAliasEventCreation: true)
8386
} else {
8487
// Username changed for some reason - switch back to anonymous first
85-
tracksService.switchToAnonymousUser(withAnonymousID: ServiceLocator.stores.sessionManager.anonymousUserID)
88+
tracksService.switchToAnonymousUser(withAnonymousID: anonymousID)
8689
tracksService.switchToAuthenticatedUser(withUsername: account.username,
8790
userID: String(account.userID),
91+
anonymousID: anonymousID,
8892
wpComToken: credentials.authToken,
8993
skipAliasEventCreation: false)
9094
}
9195
} else {
9296
UserDefaults.standard[.analyticsUsername] = nil
93-
tracksService.switchToAnonymousUser(withAnonymousID: ServiceLocator.stores.sessionManager.anonymousUserID)
97+
tracksService.switchToAnonymousUser(withAnonymousID: anonymousID)
9498
}
9599
}
96100

0 commit comments

Comments
 (0)