Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 11 additions & 11 deletions mParticle-Apple-SDK/Data Model/MPSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

@interface MPSession : MPDataModelAbstract <NSCopying>

@property (nonatomic, strong, nonnull) NSMutableDictionary *attributesDictionary;
@property (nonatomic) NSTimeInterval backgroundTime;
@property (nonatomic, readonly) NSTimeInterval foregroundTime;
@property (atomic, strong, nonnull) NSMutableDictionary *attributesDictionary;
@property (atomic) NSTimeInterval backgroundTime;
@property (atomic, readonly) NSTimeInterval foregroundTime;
@property (nonatomic) NSTimeInterval startTime;
@property (nonatomic) NSTimeInterval endTime;
@property (nonatomic) NSTimeInterval length;
@property (nonatomic, readonly) NSTimeInterval suspendTime;
@property (nonatomic, readonly) uint eventCounter;
@property (nonatomic, readonly) uint numberOfInterruptions;
@property (atomic, readonly) NSTimeInterval suspendTime;
@property (atomic, readonly) uint eventCounter;
@property (atomic, readonly) uint numberOfInterruptions;
@property (nonatomic) int64_t sessionId;
@property (nonatomic, readonly) BOOL persisted;
@property (nonatomic, strong, readwrite, nonnull) NSNumber *userId;
@property (nonatomic, strong, readwrite, nonnull) NSString *sessionUserIds;
@property (nonatomic, strong, readwrite, nullable) NSDictionary<NSString *, id> *appInfo;
@property (nonatomic, strong, readwrite, nullable) NSDictionary *deviceInfo;
@property (atomic, readonly) BOOL persisted;
@property (atomic, strong, readwrite, nonnull) NSNumber *userId;
@property (atomic, strong, readwrite, nonnull) NSString *sessionUserIds;
@property (atomic, strong, readwrite, nullable) NSDictionary<NSString *, id> *appInfo;
@property (atomic, strong, readwrite, nullable) NSDictionary *deviceInfo;


- (nonnull instancetype)initWithStartTime:(NSTimeInterval)timestamp userId:(nonnull NSNumber *)userId;
Expand Down
20 changes: 14 additions & 6 deletions mParticle-Apple-SDK/MPBackendController.m
Original file line number Diff line number Diff line change
Expand Up @@ -821,17 +821,18 @@ - (void)endSession {
}

- (void)beginSessionWithIsManual:(BOOL)isManual date:(NSDate *)date {
if (!isManual && !MParticle.sharedInstance.automaticSessionTracking) {
MParticle* mparticle = MParticle.sharedInstance;
if (!isManual && !mparticle.automaticSessionTracking) {
return;
}

@synchronized (self) {
if (_session != nil || [MParticle sharedInstance].stateMachine.optOut) {
MPStateMachine_PRIVATE *stateMachine = mparticle.stateMachine;
if (_session != nil || stateMachine.optOut) {
return;
}

MPStateMachine_PRIVATE *stateMachine = [MParticle sharedInstance].stateMachine;
MPPersistenceController_PRIVATE *persistence = [MParticle sharedInstance].persistenceController;
MPPersistenceController_PRIVATE *persistence = mparticle.persistenceController;

NSNumber *mpId = [MPPersistenceController_PRIVATE mpId];
date = date ?: [NSDate date];
Expand All @@ -846,7 +847,12 @@ - (void)beginSessionWithIsManual:(BOOL)isManual date:(NSDate *)date {
_session.appInfo = [[[MPApplication_PRIVATE alloc] init] dictionaryRepresentation];
}
if (!_session.deviceInfo) {
MPDevice *device = [[MPDevice alloc] initWithStateMachine:[MParticle sharedInstance].stateMachine userDefaults:[MPUserDefaults standardUserDefaultsWithStateMachine:[MParticle sharedInstance].stateMachine backendController:[MParticle sharedInstance].backendController identity:[MParticle sharedInstance].identity] identity:[MParticle sharedInstance].identity];
MPUserDefaults* userDefaults = [MPUserDefaults standardUserDefaultsWithStateMachine:stateMachine
backendController:mparticle.backendController
identity:mparticle.identity];
MPDevice *device = [[MPDevice alloc] initWithStateMachine:stateMachine
userDefaults:userDefaults
identity:mparticle.identity];

_session.deviceInfo = [device dictionaryRepresentationWithMpid:mpId];
}
Expand All @@ -864,7 +870,9 @@ - (void)beginSessionWithIsManual:(BOOL)isManual date:(NSDate *)date {

messageInfo[kMPPreviousSessionLengthKey] = @(previousSessionLength);

MPMessageBuilder *messageBuilder = [[MPMessageBuilder alloc] initWithMessageType:MPMessageTypeSessionStart session:_session messageInfo:messageInfo];
MPMessageBuilder *messageBuilder = [[MPMessageBuilder alloc] initWithMessageType:MPMessageTypeSessionStart
session:_session
messageInfo:messageInfo];
#if TARGET_OS_IOS == 1
#ifndef MPARTICLE_LOCATION_DISABLE
[messageBuilder location:stateMachine.location];
Expand Down
2 changes: 0 additions & 2 deletions mParticle-Apple-SDK/Persistence/MPPersistenceController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1659,8 +1659,6 @@ - (void)saveSession:(MPSession *)session {
}

session.sessionId = sqlite3_last_insert_rowid(mParticleDB);

[MPListenerController.sharedInstance onEntityStored:MPDatabaseTableSessions primaryKey:@(session.sessionId) message:session.description];

sqlite3_clear_bindings(preparedStatement);
} else {
Expand Down
Loading