Skip to content

Commit

Permalink
Merging dev into master
Browse files Browse the repository at this point in the history
  • Loading branch information
wmathurin committed Aug 15, 2024
2 parents 0aa8303 + d7a769b commit 4c5b4fc
Show file tree
Hide file tree
Showing 41 changed files with 1,063 additions and 147 deletions.
15 changes: 11 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
orbs:
codecov: codecov/[email protected]


# Xcode version announcments can be found here: https://discuss.circleci.com/c/announcements/
# Each post contains a full image manifest, including iOS runtimes, devices, CocoaPods version, etc.
anchors:
- &latest-xcode "15.2"
- &latest-ios "17.2"
- &latest-xcode "15.3.0"
- &latest-ios "17.4"
- &min-ios "16.4"
- &requres-string "test << matrix.lib >> iOS 16.4" # Keep this min version up to date
- &device "iPhone-SE-3rd-generation"
Expand Down Expand Up @@ -34,7 +38,7 @@ jobs:
default: *device
macos:
xcode: << parameters.xcode >>
resource_class: macos.x86.medium.gen2
resource_class: macos.m1.medium.gen1
working_directory: ~/SalesforceMobileSDK-iOS
environment:
DEVICE: << parameters.device >>
Expand All @@ -58,6 +62,7 @@ jobs:
cd .circleci
bundle check || sudo bundle install --path vendor/bundle
brew install xcbeautify
mkdir -p ~/.gnupg
- save_cache:
key: v1-gem-cahce{{ checksum ".circleci/Gemfile.lock" }}
paths:
Expand All @@ -66,14 +71,16 @@ jobs:
name: Run Tests
command: |
cd .circleci
bundle exec fastlane PR lib:<< parameters.lib >>
fastlane PR lib:<< parameters.lib >>
no_output_timeout: 20m
- run:
name: Danger Lib
command: |
danger --dangerfile=.circleci/Dangerfile-Lib.rb --danger_id="${LIB}" --verbose
background: true
when: always
- codecov/upload:
flags: << parameters.lib >>
- store_test_results:
path: /Users/distiller/SalesforceMobileSDK-iOS/test_output/
- store_artifacts:
Expand Down
57 changes: 57 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Validate changes to this class with: curl -X POST --data-binary @.codecov.yml https://codecov.io/validate

codecov:
branch: dev

coverage:
precision: 2
round: down
range: "25...75"

status:
project:
default: false # disable the default status that measures entire project
SalesforceAnalytics:
target: auto
paths:
- "libs/SalesforceAnalytics/SalesforceAnalytics/"
flags:
- SalesforceAnalytics
SalesforceSDKCommon:
target: auto
paths:
- "libs/SalesforceSDKCore/SalesforceSDKCommon/"
flags:
- SalesforceSDKCommon
SalesforceSDKCore:
target: auto
paths:
- "libs/SalesforceSDKCore/SalesforceSDKCore/"
flags:
- SalesforceSDKCore
SmartStore:
target: auto
paths:
- "libs/SmartStore/SmartStore/"
flags:
- SmartStore
MobileSync:
target: auto
paths:
- "libs/MobileSync/MobileSync/"
flags:
- MobileSync

ignore:
- "shared"
- "native"
- "libs/**/*Test*/*"

flag_management:
default_rules: # the rules that will be followed for any flag added, generally
carryforward: true

comment:
layout: "diff, flags, files"
behavior: default
require_changes: false
2 changes: 1 addition & 1 deletion MobileSync.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "MobileSync"
s.version = "12.0.1"
s.version = "12.1.0"
s.summary = "Salesforce Mobile SDK for iOS - MobileSync"
s.homepage = "https://github.com/forcedotcom/SalesforceMobileSDK-iOS"

Expand Down
2 changes: 1 addition & 1 deletion SalesforceAnalytics.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "SalesforceAnalytics"
s.version = "12.0.1"
s.version = "12.1.0"
s.summary = "Salesforce Mobile SDK for iOS"
s.homepage = "https://github.com/forcedotcom/SalesforceMobileSDK-iOS"

Expand Down
2 changes: 1 addition & 1 deletion SalesforceSDKCommon.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "SalesforceSDKCommon"
s.version = "12.0.1"
s.version = "12.1.0"
s.summary = "Salesforce Mobile SDK for iOS"
s.homepage = "https://github.com/forcedotcom/SalesforceMobileSDK-iOS"

Expand Down
2 changes: 1 addition & 1 deletion SalesforceSDKCore.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "SalesforceSDKCore"
s.version = "12.0.1"
s.version = "12.1.0"
s.summary = "Salesforce Mobile SDK for iOS"
s.homepage = "https://github.com/forcedotcom/SalesforceMobileSDK-iOS"

Expand Down
4 changes: 2 additions & 2 deletions SmartStore.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "SmartStore"
s.version = "12.0.1"
s.version = "12.1.0"
s.summary = "Salesforce Mobile SDK for iOS - SmartStore"
s.homepage = "https://github.com/forcedotcom/SalesforceMobileSDK-iOS"

