Skip to content

Commit 4cfb964

Browse files
authored
Use pushInstallReferrerSource (#520)
* Use pushInstallReferrerSource for traffic source * Fix warnings * Fix migrationState in tests
1 parent f738453 commit 4cfb964

File tree

6 files changed

+33
-34
lines changed

6 files changed

+33
-34
lines changed

LeanplumSDK/LeanplumSDK/Classes/Managers/Networking/LPRequestSender.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,6 @@ - (void)sendRequests
345345

346346
// Invoke errors on all requests.
347347
[LPEventCallbackManager invokeErrorCallbacksWithError:err];
348-
// [[LPOperationQueue serialQueue] cancelAllOperations];
349-
350-
351348

352349
dispatch_semaphore_signal(semaphore);
353350
LP_END_TRY
@@ -366,7 +363,6 @@ - (void)sendRequests
366363
NSError *error = [NSError errorWithDomain:@"Leanplum" code:1
367364
userInfo:@{NSLocalizedDescriptionKey: @"Request timed out"}];
368365
[LPEventCallbackManager invokeErrorCallbacksWithError:error];
369-
// [[LPOperationQueue serialQueue] cancelAllOperations];
370366
LP_END_TRY
371367
}
372368
LP_END_TRY

LeanplumSDK/LeanplumSDK/ClassesSwift/Migration/Wrapper/CTWrapper.swift

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class CTWrapper: Wrapper {
1313
// MARK: Constants
1414
enum Constants {
1515
static let StatePrefix = "state_"
16-
static let UTMVisitedEvent = "UTM Visited"
1716

1817
static let ValueParamName = "value"
1918
static let InfoParamName = "info"
@@ -206,27 +205,15 @@ class CTWrapper: Wrapper {
206205

207206
// MARK: Traffic Source
208207
func setTrafficSourceInfo(_ info: [AnyHashable: Any]) {
209-
let trafficSourceInfoMappings = [
210-
"publisherId": "utm_source_id",
211-
"publisherName": "utm_source",
212-
"publisherSubPublisher": "utm_medium",
213-
"publisherSubSite": "utm_subscribe.site",
214-
"publisherSubCampaign": "utm_campaign",
215-
"publisherSubAdGroup": "utm_sourcepublisher.ad_group",
216-
"publisherSubAd": "utm_SourcePublisher.ad"
217-
]
218-
219-
let props = info.mapKeys({ key -> AnyHashable in
220-
guard let keyStr = key as? String,
221-
let newKey = trafficSourceInfoMappings[keyStr]
222-
else {
223-
return key
224-
}
225-
return newKey
226-
})
208+
let source = info["publisherName"] as? String
209+
let medium = info["publisherSubPublisher"] as? String
210+
let campaign = info["publisherSubCampaign"] as? String
227211

228-
Log.debug("[Wrapper] Leanplum.setTrafficSourceInfo will call pushEvent with \(Constants.UTMVisitedEvent) and \(props)")
229-
cleverTapInstance?.recordEvent(Constants.UTMVisitedEvent, withProps: props)
212+
Log.debug("""
213+
[Wrapper] Leanplum.setTrafficSourceInfo will call pushInstallReferrerSource \
214+
with \(source ?? "null"), \(medium ?? "null") and \(campaign ?? "null")
215+
""")
216+
cleverTapInstance?.pushInstallReferrerSource(source, medium: medium, campaign: campaign)
230217
}
231218

232219
// MARK: Log Level

LeanplumSDKApp/LeanplumSDKTests/Classes/Extensions/Leanplum+Extensions.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ NS_ASSUME_NONNULL_END
7171
+ (void)maybeSendLog:(nonnull NSString *)message;
7272
@end
7373

74-
7574
@interface ApiConfig(UnitTest)
7675
@property (strong, nonatomic, nonnull) NSString *appId;
7776
@property (strong, nonatomic, nonnull) NSString *accessKey;

LeanplumSDKApp/LeanplumSDKTests/Classes/Migration/CTWrapperTest.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class WrapperTest: XCTestCase {
2525
let `nil` = nilString as Any
2626

2727
XCTAssertFalse(wrapper.isAnyNil(notNil))
28-
XCTAssertFalse(wrapper.isAnyNil(notNilOptional))
29-
XCTAssertTrue(wrapper.isAnyNil(nilString))
28+
XCTAssertFalse(wrapper.isAnyNil(notNilOptional as Any))
29+
XCTAssertTrue(wrapper.isAnyNil(nilString as Any))
3030
XCTAssertTrue(wrapper.isAnyNil(`nil`))
3131
}
3232

@@ -60,13 +60,15 @@ class WrapperTest: XCTestCase {
6060
}
6161

6262
func testAttributeValues() {
63-
let attributes = ["lpName": "ct value",
63+
let values = ["lpName": "ct value",
6464
"number": 4,
6565
"arr": ["a", 1, "b", 2],
6666
"arrStr": ["a", "b"],
6767
"arrNumber": [0.5, 1.2, 2.5],
6868
"lpName2": "ct value 2",
69-
"empty": nil] as [AnyHashable : Any]
69+
"empty": nil] as [String : Any?]
70+
71+
let attributes = values as [AnyHashable : Any]
7072

7173

7274
let actual = attributes.mapValues(wrapper.transformArrayValues)
@@ -78,9 +80,9 @@ class WrapperTest: XCTestCase {
7880
"arrStr": "[a,b]",
7981
"arrNumber": "[0.5,1.2,2.5]",
8082
"ctName2": "ct value 2",
81-
"empty": nil] as [AnyHashable : Any]
83+
"empty": nil] as [String : Any?]
8284

83-
XCTAssertTrue(actual.isEqual(expected))
85+
XCTAssertTrue(actual.isEqual(expected as [AnyHashable : Any]))
8486
}
8587

8688
func testAttributeValuesNil() {

LeanplumSDKApp/LeanplumSDKTests/Classes/Migration/Migration+Extensions.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ import Foundation
1414
migrationState = state
1515
}
1616
}
17+
18+
@objcMembers public class MigrationManagerUtil: NSObject {
19+
static func setSharedMigrateState(_ state: MigrationState) {
20+
MigrationManager.shared.migrationState = state
21+
}
22+
}

LeanplumSDKApp/LeanplumSDKTests/Classes/Utilities/LeanplumHelper.m

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,22 @@ + (void)setup_development_test {
9696
[Leanplum setLogLevel:LPLogLevelDebug];
9797
[Leanplum setAppId:APPLICATION_ID withDevelopmentKey:DEVELOPMENT_KEY];
9898

99-
[[MigrationManager shared] setMigrationState:MigrationStateLeanplum];
99+
if (@available(iOS 13.0, *)) {
100+
[[MigrationManager shared] setMigrationState:MigrationStateLeanplum];
101+
} else {
102+
[MigrationManagerUtil setSharedMigrateState:MigrationStateLeanplum];
103+
}
100104
}
101105

102106
+ (void)setup_production_test {
107+
[Leanplum setLogLevel:LPLogLevelDebug];
103108
[Leanplum setAppId:APPLICATION_ID withProductionKey:PRODUCTION_KEY];
104109

105-
[[MigrationManager shared] setMigrationState:MigrationStateLeanplum];
110+
if (@available(iOS 13.0, *)) {
111+
[[MigrationManager shared] setMigrationState:MigrationStateLeanplum];
112+
} else {
113+
[MigrationManagerUtil setSharedMigrateState:MigrationStateLeanplum];
114+
}
106115
}
107116

108117
+ (BOOL)start_development_test {

0 commit comments

Comments
 (0)