Skip to content

Commit

Permalink
Rename classes from SF* to Sift* (#81)
Browse files Browse the repository at this point in the history
* Rename classes from SF* to Sift*

* updating README with renamed class names

* Changing release artifacts to new release 1.0.2

* Rename one class from SF* to Sift*

* Updating Cartfile with newly released version

* Making it a major release 2.0.0
  • Loading branch information
pjain-sift authored Feb 24, 2020
1 parent 743bb7a commit 758a5a1
Show file tree
Hide file tree
Showing 49 changed files with 626 additions and 622 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

## [2.0.0] - 2019-02-25
- Rename classes to remove SF reserve keyword from their names

## [1.0.1] - 2018-07-17
- Removes fork() check

Expand Down
2 changes: 1 addition & 1 deletion HelloSift/Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "SiftScience/sift-ios" ~> 1.0.1
github "SiftScience/sift-ios" ~> 2.0.0
2 changes: 1 addition & 1 deletion HelloSift/HelloSift/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@import CoreLocation;
@import UIKit;

#import "Sift/SFEvent.h"
#import "Sift/SiftEvent.h"
#import "Sift/Sift.h"

#import "ViewController.h"
Expand Down
8 changes: 4 additions & 4 deletions Sift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'Sift'
spec.version = '1.0.1'
spec.version = '2.0.0'
spec.authors = 'Sift Science'
spec.license = {
:type => 'MIT',
Expand Down Expand Up @@ -29,9 +29,9 @@ Pod::Spec.new do |spec|
# File patterns
spec.source_files = 'Sift/*.{h,m}', 'Sift/Vendor/*.{h,m}'
spec.public_header_files = [
'Sift/SFCompatibility.h',
'Sift/SFEvent.h',
'Sift/SFQueueConfig.h',
'Sift/SiftCompatibility.h',
'Sift/SiftEvent.h',
'Sift/SiftQueueConfig.h',
'Sift/Sift.h',
]
end
293 changes: 147 additions & 146 deletions Sift.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions Sift/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
Overview of the Sift module

The "unit" of data is an `SFEvent` object. You create it and send it to
the shared `Sift` object. The `Sift` object will append that `SFEvent`
to the `SFQueue` you specify. When the events of a `SFQueue` is ready
for uploading (as specified in `SFQueueConfig`), that `SFQueue` will
notify `SFUploader`, which will then collect events from all queues of
The "unit" of data is an `SiftEvent` object. You create it and send it to
the shared `Sift` object. The `Sift` object will append that `SiftEvent`
to the `SiftQueue` you specify. When the events of a `SiftQueue` is ready
for uploading (as specified in `SiftQueueConfig`), that `SiftQueue` will
notify `SiftUploader`, which will then collect events from all queues of
which events are ready for uploading, and upload events in one batch.

To have better batching results, you should create queues based on your
batching requirements rather than solely based on event types. (There
is a default queue, which might be all you need.)

```
+---------+
| SFEvent |
+---------+ _ _
+-----------+
| SiftEvent |
+-----------+ _ _
| ( ` )_
| 0. Send event to Sift ( ) `) )
| (_ (_ . _) _)
Expand All @@ -23,27 +23,27 @@ is a default queue, which might be all you need.)
| Sift | |
+------+ | 4. Upload events to Sift
| |
| +------------+
| | SFUploader |
| +------------+
| 1. Appene event to ^ |
| SFQueue | |
| +--------------+
| | SiftUploader |
| +--------------+
| 1. Append event to ^ |
| SiftQueue | |
| | |
| 2. Request upload | |
| when ready | |
| | |
| +-----------------+ | | 3. Collect events from
| | SFQueue | | | all ready queues
| | SFQueueConfig |<-|----+
| | SiftQueue | | | all ready queues
| | SiftQueueConfig |<-|----+
| +-----------------+ | |
| | |
| +-----------------+ | |
+--->| SFQueue |--+ |
| SFQueueConfig |<------+
+--->| SiftQueue |--+ |
| SiftQueueConfig |<------+
+-----------------+ |
|
+-----------------+ |
| SFQueue | |
| SFQueueConfig |<------+
| SiftQueue | |
| SiftQueueConfig |<------+
+-----------------+
```
21 changes: 0 additions & 21 deletions Sift/SFIosAppState.h

This file was deleted.

9 changes: 0 additions & 9 deletions Sift/SFIosDeviceProperties.h

This file was deleted.

10 changes: 5 additions & 5 deletions Sift/Sift.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#import <CoreMotion/CoreMotion.h>
#import <Foundation/Foundation.h>

#import "SFEvent.h"
#import "SFQueueConfig.h"
#import "SiftEvent.h"
#import "SiftQueueConfig.h"

/**
* This is the main interface you interact with Sift.
Expand Down Expand Up @@ -40,7 +40,7 @@
*
* @return YES on success.
*/
- (BOOL)addEventQueue:(NSString *)identifier config:(SFQueueConfig)config;
- (BOOL)addEventQueue:(NSString *)identifier config:(SiftQueueConfig)config;

/**
* Remove an event queue.
Expand All @@ -55,13 +55,13 @@
*
* @return YES on success.
*/
- (BOOL)appendEvent:(SFEvent *)event toQueue:(NSString *)identifier;
- (BOOL)appendEvent:(SiftEvent *)event toQueue:(NSString *)identifier;

/**
* Same as above but use the default queue (most of the time you should
* probably use this).
*/
- (BOOL)appendEvent:(SFEvent *)event;
- (BOOL)appendEvent:(SiftEvent *)event;

/**
* Unset the user id attached to the Sift object.
Expand Down
46 changes: 23 additions & 23 deletions Sift/Sift.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
@import Foundation;
@import UIKit;

#import "SFDebug.h"
#import "SFEvent.h"
#import "SFEvent+Private.h"
#import "SFIosAppStateCollector.h"
#import "SFIosDevicePropertiesCollector.h"
#import "SFQueue.h"
#import "SFQueueConfig.h"
#import "SFUploader.h"
#import "SFUtils.h"
#import "SiftDebug.h"
#import "SiftEvent.h"
#import "SiftEvent+Private.h"
#import "SiftIosAppStateCollector.h"
#import "SiftIosDevicePropertiesCollector.h"
#import "SiftQueue.h"
#import "SiftQueueConfig.h"
#import "SiftUploader.h"
#import "SiftUtils.h"

#import "Sift.h"
#import "Sift+Private.h"
Expand All @@ -23,7 +23,7 @@
static NSString * const SFDefaultEventQueueIdentifier = @"sift-default";

// TODO(clchiou): Experiment a sensible config for the default event queue.
static const SFQueueConfig SFDefaultEventQueueConfig = {
static const SiftQueueConfig SFDefaultEventQueueConfig = {
.uploadWhenMoreThan = 32, // Unit: number of events.
.uploadWhenOlderThan = 60, // 1 minute.
};
Expand All @@ -36,11 +36,11 @@ @implementation Sift {
NSString *_userId;

NSMutableDictionary *_eventQueues;
SFUploader *_uploader;
SiftUploader *_uploader;

// Extra collection mechanisms.
SFIosAppStateCollector *_iosAppStateCollector;
SFIosDevicePropertiesCollector *_iosDevicePropertiesCollector;
SiftIosAppStateCollector *_iosAppStateCollector;
SiftIosDevicePropertiesCollector *_iosDevicePropertiesCollector;
}

+ (instancetype)sharedInstance {
Expand All @@ -55,7 +55,7 @@ + (instancetype)sharedInstance {
- (instancetype)initWithRootDirPath:(NSString *)rootDirPath {
self = [super init];
if (self) {
_sdkVersion = @"v1.0.0";
_sdkVersion = @"v2.0.0";

_rootDirPath = rootDirPath;

Expand All @@ -65,7 +65,7 @@ - (instancetype)initWithRootDirPath:(NSString *)rootDirPath {

_eventQueues = [NSMutableDictionary new];

_uploader = [[SFUploader alloc] initWithArchivePath:self.archivePathForUploader sift:self];
_uploader = [[SiftUploader alloc] initWithArchivePath:self.archivePathForUploader sift:self];
if (!_uploader) {
self = nil;
return nil;
Expand All @@ -82,13 +82,13 @@ - (instancetype)initWithRootDirPath:(NSString *)rootDirPath {
[notificationCenter addObserver:self selector:@selector(applicationDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil];

// Create autonomous data collection.
_iosAppStateCollector = [[SFIosAppStateCollector alloc] initWithArchivePath:self.archivePathForIosAppStateCollector];
_iosAppStateCollector = [[SiftIosAppStateCollector alloc] initWithArchivePath:self.archivePathForIosAppStateCollector];
if (!_iosAppStateCollector) {
SF_DEBUG(@"Could not create _iosAppStateCollector");
self = nil;
return nil;
}
_iosDevicePropertiesCollector = [SFIosDevicePropertiesCollector new];
_iosDevicePropertiesCollector = [SiftIosDevicePropertiesCollector new];
if (!_iosDevicePropertiesCollector) {
SF_DEBUG(@"Could not create _iosDevicePropertiesCollector");
self = nil;
Expand All @@ -111,14 +111,14 @@ - (BOOL)hasEventQueue:(NSString *)identifier {
}
}

- (BOOL)addEventQueue:(NSString *)identifier config:(SFQueueConfig)config {
- (BOOL)addEventQueue:(NSString *)identifier config:(SiftQueueConfig)config {
@synchronized(_eventQueues) {
if ([_eventQueues objectForKey:identifier]) {
SF_DEBUG(@"Could not overwrite event queue for identifier \"%@\"", identifier);
return NO;
}
NSString *archivePath = [self archivePathForQueue:identifier];
SFQueue *queue = [[SFQueue alloc] initWithIdentifier:identifier config:config archivePath:archivePath sift:self];
SiftQueue *queue = [[SiftQueue alloc] initWithIdentifier:identifier config:config archivePath:archivePath sift:self];
if (!queue) {
SF_DEBUG(@"Could not create SFEventQueue for identifier \"%@\"", identifier);
return NO;
Expand All @@ -139,13 +139,13 @@ - (BOOL)removeEventQueue:(NSString *)identifier {
}
}

- (BOOL)appendEvent:(SFEvent *)event {
- (BOOL)appendEvent:(SiftEvent *)event {
return [self appendEvent:event toQueue:_defaultQueueIdentifier];
}

- (BOOL)appendEvent:(SFEvent *)event toQueue:(NSString *)identifier {
- (BOOL)appendEvent:(SiftEvent *)event toQueue:(NSString *)identifier {
@synchronized(_eventQueues) {
SFQueue *queue = [_eventQueues objectForKey:identifier];
SiftQueue *queue = [_eventQueues objectForKey:identifier];
if (!queue) {
SF_DEBUG(@"Could not find event queue for identifier \"%@\" and will drop event", identifier);
return NO;
Expand Down Expand Up @@ -178,7 +178,7 @@ - (BOOL)upload:(BOOL)force {
NSMutableArray *events = [NSMutableArray new];
@synchronized(_eventQueues) {
for (NSString *identifier in _eventQueues) {
SFQueue *queue = [_eventQueues objectForKey:identifier];
SiftQueue *queue = [_eventQueues objectForKey:identifier];
if (force || queue.readyForUpload) {
[events addObjectsFromArray:[queue transfer]];
}
Expand Down
4 changes: 2 additions & 2 deletions Sift/SFCircularBuffer.h → Sift/SiftCircularBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

@import Foundation;

#import "SFCompatibility.h"
#import "SiftCompatibility.h"

/**
* Append-only circular buffer.
*
* Note that this class is not thread-safe.
*/
@interface SF_GENERICS(SFCircularBuffer, __covariant ObjectType) : NSObject
@interface SF_GENERICS(SiftCircularBuffer, __covariant ObjectType) : NSObject

- (instancetype)initWithSize:(NSUInteger)size;

Expand Down
8 changes: 4 additions & 4 deletions Sift/SFCircularBuffer.m → Sift/SiftCircularBuffer.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

@import Foundation;

#import "SFCompatibility.h"
#import "SFDebug.h"
#import "SiftCompatibility.h"
#import "SiftDebug.h"

#import "SFCircularBuffer.h"
#import "SiftCircularBuffer.h"

@implementation SFCircularBuffer {
@implementation SiftCircularBuffer {
NSUInteger _size;
NSUInteger _head;
SF_GENERICS(NSMutableArray, id) *_items;
Expand Down
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions Sift/SFEvent+Private.h → Sift/SiftEvent+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

@import Foundation;

#import "SFCompatibility.h"
#import "SFEvent.h"
#import "SFIosAppState.h"
#import "SFIosDeviceProperties.h"
#import "SiftCompatibility.h"
#import "SiftEvent.h"
#import "SiftIosAppState.h"
#import "SiftIosDeviceProperties.h"

@interface SFEvent ()
@interface SiftEvent ()

/** An unique ID. */
@property NSString *installationId;
Expand All @@ -16,16 +16,16 @@
@property SF_GENERICS(NSDictionary, NSString *, NSString *) *deviceProperties;

/** Structured iOS app state. Default to nil. */
@property SFHtDictionary *iosAppState;
@property SiftHtDictionary *iosAppState;

/** Structured iOS device properties. Default to nil. */
@property SFHtDictionary *iosDeviceProperties;
@property SiftHtDictionary *iosDeviceProperties;

/** Internal metrics. Default to nil. */
@property SF_GENERICS(NSDictionary, NSString *, NSString *) *metrics;

/** Compare event contents except `time`. */
- (BOOL)isEssentiallyEqualTo:(SFEvent *)event;
- (BOOL)isEssentiallyEqualTo:(SiftEvent *)event;

/** Create a JSON-encoded list request object. */
+ (NSData *)listRequest:(NSArray *)events;
Expand Down
6 changes: 3 additions & 3 deletions Sift/SFEvent.h → Sift/SiftEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

@import Foundation;

#import "SFCompatibility.h"
#import "SiftCompatibility.h"

/**
* An event has: time, (mobile event) type, path, user ID, and a
* dictionary of custom fields.
*/
@interface SFEvent : NSObject <NSCoding>
@interface SiftEvent : NSObject <NSCoding>

/** Create an `SFEvent` object. All arguments are nullable. */
+ (SFEvent *)eventWithType:(NSString *)type path:(NSString *)path fields:(NSDictionary *)fields;
+ (SiftEvent *)eventWithType:(NSString *)type path:(NSString *)path fields:(NSDictionary *)fields;

/** @name Event properties. */

Expand Down
Loading

0 comments on commit 758a5a1

Please sign in to comment.