|
28 | 28 | static NSString *const kRCNGroupPrefix = @"frc.group.";
|
29 | 29 | static NSString *const kRCNUserDefaultsKeyNamelastETag = @"lastETag";
|
30 | 30 | static NSString *const kRCNUserDefaultsKeyNameLastSuccessfulFetchTime = @"lastSuccessfulFetchTime";
|
| 31 | +static NSString *const kRCNAnalyticsFirstOpenTimePropertyName = @"_fot"; |
31 | 32 | static const int kRCNExponentialBackoffMinimumInterval = 60 * 2; // 2 mins.
|
32 | 33 | static const int kRCNExponentialBackoffMaximumInterval = 60 * 60 * 4; // 4 hours.
|
33 | 34 |
|
@@ -359,16 +360,31 @@ - (NSString *)nextRequestWithUserProperties:(NSDictionary *)userProperties {
|
359 | 360 |
|
360 | 361 | if (userProperties && userProperties.count > 0) {
|
361 | 362 | NSError *error;
|
362 |
| - NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userProperties |
363 |
| - options:0 |
364 |
| - error:&error]; |
365 |
| - if (!error) { |
366 |
| - ret = [ret |
367 |
| - stringByAppendingString:[NSString |
368 |
| - stringWithFormat:@", analytics_user_properties:%@", |
369 |
| - [[NSString alloc] |
370 |
| - initWithData:jsonData |
371 |
| - encoding:NSUTF8StringEncoding]]]; |
| 363 | + |
| 364 | + // Extract first open time from user properties and send as a separate field |
| 365 | + NSNumber *firstOpenTime = userProperties[kRCNAnalyticsFirstOpenTimePropertyName]; |
| 366 | + NSMutableDictionary *remainingUserProperties = [userProperties mutableCopy]; |
| 367 | + if (firstOpenTime != nil) { |
| 368 | + NSDate *date = [NSDate dateWithTimeIntervalSince1970:([firstOpenTime longValue] / 1000)]; |
| 369 | + NSISO8601DateFormatter *formatter = [[NSISO8601DateFormatter alloc] init]; |
| 370 | + NSString *firstOpenTimeISOString = [formatter stringFromDate:date]; |
| 371 | + ret = [ret stringByAppendingString:[NSString stringWithFormat:@", first_open_time:'%@'", |
| 372 | + firstOpenTimeISOString]]; |
| 373 | + |
| 374 | + [remainingUserProperties removeObjectForKey:kRCNAnalyticsFirstOpenTimePropertyName]; |
| 375 | + } |
| 376 | + if (remainingUserProperties.count > 0) { |
| 377 | + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:remainingUserProperties |
| 378 | + options:0 |
| 379 | + error:&error]; |
| 380 | + if (!error) { |
| 381 | + ret = [ret |
| 382 | + stringByAppendingString:[NSString |
| 383 | + stringWithFormat:@", analytics_user_properties:%@", |
| 384 | + [[NSString alloc] |
| 385 | + initWithData:jsonData |
| 386 | + encoding:NSUTF8StringEncoding]]]; |
| 387 | + } |
372 | 388 | }
|
373 | 389 | }
|
374 | 390 | ret = [ret stringByAppendingString:@"}"];
|
|
0 commit comments