Expand All @@ -21,7 +21,7 @@ Pod::Spec.new do |s|

smartstore.dependency 'SalesforceSDKCore', "~>#{s.version}"
smartstore.dependency 'FMDB/SQLCipher', '~> 2.7.10'
smartstore.dependency 'SQLCipher', '~> 4.5.7'
smartstore.dependency 'SQLCipher', '~> 4.6.0'
smartstore.source_files = 'libs/SmartStore/SmartStore/Classes/**/*.{h,m,swift}', 'libs/SmartStore/SmartStore/SmartStore.h'
smartstore.public_header_files = 'libs/SmartStore/SmartStore/Classes/SFAlterSoupLongOperation.h', 'libs/SmartStore/SmartStore/Classes/SFQuerySpec.h', 'libs/SmartStore/SmartStore/Classes/SFSDKSmartStoreLogger.h', 'libs/SmartStore/SmartStore/Classes/SFSDKStoreConfig.h', 'libs/SmartStore/SmartStore/Classes/SFSmartSqlHelper.h', 'libs/SmartStore/SmartStore/Classes/SFSmartStore.h', 'libs/SmartStore/SmartStore/Classes/SFSmartStoreDatabaseManager.h', 'libs/SmartStore/SmartStore/Classes/SFSmartStoreInspectorViewController.h', 'libs/SmartStore/SmartStore/Classes/SFSmartStoreUtils.h', 'libs/SmartStore/SmartStore/Classes/SFSoupIndex.h', 'libs/SmartStore/SmartStore/Classes/SFStoreCursor.h', 'libs/SmartStore/SmartStore/SmartStore.h', 'libs/SmartStore/SmartStore/Classes/SmartStoreSDKManager.h'
smartstore.prefix_header_contents = '#import "SFSDKSmartStoreLogger.h"', '#import <SalesforceSDKCore/SalesforceSDKConstants.h>'
Expand Down
2 changes: 1 addition & 1 deletion configuration/Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_PROJECT_VERSION = 12.0.1
CURRENT_PROJECT_VERSION = 12.1.0
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ typedef NSData * _Nullable (^ _Nullable DataDecryptorBlock)(NSData * _Nullable d
*/
- (void) storeEvents:(nullable NSArray<SFSDKInstrumentationEvent *> *) events;

/**
* Returns all the event files stored on the filesystem for that unique identifier.
*
* @return List of event files.
*/
- (nullable NSArray<NSString *> *)eventFiles;

/**
* Returns a specific event stored on the filesystem.
*
Expand Down Expand Up @@ -99,4 +106,9 @@ typedef NSData * _Nullable (^ _Nullable DataDecryptorBlock)(NSData * _Nullable d
*/
- (void) deleteAllEvents;

/**
* Lets callers know if they _can_ store an event (optimization, so they wouldn't have to build and call -store: unnecessarily).
*/
- (BOOL) shouldStoreEvent;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ - (void) storeEvents:(NSArray<SFSDKInstrumentationEvent *> *) events {
}
}

- (NSArray<NSString *> *)eventFiles {
return [[NSFileManager defaultManager] contentsOfDirectoryAtPath:self.storeDirectory error:nil];
}

