Skip to content

Commit

Permalink
Merge pull request #674 from snowplow/release/3.1
Browse files Browse the repository at this point in the history
Release/3.1
  • Loading branch information
AlexBenny authored Feb 28, 2022
2 parents 1c36534 + e053027 commit d223aa3
Show file tree
Hide file tree
Showing 243 changed files with 1,016 additions and 648 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Version 3.1.0 (2022-02-25)
--------------------------
Update copyright headers to 2022 (#669)
Update links to v3 docs in README (#665)
Add pause and resume to EmitterController (#672)
Check session for background event using foreground timeout (#667)
Add session callback (#664)

Version 3.0.2 (2021-12-23)
--------------------------
Fix updating IDFA during app runtime (#661)
Expand Down
5 changes: 3 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2021 Snowplow Analytics Ltd.
Copyright 2022 Snowplow Analytics Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -198,4 +198,5 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Some examples of demo apps instrumented with our iOS Tracker can be found in the

## Copyright and license

The Snowplow iOS/macOS/tvOS/watchOS Tracker is copyright 2013-2021 Snowplow Analytics Ltd.
The Snowplow iOS/macOS/tvOS/watchOS Tracker is copyright 2013-2022 Snowplow Analytics Ltd.

Licensed under the **[Apache License, Version 2.0][license]** (the "License");
you may not use this software except in compliance with the License.
Expand Down Expand Up @@ -74,10 +74,10 @@ limitations under the License.
[carthage]: https://github.com/Carthage/Carthage
[carthage-badge]: https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat

[setup-docs]: https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/mobile-trackers/mobile-trackers-v2-0/quick-start-guide/#tab-ios-tracker
[setup-docs]: https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/mobile-trackers/mobile-trackers-v3-0/quick-start-guide/#tab-ios-tracker
[setup-docs-image]: https://d3i6fms1cm1j0i.cloudfront.net/github/images/setup.png

[tech-docs]: https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/mobile-trackers/mobile-trackers-v2-0/introduction/
[tech-docs]: https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/mobile-trackers/mobile-trackers-v3-0/introduction/
[tech-docs-image]: https://d3i6fms1cm1j0i.cloudfront.net/github/images/techdocs.png

[api-docs]: https://snowplow.github.io/snowplow-objc-tracker/
Expand Down
76 changes: 76 additions & 0 deletions Snowplow iOSTests/Configurations/TestEmitterConfiguration.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//
// TestEmitterConfiguration.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: Alex Benini, Matus Tomlein
// License: Apache License Version 2.0
//

#import <XCTest/XCTest.h>
#import "SPSnowplow.h"
#import "SPNetworkConfiguration.h"
#import "SPTrackerConfiguration.h"
#import "SPSession.h"
#import "SPMockEventStore.h"
#import "SPDataPersistence.h"
#import "SPMockNetworkConnection.h"
#import "SPLogger.h"


@interface TestEmitterConfiguration : XCTestCase

@end

@implementation TestEmitterConfiguration

- (void)setUp {
[super setUp];
[SPLogger setLogLevel:SPLogLevelVerbose];
}

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

- (void)testPauseEmitter {
SPMockNetworkConnection *networkConnection = [[SPMockNetworkConnection alloc] initWithRequestOption:SPHttpMethodPost successfulConnection:YES];
SPEmitterConfiguration *emitterConfig = [[SPEmitterConfiguration alloc] init];
emitterConfig.eventStore = [SPMockEventStore new];
emitterConfig.bufferOption = SPBufferOptionSingle;
SPNetworkConfiguration *networkConfig = [[SPNetworkConfiguration alloc] initWithEndpoint:@"" method:SPHttpMethodPost];
networkConfig.networkConnection = networkConnection;

SPTrackerConfiguration *trackerConfig = [[SPTrackerConfiguration new] appId:@"appid"];
trackerConfig.installAutotracking = false;
trackerConfig.screenViewAutotracking = false;
trackerConfig.lifecycleAutotracking = false;
id<SPTrackerController> tracker = [SPSnowplow createTrackerWithNamespace:@"namespace" network:networkConfig configurations:@[trackerConfig, emitterConfig]];
XCTAssertNotNil(tracker);

[tracker.emitter pause];
[tracker track:[[SPStructured alloc] initWithCategory:@"cat" action:@"act"]];
[NSThread sleepForTimeInterval:3];
XCTAssertEqual(1, [[tracker emitter] dbCount]);
XCTAssertEqual(0, networkConnection.previousResults.count);

[tracker.emitter resume];
[NSThread sleepForTimeInterval:3];
XCTAssertEqual(1, networkConnection.previousResults.count);
XCTAssertEqual(0, [[tracker emitter] dbCount]);
}


@end
3 changes: 1 addition & 2 deletions Snowplow iOSTests/Configurations/TestMultipleInstances.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// TestMultipleInstances.m
// Snowplow-iOSTests
//
// Copyright (c) 2013-2021 Snowplow Analytics Ltd. All rights reserved.
// 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
Expand All @@ -16,7 +16,6 @@
// language governing permissions and limitations there under.
//
// Authors: Alex Benini
// Copyright: Copyright (c) 2013-2021 Snowplow Analytics Ltd
// License: Apache License Version 2.0
//

Expand Down
3 changes: 1 addition & 2 deletions Snowplow iOSTests/Configurations/TestRemoteConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// TestRemoteConfiguration.m
// Snowplow-iOSTests
//
// Copyright (c) 2013-2021 Snowplow Analytics Ltd. All rights reserved.
// 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
Expand All @@ -16,7 +16,6 @@
// language governing permissions and limitations there under.
//
// Authors: Alex Benini
// Copyright: Copyright (c) 2013-2021 Snowplow Analytics Ltd
// License: Apache License Version 2.0
//

Expand Down
55 changes: 53 additions & 2 deletions Snowplow iOSTests/Configurations/TestTrackerConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// TestTrackerConfiguration.m
// Snowplow-iOSTests
//
// Copyright (c) 2013-2021 Snowplow Analytics Ltd. All rights reserved.
// 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
Expand All @@ -16,7 +16,6 @@
// language governing permissions and limitations there under.
//
// Authors: Alex Benini
// Copyright: Copyright (c) 2013-2021 Snowplow Analytics Ltd
// License: Apache License Version 2.0
//

Expand All @@ -26,6 +25,8 @@
#import "SPTrackerConfiguration.h"
#import "SPSession.h"
#import "SPMockEventStore.h"
#import "SPDataPersistence.h"


@interface TestTrackerConfiguration : XCTestCase

Expand Down Expand Up @@ -154,6 +155,56 @@ - (void)testSessionControllerUnavailableWhenContextTurnedOff {
XCTAssertNil(tracker.session);
}

- (void)testSessionConfigurationCallback {
[SPDataPersistence removeDataPersistenceWithNamespace:@"namespace"];
XCTestExpectation *expectation = [XCTestExpectation new];

SPNetworkConfiguration *networkConfig = [[SPNetworkConfiguration alloc] initWithEndpoint:@"https://fake-url" method:SPHttpMethodPost];
SPTrackerConfiguration *trackerConfig = [[SPTrackerConfiguration new] appId:@"appid"];
SPSessionConfiguration *sessionConfig = [[SPSessionConfiguration alloc] initWithForegroundTimeoutInSeconds:100 backgroundTimeoutInSeconds:100];

sessionConfig.onSessionStateUpdate = ^(SPSessionState * _Nonnull sessionState) {
XCTAssertEqual(1, sessionState.sessionIndex);
XCTAssertNil(sessionState.previousSessionId);
[expectation fulfill];
};

id<SPTrackerController> tracker = [SPSnowplow createTrackerWithNamespace:@"namespace" network:networkConfig configurations:@[trackerConfig, sessionConfig]];

[tracker track:[[SPTiming alloc] initWithCategory:@"cat" variable:@"var" timing:@123]];

[self waitForExpectations:@[expectation] timeout:10];
}

- (void)testSessionConfigurationCallbackAfterNewSession {
[SPDataPersistence removeDataPersistenceWithNamespace:@"namespace"];
XCTestExpectation *expectation = [XCTestExpectation new];

SPNetworkConfiguration *networkConfig = [[SPNetworkConfiguration alloc] initWithEndpoint:@"https://fake-url" method:SPHttpMethodPost];
SPTrackerConfiguration *trackerConfig = [[SPTrackerConfiguration new] appId:@"appid"];
SPSessionConfiguration *sessionConfig = [[SPSessionConfiguration alloc] initWithForegroundTimeoutInSeconds:100 backgroundTimeoutInSeconds:100];
__block NSString *sessionId;
sessionConfig.onSessionStateUpdate = ^(SPSessionState * _Nonnull sessionState) {
if (sessionState.sessionIndex == 1) {
XCTAssertNil(sessionState.previousSessionId);
sessionId = sessionState.sessionId;
} else {
XCTAssertEqual(2, sessionState.sessionIndex);
XCTAssertEqualObjects(sessionId, sessionState.previousSessionId);
[expectation fulfill];
}
};

id<SPTrackerController> tracker = [SPSnowplow createTrackerWithNamespace:@"namespace" network:networkConfig configurations:@[trackerConfig, sessionConfig]];

[tracker track:[[SPTiming alloc] initWithCategory:@"cat" variable:@"var" timing:@123]];
[tracker.session startNewSession];
[tracker track:[[SPTiming alloc] initWithCategory:@"cat" variable:@"var" timing:@123]];

[self waitForExpectations:@[expectation] timeout:10];
}


- (void)testTrackerVersionSuffix {
SPTrackerConfiguration *trackerConfiguration = [SPTrackerConfiguration new];
trackerConfiguration.trackerVersionSuffix = @"test With Space 1-2-3";
Expand Down
3 changes: 1 addition & 2 deletions Snowplow iOSTests/Configurations/TestTrackerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// TestTrackerController.m
// Snowplow-iOSTests
//
// Copyright (c) 2013-2021 Snowplow Analytics Ltd. All rights reserved.
// 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
Expand All @@ -16,7 +16,6 @@
// language governing permissions and limitations there under.
//
// Authors: Alex Benini
// Copyright: Copyright (c) 2013-2021 Snowplow Analytics Ltd
// License: Apache License Version 2.0
//

Expand Down
2 changes: 1 addition & 1 deletion Snowplow iOSTests/Global Contexts/TestGlobalContexts.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// TestGlobalContexts.m
// Snowplow-iOSTests
//
// Copyright (c) 2013-2021 Snowplow Analytics Ltd. All rights reserved.
// 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
Expand Down
2 changes: 1 addition & 1 deletion Snowplow iOSTests/Global Contexts/TestSchemaRuleset.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// TestSchemaRuleset.m
// Snowplow-iOSTests
//
// Copyright (c) 2013-2021 Snowplow Analytics Ltd. All rights reserved.
// 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
Expand Down
51 changes: 3 additions & 48 deletions Snowplow iOSTests/Legacy Tests/LegacyTestEmitter.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// LegacyTestEmitter.m
// Snowplow
//
// Copyright (c) 2013-2021 Snowplow Analytics Ltd. All rights reserved.
// 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
Expand All @@ -25,6 +25,7 @@
#import "SPEmitter.h"
#import "SPLogger.h"
#import "SPMockEventStore.h"
#import "SPMockNetworkConnection.h"


@interface SPBrokenNetworkConnection : NSObject <SPNetworkConnection>
Expand All @@ -49,52 +50,6 @@ - (SPHttpMethod)httpMethod {

@end


@interface SPMockNetworkConnection : NSObject <SPNetworkConnection>

@property (nonatomic) BOOL successfulConnection;
@property (nonatomic) SPHttpMethod httpMethod;
@property (nonatomic) NSMutableArray<NSMutableArray<SPRequestResult *> *> *previousResults;

@end

@implementation SPMockNetworkConnection

- initWithRequestOption:(SPHttpMethod)httpMethod successfulConnection:(BOOL)successfulConnection {
if (self = [super init]) {
self.httpMethod = httpMethod;
self.successfulConnection = successfulConnection;
self.previousResults = [NSMutableArray new];
}
return self;
}

- (nonnull NSArray<SPRequestResult *> *)sendRequests:(nonnull NSArray<SPRequest *> *)requests {
NSMutableArray<SPRequestResult *> *requestResults = [NSMutableArray new];
for (SPRequest *request in requests) {
BOOL isSuccessful = request.oversize || self.successfulConnection;
SPRequestResult *result = [[SPRequestResult alloc] initWithSuccess:isSuccessful storeIds:request.emitterEventIds];
SPLogVerbose(@"Sent %@ with success %@", request.emitterEventIds, isSuccessful ? @"YES" : @"NO");
[requestResults addObject:result];
}
[self.previousResults addObject:requestResults];
return requestResults;
}

- (SPHttpMethod)httpMethod {
return _httpMethod;
}

- (nonnull NSURL *)url {
return [NSURL URLWithString:@"http://fake-url.com"];
}

- (NSUInteger)sendingCount {
return self.previousResults.count;
}

@end

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"

Expand Down Expand Up @@ -179,7 +134,7 @@ - (void)testEmitterBuilderAndOptions {

// Allow timer to be set
[[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]];
[emitter resume];
[emitter resumeTimer];
}

// MARK: - Emitting tests
Expand Down
3 changes: 1 addition & 2 deletions Snowplow iOSTests/Legacy Tests/LegacyTestEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// TestEvent.m
// Snowplow
//
// Copyright (c) 2013-2021 Snowplow Analytics Ltd. All rights reserved.
// 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
Expand All @@ -16,7 +16,6 @@
// language governing permissions and limitations there under.
//
// Authors: Jonathan Almeida, Joshua Beemster
// Copyright: Copyright (c) 2013-2021 Snowplow Analytics Ltd
// License: Apache License Version 2.0
//

Expand Down
2 changes: 1 addition & 1 deletion Snowplow iOSTests/Legacy Tests/LegacyTestSubject.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// LegacyTestSubject.m
// Snowplow
//
// Copyright (c) 2013-2021 Snowplow Analytics Ltd. All rights reserved.
// 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
Expand Down
Loading

0 comments on commit d223aa3

Please sign in to comment.