Skip to content

Commit 956b4eb

Browse files
authored
Address Issue #851; Expect dictionary as well for for integration enablement (#863)
* Address Issue #851; Expect dictionary as well for for integration enablement. * Fixed broken test.
1 parent 9ce3779 commit 956b4eb

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Analytics/Classes/Integrations/SEGIntegrationsManager.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,10 @@ + (BOOL)isIntegration:(NSString *)key enabledInOptions:(NSDictionary *)options
425425
if ([value isKindOfClass:[NSNumber class]]) {
426426
NSNumber *numberValue = (NSNumber *)value;
427427
return [numberValue boolValue];
428+
} if ([value isKindOfClass:[NSDictionary class]]) {
429+
return YES;
428430
} else {
429-
NSString *msg = [NSString stringWithFormat: @"Value for `%@` in integration options is supposed to be a boolean and it is not!"
431+
NSString *msg = [NSString stringWithFormat: @"Value for `%@` in integration options is supposed to be a boolean or dictionary and it is not!"
430432
"This is likely due to a user-added value in `integrations` that overwrites a value received from the server", key];
431433
SEGLog(msg);
432434
NSAssert(NO, msg);

AnalyticsTests/IntegrationsManagerTest.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ class IntegrationsManagerTest: QuickSpec {
99
describe("IntegrationsManager") {
1010
context("is track event enabled for integration in plan") {
1111

12+
it("valid value types are used in integration enablement flags") {
13+
var exception: NSException? = nil
14+
SwiftTryCatch.tryRun({
15+
SEGIntegrationsManager.isIntegration("comScore", enabledInOptions: ["comScore": ["blah": 1]])
16+
SEGIntegrationsManager.isIntegration("comScore", enabledInOptions: ["comScore": true])
17+
}, catchRun: { e in
18+
exception = e
19+
}, finallyRun: nil)
20+
21+
expect(exception).to(beNil())
22+
}
23+
1224
it("asserts when invalid value types are used integration enablement flags") {
1325
var exception: NSException? = nil
1426
SwiftTryCatch.tryRun({
@@ -23,7 +35,8 @@ class IntegrationsManagerTest: QuickSpec {
2335
it("asserts when invalid value types are used integration enablement flags") {
2436
var exception: NSException? = nil
2537
SwiftTryCatch.tryRun({
26-
SEGIntegrationsManager.isIntegration("comScore", enabledInOptions: ["comScore": ["key": 1]])
38+
// we don't accept array's as values.
39+
SEGIntegrationsManager.isIntegration("comScore", enabledInOptions: ["comScore": ["key", 1]])
2740
}, catchRun: { e in
2841
exception = e
2942
}, finallyRun: nil)

0 commit comments

Comments
 (0)