Skip to content

Commit

Permalink
Merge branch 'release/3.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
mscwilson committed May 25, 2022
2 parents c873da2 + 157e6a8 commit 78fca9f
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 3.1.2 (2022-05-25)
--------------------------
Attach LifecycleEntity before the first Background event (#679)

Version 3.1.1 (2022-03-03)
--------------------------
Fix object cannot be nil (key: userId) when initialising Snowplow tracker (#675)
Expand Down
102 changes: 102 additions & 0 deletions Snowplow iOSTests/TestLifecycleState.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
//
// TestLifecycleState.m
// Snowplow-iOSTests
//
// Copyright (c) 2013-2022 Snowplow Analytics Ltd. All rights reserved.
//
// This program is licensed to you under the Apache License Version 2.0,
// and you may not use this file except in compliance with the Apache License
// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at
// http://www.apache.org/licenses/LICENSE-2.0.
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the Apache License Version 2.0 is distributed on
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the Apache License Version 2.0 for the specific
// language governing permissions and limitations there under.
//
// Authors: Michael Hadam
// License: Apache License Version 2.0
//

#import <XCTest/XCTest.h>
#import "SPTracker.h"
#import "SPEmitter.h"
#import "SPPayload.h"
#import "SPEvent.h"
#import "SPMockEventStore.h"

@interface TestLifecycleState : XCTestCase

@end

@implementation TestLifecycleState

- (void)setUp {
[super setUp];
}

- (void)tearDown {
[super tearDown];
}

- (void)testLifeycleStateMachine {
SPMockEventStore *eventStore = [SPMockEventStore new];
SPTracker *tracker = [SPTracker build:^(id<SPTrackerBuilder> _Nonnull builder) {
[builder setEmitter:[SPEmitter build:^(id<SPEmitterBuilder> builder) {
[builder setUrlEndpoint:@"http://snowplow-fake-url.com"];
[builder setEventStore:eventStore];
}]];
[builder setTrackerNamespace:@"namespace"];
[builder setBase64Encoded:NO];
[builder setLifecycleEvents:YES];
}];

// Send events
[tracker track:[[SPTiming alloc] initWithCategory:@"category" variable:@"variable" timing:@123]];
[NSThread sleepForTimeInterval:1];
if (eventStore.lastInsertedRow == -1) XCTFail();
SPPayload *payload = eventStore.db[@(eventStore.lastInsertedRow)];
[eventStore removeAllEvents];
NSString *entities = (NSString *)(payload.getAsDictionary[@"co"]);
XCTAssertNotNil(entities);
XCTAssertTrue([entities containsString:@"\"isVisible\":true"]);

[tracker track:[[SPBackground alloc] initWithIndex:@1]];
[NSThread sleepForTimeInterval:1];
if (eventStore.lastInsertedRow == -1) XCTFail();
payload = eventStore.db[@(eventStore.lastInsertedRow)];
[eventStore removeAllEvents];
entities = (NSString *)(payload.getAsDictionary[@"co"]);
XCTAssertNotNil(entities);
XCTAssertTrue([entities containsString:@"\"isVisible\":false"]);

[tracker track:[[SPTiming alloc] initWithCategory:@"category" variable:@"variable" timing:@123]];
[NSThread sleepForTimeInterval:1];
if (eventStore.lastInsertedRow == -1) XCTFail();
payload = eventStore.db[@(eventStore.lastInsertedRow)];
[eventStore removeAllEvents];
entities = (NSString *)(payload.getAsDictionary[@"co"]);
XCTAssertTrue([entities containsString:@"\"isVisible\":false"]);

[tracker track:[[SPForeground alloc] initWithIndex:@1]];
[NSThread sleepForTimeInterval:1];
if (eventStore.lastInsertedRow == -1) XCTFail();
payload = eventStore.db[@(eventStore.lastInsertedRow)];
[eventStore removeAllEvents];
entities = (NSString *)(payload.getAsDictionary[@"co"]);
XCTAssertNotNil(entities);
XCTAssertTrue([entities containsString:@"\"isVisible\":true"]);

NSUUID *uuid = [NSUUID UUID];
[tracker track:[[SPScreenView alloc] initWithName:@"screen1" screenId:uuid]];
[NSThread sleepForTimeInterval:1];
if (eventStore.lastInsertedRow == -1) XCTFail();
payload = eventStore.db[@(eventStore.lastInsertedRow)];
[eventStore removeAllEvents];
entities = (NSString *)(payload.getAsDictionary[@"co"]);
XCTAssertTrue([entities containsString:@"\"isVisible\":true"]);
}

@end

4 changes: 4 additions & 0 deletions Snowplow.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@
CE4F9D1F244B066500968CFC /* SPEcommerce.m in Sources */ = {isa = PBXBuildFile; fileRef = CE4F9C85244B066500968CFC /* SPEcommerce.m */; };
CE4F9D20244B066500968CFC /* SPEcommerce.m in Sources */ = {isa = PBXBuildFile; fileRef = CE4F9C85244B066500968CFC /* SPEcommerce.m */; };
CE4F9D21244B066500968CFC /* SPEcommerce.m in Sources */ = {isa = PBXBuildFile; fileRef = CE4F9C85244B066500968CFC /* SPEcommerce.m */; };
D99BDC6D2834F89A00F6A14F /* TestLifecycleState.m in Sources */ = {isa = PBXBuildFile; fileRef = D99BDC6C2834F89A00F6A14F /* TestLifecycleState.m */; };
ED0EFE2D26E240B0002CAA21 /* SPDeepLinkReceived.m in Sources */ = {isa = PBXBuildFile; fileRef = ED0EFE2B26E240B0002CAA21 /* SPDeepLinkReceived.m */; };
ED0EFE2E26E240B0002CAA21 /* SPDeepLinkReceived.m in Sources */ = {isa = PBXBuildFile; fileRef = ED0EFE2B26E240B0002CAA21 /* SPDeepLinkReceived.m */; };
ED0EFE2F26E240B0002CAA21 /* SPDeepLinkReceived.m in Sources */ = {isa = PBXBuildFile; fileRef = ED0EFE2B26E240B0002CAA21 /* SPDeepLinkReceived.m */; };
Expand Down Expand Up @@ -1036,6 +1037,7 @@
CE4F9C83244B066500968CFC /* SPGlobalContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPGlobalContext.m; sourceTree = "<group>"; };
CE4F9C84244B066500968CFC /* SPEcommerce.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPEcommerce.h; sourceTree = "<group>"; };
CE4F9C85244B066500968CFC /* SPEcommerce.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPEcommerce.m; sourceTree = "<group>"; };
D99BDC6C2834F89A00F6A14F /* TestLifecycleState.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TestLifecycleState.m; sourceTree = "<group>"; };
ED0EFE2B26E240B0002CAA21 /* SPDeepLinkReceived.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPDeepLinkReceived.m; sourceTree = "<group>"; };
ED0EFE2C26E240B0002CAA21 /* SPDeepLinkReceived.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPDeepLinkReceived.h; sourceTree = "<group>"; };
ED26E6B923842AAF0096AF7C /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/AdSupport.framework; sourceTree = DEVELOPER_DIR; };
Expand Down Expand Up @@ -1268,6 +1270,7 @@
75CAC3F121F2955000271FB3 /* TestSession.m */,
75CAC40221F2955100271FB3 /* TestUtils.m */,
7534D20722569F3400904EE5 /* TestScreenState.m */,
D99BDC6C2834F89A00F6A14F /* TestLifecycleState.m */,
EDEE836224C0C317000B8530 /* TestLogger.m */,
EDB2FD2126C57F6C0031B872 /* TestDataPersistence.m */,
EDAB664826D69A160067755F /* TestStateManager.m */,
Expand Down Expand Up @@ -2624,6 +2627,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D99BDC6D2834F89A00F6A14F /* TestLifecycleState.m in Sources */,
6BF15D0C2702ECD70048F376 /* TestPlatformContext.m in Sources */,
75CAC40821F2955100271FB3 /* LegacyTestSubject.m in Sources */,
ED8BF8ED2570FB2F001DFDD9 /* TestTrackerConfiguration.m in Sources */,
Expand Down
8 changes: 4 additions & 4 deletions Snowplow/Internal/SPTrackerConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ @implementation SPTrackerConstants
// --- Version

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

// --- Session Dictionary keys
Expand Down
2 changes: 1 addition & 1 deletion Snowplow/Internal/Tracker/SPLifecycleStateMachine.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ @implementation SPLifecycleStateMachine
}

- (NSArray<SPSelfDescribingJson *> *)entitiesFromEvent:(id<SPInspectableEvent>)event state:(id<SPState>)state {
if (!state) return nil;
if (!state) return @[[[[SPLifecycleEntity alloc] initWithIsVisible:YES] index:0]];
SPLifecycleState *s = (SPLifecycleState *)state;
return @[[[[SPLifecycleEntity alloc] initWithIsVisible:s.isForeground] index:s.index]];
}
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 = "3.1.1"
s.version = "3.1.2"
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 @@
3.1.1
3.1.2

0 comments on commit 78fca9f

Please sign in to comment.