Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replay time ordering #405

Merged
merged 28 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
83ace70
Include locationMs, and replayRequestMs
lmeier Oct 21, 2024
233ccc2
Ensure updatedAtMsDiff is correct
lmeier Oct 21, 2024
3b84c99
bump version
lmeier Oct 21, 2024
2e7bbbd
fix ordering
lmeier Oct 21, 2024
109283d
correct version
lmeier Oct 21, 2024
9ee710f
Add logging of visits
lmeier Oct 23, 2024
dcd18b8
simplify to just updatedAtMsDiff
lmeier Oct 25, 2024
531feb1
fix lint error
lmeier Oct 25, 2024
ce6fb3a
always include updatedAtMsDiff
lmeier Oct 25, 2024
19dfb83
log cleanup
lmeier Oct 28, 2024
b6a5ee8
Merge branch 'master' into replayTimestamps
lmeier Oct 28, 2024
cc8b817
timeInMs --> locationMs, don't send updatedAtMsDiff if verified
lmeier Nov 7, 2024
161cba4
extra bracket
lmeier Nov 7, 2024
8d7bdd6
nit
lmeier Nov 7, 2024
a214c59
Merge branch 'master' into replayTimestamps
KennyHuRadar Nov 7, 2024
2d22f43
not verified or not foreground
lmeier Nov 7, 2024
9b1432c
version bump
KennyHuRadar Nov 7, 2024
a3818cf
don't conditionalize for verified
lmeier Nov 8, 2024
63d548d
Revert "log cleanup"
lmeier Nov 8, 2024
04bae9e
don't conditionalize updatedAtMsDiff at all
lmeier Nov 8, 2024
910d489
make api helper logic more clear
lmeier Nov 8, 2024
ad35612
Merge branch 'master' into replayTimestamps
KennyHuRadar Nov 11, 2024
1cd42d9
Reformat to more closely match android impl
lmeier Dec 5, 2024
b138b15
Make nil check explict
lmeier Dec 5, 2024
1f5c6d0
put behind a feature setting
lmeier Dec 6, 2024
1c7ca58
Typo
lmeier Dec 6, 2024
d3c24f7
Merge branch 'master' into replayTimestamps
KennyHuRadar Dec 9, 2024
f06ebe5
bump version
KennyHuRadar Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RadarSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'RadarSDK'
s.version = '3.18.3'
s.version = '3.18.4-beta.2'
s.summary = 'iOS SDK for Radar, the leading geofencing and location tracking platform'
s.homepage = 'https://radar.com'
s.author = { 'Radar Labs, Inc.' => '[email protected]' }
Expand Down
4 changes: 2 additions & 2 deletions RadarSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MARKETING_VERSION = 3.18.3;
MARKETING_VERSION = 3.18.4;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -1120,7 +1120,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MARKETING_VERSION = 3.18.3;
MARKETING_VERSION = 3.18.4;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
OTHER_CFLAGS = "-fembed-bitcode";
Expand Down
9 changes: 6 additions & 3 deletions RadarSDK/RadarAPIClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ - (void)flushReplays:(NSArray<NSDictionary *> *_Nonnull)replays

NSMutableDictionary *requestParams = [NSMutableDictionary new];
requestParams[@"replays"] = replays;
long nowMs = (long)([NSDate date].timeIntervalSince1970 * 1000);
requestParams[@"replayRequestMs"] = @(nowMs);

[self.apiHelper requestWithMethod:@"POST"
url:url
Expand Down Expand Up @@ -251,10 +253,12 @@ - (void)trackWithLocation:(CLLocation *_Nonnull)location
params[@"floorLevel"] = @(location.floor.level);
}
long nowMs = (long)([NSDate date].timeIntervalSince1970 * 1000);
if (!foreground) {
long timeInMs = (long)(location.timestamp.timeIntervalSince1970 * 1000);
long timeInMs = (long)(location.timestamp.timeIntervalSince1970 * 1000);
RadarTrackingOptions *options = [Radar getTrackingOptions];
if (!foreground || options.replay != RadarTrackingOptionsReplayNone) {
params[@"updatedAtMsDiff"] = @(nowMs - timeInMs);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all track requests should have this updatedAtMsDiff, likely = 0 for normal tracks, but it'll keep our server code path consistent. We also don't need to set locationMs in the request as its not used, a bit of wasted bandwidth, we can send it at line:417 if the request fails.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can basically think that all tracks are replays, but some are replayed immediately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We toss in the locationMs for updating the updatedAtMsDiff in RadarAPIHelper.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had initial hesitancy towards making all /tracks have updatedAtMsDiff, but yea, your model that they'd all have it matches mine. Might as well change that.

}
params[@"locationMs"] = @(timeInMs);
params[@"foreground"] = @(foreground);
params[@"stopped"] = @(stopped);
params[@"replayed"] = @(replayed);
Expand Down Expand Up @@ -299,7 +303,6 @@ - (void)trackWithLocation:(CLLocation *_Nonnull)location
params[@"tripOptions"] = tripParams;
}

RadarTrackingOptions *options = [Radar getTrackingOptions];
if (options.syncGeofences) {
params[@"nearbyGeofences"] = @(YES);
}
Expand Down
17 changes: 16 additions & 1 deletion RadarSDK/RadarAPIHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,24 @@ - (void)requestWithMethod:(NSString *)method
}

if (params) {
[req setHTTPBody:[NSJSONSerialization dataWithJSONObject:params options:0 error:NULL]];
if (!params[@"updatedAtMsDiff"]) {
[req setHTTPBody:[NSJSONSerialization dataWithJSONObject:params options:0 error:NULL]];
} else {
// We replace updatedAtMsDiff because there might have been a delay in sending a /track with SLEEP:YES
NSNumber *locationMs = params[@"locationMs"];
if (locationMs) {
long nowMs = (long)([NSDate date].timeIntervalSince1970 * 1000);
long updatedAtMsDiff = nowMs - [locationMs longValue];
NSMutableDictionary *requestParams = [params mutableCopy];
requestParams[@"updatedAtMsDiff"] = @(updatedAtMsDiff);
[req setHTTPBody:[NSJSONSerialization dataWithJSONObject:requestParams options:0 error:NULL]];
} else {
[req setHTTPBody:[NSJSONSerialization dataWithJSONObject:params options:0 error:NULL]];
}
}
}


NSURLSessionConfiguration *configuration;
if (extendedTimeout) {
configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
Expand Down
2 changes: 1 addition & 1 deletion RadarSDK/RadarUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ + (NSNumber *)timeZoneOffset {
}

+ (NSString *)sdkVersion {
return @"3.18.3";
return @"3.18.4-beta.2";
}

+ (NSString *)deviceId {
Expand Down
2 changes: 1 addition & 1 deletion RadarSDKMotion.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'RadarSDKMotion'
s.version = '3.18.3'
s.version = '3.18.4-beta.2'
s.summary = 'Motion detection plugin for RadarSDK, the leading geofencing and location tracking platform'
s.homepage = 'https://radar.com'
s.author = { 'Radar Labs, Inc.' => '[email protected]' }
Expand Down
Loading