- (SFSDKInstrumentationEvent *) fetchEvent:(NSString *) eventId {
if (!eventId) {
return nil;
Expand All @@ -129,7 +133,7 @@ - (SFSDKInstrumentationEvent *) fetchEvent:(NSString *) eventId {
}

- (NSArray<SFSDKInstrumentationEvent *> *) fetchAllEvents {
NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:self.storeDirectory error:nil];
NSArray *files = [self eventFiles];
NSMutableArray *events = [[NSMutableArray alloc] init];
for (NSString *file in files) {
SFSDKInstrumentationEvent *event = [self fetchEventFromFile:[self filenameForEvent:file]];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
*/
@property (nonatomic, readwrite, assign, getter=isLoggingEnabled) BOOL loggingEnabled;

/**
* Disables or enables batch processing of events.
*
* @discussion If batching is enabled, publishing of events will happen in smaller chunks
*/
@property (nonatomic, readwrite, assign, getter=isBatchingEnabled) BOOL batchingEnabled;


/**
* Returns an instance of this class associated with the specified user account.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@

static NSMutableDictionary *analyticsManagerList = nil;

static SInt32 kBatchProcessCount = 100;

@implementation SFSDKSalesforceAnalyticsManager

+ (void)initialize {
Expand Down Expand Up @@ -209,16 +211,56 @@ - (void) updateLoggingPrefs {

- (void) publishAllEvents {
@synchronized (self) {
NSArray<SFSDKInstrumentationEvent *> *events = [self.eventStoreManager fetchAllEvents];
[self publishEvents:events];
dispatch_group_t publishEventsGroup = dispatch_group_create();

if (self.batchingEnabled == NO) {
NSArray<SFSDKInstrumentationEvent *> *events = [self.eventStoreManager fetchAllEvents];
[self publishEvents:events dispatchGroup:publishEventsGroup];
} else {
NSArray *eventFiles = [self.eventStoreManager eventFiles];
SInt32 i = 0;
NSUInteger remainingEvents = eventFiles.count;

while (i < eventFiles.count) {
NSArray *subEvents = [eventFiles subarrayWithRange:NSMakeRange(i, MIN(kBatchProcessCount, remainingEvents))];
//MIN() used because array must be larger than or equal to range size, else exception will be thrown

// batch process and use autorelease pool to best manage memory usage in processsing events
@autoreleasepool {
NSMutableArray * eventsArray = [NSMutableArray arrayWithCapacity:kBatchProcessCount];
for (SInt32 subCount = 0; subCount < subEvents.count; subCount++) {

NSString *eventFile = subEvents[subCount];
[eventsArray addObject:[self.eventStoreManager fetchEvent:eventFile]];
}
[self publishEvents:eventsArray dispatchGroup:publishEventsGroup];
i += subEvents.count;
remainingEvents = remainingEvents - subEvents.count;
}

}
}

dispatch_group_notify(publishEventsGroup, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^{
[self cleanupBackgroundTask];
});
}
}

- (void) publishEvents:(NSArray<SFSDKInstrumentationEvent *> *) events {
[self publishEvents:events dispatchGroup:nil];
}

- (void) publishEvents:(NSArray<SFSDKInstrumentationEvent *> *) events dispatchGroup:(nullable dispatch_group_t) dispatchGroup {
if (events.count == 0 || self.remotes.count == 0) {
return;
}
@synchronized (self) {

if (dispatchGroup != nil) {
dispatch_group_enter(dispatchGroup);
}

NSMutableArray<NSString *> *eventIds = [[NSMutableArray alloc] init];
for (SFSDKInstrumentationEvent *event in events) {
[eventIds addObject:event.eventId];
Expand Down Expand Up @@ -260,7 +302,10 @@ - (void) publishEvents:(NSArray<SFSDKInstrumentationEvent *> *) events {
}
publishCompleteBlock = nil;
}
[self cleanupBackgroundTask];

if (dispatchGroup != nil) {
dispatch_group_leave(dispatchGroup);
}
};
[self applyTransformAndPublish:currentTpp events:events publishCompleteBlock:publishCompleteBlock];
}
Expand Down Expand Up @@ -346,11 +391,14 @@ - (void) applyTransformAndPublish:(SFSDKAnalyticsTransformPublisherPair *)tpp ev
if (tpp) {
NSMutableArray *eventsArray = [[NSMutableArray alloc] init];
for (SFSDKInstrumentationEvent *event in events) {
id transformedEvent = [tpp.transform transform:event];
if (transformedEvent != nil) {
[eventsArray addObject:transformedEvent];
@autoreleasepool {
id transformedEvent = [tpp.transform transform:event];
if (transformedEvent != nil) {
[eventsArray addObject:transformedEvent];
}
}
}

id<SFSDKAnalyticsPublisher> networkPublisher = tpp.publisher;
if (networkPublisher) {
[networkPublisher publish:eventsArray user:self.userAccount publishCompleteBlock:publishCompleteBlock];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SalesforceSDKConstants_h
#define SalesforceSDKConstants_h

#define SALESFORCE_SDK_IS_PRODUCTION_VERSION YES
#define SALESFORCE_SDK_IS_PRODUCTION_VERSION NO

#define SALESFORCE_SDK_BUILD_IDENTIFIER @".dev"

Expand Down Expand Up @@ -77,7 +77,7 @@

#define __SALESFORCE_SDK_12_0_1 120001

#define SALESFORCE_SDK_VERSION_MIN_REQUIRED __SALESFORCE_SDK_12_0_1
#define SALESFORCE_SDK_VERSION_MIN_REQUIRED __SALESFORCE_SDK_12_1_0

#define SALESFORCE_SDK_VERSION [NSString stringWithFormat:@"%d.%d.%d%@", \
(SALESFORCE_SDK_VERSION_MIN_REQUIRED / 10000), \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ - (NSString *)devInfoTitleString
[presentedViewController presentViewController:devInfo animated:NO completion:nil];
}],
[[SFSDKDevAction alloc]initWith:@"Logout" handler:^{
[[SFUserAccountManager sharedInstance] logout];
[[SFUserAccountManager sharedInstance] logout:SFLogoutReasonUserInitiated];
}],
[[SFSDKDevAction alloc]initWith:@"Switch user" handler:^{
SFDefaultUserManagementViewController *umvc = [[SFDefaultUserManagementViewController alloc] initWithCompletionBlock:^(SFUserManagementAction action) {
Expand Down
Loading

0 comments on commit 4c5b4fc

Please sign in to comment.