Skip to content

Commit

Permalink
Merge pull request #1 from walmartlabs-wmusiphone/mparticle-6.17.0
Browse files Browse the repository at this point in the history
mParticle version 6.17.0
  • Loading branch information
Tres Spicher authored Mar 29, 2018
2 parents 1178a0a + 3a46e1c commit 8658468
Show file tree
Hide file tree
Showing 49 changed files with 552 additions and 978 deletions.
55 changes: 55 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,60 @@
# mParticle Apple SDK CHANGELOG

## 6.15.16

### Core SDK Updates

This release fixes an issue with setting user attributes concurrently from multiple threads.

### Kit Updates

- None

## 6.15.15

### Core SDK Updates

This release introduces a new API to kit developers. Kits can now delay the first upload of the Core SDK. This is to allow for necessary 3rd-party ID collection.

### Kit Updates

- Update Adobe kit to delay uploads prior to MCID collection

## 6.15.14

### Core SDK Updates

- Always forward didReceiveRemoteNotification API
- Fix main thread error

### Kit Updates

- Add Carthage support to Leanplum
- Update Apptentive SDK to 4.0.7
- Update BranchMetrics SDK to 0.20.2

## 6.15.13

### Core SDK Updates

- None

### Kit Updates

- Update UrbanAirship kit with named user support

## 6.15.12

### Core SDK Updates

- Disable code coverage settings
- Limit how often config requests can be sent

### Kit Updates

- Update Appboy kit with simplified endpoint logic
- Update ComScore SDK to 5.0

## 6.15.11

