Skip to content

Commit

Permalink
Merge pull request #606 from snowplow/release/2.0.2
Browse files Browse the repository at this point in the history
Release/2.0.2
  • Loading branch information
AlexBenny authored May 24, 2021
2 parents c40aa20 + 78d1f7e commit 30440e5
Show file tree
Hide file tree
Showing 13 changed files with 345 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

Version 2.0.2 (2021-05-24)
--------------------------
Add geolocation to SubjectConfiguration and SubjectController (#604)
Fix duplicate NS_SWIFT_NAME macro (#603)
Fix IDFA not accessible on iOS 14 (#601)

Version 2.0.1 (2021-05-12)
--------------------------
Fix crash if data from Database is corrupted (#596) (Contribution of @glukhanyk)
Expand Down
12 changes: 12 additions & 0 deletions Snowplow iOSTests/Configurations/TestTrackerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,16 @@ - (void)testSubjectUserIdCanBeUpdated {
XCTAssertNil(tracker.subject.userId);
}

- (void)testSubjectGeoLocationCanBeUpdated {
id<SPTrackerController> tracker = [SPSnowplow createTrackerWithNamespace:@"namespace" endpoint:@"https://fake-url" method:SPHttpMethodPost];
XCTAssertNotNil(tracker.subject);
XCTAssertNil(tracker.subject.geoLatitude);
tracker.subject.geoLatitude = @12.3456;
XCTAssertEqualObjects([NSNumber numberWithFloat:12.3456], tracker.subject.geoLatitude);
tracker.subject.geoLatitude = nil;
// TODO: On version 3 setting to nil should get back nil.
// Here it should be nil rather than 0 but it's the way the beneith SPSubject works.
XCTAssertEqualObjects([NSNumber numberWithFloat:0], tracker.subject.geoLatitude);
}

@end
13 changes: 13 additions & 0 deletions Snowplow iOSTests/Legacy Tests/LegacyTestSubject.m
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ - (void) testGeoLocationGetWithoutNeededKeys {
XCTAssertNotNil([subject getGeoLocationDict]);
}

- (void)testGeoLocationWithSubjectConfiguration {
SPSubjectConfiguration *config = [[SPSubjectConfiguration alloc] init];
config.geoLatitude = @12.12;
config.geoLongitude = @24.24;
SPSubject * subject = [[SPSubject alloc] initWithPlatformContext:NO geoLocationContext:YES subjectConfiguration:config];

NSDictionary *values = [subject getGeoLocationDict];

XCTAssertEqualObjects([NSNumber numberWithFloat:12.12], [values objectForKey:kSPGeoLatitude]);
XCTAssertEqualObjects([NSNumber numberWithFloat:24.24], [values objectForKey:kSPGeoLongitude]);
XCTAssertNil(values[kSPGeoAltitude]);
}

@end

#pragma clang diagnostic pop
68 changes: 68 additions & 0 deletions Snowplow/Internal/Configurations/SPSubjectConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,48 @@ NS_SWIFT_NAME(SubjectConfigurationProtocol)
*/
@property (nullable) NSNumber *colorDepth;

// MARK: - GeoLocation

/*!
Latitude value for the geolocation context.
*/
@property (nullable) NSNumber *geoLatitude;

/*!
Longitude value for the geo context.
*/
@property (nullable) NSNumber *geoLongitude;

/*!
LatitudeLongitudeAccuracy value for the geolocation context.
*/
@property (nullable) NSNumber *geoLatitudeLongitudeAccuracy;

/*!
Altitude value for the geolocation context.
*/
@property (nullable) NSNumber *geoAltitude;

/*!
AltitudeAccuracy value for the geolocation context.
*/
@property (nullable) NSNumber *geoAltitudeAccuracy;

/*!
Bearing value for the geolocation context.
*/
@property (nullable) NSNumber *geoBearing;

/*!
Speed value for the geolocation context.
*/
@property (nullable) NSNumber *geoSpeed;

/*!
Timestamp value for the geolocation context.
*/
@property (nullable) NSNumber *geoTimestamp;

@end

/**
Expand Down Expand Up @@ -146,6 +188,32 @@ SP_BUILDER_DECLARE_NULLABLE(SPSize *, screenViewPort)
*/
SP_BUILDER_DECLARE_NULLABLE(NSNumber *, colorDepth)

// GeoLocation builders

/// Latitude value for the geolocation context.
SP_BUILDER_DECLARE_NULLABLE(NSNumber *, geoLatitude)

/// Longitude value for the geo context.
SP_BUILDER_DECLARE_NULLABLE(NSNumber *, geoLongitude)

/// LatitudeLongitudeAccuracy value for the geolocation context.
SP_BUILDER_DECLARE_NULLABLE(NSNumber *, geoLatitudeLongitudeAccuracy)

/// Altitude value for the geolocation context.
SP_BUILDER_DECLARE_NULLABLE(NSNumber *, geoAltitude)

/// AltitudeAccuracy value for the geolocation context.
SP_BUILDER_DECLARE_NULLABLE(NSNumber *, geoAltitudeAccuracy)

/// Bearing value for the geolocation context.
SP_BUILDER_DECLARE_NULLABLE(NSNumber *, geoBearing)

/// Speed value for the geolocation context.
SP_BUILDER_DECLARE_NULLABLE(NSNumber *, geoSpeed)

/// Timestamp value for the geolocation context.
SP_BUILDER_DECLARE_NULLABLE(NSNumber *, geoTimestamp)

@end

NS_ASSUME_NONNULL_END
47 changes: 47 additions & 0 deletions Snowplow/Internal/Configurations/SPSubjectConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ @implementation SPSubjectConfiguration
@synthesize screenViewPort;
@synthesize colorDepth;

@synthesize geoLatitude;
@synthesize geoLongitude;
@synthesize geoLatitudeLongitudeAccuracy;
@synthesize geoAltitude;
@synthesize geoAltitudeAccuracy;
@synthesize geoSpeed;
@synthesize geoBearing;
@synthesize geoTimestamp;

// MARK: - Builder

SP_BUILDER_METHOD(NSString *, userId)
Expand All @@ -82,6 +91,16 @@ @implementation SPSubjectConfiguration
SP_BUILDER_METHOD(SPSize *, screenViewPort)
SP_BUILDER_METHOD(NSNumber *, colorDepth)

// geolocation
SP_BUILDER_METHOD(NSNumber *, geoLatitude)
SP_BUILDER_METHOD(NSNumber *, geoLongitude)
SP_BUILDER_METHOD(NSNumber *, geoLatitudeLongitudeAccuracy)
SP_BUILDER_METHOD(NSNumber *, geoAltitude)
SP_BUILDER_METHOD(NSNumber *, geoAltitudeAccuracy)
SP_BUILDER_METHOD(NSNumber *, geoBearing)
SP_BUILDER_METHOD(NSNumber *, geoSpeed)
SP_BUILDER_METHOD(NSNumber *, geoTimestamp)

// MARK: - NSCopying

- (id)copyWithZone:(nullable NSZone *)zone {
Expand All @@ -96,6 +115,16 @@ - (id)copyWithZone:(nullable NSZone *)zone {
copy.screenResolution = self.screenResolution;
copy.screenViewPort = self.screenViewPort;
copy.colorDepth = self.colorDepth;

// geolocation
copy.geoLatitude = self.geoLatitude;
copy.geoLongitude = self.geoLongitude;
copy.geoLatitudeLongitudeAccuracy = self.geoLatitudeLongitudeAccuracy;
copy.geoAltitude = self.geoAltitude;
copy.geoAltitudeAccuracy = self.geoAltitudeAccuracy;
copy.geoSpeed = self.geoSpeed;
copy.geoBearing = self.geoBearing;
copy.geoTimestamp = self.geoTimestamp;
return copy;
}

Expand All @@ -112,6 +141,15 @@ - (void)encodeWithCoder:(nonnull NSCoder *)coder {
[coder encodeObject:self.screenResolution forKey:SP_STR_PROP(screenResolution)];
[coder encodeObject:self.screenViewPort forKey:SP_STR_PROP(screenViewPort)];
[coder encodeObject:self.colorDepth forKey:SP_STR_PROP(colorDepth)];
// geolocation
[coder encodeObject:self.geoLatitude forKey:SP_STR_PROP(geoLatitude)];
[coder encodeObject:self.geoLongitude forKey:SP_STR_PROP(geoLongitude)];
[coder encodeObject:self.geoLatitudeLongitudeAccuracy forKey:SP_STR_PROP(geoLatitudeLongitudeAccuracy)];
[coder encodeObject:self.geoAltitude forKey:SP_STR_PROP(geoAltitude)];
[coder encodeObject:self.geoAltitudeAccuracy forKey:SP_STR_PROP(geoAltitudeAccuracy)];
[coder encodeObject:self.geoSpeed forKey:SP_STR_PROP(geoSpeed)];
[coder encodeObject:self.geoBearing forKey:SP_STR_PROP(geoBearing)];
[coder encodeObject:self.geoTimestamp forKey:SP_STR_PROP(geoTimestamp)];
}

- (nullable instancetype)initWithCoder:(nonnull NSCoder *)coder {
Expand All @@ -126,6 +164,15 @@ - (nullable instancetype)initWithCoder:(nonnull NSCoder *)coder {
self.screenResolution = [coder decodeObjectForKey:SP_STR_PROP(screenResolution)];
self.screenViewPort = [coder decodeObjectForKey:SP_STR_PROP(screenViewPort)];
self.colorDepth = [coder decodeObjectForKey:SP_STR_PROP(colorDepth)];
// geolocation
self.geoLatitude = [coder decodeObjectForKey:SP_STR_PROP(geoLatitude)];
self.geoLongitude = [coder decodeObjectForKey:SP_STR_PROP(geoLongitude)];
self.geoLatitudeLongitudeAccuracy = [coder decodeObjectForKey:SP_STR_PROP(geoLatitudeLongitudeAccuracy)];
self.geoAltitude = [coder decodeObjectForKey:SP_STR_PROP(geoAltitude)];
self.geoAltitudeAccuracy = [coder decodeObjectForKey:SP_STR_PROP(geoAltitudeAccuracy)];
self.geoSpeed = [coder decodeObjectForKey:SP_STR_PROP(geoSpeed)];
self.geoBearing = [coder decodeObjectForKey:SP_STR_PROP(geoBearing)];
self.geoTimestamp = [coder decodeObjectForKey:SP_STR_PROP(geoTimestamp)];
}
return self;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

NS_ASSUME_NONNULL_BEGIN

NS_SWIFT_NAME(NetworkController)
NS_SWIFT_NAME(NetworkControllerImpl)
@interface SPNetworkControllerImpl : NSObject <SPNetworkController>

- (instancetype)initWithEmitter:(SPEmitter *)emitter;
Expand Down
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.0.1";
NSString * const kSPVersion = @"ios-2.0.2";
#elif SNOWPLOW_TARGET_TV
NSString * const kSPVersion = @"tvos-2.0.1";
NSString * const kSPVersion = @"tvos-2.0.2";
#elif SNOWPLOW_TARGET_WATCHOS
NSString * const kSPVersion = @"watchos-2.0.1";
NSString * const kSPVersion = @"watchos-2.0.2";
#else
NSString * const kSPVersion = @"osx-2.0.1";
NSString * const kSPVersion = @"osx-2.0.2";
#endif

// --- Emitter
Expand Down
8 changes: 8 additions & 0 deletions Snowplow/Internal/Subject/SPSubject.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,55 +186,63 @@ NS_SWIFT_NAME(Subject)
@param latitude A non-nil number.
*/
- (void) setGeoLatitude:(float)latitude;
- (NSNumber *)geoLatitude;

/*!
@brief Sets the longitude value for the geo context.
@param longitude A non-nil number.
*/
- (void) setGeoLongitude:(float)longitude;
- (NSNumber *)geoLongitude;

/*!
@brief Sets the latitudeLongitudeAccuracy value for the geolocation context.
@param latitudeLongitudeAccuracy A non-nil number
*/
- (void) setGeoLatitudeLongitudeAccuracy:(float)latitudeLongitudeAccuracy;
- (NSNumber *)geoLatitudeLongitudeAccuracy;

/*!
@brief Sets the altitude value for the geolocation context.
@param altitude A non-nil number.
*/
- (void) setGeoAltitude:(float)altitude;
- (NSNumber *)geoAltitude;

/*!
@brief Sets the altitudeAccuracy value for the geolocation context.
@param altitudeAccuracy A non-nil number.
*/
- (void) setGeoAltitudeAccuracy:(float)altitudeAccuracy;
- (NSNumber *)geoAltitudeAccuracy;

/*!
@brief Sets the bearing value for the geolocation context.
@param bearing A non-nil number.
*/
- (void) setGeoBearing:(float)bearing;
- (NSNumber *)geoBearing;

/*!
@brief Sets the speed value for the geolocation context.
@param speed A non-nil number.
*/
- (void) setGeoSpeed:(float)speed;
- (NSNumber *)geoSpeed;

/*!
@brief Sets the timestamp value for the geolocation context.
@param timestamp The timestamp.
*/
- (void) setGeoTimestamp:(NSNumber *)timestamp;
- (NSNumber *)geoTimestamp;

@end

57 changes: 57 additions & 0 deletions Snowplow/Internal/Subject/SPSubject.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,31 @@ - (instancetype)initWithPlatformContext:(BOOL)platformContext geoLocationContext
if (config.colorDepth) {
[self setColorDepth:config.colorDepth.integerValue];
}
// geolocation
if (config.geoLatitude) {
[self setGeoLatitude:config.geoLatitude.floatValue];
}
if (config.geoLongitude) {
[self setGeoLongitude:config.geoLongitude.floatValue];
}
if (config.geoLatitudeLongitudeAccuracy) {
[self setGeoLatitudeLongitudeAccuracy:config.geoLatitudeLongitudeAccuracy.floatValue];
}
if (config.geoAltitude) {
[self setGeoAltitude:config.geoAltitude.floatValue];
}
if (config.geoAltitudeAccuracy) {
[self setGeoAltitudeAccuracy:config.geoAltitudeAccuracy.floatValue];
}
if (config.geoSpeed) {
[self setGeoSpeed:config.geoSpeed.floatValue];
}
if (config.geoBearing) {
[self setGeoBearing:config.geoBearing.floatValue];
}
if (config.geoTimestamp) {
[self setGeoTimestamp:config.geoTimestamp];
}
}
}
return self;
Expand Down Expand Up @@ -193,32 +218,64 @@ - (void) setGeoLatitude:(float)latitude {
[_geoLocationDict setObject:[NSNumber numberWithFloat:latitude] forKey:kSPGeoLatitude];
}

- (NSNumber *)geoLatitude {
return (NSNumber *)_geoLocationDict[kSPGeoLatitude];
}

- (void) setGeoLongitude:(float)longitude {
[_geoLocationDict setObject:[NSNumber numberWithFloat:longitude] forKey:kSPGeoLongitude];
}

- (NSNumber *)geoLongitude {
return (NSNumber *)_geoLocationDict[kSPGeoLongitude];
}

- (void) setGeoLatitudeLongitudeAccuracy:(float)latitudeLongitudeAccuracy {
[_geoLocationDict setObject:[NSNumber numberWithFloat:latitudeLongitudeAccuracy] forKey:kSPGeoLatLongAccuracy];
}

- (NSNumber *)geoLatitudeLongitudeAccuracy {
return (NSNumber *)_geoLocationDict[kSPGeoLatLongAccuracy];
}

- (void) setGeoAltitude:(float)altitude {
[_geoLocationDict setObject:[NSNumber numberWithFloat:altitude] forKey:kSPGeoAltitude];
}

- (NSNumber *)geoAltitude {
return (NSNumber *)_geoLocationDict[kSPGeoAltitude];
}

- (void) setGeoAltitudeAccuracy:(float)altitudeAccuracy {
[_geoLocationDict setObject:[NSNumber numberWithFloat:altitudeAccuracy] forKey:kSPGeoAltitudeAccuracy];
}

- (NSNumber *)geoAltitudeAccuracy {
return (NSNumber *)_geoLocationDict[kSPGeoAltitudeAccuracy];
}

- (void) setGeoBearing:(float)bearing {
[_geoLocationDict setObject:[NSNumber numberWithFloat:bearing] forKey:kSPGeoBearing];
}

- (NSNumber *)geoBearing {
return (NSNumber *)_geoLocationDict[kSPGeoBearing];
}

- (void) setGeoSpeed:(float)speed {
[_geoLocationDict setObject:[NSNumber numberWithFloat:speed] forKey:kSPGeoSpeed];
}

- (NSNumber *)geoSpeed {
return (NSNumber *)_geoLocationDict[kSPGeoSpeed];
}

- (void) setGeoTimestamp:(NSNumber *)timestamp {
[_geoLocationDict setObject:timestamp forKey:kSPGeoTimestamp];
}

- (NSNumber *)geoTimestamp {
return (NSNumber *)_geoLocationDict[kSPGeoTimestamp];
}

@end
Loading

0 comments on commit 30440e5

Please sign in to comment.