Skip to content

Commit

Permalink
Merge pull request #619 from snowplow/release/2.1.1
Browse files Browse the repository at this point in the history
Release/2.1.1
  • Loading branch information
AlexBenny authored Jun 24, 2021
2 parents 1afcf4c + 323dc88 commit 2b0d6b7
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

Version 2.1.1 (2021-06-24)
--------------------------
Fix Gdpr context being tracked without enabling it (#618)

Version 2.1.0 (2021-06-18)
--------------------------
Fix sessionIndex starting from 0 rather than 1 (#616)
Expand Down
48 changes: 48 additions & 0 deletions Snowplow iOSTests/Configurations/TestTrackerConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,52 @@ - (void)testGDPRConfiguration {
XCTAssertTrue(gdprController.isEnabled);
}

- (void)testWithoutGDPRConfiguration {
SPMockEventStore *eventStore = [SPMockEventStore new];
SPNetworkConfiguration *networkConfiguration = [[SPNetworkConfiguration alloc] initWithEndpoint:@"fake-url" method:SPHttpMethodPost];
SPTrackerConfiguration *trackerConfiguration = [[[SPTrackerConfiguration alloc] init] appId:@"appid"];
trackerConfiguration.base64Encoding = NO;
SPEmitterConfiguration *emitterConfiguration = [[SPEmitterConfiguration alloc] init];
emitterConfiguration.eventStore = eventStore;
emitterConfiguration.threadPoolSize = 10;
id<SPTrackerController> trackerController = [SPSnowplow createTrackerWithNamespace:@"namespace" network:networkConfiguration configurations:@[trackerConfiguration, emitterConfiguration]];
id<SPGDPRController> gdprController = trackerController.gdpr;

// Check gdpr settings
XCTAssertFalse(gdprController.isEnabled);

// Check gdpr context not added
SPStructured *event = [[SPStructured alloc] initWithCategory:@"category" action:@"action"];
[trackerController track:event];
for (int i=0; eventStore.count < 1 && i < 10; i++) {
[NSThread sleepForTimeInterval:1];
}
NSArray<SPEmitterEvent *> *events = [eventStore emittableEventsWithQueryLimit:10];
[eventStore removeAllEvents];
XCTAssertEqual(1, events.count);
SPPayload *payload = [[events firstObject] payload];
NSString *contexts = (NSString *)[[payload getAsDictionary] objectForKey:@"co"];
XCTAssertFalse([contexts containsString:@"\"basisForProcessing\""]);

// Check gdpr can be enabled again
[gdprController resetWithBasis:SPGdprProcessingBasisContract documentId:@"id1" documentVersion:@"ver1" documentDescription:@"desc1"];
XCTAssertEqual(SPGdprProcessingBasisContract, gdprController.basisForProcessing);
XCTAssertEqualObjects(@"id1", gdprController.documentId);
XCTAssertTrue(gdprController.isEnabled);

// Check gdpr context added
event = [[SPStructured alloc] initWithCategory:@"category" action:@"action"];
[trackerController track:event];
for (int i=0; eventStore.count < 1 && i < 10; i++) {
[NSThread sleepForTimeInterval:1];
}
events = [eventStore emittableEventsWithQueryLimit:10];
[eventStore removeAllEvents];
XCTAssertEqual(1, events.count);
payload = [[events firstObject] payload];
contexts = (NSString *)[[payload getAsDictionary] objectForKey:@"co"];
XCTAssertTrue([contexts containsString:@"\"basisForProcessing\":\"contract\""]);
XCTAssertTrue([contexts containsString:@"\"documentId\":\"id1\""]);
}

@end
8 changes: 4 additions & 4 deletions Snowplow/Internal/SPTrackerConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ @implementation SPTrackerConstants
// --- Version

#if SNOWPLOW_TARGET_IOS
NSString * const kSPVersion = @"ios-2.1.0";
NSString * const kSPVersion = @"ios-2.1.1";
#elif SNOWPLOW_TARGET_TV
NSString * const kSPVersion = @"tvos-2.1.0";
NSString * const kSPVersion = @"tvos-2.1.1";
#elif SNOWPLOW_TARGET_WATCHOS
NSString * const kSPVersion = @"watchos-2.1.0";
NSString * const kSPVersion = @"watchos-2.1.1";
#else
NSString * const kSPVersion = @"osx-2.1.0";
NSString * const kSPVersion = @"osx-2.1.1";
#endif

// --- Emitter
Expand Down
8 changes: 5 additions & 3 deletions Snowplow/Internal/Tracker/SPServiceProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ - (SPTracker *)makeTracker {
SPTrackerConfiguration *trackerConfig = self.trackerConfigurationUpdate;
SPSessionConfiguration *sessionConfig = self.sessionConfigurationUpdate;
SPGlobalContextsConfiguration *gcConfig = self.globalContextConfiguration;
SPGDPRConfiguration *gdprConfig = self.gdprConfigurationUpdate;
SPTracker *tracker = [SPTracker build:^(id<SPTrackerBuilder> builder) {
[builder setTrackerNamespace:self.namespace];
[builder setEmitter:emitter];
Expand All @@ -322,7 +321,8 @@ - (SPTracker *)makeTracker {
if (gcConfig) {
[builder setGlobalContextGenerators:gcConfig.contextGenerators];
}
if (gdprConfig) {
SPGDPRConfigurationUpdate *gdprConfig = self.gdprConfigurationUpdate;
if (gdprConfig.sourceConfig) {
[builder setGdprContextWithBasis:gdprConfig.basisForProcessing documentId:gdprConfig.documentId documentVersion:gdprConfig.documentVersion documentDescription:gdprConfig.documentDescription];
}
}];
Expand Down Expand Up @@ -353,7 +353,9 @@ - (SPEmitterControllerImpl *)makeEmitterController {
- (SPGDPRControllerImpl *)makeGDPRController {
SPGDPRControllerImpl *controller = [[SPGDPRControllerImpl alloc] initWithServiceProvider:self];
SPGdprContext *gdpr = self.tracker.gdprContext;
[controller resetWithBasis:gdpr.basis documentId:gdpr.documentId documentVersion:gdpr.documentVersion documentDescription:gdpr.documentDescription];
if (gdpr) {
[controller resetWithBasis:gdpr.basis documentId:gdpr.documentId documentVersion:gdpr.documentVersion documentDescription:gdpr.documentDescription];
}
return controller;
}

Expand Down
2 changes: 1 addition & 1 deletion SnowplowTracker.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SnowplowTracker"
s.version = "2.1.0"
s.version = "2.1.1"
s.summary = "Snowplow event tracker for iOS, macOS, tvOS, watchOS for apps and games."
s.description = <<-DESC
Snowplow is a mobile and event analytics platform with a difference: rather than tell our users how they should analyze their data, we deliver their event-level data in their own data warehouse, on their own Amazon Redshift or Postgres database, so they can analyze it any way they choose. Snowplow mobile is used by data-savvy games companies and app developers to better understand their users and how they engage with their games and applications. Snowplow is open source using the business-friendly Apache License, Version 2.0 and scales horizontally to many billions of events.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
2.1.1

0 comments on commit 2b0d6b7

Please sign in to comment.