Skip to content

Commit

Permalink
fix: Expose session start time (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
alla-uday committed Sep 30, 2021
1 parent a1d21d5 commit 8a3437f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mParticle-Apple-SDK/Include/mParticle.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic, readonly) NSString *UUID;

/**
The session start time.
*/
@property (nonatomic, readonly) NSNumber *startTime;

@end

/**
Expand Down
5 changes: 5 additions & 0 deletions mParticle-Apple-SDK/MPBackendController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@
static BOOL appBackgrounded = NO;

@interface MParticleSession ()

@property (nonatomic, readwrite) NSNumber *startTime;
- (instancetype)initWithUUID:(NSString *)uuid;

@end

@interface MParticle ()
Expand Down Expand Up @@ -1139,6 +1142,8 @@ - (void)createTempSession {
MPSession *mpSession = [[MPSession alloc] init];
mpSession.uuid = tempSession.UUID;

tempSession.startTime = MPMilliseconds(mpSession.startTime);

[self broadcastSessionDidBegin:mpSession];

MPILogVerbose(@"New Session Has Begun: %@", tempSession.UUID);
Expand Down
2 changes: 2 additions & 0 deletions mParticle-Apple-SDK/mParticle.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ @interface MParticleSession ()
- (instancetype)initWithUUID:(NSString *)uuid;
@property (nonatomic, readwrite) NSNumber *sessionID;
@property (nonatomic, readwrite) NSString *UUID;
@property (nonatomic, readwrite) NSNumber *startTime;

@end

Expand Down Expand Up @@ -645,6 +646,7 @@ - (MParticleSession *)currentSession {

if (sessionInternal) {
session = [[MParticleSession alloc] initWithUUID:sessionInternal.uuid];
session.startTime = MPMilliseconds(sessionInternal.startTime);
}

return session;
Expand Down

0 comments on commit 8a3437f

Please sign in to comment.