Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect schema defaults. #727

Merged
merged 1 commit into from
Nov 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Analytics/Classes/Integrations/SEGIntegrationsManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ + (BOOL)isTrackEvent:(NSString *)event enabledForIntegration:(NSString *)key inP
} else {
return NO;
}
} else if (plan[@"track"][@"__default"]) {
return [plan[@"track"][@"__default"][@"enabled"] boolValue];
}

return YES;
Expand Down
17 changes: 16 additions & 1 deletion AnalyticsTests/IntegrationsManagerTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ class IntegrationsManagerTest: QuickSpec {
describe("IntegrationsManager") {
context("is track event enabled for integration in plan") {

it("returns true when plan is empty") {
it("returns true when there is no plan") {
let enabled = SEGIntegrationsManager.isTrackEvent("hello world", enabledForIntegration: "Amplitude", inPlan:[:])
expect(enabled).to(beTrue())
}

it("returns true when plan is empty") {
let enabled = SEGIntegrationsManager.isTrackEvent("hello world", enabledForIntegration: "Mixpanel", inPlan:["track":[:]])
expect(enabled).to(beTrue())
}

it("returns true when plan enables event") {
let enabled = SEGIntegrationsManager.isTrackEvent("hello world", enabledForIntegration: "Mixpanel", inPlan:["track":["hello world":["enabled":true]]])
expect(enabled).to(beTrue())
Expand All @@ -37,6 +42,16 @@ class IntegrationsManagerTest: QuickSpec {
let enabled = SEGIntegrationsManager.isTrackEvent("hello world", enabledForIntegration: "Mixpanel", inPlan:["track":["hello world":["enabled":true, "integrations":["Mixpanel":false]]]])
expect(enabled).to(beFalse())
}

it("returns false when plan disables new events by default") {
let enabled = SEGIntegrationsManager.isTrackEvent("hello world", enabledForIntegration: "Mixpanel", inPlan:["track":["__default":["enabled":false]]])
expect(enabled).to(beFalse())
}

it("returns uses event plan rather over defaults") {
let enabled = SEGIntegrationsManager.isTrackEvent("hello world", enabledForIntegration: "Mixpanel", inPlan:["track":["__default":["enabled":false],"hello world":["enabled":true]]])
expect(enabled).to(beTrue())
}
}
}
}
Expand Down