Skip to content

Commit

Permalink
Merge pull request #224 from apptentive/branch_5.2.2
Browse files Browse the repository at this point in the history
Release 5.2.2
  • Loading branch information
weeeBox authored Oct 24, 2018
2 parents 839aff0 + 972ae84 commit 978b403
Show file tree
Hide file tree
Showing 38 changed files with 217 additions and 163 deletions.
8 changes: 4 additions & 4 deletions Apptentive/Apptentive.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2382,7 +2382,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 19;
CURRENT_PROJECT_VERSION = 20;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -2440,7 +2440,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 19;
CURRENT_PROJECT_VERSION = 20;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -2472,7 +2472,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 86WML2UN43;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 19;
DYLIB_CURRENT_VERSION = 20;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_PREFIX_HEADER = "Apptentive/Misc/ApptentiveConnect-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = "APPTENTIVE_DEBUG=1";
Expand All @@ -2494,7 +2494,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 86WML2UN43;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 19;
DYLIB_CURRENT_VERSION = 20;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_PREFIX_HEADER = "Apptentive/Misc/ApptentiveConnect-Prefix.pch";
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
Expand Down
2 changes: 1 addition & 1 deletion Apptentive/Apptentive/Apptentive.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ FOUNDATION_EXPORT double ApptentiveVersionNumber;
FOUNDATION_EXPORT const unsigned char ApptentiveVersionString[];

/** The version number of the Apptentive SDK. */
#define kApptentiveVersionString @"5.2.1"
#define kApptentiveVersionString @"5.2.2"

