Skip to content

Commit 128887f

Browse files
committed
8015 Pass platform and build identifiers in JITM
1 parent 4f4915e commit 128887f

File tree

4 files changed

+55
-5
lines changed

4 files changed

+55
-5
lines changed

Networking/Networking.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@
865865
09885C7F27C3FFD200910A62 /* product-variations-bulk-update.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "product-variations-bulk-update.json"; sourceTree = "<group>"; };
866866
09EA564A27C75FCE00407D40 /* ProductVariationsBulkUpdateMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductVariationsBulkUpdateMapper.swift; sourceTree = "<group>"; };
867867
24F98C512502E79800F49B68 /* FeatureFlagsRemote.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureFlagsRemote.swift; sourceTree = "<group>"; };
868-
24F98C532502E8DD00F49B68 /* Bundle+Woo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bundle+Woo.swift"; sourceTree = "<group>"; };
868+
24F98C532502E8DD00F49B68 /* Bundle+Woo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "Bundle+Woo.swift"; path = "../../../WooFoundation/WooFoundation/Extensions/Bundle+Woo.swift"; sourceTree = "<group>"; };
869869
24F98C552502EA4800F49B68 /* FeatureFlag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureFlag.swift; sourceTree = "<group>"; };
870870
24F98C572502EA8800F49B68 /* FeatureFlagMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureFlagMapper.swift; sourceTree = "<group>"; };
871871
24F98C5D2502EDCF00F49B68 /* BundleWooTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BundleWooTests.swift; sourceTree = "<group>"; };

WooFoundation/WooFoundation.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
03597A9D28F93409005E4A98 /* WooCommerceComUTMProviderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03597A9C28F93409005E4A98 /* WooCommerceComUTMProviderTests.swift */; };
1414
035BA3A6290FF98D0056F0AD /* UTMProviderProtocolExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 035BA3A5290FF98D0056F0AD /* UTMProviderProtocolExtensionTests.swift */; };
1515
036563D728F93F8D00D84BFD /* TestKit in Frameworks */ = {isa = PBXBuildFile; productRef = 036563D628F93F8D00D84BFD /* TestKit */; };
16+
03B8C3892914083F002235B1 /* Bundle+Woo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03B8C3882914083F002235B1 /* Bundle+Woo.swift */; };
1617
265C99D828B93F04005E6117 /* ColorPalette.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 265C99D728B93F04005E6117 /* ColorPalette.xcassets */; };
1718
265C99DD28B941D5005E6117 /* UIColor+Muriel-Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 265C99DC28B941D5005E6117 /* UIColor+Muriel-Tests.swift */; };
1819
265C99DF28B94271005E6117 /* MurielColorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 265C99DE28B94271005E6117 /* MurielColorTests.swift */; };
@@ -56,6 +57,7 @@
5657
03597A9A28F87BFC005E4A98 /* WooCommerceComUTMProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WooCommerceComUTMProvider.swift; sourceTree = "<group>"; };
5758
03597A9C28F93409005E4A98 /* WooCommerceComUTMProviderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WooCommerceComUTMProviderTests.swift; sourceTree = "<group>"; };
5859
035BA3A5290FF98D0056F0AD /* UTMProviderProtocolExtensionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UTMProviderProtocolExtensionTests.swift; sourceTree = "<group>"; };
60+
03B8C3882914083F002235B1 /* Bundle+Woo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bundle+Woo.swift"; sourceTree = "<group>"; };
5961
265C99D728B93F04005E6117 /* ColorPalette.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = ColorPalette.xcassets; sourceTree = "<group>"; };
6062
265C99DC28B941D5005E6117 /* UIColor+Muriel-Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+Muriel-Tests.swift"; sourceTree = "<group>"; };
6163
265C99DE28B94271005E6117 /* MurielColorTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MurielColorTests.swift; sourceTree = "<group>"; };
@@ -243,6 +245,7 @@
243245
B9C9C65F283E71F4001B879F /* Double+Woo.swift */,
244246
B9C9C658283E7195001B879F /* NSDecimalNumber+Helpers.swift */,
245247
68FBC5B228926B2C00A05461 /* Collection+Extensions.swift */,
248+
03B8C3882914083F002235B1 /* Bundle+Woo.swift */,
246249
);
247250
path = Extensions;
248251
sourceTree = "<group>";
@@ -471,6 +474,7 @@
471474
isa = PBXSourcesBuildPhase;
472475
buildActionMask = 2147483647;
473476
files = (
477+
03B8C3892914083F002235B1 /* Bundle+Woo.swift in Sources */,
474478
B9C9C659283E7195001B879F /* NSDecimalNumber+Helpers.swift in Sources */,
475479
26AF1F5328B8362800937BA9 /* UIColor+SemanticColors.swift in Sources */,
476480
03597A9B28F87BFC005E4A98 /* WooCommerceComUTMProvider.swift in Sources */,

Networking/Networking/Extensions/Bundle+Woo.swift renamed to WooFoundation/WooFoundation/Extensions/Bundle+Woo.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import Foundation
22

33
extension Bundle {
4-
var buildNumber: String {
4+
public var buildNumber: String {
55
guard let buildNumber = Bundle.main.infoDictionary?["CFBundleVersion"] as? String else {
66
return "unknown"
77
}
88

99
return buildNumber
1010
}
1111

12-
var marketingVersion: String {
12+
public var marketingVersion: String {
1313
guard let marketingVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String else {
1414
return "unknown"
1515
}

Yosemite/Yosemite/Stores/JustInTimeMessageStore.swift

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,61 @@ private extension JustInTimeMessageStore {
5151
messagePath: .init(app: .wooMobile,
5252
screen: screen,
5353
hook: hook),
54-
query: nil,
55-
locale: "")
54+
query: justInTimeMessageQuery(),
55+
locale: localeLanguageRegionIdentifier())
5656
let displayResult = result.map(displayMessages(_:))
5757
await MainActor.run {
5858
completion(displayResult)
5959
}
6060
}
6161
}
6262

63+
func justInTimeMessageQuery() -> [String: String] {
64+
var queryItems = [
65+
"platform": "ios",
66+
"version": Bundle.main.marketingVersion
67+
]
68+
69+
if let device = deviceIdiomName() {
70+
queryItems["device"] = device
71+
}
72+
73+
if let buildType = buildType() {
74+
queryItems["build_type"] = buildType
75+
}
76+
77+
return queryItems
78+
}
79+
80+
func deviceIdiomName() -> String? {
81+
switch UIDevice.current.userInterfaceIdiom {
82+
case .phone:
83+
return "phone"
84+
case .pad:
85+
return "pad"
86+
default:
87+
return nil
88+
}
89+
}
90+
91+
func buildType() -> String? {
92+
#if DEBUG
93+
return "developer"
94+
#else
95+
return nil
96+
#endif
97+
}
98+
99+
func localeLanguageRegionIdentifier() -> String? {
100+
guard let languageCode = Locale.current.languageCode else {
101+
return nil
102+
}
103+
guard let regionCode = Locale.current.regionCode else {
104+
return languageCode
105+
}
106+
return "\(languageCode)_\(regionCode)"
107+
}
108+
63109
func displayMessages(_ messages: [Networking.JustInTimeMessage]) -> [JustInTimeMessage] {
64110
return messages.map { JustInTimeMessage(message: $0) }
65111
}

0 commit comments

Comments
 (0)