### Core SDK Updates
Expand Down
2 changes: 1 addition & 1 deletion Framework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>6.15.11</string>
<string>6.17.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Kit | CocoaPods | Carthage
[Iterable](https://github.com/mparticle-integrations/mparticle-apple-integration-iterable) | ✓ | ✓
[Kahuna](https://github.com/mparticle-integrations/mparticle-apple-integration-kahuna) | ✓ |
[Kochava](https://github.com/mparticle-integrations/mparticle-apple-integration-kochava) | ✓ |
[Leanplum](https://github.com/mparticle-integrations/mparticle-apple-integration-leanplum) | ✓ |
[Leanplum](https://github.com/mparticle-integrations/mparticle-apple-integration-leanplum) | ✓ |
[Localytics](https://github.com/mparticle-integrations/mparticle-apple-integration-localytics) | ✓ |
[Primer](https://github.com/mparticle-integrations/mparticle-apple-integration-primer) | ✓ | ✓
[Radar](https://github.com/mparticle-integrations/mparticle-apple-integration-radar) | ✓ |
Expand Down
6 changes: 4 additions & 2 deletions UnitTests/MPAppNotificationHandlerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ - (void)testOpenURLOptions {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wtautological-pointer-compare"
#pragma clang diagnostic ignored "-Wunreachable-code"
if (&UIApplicationOpenURLOptionsSourceApplicationKey != NULL) {
options = @{UIApplicationOpenURLOptionsSourceApplicationKey:@"testApp"};
if (@available(iOS 9.0, *)) {
if (&UIApplicationOpenURLOptionsSourceApplicationKey != NULL) {
options = @{UIApplicationOpenURLOptionsSourceApplicationKey:@"testApp"};
}
}
#pragma clang diagnostic pop
[appNotificationHandler openURL:url options:options];
Expand Down
3 changes: 1 addition & 2 deletions UnitTests/MPBackendControllerTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ + (void)includeUnitTestKits:(NSArray<NSNumber *> *)kitCodes;
@interface MPBackendController(Tests)

@property (nonatomic, strong) MPNetworkCommunication *networkCommunication;
@property (nonatomic, strong) NSMutableDictionary *userAttributes;
@property (nonatomic, strong) NSMutableArray *userIdentities;
@property (nonatomic, unsafe_unretained) MPInitializationStatus initializationStatus;

Expand Down Expand Up @@ -840,7 +839,7 @@ - (void)testUserAttributes {
XCTAssertEqualObjects(userAttributes, attributes);

[self.backendController setUserAttribute:@"TardisKey4" values:nil attempt:0 completionHandler:^(NSString * _Nonnull key, NSArray<NSString *> * _Nullable values, MPExecStatus execStatus) {}];
XCTAssertNil(userAttributes[@"TardisKey4"]);
XCTAssertNil(self.backendController.userAttributes[@"TardisKey4"]);

attributes = @{@"TardisKey2":[NSNull null],
@"TardisKey3":@42
Expand Down
2 changes: 2 additions & 0 deletions UnitTests/MPForwardRecordTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ - (void)testEquality {
execStatus:execStatus
stateFlag:YES];

forwardRecord2.timestamp = forwardRecord1.timestamp;

XCTAssertEqualObjects(forwardRecord1, forwardRecord2, @"Should have been equal");

forwardRecord1.forwardRecordId = 123;
Expand Down
7 changes: 7 additions & 0 deletions UnitTests/MPKitContainerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -2104,4 +2104,11 @@ - (void)testExpandedCommerceEventProjection {
[self resetUserAttributesAndIdentities];
}

- (void)testShouldDelayUploadMaxTime {
MPKitContainer *localKitContainer = [[MPKitContainer alloc] init];
[localKitContainer setKitsInitialized:NO];
XCTAssertFalse([localKitContainer shouldDelayUpload:0]);
XCTAssertTrue([localKitContainer shouldDelayUpload:10000]);
}

@end
139 changes: 0 additions & 139 deletions UnitTests/MPPersistenceControllerTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,6 @@ - (void)tearDown {
[super tearDown];
}

- (NSDictionary *)remoteNotificationDictionary:(BOOL)expired {
NSTimeInterval increment = expired ? -100 : 100;

NSDictionary *remoteNotificationDictionary = @{@"aps":@{
@"alert":@{
@"body":@"Your pre-historic ride has arrived.",
@"show-view":@NO
},
@"badge":@1,
@"sound":@"t-rex_roar.aiff",
@"category":@"DINOSAUR_TRANSPORTATION_CATEGORY"
},
@"m_cmd":@1,
@"m_cid":@2,
@"m_cntid":@3,
@"m_expy":MPMilliseconds([[NSDate date] timeIntervalSince1970] + increment),
@"m_uid":@(arc4random_uniform(INT_MAX))
};

return remoteNotificationDictionary;
}

- (NSDictionary *)nonmParticleRemoteNotificationDictionary {
NSDictionary *remoteNotificationDictionary = @{@"aps":@{
@"alert":@{
Expand Down Expand Up @@ -576,121 +554,4 @@ - (void)testForwardRecord {
XCTAssertNil(forwardRecords);
}

#if TARGET_OS_IOS == 1
- (void)testRemoteNotification {
MPPersistenceController *persistence = [MPPersistenceController sharedInstance];

[persistence fetchUserNotificationCampaignHistory:^(NSArray<MParticleUserNotification *> *userNotificationCampaignHistory) {
for (MParticleUserNotification *userNotification in userNotificationCampaignHistory) {
[persistence deleteUserNotification:userNotification];
}
}];

NSDictionary *remoteNotificationDictionary = [self remoteNotificationDictionary:NO];

MParticleUserNotification *userNotification = [[MParticleUserNotification alloc] initWithDictionary:remoteNotificationDictionary
actionIdentifier:nil
state:kMPPushNotificationStateBackground
behavior:MPUserNotificationBehaviorDirectOpen
mode:MPUserNotificationModeRemote
runningMode:MPUserNotificationRunningModeBackground];

XCTAssertNotNil(userNotification, @"Remote notification should not have been nil.");

[persistence saveUserNotification:userNotification];

XCTAssertGreaterThan(userNotification.userNotificationId, 0, @"Remote notification id is not being assign.");

MParticleUserNotification *latestRemoteNotification = [[persistence fetchDisplayedRemoteUserNotifications] firstObject];
XCTAssertNotNil(latestRemoteNotification, @"Latest remote notification should not have been nil.");
XCTAssertEqualObjects(userNotification, latestRemoteNotification);
XCTAssertFalse(userNotification.hasBeenUsedInInfluencedOpen, @"Should not have been marked as used in influenced open.");

userNotification.hasBeenUsedInInfluencedOpen = YES;
[persistence updateUserNotification:userNotification];

latestRemoteNotification = [[persistence fetchDisplayedRemoteUserNotifications] firstObject];

XCTestExpectation *expectation = [self expectationWithDescription:@"Remote notification test"];

[persistence fetchUserNotificationCampaignHistory:^(NSArray<MParticleUserNotification *> *userNotificationCampaignHistory) {
MParticleUserNotification *fetchedRemoteNotification = [userNotificationCampaignHistory lastObject];
XCTAssertNotNil(fetchedRemoteNotification, @"Fetched remote notification should not have been nil.");
XCTAssertTrue(fetchedRemoteNotification.hasBeenUsedInInfluencedOpen, @"Should have been marked as used in influenced open.");
XCTAssertTrue(latestRemoteNotification.hasBeenUsedInInfluencedOpen, @"Should have been marked as used in influenced open.");

[persistence deleteUserNotification:userNotification];

[persistence fetchUserNotificationCampaignHistory:^(NSArray *userNotificationCampaignHistory) {
MParticleUserNotification *fetchedRemoteNotification = [userNotificationCampaignHistory lastObject];
XCTAssertNil(fetchedRemoteNotification, @"Remote notification should have been deleted.");

[expectation fulfill];
}];
}];

[self waitForExpectationsWithTimeout:DATABASE_TESTS_EXPECTATIONS_TIMEOUT handler:nil];
}

- (void)testExpiredRemoteNotification {
MPPersistenceController *persistence = [MPPersistenceController sharedInstance];

[persistence fetchUserNotificationCampaignHistory:^(NSArray<MParticleUserNotification *> *userNotificationCampaignHistory) {
for (MParticleUserNotification *userNotification in userNotificationCampaignHistory) {
[persistence deleteUserNotification:userNotification];
}
}];

NSDictionary *remoteNotificationDictionary = [self remoteNotificationDictionary:YES];

MParticleUserNotification *userNotification = [[MParticleUserNotification alloc] initWithDictionary:remoteNotificationDictionary
actionIdentifier:nil
state:kMPPushNotificationStateBackground
behavior:MPUserNotificationBehaviorReceived
mode:MPUserNotificationModeRemote
runningMode:MPUserNotificationRunningModeBackground];


[persistence saveUserNotification:userNotification];

XCTestExpectation *expectation = [self expectationWithDescription:@"Expired remote notification test"];

[persistence fetchUserNotificationCampaignHistory:^(NSArray<MParticleUserNotification *> *userNotificationCampaignHistory) {
MParticleUserNotification *fetchedRemoteNotification = [userNotificationCampaignHistory lastObject];

fetchedRemoteNotification = [[persistence fetchUserNotifications] firstObject];
XCTAssertNotNil(fetchedRemoteNotification, @"Fetched remote notification should not have been nil.");

[persistence deleteExpiredUserNotifications];
fetchedRemoteNotification = [[persistence fetchUserNotifications] firstObject];
XCTAssertNil(fetchedRemoteNotification, @"Fetched remote notification should have been nil.");

[expectation fulfill];
}];

[self waitForExpectationsWithTimeout:DATABASE_TESTS_EXPECTATIONS_TIMEOUT handler:nil];
}

- (void)testNonmParticleRemoteNotification {
NSDictionary *remoteNotificationDictionary = [self nonmParticleRemoteNotificationDictionary];

MParticleUserNotification *userNotification = [[MParticleUserNotification alloc] initWithDictionary:remoteNotificationDictionary
actionIdentifier:nil
state:kMPPushNotificationStateBackground
behavior:(MPUserNotificationBehaviorDirectOpen | MPUserNotificationBehaviorRead)
mode:MPUserNotificationModeRemote
runningMode:MPUserNotificationRunningModeBackground];

MPPersistenceController *persistence = [MPPersistenceController sharedInstance];
[persistence saveUserNotification:userNotification];
MParticleUserNotification *latestRemoteNotification = [[persistence fetchDisplayedRemoteUserNotifications] firstObject];

if (latestRemoteNotification) {
XCTAssertNotEqual(userNotification, latestRemoteNotification, @"Non mParticle user notifications should not have been persisted.");
} else {
XCTAssertNil(latestRemoteNotification, @"Non mParticle user notifications should not be persisted.");
}
}
#endif

@end
62 changes: 62 additions & 0 deletions UnitTests/MPURLRequestBuilderTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@
#import "MPKitContainer.h"
#import "MPKitTestClass.h"
#import "MPIUserDefaults.h"
#import "mParticle.h"

#pragma mark - MPURLRequestBuilder category
@interface MPURLRequestBuilder(Tests)

- (NSString *)hmacSha256Encode:(NSString *const)message key:(NSString *const)key;
- (NSString *)userAgent;
- (void)setUserAgent:(NSString *const)userAgent;
- (NSString *)fallbackUserAgent;

@end

Expand Down Expand Up @@ -78,6 +81,7 @@ - (void)testUserAgent {
MPURLRequestBuilder *urlRequestBuilder = [MPURLRequestBuilder newBuilderWithURL:[networkCommunication eventURL]
message:[standaloneMessage serializedString]
httpMethod:@"POST"];
[urlRequestBuilder setUserAgent:nil];

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *userAgent = [urlRequestBuilder userAgent];
Expand All @@ -88,6 +92,64 @@ - (void)testUserAgent {
[self waitForExpectationsWithTimeout:1 handler:nil];
}

- (void)testCustomUserAgent {
[MParticle sharedInstance].customUserAgent = @"Test User Agent";

XCTestExpectation *expectation = [self expectationWithDescription:@"User-Agent"];

MPNetworkCommunication *networkCommunication = [[MPNetworkCommunication alloc] init];

MPStandaloneMessage *standaloneMessage = [[MPStandaloneMessage alloc] initWithMessageType:@"e"
messageInfo:@{@"key":@"value"}
uploadStatus:MPUploadStatusBatch
UUID:[[NSUUID UUID] UUIDString]
timestamp:[[NSDate date] timeIntervalSince1970]];

MPURLRequestBuilder *urlRequestBuilder = [MPURLRequestBuilder newBuilderWithURL:[networkCommunication eventURL]
message:[standaloneMessage serializedString]
httpMethod:@"POST"];
[urlRequestBuilder setUserAgent:nil];

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *userAgent = [urlRequestBuilder userAgent];
XCTAssertNotNil(userAgent, @"Should not have been nil.");
XCTAssertTrue([userAgent isEqualToString:@"Test User Agent"], @"User Agent has an invalid value: %@", userAgent);
[expectation fulfill];
});

[self waitForExpectationsWithTimeout:1 handler:nil];
}

- (void)testDisableCollectUserAgent {
[MParticle sharedInstance].customUserAgent = nil;
[MParticle sharedInstance].collectUserAgent = NO;

XCTestExpectation *expectation = [self expectationWithDescription:@"User-Agent"];

MPNetworkCommunication *networkCommunication = [[MPNetworkCommunication alloc] init];

MPStandaloneMessage *standaloneMessage = [[MPStandaloneMessage alloc] initWithMessageType:@"e"
messageInfo:@{@"key":@"value"}
uploadStatus:MPUploadStatusBatch
UUID:[[NSUUID UUID] UUIDString]
timestamp:[[NSDate date] timeIntervalSince1970]];

MPURLRequestBuilder *urlRequestBuilder = [MPURLRequestBuilder newBuilderWithURL:[networkCommunication eventURL]
message:[standaloneMessage serializedString]
httpMethod:@"POST"];
[urlRequestBuilder setUserAgent:nil];

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *userAgent = [urlRequestBuilder userAgent];
NSString *fallbackAgent = [urlRequestBuilder fallbackUserAgent];
XCTAssertNotNil(userAgent, @"Should not have been nil.");
XCTAssert([userAgent isEqualToString:fallbackAgent], @"User Agent has an invalid value: %@", userAgent);
[expectation fulfill];
});

[self waitForExpectationsWithTimeout:1 handler:nil];
}

- (void)testHMACSha256Encode {
MPURLRequestBuilder *urlRequestBuilder = [MPURLRequestBuilder newBuilderWithURL:[NSURL URLWithString:@"http://mparticle.com"]];
MPStateMachine *stateMachine = [MPStateMachine sharedInstance];
Expand Down
2 changes: 1 addition & 1 deletion mParticle-Apple-SDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "mParticle-Apple-SDK"
s.version = "6.15.11"
s.version = "6.17.0"
s.summary = "mParticle Apple SDK."

s.description = <<-DESC
Expand Down
Loading

0 comments on commit 8658468

Please sign in to comment.