/** The version number of the Apptentive API platform. */
#define kApptentiveAPIVersionString @"9"
Expand Down
2 changes: 1 addition & 1 deletion Apptentive/Apptentive/Apptentive.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ - (id)initWithConfiguration:(ApptentiveConfiguration *)configuration {
ApptentiveLogSetLevel(configuration.logLevel);

// we need to initialize dispatch queue before we start log monitor
_operationQueue = [ApptentiveDispatchQueue createQueueWithName:@"Apptentive Main Queue" concurrencyType:ApptentiveDispatchQueueConcurrencyTypeSerial];
_operationQueue = [ApptentiveDispatchQueue createQueueWithName:@"Apptentive Main Queue" concurrencyType:ApptentiveDispatchQueueConcurrencyTypeSerial qualityOfService:NSQualityOfServiceUserInitiated];

// start log writer
ApptentiveStartLogMonitor([ApptentiveUtilities cacheDirectoryPath:@"com.apptentive.logs"]);
Expand Down
10 changes: 10 additions & 0 deletions Apptentive/Apptentive/Engagement/Model/ApptentiveConversation.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ extern NSString *NSStringFromApptentiveConversationState(ApptentiveConversationS
*/
@property (readonly, nonatomic) NSDate *currentTime;


/**
Uniquely identifies the current session, i.e. period between launch and exit.
This should not be persisted.
*/
@property (readonly, nullable, nonatomic) NSString *sessionIdentifier;

- (void)startSession;
- (void)endSession;

/**
Freeform key-value data used for things `NSUserDefaults` would typically be
used for in an app.
Expand Down
11 changes: 11 additions & 0 deletions Apptentive/Apptentive/Engagement/Model/ApptentiveConversation.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ @interface ApptentiveConversation ()
@property (strong, nonatomic) NSDictionary *lastSentPerson;
@property (strong, nonatomic) NSDictionary *lastSentDevice;
@property (strong, nonatomic) NSString *directoryName;
@property (strong, nullable, nonatomic) NSString *sessionIdentifier;

@end

Expand Down Expand Up @@ -410,6 +411,14 @@ - (BOOL)isConsistent {
return YES;
}

- (void)startSession {
_sessionIdentifier = [NSUUID.UUID.UUIDString stringByReplacingOccurrencesOfString:@"-" withString:@""];
}

- (void)endSession {
_sessionIdentifier = nil;
}

+ (void)deleteMigratedData {
[ApptentiveAppRelease deleteMigratedData];
[ApptentiveSDK deleteMigratedData];
Expand Down Expand Up @@ -468,6 +477,7 @@ - (id)mutableCopy {
result.lastMessageID = self.lastMessageID;
result.delegate = self.delegate;
result.directoryName = self.directoryName;
result.sessionIdentifier = self.sessionIdentifier;
return result;
}

Expand Down Expand Up @@ -531,6 +541,7 @@ @implementation ApptentiveMutableConversation
@dynamic encryptionKey;
@dynamic lastMessageID;
@dynamic directoryName;
@dynamic sessionIdentifier;

- (void)setToken:(NSString *)token conversationID:(NSString *)conversationID personID:(NSString *)personID deviceID:(NSString *)deviceID {
[self setConversationIdentifier:conversationID JWT:token];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ extern NSString *const ApptentiveConversationStateDidChangeNotificationKeyConver

@property (readonly, strong, nonatomic) ApptentiveEngagementManifest *manifest;

@property (readonly, strong, nonatomic) NSManagedObjectContext *parentManagedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;

- (instancetype)initWithStoragePath:(NSString *)storagePath operationQueue:(ApptentiveDispatchQueue *)operationQueue client:(ApptentiveClient *)client parentManagedObjectContext:(NSManagedObjectContext *)parentManagedObjectContext;
- (instancetype)initWithStoragePath:(NSString *)storagePath operationQueue:(ApptentiveDispatchQueue *)operationQueue client:(ApptentiveClient *)client managedObjectContext:(NSManagedObjectContext *)managedObjectContext;

/**
* Attempts to load an active conversation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ @implementation ApptentiveConversationManager

@synthesize activeConversation = _activeConversation;

- (instancetype)initWithStoragePath:(NSString *)storagePath operationQueue:(ApptentiveDispatchQueue *)operationQueue client:(ApptentiveClient *)client parentManagedObjectContext:(NSManagedObjectContext *)parentManagedObjectContext {
- (instancetype)initWithStoragePath:(NSString *)storagePath operationQueue:(ApptentiveDispatchQueue *)operationQueue client:(ApptentiveClient *)client managedObjectContext:(NSManagedObjectContext *)managedObjectContext {
self = [super init];

if (self) {
_storagePath = storagePath;
_operationQueue = operationQueue;
_client = client;
_parentManagedObjectContext = parentManagedObjectContext;
_managedObjectContext = managedObjectContext;
}

return self;
Expand Down Expand Up @@ -305,7 +305,7 @@ - (void)endActiveConversation {

ApptentiveLogoutPayload *payload = [[ApptentiveLogoutPayload alloc] init];

[ApptentiveSerialRequest enqueuePayload:payload forConversation:conversation usingAuthToken:conversation.token inContext:self.parentManagedObjectContext];
[ApptentiveSerialRequest enqueuePayload:payload forConversation:conversation usingAuthToken:conversation.token inContext:self.managedObjectContext];

[self.delegate processQueuedRecords];

Expand Down Expand Up @@ -652,7 +652,7 @@ - (void)conversationAppReleaseOrSDKDidChange:(ApptentiveConversation *)conversat

ApptentiveSDKAppReleasePayload *payload = [[ApptentiveSDKAppReleasePayload alloc] initWithConversation:conversation];

[ApptentiveSerialRequest enqueuePayload:payload forConversation:conversation usingAuthToken:conversation.token inContext:self.parentManagedObjectContext];
[ApptentiveSerialRequest enqueuePayload:payload forConversation:conversation usingAuthToken:conversation.token inContext:self.managedObjectContext];

[self.delegate processQueuedRecords];

Expand All @@ -666,7 +666,7 @@ - (void)conversation:(ApptentiveConversation *)conversation personDidChange:(NSD

ApptentivePersonPayload *payload = [[ApptentivePersonPayload alloc] initWithPersonDiffs:diffs];

[ApptentiveSerialRequest enqueuePayload:payload forConversation:conversation usingAuthToken:conversation.token inContext:self.parentManagedObjectContext];
[ApptentiveSerialRequest enqueuePayload:payload forConversation:conversation usingAuthToken:conversation.token inContext:self.managedObjectContext];

[self saveConversation:conversation];

Expand All @@ -678,7 +678,7 @@ - (void)conversation:(ApptentiveConversation *)conversation deviceDidChange:(NSD

ApptentiveDevicePayload *payload = [[ApptentiveDevicePayload alloc] initWithDeviceDiffs:diffs];

[ApptentiveSerialRequest enqueuePayload:payload forConversation:conversation usingAuthToken:conversation.token inContext:self.parentManagedObjectContext];
[ApptentiveSerialRequest enqueuePayload:payload forConversation:conversation usingAuthToken:conversation.token inContext:self.managedObjectContext];

[self saveConversation:conversation];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ - (void)conversation:(ApptentiveConversation *)conversation addMetricWithName:(N
return;
}

ApptentiveEventPayload *payload = [[ApptentiveEventPayload alloc] initWithLabel:name creationDate:[NSDate date]];
ApptentiveEventPayload *payload = [[ApptentiveEventPayload alloc] initWithLabel:name creationDate:[NSDate date] sessionIdentifier:conversation.sessionIdentifier];
payload.interactionIdentifier = fromInteraction.identifier;
payload.userInfo = userInfo;
payload.customData = customData;
Expand Down
2 changes: 1 addition & 1 deletion Apptentive/Apptentive/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.2.1</string>
<string>5.2.2</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
static NSString *const AutomatedKey = @"automated";
static NSString *const CustomDataKey = @"customData";
static NSString *const InboundKey = @"inboundKey";
static NSString *const SessionIdentifier = @"sessionIdentifier";


@interface ApptentiveMessage ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ - (void)enqueueMessageForSending:(ApptentiveMessage *)message {
NSString *previousLocalIdentifier = message.localIdentifier;
ApptentiveConversation *conversation = Apptentive.shared.backend.conversationManager.activeConversation;

ApptentiveMessagePayload *payload = [[ApptentiveMessagePayload alloc] initWithMessage:message];
ApptentiveMessagePayload *payload = [[ApptentiveMessagePayload alloc] initWithMessage:message sessionIdentifier:conversation.sessionIdentifier];

[ApptentiveSerialRequest enqueuePayload:payload forConversation:conversation usingAuthToken:conversation.token inContext:Apptentive.shared.backend.managedObjectContext];

Expand Down
2 changes: 1 addition & 1 deletion Apptentive/Apptentive/Misc/ApptentiveAsyncLogWriter.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ @interface ApptentiveAsyncLogWriter ()
@implementation ApptentiveAsyncLogWriter

- (instancetype)initWithDestDir:(NSString *)destDir historySize:(NSUInteger)historySize {
return [self initWithDestDir:destDir historySize:historySize queue:[ApptentiveDispatchQueue createQueueWithName:@"Log Queue" concurrencyType:ApptentiveDispatchQueueConcurrencyTypeSerial]];
return [self initWithDestDir:destDir historySize:historySize queue:[ApptentiveDispatchQueue createQueueWithName:@"Log Queue" concurrencyType:ApptentiveDispatchQueueConcurrencyTypeSerial qualityOfService:NSQualityOfServiceBackground]];
}
- (instancetype)initWithDestDir:(NSString *)destDir historySize:(NSUInteger)historySize queue:(ApptentiveDispatchQueue *)queue {
APPTENTIVE_CHECK_INIT_NOT_EMPTY_ARG(destDir)
Expand Down
7 changes: 1 addition & 6 deletions Apptentive/Apptentive/Misc/ApptentiveDispatchQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,10 @@ extern NSString * _Nullable ApptentiveGetCurrentThreadName(void);
*/
+ (instancetype)main;

/**
@return a global concurrent dispatch queue associated with a background thread.
*/
+ (instancetype)background;

/**
Creates a background queue with a specified name and concurrency type
*/
+ (nullable instancetype)createQueueWithName:(NSString *)name concurrencyType:(ApptentiveDispatchQueueConcurrencyType)type;
+ (nullable instancetype)createQueueWithName:(NSString *)name concurrencyType:(ApptentiveDispatchQueueConcurrencyType)type qualityOfService:(NSQualityOfService)qualityOfService;

- (void)dispatchAsync:(void (^)(void))task;

Expand Down
9 changes: 2 additions & 7 deletions Apptentive/Apptentive/Misc/ApptentiveDispatchQueue.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,19 @@ @implementation ApptentiveDispatchQueue
+ (void)initialize {
if ([self class] == [ApptentiveDispatchQueue class]) {
_mainQueue = [[ApptentiveGCDDispatchQueue alloc] initWithQueue:NSOperationQueue.mainQueue];

_backgroundQueue = [self createQueueWithName:@"Apptentive Background Queue" concurrencyType:ApptentiveDispatchQueueConcurrencyTypeConcurrent];
}
}

+ (instancetype)main {
return _mainQueue;
}

+ (instancetype)background {
return _backgroundQueue;
}

+ (nullable instancetype)createQueueWithName:(NSString *)name concurrencyType:(ApptentiveDispatchQueueConcurrencyType)type {
+ (nullable instancetype)createQueueWithName:(NSString *)name concurrencyType:(ApptentiveDispatchQueueConcurrencyType)type qualityOfService:(NSQualityOfService)qualityOfService {
if (type == ApptentiveDispatchQueueConcurrencyTypeSerial) {
NSOperationQueue *queue = [NSOperationQueue new];
queue.name = name;
queue.maxConcurrentOperationCount = 1;
queue.qualityOfService = qualityOfService;
return [[ApptentiveGCDDispatchQueue alloc] initWithQueue:queue];
}

Expand Down
2 changes: 1 addition & 1 deletion Apptentive/Apptentive/Model/ApptentiveLegacyEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ + (void)enqueueUnsentEventsInContext:(NSManagedObjectContext *)context forConver

for (ApptentiveLegacyEvent *event in unsentEvents) {
NSDate *creationDate = [NSDate dateWithTimeIntervalSince1970:event.clientCreationTime.doubleValue];
ApptentiveEventPayload *payload = [[ApptentiveEventPayload alloc] initWithLabel:event.label creationDate:creationDate];
ApptentiveEventPayload *payload = [[ApptentiveEventPayload alloc] initWithLabel:event.label creationDate:creationDate sessionIdentifier:nil];
ApptentiveAssertNotNil(payload, @"Failed to create an event payload");

// Add custom data, interaction identifier, and extended data
Expand Down
2 changes: 1 addition & 1 deletion Apptentive/Apptentive/Model/ApptentiveLegacyMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ + (void)enqueueUnsentMessagesInContext:(NSManagedObjectContext *)context forConv
message.state = ApptentiveMessageStateHidden;
}

ApptentiveMessagePayload *payload = [[ApptentiveMessagePayload alloc] initWithMessage:message];
ApptentiveMessagePayload *payload = [[ApptentiveMessagePayload alloc] initWithMessage:message sessionIdentifier:nil];
ApptentiveAssertNotNil(payload, @"Failed to create a message payload");

if (payload != nil) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ + (void)enqueueUnsentSurveyResponsesInContext:(NSManagedObjectContext *)context
NSDictionary *JSON = response.apiJSON[@"survey"];

NSDate *creationDate = [NSDate dateWithTimeIntervalSince1970:[JSON[@"client_created_at"] doubleValue]];
ApptentiveSurveyResponsePayload *payload = [[ApptentiveSurveyResponsePayload alloc] initWithAnswers:JSON[@"answers"] identifier:JSON[@"id"] creationDate:creationDate];
ApptentiveSurveyResponsePayload *payload = [[ApptentiveSurveyResponsePayload alloc] initWithAnswers:JSON[@"answers"] identifier:JSON[@"id"] creationDate:creationDate sessionIdentifier:nil];
ApptentiveAssertNotNil(payload, @"Failed to create a survey response payload");

if (payload != nil) {
Expand Down
2 changes: 1 addition & 1 deletion Apptentive/Apptentive/Networking/ApptentivePayloadSender.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ typedef NS_ENUM(NSInteger, ApptentiveQueueStatus) {
Instructs the client to read any pending request information from Core Data and
create an `ApptentiveSerialRequestOperation` instance for each of them. These
operations are then enqueued, followed by an operation that saves the private
context to its parent, and saves the parent context to disk.
context to disk.
@param context The managed object context in which to look for pending network payloads.
*/
Expand Down
Loading

0 comments on commit 978b403

Please sign in to comment.