From 758a5a1c084db66f57b336fc2653c8be1d74c2d9 Mon Sep 17 00:00:00 2001 From: Pramod Jain <59588493+pjain-sift@users.noreply.github.com> Date: Mon, 24 Feb 2020 15:51:43 -0800 Subject: [PATCH] Rename classes from SF* to Sift* (#81) * 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 --- CHANGELOG.md | 3 + HelloSift/Cartfile | 2 +- HelloSift/HelloSift/ViewController.m | 2 +- Sift.podspec | 8 +- Sift.xcodeproj/project.pbxproj | 293 +++++++++--------- Sift/README.md | 38 +-- Sift/SFIosAppState.h | 21 -- Sift/SFIosDeviceProperties.h | 9 - Sift/Sift.h | 10 +- Sift/Sift.m | 46 +-- ...FCircularBuffer.h => SiftCircularBuffer.h} | 4 +- ...FCircularBuffer.m => SiftCircularBuffer.m} | 8 +- ...{SFCompatibility.h => SiftCompatibility.h} | 0 Sift/{SFDebug.h => SiftDebug.h} | 0 ...{SFEvent+Private.h => SiftEvent+Private.h} | 16 +- Sift/{SFEvent.h => SiftEvent.h} | 6 +- Sift/{SFEvent.m => SiftEvent.m} | 18 +- Sift/{SFHtDictionary.h => SiftHtDictionary.h} | 4 +- Sift/{SFHtDictionary.m => SiftHtDictionary.m} | 12 +- Sift/SiftIosAppState.h | 21 ++ Sift/{SFIosAppState.m => SiftIosAppState.m} | 64 ++-- ...Collector.h => SiftIosAppStateCollector.h} | 2 +- ...Collector.m => SiftIosAppStateCollector.m} | 58 ++-- Sift/SiftIosDeviceProperties.h | 9 + ...Properties.m => SiftIosDeviceProperties.m} | 14 +- ...r.h => SiftIosDevicePropertiesCollector.h} | 2 +- ...r.m => SiftIosDevicePropertiesCollector.m} | 20 +- Sift/{SFQueue.h => SiftQueue.h} | 10 +- Sift/{SFQueue.m => SiftQueue.m} | 20 +- Sift/{SFQueueConfig.h => SiftQueueConfig.h} | 2 +- Sift/{SFTokenBucket.h => SiftTokenBucket.h} | 2 +- Sift/{SFTokenBucket.m => SiftTokenBucket.m} | 6 +- Sift/{SFUploader.h => SiftUploader.h} | 2 +- Sift/{SFUploader.m => SiftUploader.m} | 14 +- Sift/{SFUtils.h => SiftUtils.h} | 0 Sift/{SFUtils.m => SiftUtils.m} | 4 +- SiftTests/SFQueueTests.m | 175 ----------- ...ufferTests.m => SiftCircularBufferTests.m} | 14 +- .../{SFEventTests.m => SiftEventTests.m} | 36 +-- ...tionaryTests.m => SiftHtDictionaryTests.m} | 14 +- ...AppStateTests.m => SiftIosAppStateTests.m} | 10 +- ...Tests.m => SiftIosDevicePropertiesTests.m} | 24 +- SiftTests/SiftQueueTests.m | 175 +++++++++++ ...bHttpProtocol.h => SiftStubHttpProtocol.h} | 2 +- ...bHttpProtocol.m => SiftStubHttpProtocol.m} | 4 +- SiftTests/SiftTests.m | 6 +- ...enBucketTests.m => SiftTokenBucketTests.m} | 12 +- ...{SFUploaderTests.m => SiftUploaderTests.m} | 20 +- .../{SFUtilsTests.m => SiftUtilsTests.m} | 6 +- 49 files changed, 626 insertions(+), 622 deletions(-) delete mode 100644 Sift/SFIosAppState.h delete mode 100644 Sift/SFIosDeviceProperties.h rename Sift/{SFCircularBuffer.h => SiftCircularBuffer.h} (86%) rename Sift/{SFCircularBuffer.m => SiftCircularBuffer.m} (94%) rename Sift/{SFCompatibility.h => SiftCompatibility.h} (100%) rename Sift/{SFDebug.h => SiftDebug.h} (100%) rename Sift/{SFEvent+Private.h => SiftEvent+Private.h} (71%) rename Sift/{SFEvent.h => SiftEvent.h} (82%) rename Sift/{SFEvent.m => SiftEvent.m} (95%) rename Sift/{SFHtDictionary.h => SiftHtDictionary.h} (86%) rename Sift/{SFHtDictionary.m => SiftHtDictionary.m} (88%) create mode 100644 Sift/SiftIosAppState.h rename Sift/{SFIosAppState.m => SiftIosAppState.m} (89%) rename Sift/{SFIosAppStateCollector.h => SiftIosAppStateCollector.h} (95%) rename Sift/{SFIosAppStateCollector.m => SiftIosAppStateCollector.m} (90%) create mode 100644 Sift/SiftIosDeviceProperties.h rename Sift/{SFIosDeviceProperties.m => SiftIosDeviceProperties.m} (98%) rename Sift/{SFIosDevicePropertiesCollector.h => SiftIosDevicePropertiesCollector.h} (75%) rename Sift/{SFIosDevicePropertiesCollector.m => SiftIosDevicePropertiesCollector.m} (85%) rename Sift/{SFQueue.h => SiftQueue.h} (76%) rename Sift/{SFQueue.m => SiftQueue.m} (92%) rename Sift/{SFQueueConfig.h => SiftQueueConfig.h} (97%) rename Sift/{SFTokenBucket.h => SiftTokenBucket.h} (90%) rename Sift/{SFTokenBucket.m => SiftTokenBucket.m} (97%) rename Sift/{SFUploader.h => SiftUploader.h} (84%) rename Sift/{SFUploader.m => SiftUploader.m} (96%) rename Sift/{SFUtils.h => SiftUtils.h} (100%) rename Sift/{SFUtils.m => SiftUtils.m} (97%) delete mode 100644 SiftTests/SFQueueTests.m rename SiftTests/{SFCircularBufferTests.m => SiftCircularBufferTests.m} (87%) rename SiftTests/{SFEventTests.m => SiftEventTests.m} (83%) rename SiftTests/{SFHtDictionaryTests.m => SiftHtDictionaryTests.m} (76%) rename SiftTests/{SFIosAppStateTests.m => SiftIosAppStateTests.m} (50%) rename SiftTests/{SFIosDevicePropertiesTests.m => SiftIosDevicePropertiesTests.m} (81%) create mode 100644 SiftTests/SiftQueueTests.m rename SiftTests/{SFStubHttpProtocol.h => SiftStubHttpProtocol.h} (93%) rename SiftTests/{SFStubHttpProtocol.m => SiftStubHttpProtocol.m} (98%) rename SiftTests/{SFTokenBucketTests.m => SiftTokenBucketTests.m} (76%) rename SiftTests/{SFUploaderTests.m => SiftUploaderTests.m} (80%) rename SiftTests/{SFUtilsTests.m => SiftUtilsTests.m} (93%) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddf0ff5..6ed36c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/HelloSift/Cartfile b/HelloSift/Cartfile index 5472dd4..0bbe3df 100644 --- a/HelloSift/Cartfile +++ b/HelloSift/Cartfile @@ -1 +1 @@ -github "SiftScience/sift-ios" ~> 1.0.1 +github "SiftScience/sift-ios" ~> 2.0.0 diff --git a/HelloSift/HelloSift/ViewController.m b/HelloSift/HelloSift/ViewController.m index cd2c552..4fdf007 100644 --- a/HelloSift/HelloSift/ViewController.m +++ b/HelloSift/HelloSift/ViewController.m @@ -3,7 +3,7 @@ @import CoreLocation; @import UIKit; -#import "Sift/SFEvent.h" +#import "Sift/SiftEvent.h" #import "Sift/Sift.h" #import "ViewController.h" diff --git a/Sift.podspec b/Sift.podspec index 24c14bd..a49eb70 100644 --- a/Sift.podspec +++ b/Sift.podspec @@ -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', @@ -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 diff --git a/Sift.xcodeproj/project.pbxproj b/Sift.xcodeproj/project.pbxproj index 6fc06f3..a56c004 100644 --- a/Sift.xcodeproj/project.pbxproj +++ b/Sift.xcodeproj/project.pbxproj @@ -7,47 +7,47 @@ objects = { /* Begin PBXBuildFile section */ - 713AF4241DA456740061B688 /* SFUtilsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 713AF4231DA456740061B688 /* SFUtilsTests.m */; }; - 713D859A1D627E9F0011D5FE /* SFIosDeviceProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 713D85991D627E9F0011D5FE /* SFIosDeviceProperties.m */; }; - 713D859B1D627EA60011D5FE /* SFIosDeviceProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 713D85981D627E860011D5FE /* SFIosDeviceProperties.h */; }; - 713D859D1D6CF69E0011D5FE /* SFIosDevicePropertiesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 713D859C1D6CF69E0011D5FE /* SFIosDevicePropertiesTests.m */; }; - 713D85BD1D8744040011D5FE /* SFHtDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 713D85BC1D8744040011D5FE /* SFHtDictionary.h */; }; - 713D85BF1D87441A0011D5FE /* SFHtDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = 713D85BE1D87441A0011D5FE /* SFHtDictionary.m */; }; - 713D85C11D874ED40011D5FE /* SFHtDictionaryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 713D85C01D874ED40011D5FE /* SFHtDictionaryTests.m */; }; - 715AB3EB1D9DBBFB00771402 /* SFCompatibility.h in Headers */ = {isa = PBXBuildFile; fileRef = 715AB3EA1D9DBBFB00771402 /* SFCompatibility.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 713AF4241DA456740061B688 /* SiftUtilsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 713AF4231DA456740061B688 /* SiftUtilsTests.m */; }; + 713D859A1D627E9F0011D5FE /* SiftIosDeviceProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 713D85991D627E9F0011D5FE /* SiftIosDeviceProperties.m */; }; + 713D859B1D627EA60011D5FE /* SiftIosDeviceProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 713D85981D627E860011D5FE /* SiftIosDeviceProperties.h */; }; + 713D859D1D6CF69E0011D5FE /* SiftIosDevicePropertiesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 713D859C1D6CF69E0011D5FE /* SiftIosDevicePropertiesTests.m */; }; + 713D85BD1D8744040011D5FE /* SiftHtDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 713D85BC1D8744040011D5FE /* SiftHtDictionary.h */; }; + 713D85BF1D87441A0011D5FE /* SiftHtDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = 713D85BE1D87441A0011D5FE /* SiftHtDictionary.m */; }; + 713D85C11D874ED40011D5FE /* SiftHtDictionaryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 713D85C01D874ED40011D5FE /* SiftHtDictionaryTests.m */; }; + 715AB3EB1D9DBBFB00771402 /* SiftCompatibility.h in Headers */ = {isa = PBXBuildFile; fileRef = 715AB3EA1D9DBBFB00771402 /* SiftCompatibility.h */; settings = {ATTRIBUTES = (Public, ); }; }; 7168EE051C7B977500A88245 /* Sift.h in Headers */ = {isa = PBXBuildFile; fileRef = 7168EE041C7B977500A88245 /* Sift.h */; settings = {ATTRIBUTES = (Public, ); }; }; 7168EE0C1C7B977500A88245 /* Sift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7168EE011C7B977500A88245 /* Sift.framework */; }; 7168EE111C7B977500A88245 /* SiftTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7168EE101C7B977500A88245 /* SiftTests.m */; }; - 7168EE1C1C7E61E900A88245 /* SFEventTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7168EE1B1C7E61E900A88245 /* SFEventTests.m */; }; - 7168EE1E1C7E7A6800A88245 /* SFQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 7168EE1D1C7E7A6800A88245 /* SFQueue.h */; }; - 7168EE201C7E7B6700A88245 /* SFQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 7168EE1F1C7E7B6700A88245 /* SFQueue.m */; }; + 7168EE1C1C7E61E900A88245 /* SiftEventTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7168EE1B1C7E61E900A88245 /* SiftEventTests.m */; }; + 7168EE1E1C7E7A6800A88245 /* SiftQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 7168EE1D1C7E7A6800A88245 /* SiftQueue.h */; }; + 7168EE201C7E7B6700A88245 /* SiftQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 7168EE1F1C7E7B6700A88245 /* SiftQueue.m */; }; 7168EE221C7F978D00A88245 /* Sift+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 7168EE211C7F978D00A88245 /* Sift+Private.h */; }; - 7168EE241C7F99AF00A88245 /* SFQueueTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7168EE231C7F99AF00A88245 /* SFQueueTests.m */; }; - 7168EE271C7FB80C00A88245 /* SFUploader.h in Headers */ = {isa = PBXBuildFile; fileRef = 7168EE251C7FB80C00A88245 /* SFUploader.h */; }; - 7168EE281C7FB80C00A88245 /* SFUploader.m in Sources */ = {isa = PBXBuildFile; fileRef = 7168EE261C7FB80C00A88245 /* SFUploader.m */; }; - 7168EE2C1C86250100A88245 /* SFEvent+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 7168EE2B1C86250100A88245 /* SFEvent+Private.h */; }; - 7168EE341C864A4100A88245 /* SFIosDevicePropertiesCollector.h in Headers */ = {isa = PBXBuildFile; fileRef = 7168EE321C864A4100A88245 /* SFIosDevicePropertiesCollector.h */; }; - 7168EE351C864A4100A88245 /* SFIosDevicePropertiesCollector.m in Sources */ = {isa = PBXBuildFile; fileRef = 7168EE331C864A4100A88245 /* SFIosDevicePropertiesCollector.m */; }; - 7168EE411C88C91900A88245 /* SFStubHttpProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = 7168EE3F1C88C91900A88245 /* SFStubHttpProtocol.m */; }; - 7168EE421C88C91900A88245 /* SFUploaderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7168EE401C88C91900A88245 /* SFUploaderTests.m */; }; - 716BEB871C7D304D009C3706 /* SFDebug.h in Headers */ = {isa = PBXBuildFile; fileRef = 716BEB861C7D304D009C3706 /* SFDebug.h */; }; - 716BEB8A1C7D336B009C3706 /* SFEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 716BEB881C7D336B009C3706 /* SFEvent.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 716BEB8B1C7D336B009C3706 /* SFQueueConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 716BEB891C7D336B009C3706 /* SFQueueConfig.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 716BEB901C7D3695009C3706 /* SFEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 716BEB8C1C7D3695009C3706 /* SFEvent.m */; }; - 716BEB911C7D3695009C3706 /* SFUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 716BEB8D1C7D3695009C3706 /* SFUtils.h */; }; - 716BEB921C7D3695009C3706 /* SFUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 716BEB8E1C7D3695009C3706 /* SFUtils.m */; }; + 7168EE241C7F99AF00A88245 /* SiftQueueTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7168EE231C7F99AF00A88245 /* SiftQueueTests.m */; }; + 7168EE271C7FB80C00A88245 /* SiftUploader.h in Headers */ = {isa = PBXBuildFile; fileRef = 7168EE251C7FB80C00A88245 /* SiftUploader.h */; }; + 7168EE281C7FB80C00A88245 /* SiftUploader.m in Sources */ = {isa = PBXBuildFile; fileRef = 7168EE261C7FB80C00A88245 /* SiftUploader.m */; }; + 7168EE2C1C86250100A88245 /* SiftEvent+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 7168EE2B1C86250100A88245 /* SiftEvent+Private.h */; }; + 7168EE341C864A4100A88245 /* SiftIosDevicePropertiesCollector.h in Headers */ = {isa = PBXBuildFile; fileRef = 7168EE321C864A4100A88245 /* SiftIosDevicePropertiesCollector.h */; }; + 7168EE351C864A4100A88245 /* SiftIosDevicePropertiesCollector.m in Sources */ = {isa = PBXBuildFile; fileRef = 7168EE331C864A4100A88245 /* SiftIosDevicePropertiesCollector.m */; }; + 7168EE411C88C91900A88245 /* SiftStubHttpProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = 7168EE3F1C88C91900A88245 /* SiftStubHttpProtocol.m */; }; + 7168EE421C88C91900A88245 /* SiftUploaderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7168EE401C88C91900A88245 /* SiftUploaderTests.m */; }; + 716BEB871C7D304D009C3706 /* SiftDebug.h in Headers */ = {isa = PBXBuildFile; fileRef = 716BEB861C7D304D009C3706 /* SiftDebug.h */; }; + 716BEB8A1C7D336B009C3706 /* SiftEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 716BEB881C7D336B009C3706 /* SiftEvent.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 716BEB8B1C7D336B009C3706 /* SiftQueueConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 716BEB891C7D336B009C3706 /* SiftQueueConfig.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 716BEB901C7D3695009C3706 /* SiftEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 716BEB8C1C7D3695009C3706 /* SiftEvent.m */; }; + 716BEB911C7D3695009C3706 /* SiftUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 716BEB8D1C7D3695009C3706 /* SiftUtils.h */; }; + 716BEB921C7D3695009C3706 /* SiftUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 716BEB8E1C7D3695009C3706 /* SiftUtils.m */; }; 716BEB931C7D3695009C3706 /* Sift.m in Sources */ = {isa = PBXBuildFile; fileRef = 716BEB8F1C7D3695009C3706 /* Sift.m */; }; - 71B1B58D1D8B281900EA9B17 /* SFIosAppState.h in Headers */ = {isa = PBXBuildFile; fileRef = 71B1B58C1D8B281900EA9B17 /* SFIosAppState.h */; }; - 71B1B58F1D8B282C00EA9B17 /* SFIosAppState.m in Sources */ = {isa = PBXBuildFile; fileRef = 71B1B58E1D8B282C00EA9B17 /* SFIosAppState.m */; }; - 71B1B5911D8B31ED00EA9B17 /* SFIosAppStateTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 71B1B5901D8B31ED00EA9B17 /* SFIosAppStateTests.m */; }; - 71B1B5971D8C700C00EA9B17 /* SFIosAppStateCollector.h in Headers */ = {isa = PBXBuildFile; fileRef = 71B1B5961D8C700C00EA9B17 /* SFIosAppStateCollector.h */; }; - 71B1B5991D8C701E00EA9B17 /* SFIosAppStateCollector.m in Sources */ = {isa = PBXBuildFile; fileRef = 71B1B5981D8C701E00EA9B17 /* SFIosAppStateCollector.m */; }; - 71E15CF51D95C8FA00A0305C /* SFCircularBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 71E15CF31D95C8FA00A0305C /* SFCircularBuffer.h */; }; - 71E15CF81D95C90000A0305C /* SFCircularBufferTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 71E15CF71D95C90000A0305C /* SFCircularBufferTests.m */; }; - 71E15CF91D95C92300A0305C /* SFCircularBuffer.m in Sources */ = {isa = PBXBuildFile; fileRef = 71E15CF41D95C8FA00A0305C /* SFCircularBuffer.m */; }; - 71E15CFB1D95D14700A0305C /* SFTokenBucket.h in Headers */ = {isa = PBXBuildFile; fileRef = 71E15CFA1D95D14700A0305C /* SFTokenBucket.h */; }; - 71E15CFD1D95D15900A0305C /* SFTokenBucket.m in Sources */ = {isa = PBXBuildFile; fileRef = 71E15CFC1D95D15900A0305C /* SFTokenBucket.m */; }; - 71E15CFF1D95DEC300A0305C /* SFTokenBucketTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 71E15CFE1D95DEC300A0305C /* SFTokenBucketTests.m */; }; + 71B1B58D1D8B281900EA9B17 /* SiftIosAppState.h in Headers */ = {isa = PBXBuildFile; fileRef = 71B1B58C1D8B281900EA9B17 /* SiftIosAppState.h */; }; + 71B1B58F1D8B282C00EA9B17 /* SiftIosAppState.m in Sources */ = {isa = PBXBuildFile; fileRef = 71B1B58E1D8B282C00EA9B17 /* SiftIosAppState.m */; }; + 71B1B5911D8B31ED00EA9B17 /* SiftIosAppStateTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 71B1B5901D8B31ED00EA9B17 /* SiftIosAppStateTests.m */; }; + 71B1B5971D8C700C00EA9B17 /* SiftIosAppStateCollector.h in Headers */ = {isa = PBXBuildFile; fileRef = 71B1B5961D8C700C00EA9B17 /* SiftIosAppStateCollector.h */; }; + 71B1B5991D8C701E00EA9B17 /* SiftIosAppStateCollector.m in Sources */ = {isa = PBXBuildFile; fileRef = 71B1B5981D8C701E00EA9B17 /* SiftIosAppStateCollector.m */; }; + 71E15CF51D95C8FA00A0305C /* SiftCircularBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 71E15CF31D95C8FA00A0305C /* SiftCircularBuffer.h */; }; + 71E15CF81D95C90000A0305C /* SiftCircularBufferTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 71E15CF71D95C90000A0305C /* SiftCircularBufferTests.m */; }; + 71E15CF91D95C92300A0305C /* SiftCircularBuffer.m in Sources */ = {isa = PBXBuildFile; fileRef = 71E15CF41D95C8FA00A0305C /* SiftCircularBuffer.m */; }; + 71E15CFB1D95D14700A0305C /* SiftTokenBucket.h in Headers */ = {isa = PBXBuildFile; fileRef = 71E15CFA1D95D14700A0305C /* SiftTokenBucket.h */; }; + 71E15CFD1D95D15900A0305C /* SiftTokenBucket.m in Sources */ = {isa = PBXBuildFile; fileRef = 71E15CFC1D95D15900A0305C /* SiftTokenBucket.m */; }; + 71E15CFF1D95DEC300A0305C /* SiftTokenBucketTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 71E15CFE1D95DEC300A0305C /* SiftTokenBucketTests.m */; }; F712CDD41DD15D5400C069BD /* NSData+GZIP.h in Headers */ = {isa = PBXBuildFile; fileRef = F712CDD21DD15D5400C069BD /* NSData+GZIP.h */; }; F712CDD51DD15D5400C069BD /* NSData+GZIP.m in Sources */ = {isa = PBXBuildFile; fileRef = F712CDD31DD15D5400C069BD /* NSData+GZIP.m */; }; /* End PBXBuildFile section */ @@ -63,51 +63,51 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 713AF4231DA456740061B688 /* SFUtilsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFUtilsTests.m; sourceTree = ""; }; - 713D85981D627E860011D5FE /* SFIosDeviceProperties.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SFIosDeviceProperties.h; sourceTree = ""; }; - 713D85991D627E9F0011D5FE /* SFIosDeviceProperties.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFIosDeviceProperties.m; sourceTree = ""; }; - 713D859C1D6CF69E0011D5FE /* SFIosDevicePropertiesTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFIosDevicePropertiesTests.m; sourceTree = ""; }; - 713D85BC1D8744040011D5FE /* SFHtDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFHtDictionary.h; sourceTree = ""; }; - 713D85BE1D87441A0011D5FE /* SFHtDictionary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFHtDictionary.m; sourceTree = ""; }; - 713D85C01D874ED40011D5FE /* SFHtDictionaryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFHtDictionaryTests.m; sourceTree = ""; }; - 715AB3EA1D9DBBFB00771402 /* SFCompatibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFCompatibility.h; sourceTree = ""; }; + 713AF4231DA456740061B688 /* SiftUtilsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftUtilsTests.m; sourceTree = ""; }; + 713D85981D627E860011D5FE /* SiftIosDeviceProperties.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SiftIosDeviceProperties.h; sourceTree = ""; }; + 713D85991D627E9F0011D5FE /* SiftIosDeviceProperties.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftIosDeviceProperties.m; sourceTree = ""; }; + 713D859C1D6CF69E0011D5FE /* SiftIosDevicePropertiesTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftIosDevicePropertiesTests.m; sourceTree = ""; }; + 713D85BC1D8744040011D5FE /* SiftHtDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SiftHtDictionary.h; sourceTree = ""; }; + 713D85BE1D87441A0011D5FE /* SiftHtDictionary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftHtDictionary.m; sourceTree = ""; }; + 713D85C01D874ED40011D5FE /* SiftHtDictionaryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftHtDictionaryTests.m; sourceTree = ""; }; + 715AB3EA1D9DBBFB00771402 /* SiftCompatibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SiftCompatibility.h; sourceTree = ""; }; 7168EE011C7B977500A88245 /* Sift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Sift.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 7168EE041C7B977500A88245 /* Sift.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Sift.h; sourceTree = ""; }; 7168EE061C7B977500A88245 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 7168EE0B1C7B977500A88245 /* SiftTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SiftTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 7168EE101C7B977500A88245 /* SiftTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SiftTests.m; sourceTree = ""; }; 7168EE121C7B977500A88245 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 7168EE1B1C7E61E900A88245 /* SFEventTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFEventTests.m; sourceTree = ""; }; - 7168EE1D1C7E7A6800A88245 /* SFQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFQueue.h; sourceTree = ""; }; - 7168EE1F1C7E7B6700A88245 /* SFQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFQueue.m; sourceTree = ""; }; + 7168EE1B1C7E61E900A88245 /* SiftEventTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftEventTests.m; sourceTree = ""; }; + 7168EE1D1C7E7A6800A88245 /* SiftQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SiftQueue.h; sourceTree = ""; }; + 7168EE1F1C7E7B6700A88245 /* SiftQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftQueue.m; sourceTree = ""; }; 7168EE211C7F978D00A88245 /* Sift+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Sift+Private.h"; sourceTree = ""; }; - 7168EE231C7F99AF00A88245 /* SFQueueTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFQueueTests.m; sourceTree = ""; }; - 7168EE251C7FB80C00A88245 /* SFUploader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFUploader.h; sourceTree = ""; }; - 7168EE261C7FB80C00A88245 /* SFUploader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFUploader.m; sourceTree = ""; }; - 7168EE2B1C86250100A88245 /* SFEvent+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SFEvent+Private.h"; sourceTree = ""; }; - 7168EE321C864A4100A88245 /* SFIosDevicePropertiesCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFIosDevicePropertiesCollector.h; sourceTree = ""; }; - 7168EE331C864A4100A88245 /* SFIosDevicePropertiesCollector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFIosDevicePropertiesCollector.m; sourceTree = ""; }; - 7168EE3E1C88C91900A88245 /* SFStubHttpProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFStubHttpProtocol.h; sourceTree = ""; }; - 7168EE3F1C88C91900A88245 /* SFStubHttpProtocol.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFStubHttpProtocol.m; sourceTree = ""; }; - 7168EE401C88C91900A88245 /* SFUploaderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFUploaderTests.m; sourceTree = ""; }; - 716BEB861C7D304D009C3706 /* SFDebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFDebug.h; sourceTree = ""; }; - 716BEB881C7D336B009C3706 /* SFEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFEvent.h; sourceTree = ""; }; - 716BEB891C7D336B009C3706 /* SFQueueConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFQueueConfig.h; sourceTree = ""; }; - 716BEB8C1C7D3695009C3706 /* SFEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFEvent.m; sourceTree = ""; }; - 716BEB8D1C7D3695009C3706 /* SFUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFUtils.h; sourceTree = ""; }; - 716BEB8E1C7D3695009C3706 /* SFUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFUtils.m; sourceTree = ""; }; + 7168EE231C7F99AF00A88245 /* SiftQueueTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftQueueTests.m; sourceTree = ""; }; + 7168EE251C7FB80C00A88245 /* SiftUploader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SiftUploader.h; sourceTree = ""; }; + 7168EE261C7FB80C00A88245 /* SiftUploader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftUploader.m; sourceTree = ""; }; + 7168EE2B1C86250100A88245 /* SiftEvent+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SiftEvent+Private.h"; sourceTree = ""; }; + 7168EE321C864A4100A88245 /* SiftIosDevicePropertiesCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SiftIosDevicePropertiesCollector.h; sourceTree = ""; }; + 7168EE331C864A4100A88245 /* SiftIosDevicePropertiesCollector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftIosDevicePropertiesCollector.m; sourceTree = ""; }; + 7168EE3E1C88C91900A88245 /* SiftStubHttpProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SiftStubHttpProtocol.h; sourceTree = ""; }; + 7168EE3F1C88C91900A88245 /* SiftStubHttpProtocol.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftStubHttpProtocol.m; sourceTree = ""; }; + 7168EE401C88C91900A88245 /* SiftUploaderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftUploaderTests.m; sourceTree = ""; }; + 716BEB861C7D304D009C3706 /* SiftDebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SiftDebug.h; sourceTree = ""; }; + 716BEB881C7D336B009C3706 /* SiftEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SiftEvent.h; sourceTree = ""; }; + 716BEB891C7D336B009C3706 /* SiftQueueConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SiftQueueConfig.h; sourceTree = ""; }; + 716BEB8C1C7D3695009C3706 /* SiftEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftEvent.m; sourceTree = ""; }; + 716BEB8D1C7D3695009C3706 /* SiftUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SiftUtils.h; sourceTree = ""; }; + 716BEB8E1C7D3695009C3706 /* SiftUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftUtils.m; sourceTree = ""; }; 716BEB8F1C7D3695009C3706 /* Sift.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Sift.m; sourceTree = ""; }; - 71B1B58C1D8B281900EA9B17 /* SFIosAppState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFIosAppState.h; sourceTree = ""; }; - 71B1B58E1D8B282C00EA9B17 /* SFIosAppState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFIosAppState.m; sourceTree = ""; }; - 71B1B5901D8B31ED00EA9B17 /* SFIosAppStateTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFIosAppStateTests.m; sourceTree = ""; }; - 71B1B5961D8C700C00EA9B17 /* SFIosAppStateCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFIosAppStateCollector.h; sourceTree = ""; }; - 71B1B5981D8C701E00EA9B17 /* SFIosAppStateCollector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFIosAppStateCollector.m; sourceTree = ""; }; - 71E15CF31D95C8FA00A0305C /* SFCircularBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFCircularBuffer.h; sourceTree = ""; }; - 71E15CF41D95C8FA00A0305C /* SFCircularBuffer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFCircularBuffer.m; sourceTree = ""; }; - 71E15CF71D95C90000A0305C /* SFCircularBufferTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFCircularBufferTests.m; sourceTree = ""; }; - 71E15CFA1D95D14700A0305C /* SFTokenBucket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFTokenBucket.h; sourceTree = ""; }; - 71E15CFC1D95D15900A0305C /* SFTokenBucket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFTokenBucket.m; sourceTree = ""; }; - 71E15CFE1D95DEC300A0305C /* SFTokenBucketTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFTokenBucketTests.m; sourceTree = ""; }; + 71B1B58C1D8B281900EA9B17 /* SiftIosAppState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SiftIosAppState.h; sourceTree = ""; }; + 71B1B58E1D8B282C00EA9B17 /* SiftIosAppState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftIosAppState.m; sourceTree = ""; }; + 71B1B5901D8B31ED00EA9B17 /* SiftIosAppStateTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftIosAppStateTests.m; sourceTree = ""; }; + 71B1B5961D8C700C00EA9B17 /* SiftIosAppStateCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SiftIosAppStateCollector.h; sourceTree = ""; }; + 71B1B5981D8C701E00EA9B17 /* SiftIosAppStateCollector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftIosAppStateCollector.m; sourceTree = ""; }; + 71E15CF31D95C8FA00A0305C /* SiftCircularBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SiftCircularBuffer.h; sourceTree = ""; }; + 71E15CF41D95C8FA00A0305C /* SiftCircularBuffer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftCircularBuffer.m; sourceTree = ""; }; + 71E15CF71D95C90000A0305C /* SiftCircularBufferTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftCircularBufferTests.m; sourceTree = ""; }; + 71E15CFA1D95D14700A0305C /* SiftTokenBucket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SiftTokenBucket.h; sourceTree = ""; }; + 71E15CFC1D95D15900A0305C /* SiftTokenBucket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftTokenBucket.m; sourceTree = ""; }; + 71E15CFE1D95DEC300A0305C /* SiftTokenBucketTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SiftTokenBucketTests.m; sourceTree = ""; }; F712CDD21DD15D5400C069BD /* NSData+GZIP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+GZIP.h"; sourceTree = ""; }; F712CDD31DD15D5400C069BD /* NSData+GZIP.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+GZIP.m"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -154,32 +154,32 @@ children = ( F712CDD61DD15D5A00C069BD /* Vendor */, 7168EE061C7B977500A88245 /* Info.plist */, - 71E15CF31D95C8FA00A0305C /* SFCircularBuffer.h */, - 71E15CF41D95C8FA00A0305C /* SFCircularBuffer.m */, - 715AB3EA1D9DBBFB00771402 /* SFCompatibility.h */, - 716BEB861C7D304D009C3706 /* SFDebug.h */, - 716BEB881C7D336B009C3706 /* SFEvent.h */, - 716BEB8C1C7D3695009C3706 /* SFEvent.m */, - 7168EE2B1C86250100A88245 /* SFEvent+Private.h */, - 713D85BC1D8744040011D5FE /* SFHtDictionary.h */, - 713D85BE1D87441A0011D5FE /* SFHtDictionary.m */, - 71B1B58C1D8B281900EA9B17 /* SFIosAppState.h */, - 71B1B58E1D8B282C00EA9B17 /* SFIosAppState.m */, - 71B1B5961D8C700C00EA9B17 /* SFIosAppStateCollector.h */, - 71B1B5981D8C701E00EA9B17 /* SFIosAppStateCollector.m */, - 713D85981D627E860011D5FE /* SFIosDeviceProperties.h */, - 713D85991D627E9F0011D5FE /* SFIosDeviceProperties.m */, - 7168EE321C864A4100A88245 /* SFIosDevicePropertiesCollector.h */, - 7168EE331C864A4100A88245 /* SFIosDevicePropertiesCollector.m */, - 7168EE1D1C7E7A6800A88245 /* SFQueue.h */, - 7168EE1F1C7E7B6700A88245 /* SFQueue.m */, - 716BEB891C7D336B009C3706 /* SFQueueConfig.h */, - 71E15CFA1D95D14700A0305C /* SFTokenBucket.h */, - 71E15CFC1D95D15900A0305C /* SFTokenBucket.m */, - 7168EE251C7FB80C00A88245 /* SFUploader.h */, - 7168EE261C7FB80C00A88245 /* SFUploader.m */, - 716BEB8D1C7D3695009C3706 /* SFUtils.h */, - 716BEB8E1C7D3695009C3706 /* SFUtils.m */, + 71E15CF31D95C8FA00A0305C /* SiftCircularBuffer.h */, + 71E15CF41D95C8FA00A0305C /* SiftCircularBuffer.m */, + 715AB3EA1D9DBBFB00771402 /* SiftCompatibility.h */, + 716BEB861C7D304D009C3706 /* SiftDebug.h */, + 716BEB881C7D336B009C3706 /* SiftEvent.h */, + 716BEB8C1C7D3695009C3706 /* SiftEvent.m */, + 7168EE2B1C86250100A88245 /* SiftEvent+Private.h */, + 713D85BC1D8744040011D5FE /* SiftHtDictionary.h */, + 713D85BE1D87441A0011D5FE /* SiftHtDictionary.m */, + 71B1B58C1D8B281900EA9B17 /* SiftIosAppState.h */, + 71B1B58E1D8B282C00EA9B17 /* SiftIosAppState.m */, + 71B1B5961D8C700C00EA9B17 /* SiftIosAppStateCollector.h */, + 71B1B5981D8C701E00EA9B17 /* SiftIosAppStateCollector.m */, + 713D85981D627E860011D5FE /* SiftIosDeviceProperties.h */, + 713D85991D627E9F0011D5FE /* SiftIosDeviceProperties.m */, + 7168EE321C864A4100A88245 /* SiftIosDevicePropertiesCollector.h */, + 7168EE331C864A4100A88245 /* SiftIosDevicePropertiesCollector.m */, + 7168EE1D1C7E7A6800A88245 /* SiftQueue.h */, + 7168EE1F1C7E7B6700A88245 /* SiftQueue.m */, + 716BEB891C7D336B009C3706 /* SiftQueueConfig.h */, + 71E15CFA1D95D14700A0305C /* SiftTokenBucket.h */, + 71E15CFC1D95D15900A0305C /* SiftTokenBucket.m */, + 7168EE251C7FB80C00A88245 /* SiftUploader.h */, + 7168EE261C7FB80C00A88245 /* SiftUploader.m */, + 716BEB8D1C7D3695009C3706 /* SiftUtils.h */, + 716BEB8E1C7D3695009C3706 /* SiftUtils.m */, 7168EE041C7B977500A88245 /* Sift.h */, 716BEB8F1C7D3695009C3706 /* Sift.m */, 7168EE211C7F978D00A88245 /* Sift+Private.h */, @@ -191,17 +191,17 @@ isa = PBXGroup; children = ( 7168EE121C7B977500A88245 /* Info.plist */, - 71E15CF71D95C90000A0305C /* SFCircularBufferTests.m */, - 7168EE1B1C7E61E900A88245 /* SFEventTests.m */, - 713D85C01D874ED40011D5FE /* SFHtDictionaryTests.m */, - 71B1B5901D8B31ED00EA9B17 /* SFIosAppStateTests.m */, - 713D859C1D6CF69E0011D5FE /* SFIosDevicePropertiesTests.m */, - 7168EE231C7F99AF00A88245 /* SFQueueTests.m */, - 7168EE3E1C88C91900A88245 /* SFStubHttpProtocol.h */, - 7168EE3F1C88C91900A88245 /* SFStubHttpProtocol.m */, - 71E15CFE1D95DEC300A0305C /* SFTokenBucketTests.m */, - 7168EE401C88C91900A88245 /* SFUploaderTests.m */, - 713AF4231DA456740061B688 /* SFUtilsTests.m */, + 71E15CF71D95C90000A0305C /* SiftCircularBufferTests.m */, + 7168EE1B1C7E61E900A88245 /* SiftEventTests.m */, + 713D85C01D874ED40011D5FE /* SiftHtDictionaryTests.m */, + 71B1B5901D8B31ED00EA9B17 /* SiftIosAppStateTests.m */, + 713D859C1D6CF69E0011D5FE /* SiftIosDevicePropertiesTests.m */, + 7168EE231C7F99AF00A88245 /* SiftQueueTests.m */, + 7168EE3E1C88C91900A88245 /* SiftStubHttpProtocol.h */, + 7168EE3F1C88C91900A88245 /* SiftStubHttpProtocol.m */, + 71E15CFE1D95DEC300A0305C /* SiftTokenBucketTests.m */, + 7168EE401C88C91900A88245 /* SiftUploaderTests.m */, + 713AF4231DA456740061B688 /* SiftUtilsTests.m */, 7168EE101C7B977500A88245 /* SiftTests.m */, ); path = SiftTests; @@ -223,24 +223,24 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 7168EE2C1C86250100A88245 /* SFEvent+Private.h in Headers */, + 7168EE2C1C86250100A88245 /* SiftEvent+Private.h in Headers */, F712CDD41DD15D5400C069BD /* NSData+GZIP.h in Headers */, - 716BEB911C7D3695009C3706 /* SFUtils.h in Headers */, - 71E15CF51D95C8FA00A0305C /* SFCircularBuffer.h in Headers */, - 716BEB8A1C7D336B009C3706 /* SFEvent.h in Headers */, + 716BEB911C7D3695009C3706 /* SiftUtils.h in Headers */, + 71E15CF51D95C8FA00A0305C /* SiftCircularBuffer.h in Headers */, + 716BEB8A1C7D336B009C3706 /* SiftEvent.h in Headers */, 7168EE221C7F978D00A88245 /* Sift+Private.h in Headers */, - 71B1B5971D8C700C00EA9B17 /* SFIosAppStateCollector.h in Headers */, - 716BEB8B1C7D336B009C3706 /* SFQueueConfig.h in Headers */, - 7168EE1E1C7E7A6800A88245 /* SFQueue.h in Headers */, + 71B1B5971D8C700C00EA9B17 /* SiftIosAppStateCollector.h in Headers */, + 716BEB8B1C7D336B009C3706 /* SiftQueueConfig.h in Headers */, + 7168EE1E1C7E7A6800A88245 /* SiftQueue.h in Headers */, 7168EE051C7B977500A88245 /* Sift.h in Headers */, - 713D859B1D627EA60011D5FE /* SFIosDeviceProperties.h in Headers */, - 71B1B58D1D8B281900EA9B17 /* SFIosAppState.h in Headers */, - 715AB3EB1D9DBBFB00771402 /* SFCompatibility.h in Headers */, - 716BEB871C7D304D009C3706 /* SFDebug.h in Headers */, - 713D85BD1D8744040011D5FE /* SFHtDictionary.h in Headers */, - 71E15CFB1D95D14700A0305C /* SFTokenBucket.h in Headers */, - 7168EE271C7FB80C00A88245 /* SFUploader.h in Headers */, - 7168EE341C864A4100A88245 /* SFIosDevicePropertiesCollector.h in Headers */, + 713D859B1D627EA60011D5FE /* SiftIosDeviceProperties.h in Headers */, + 71B1B58D1D8B281900EA9B17 /* SiftIosAppState.h in Headers */, + 715AB3EB1D9DBBFB00771402 /* SiftCompatibility.h in Headers */, + 716BEB871C7D304D009C3706 /* SiftDebug.h in Headers */, + 713D85BD1D8744040011D5FE /* SiftHtDictionary.h in Headers */, + 71E15CFB1D95D14700A0305C /* SiftTokenBucket.h in Headers */, + 7168EE271C7FB80C00A88245 /* SiftUploader.h in Headers */, + 7168EE341C864A4100A88245 /* SiftIosDevicePropertiesCollector.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -305,6 +305,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = 7168EDF71C7B977500A88245; @@ -342,17 +343,17 @@ files = ( F712CDD51DD15D5400C069BD /* NSData+GZIP.m in Sources */, 716BEB931C7D3695009C3706 /* Sift.m in Sources */, - 71E15CF91D95C92300A0305C /* SFCircularBuffer.m in Sources */, - 7168EE281C7FB80C00A88245 /* SFUploader.m in Sources */, - 71E15CFD1D95D15900A0305C /* SFTokenBucket.m in Sources */, - 713D859A1D627E9F0011D5FE /* SFIosDeviceProperties.m in Sources */, - 71B1B58F1D8B282C00EA9B17 /* SFIosAppState.m in Sources */, - 7168EE351C864A4100A88245 /* SFIosDevicePropertiesCollector.m in Sources */, - 716BEB921C7D3695009C3706 /* SFUtils.m in Sources */, - 71B1B5991D8C701E00EA9B17 /* SFIosAppStateCollector.m in Sources */, - 7168EE201C7E7B6700A88245 /* SFQueue.m in Sources */, - 713D85BF1D87441A0011D5FE /* SFHtDictionary.m in Sources */, - 716BEB901C7D3695009C3706 /* SFEvent.m in Sources */, + 71E15CF91D95C92300A0305C /* SiftCircularBuffer.m in Sources */, + 7168EE281C7FB80C00A88245 /* SiftUploader.m in Sources */, + 71E15CFD1D95D15900A0305C /* SiftTokenBucket.m in Sources */, + 713D859A1D627E9F0011D5FE /* SiftIosDeviceProperties.m in Sources */, + 71B1B58F1D8B282C00EA9B17 /* SiftIosAppState.m in Sources */, + 7168EE351C864A4100A88245 /* SiftIosDevicePropertiesCollector.m in Sources */, + 716BEB921C7D3695009C3706 /* SiftUtils.m in Sources */, + 71B1B5991D8C701E00EA9B17 /* SiftIosAppStateCollector.m in Sources */, + 7168EE201C7E7B6700A88245 /* SiftQueue.m in Sources */, + 713D85BF1D87441A0011D5FE /* SiftHtDictionary.m in Sources */, + 716BEB901C7D3695009C3706 /* SiftEvent.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -360,17 +361,17 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 71E15CF81D95C90000A0305C /* SFCircularBufferTests.m in Sources */, - 7168EE411C88C91900A88245 /* SFStubHttpProtocol.m in Sources */, - 713AF4241DA456740061B688 /* SFUtilsTests.m in Sources */, - 71E15CFF1D95DEC300A0305C /* SFTokenBucketTests.m in Sources */, + 71E15CF81D95C90000A0305C /* SiftCircularBufferTests.m in Sources */, + 7168EE411C88C91900A88245 /* SiftStubHttpProtocol.m in Sources */, + 713AF4241DA456740061B688 /* SiftUtilsTests.m in Sources */, + 71E15CFF1D95DEC300A0305C /* SiftTokenBucketTests.m in Sources */, 7168EE111C7B977500A88245 /* SiftTests.m in Sources */, - 7168EE1C1C7E61E900A88245 /* SFEventTests.m in Sources */, - 713D859D1D6CF69E0011D5FE /* SFIosDevicePropertiesTests.m in Sources */, - 7168EE241C7F99AF00A88245 /* SFQueueTests.m in Sources */, - 713D85C11D874ED40011D5FE /* SFHtDictionaryTests.m in Sources */, - 7168EE421C88C91900A88245 /* SFUploaderTests.m in Sources */, - 71B1B5911D8B31ED00EA9B17 /* SFIosAppStateTests.m in Sources */, + 7168EE1C1C7E61E900A88245 /* SiftEventTests.m in Sources */, + 713D859D1D6CF69E0011D5FE /* SiftIosDevicePropertiesTests.m in Sources */, + 7168EE241C7F99AF00A88245 /* SiftQueueTests.m in Sources */, + 713D85C11D874ED40011D5FE /* SiftHtDictionaryTests.m in Sources */, + 7168EE421C88C91900A88245 /* SiftUploaderTests.m in Sources */, + 71B1B5911D8B31ED00EA9B17 /* SiftIosAppStateTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Sift/README.md b/Sift/README.md index 76a2b6a..125de60 100644 --- a/Sift/README.md +++ b/Sift/README.md @@ -1,10 +1,10 @@ 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 @@ -12,9 +12,9 @@ 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 ( ) `) ) | (_ (_ . _) _) @@ -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 |<------+ +-----------------+ ``` diff --git a/Sift/SFIosAppState.h b/Sift/SFIosAppState.h deleted file mode 100644 index 32245be..0000000 --- a/Sift/SFIosAppState.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2016 Sift Science. All rights reserved. - -@import CoreLocation; -@import CoreMotion; -@import Foundation; - -#import "SFHtDictionary.h" -#import "SFUtils.h" - -SFHtDictionary *SFMakeEmptyIosAppState(); - -SFHtDictionary *SFCollectIosAppState(CLLocationManager *locationManager, NSString *title); - -SFHtDictionary *SFCLHeadingToDictionary(CLHeading *heading); - -SFHtDictionary *SFCLLocationToDictionary(CLLocation *data); - -SFHtDictionary *SFCMDeviceMotionToDictionary(CMDeviceMotion *data, SFTimestamp now); -SFHtDictionary *SFCMAccelerometerDataToDictionary(CMAccelerometerData *data, SFTimestamp now); -SFHtDictionary *SFCMGyroDataToDictionary(CMGyroData *data, SFTimestamp now); -SFHtDictionary *SFCMMagnetometerDataToDictionary(CMMagnetometerData *data, SFTimestamp now); diff --git a/Sift/SFIosDeviceProperties.h b/Sift/SFIosDeviceProperties.h deleted file mode 100644 index 68e09e3..0000000 --- a/Sift/SFIosDeviceProperties.h +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2016 Sift Science. All rights reserved. - -@import Foundation; - -#import "SFHtDictionary.h" - -SFHtDictionary *SFMakeEmptyIosDeviceProperties(); - -SFHtDictionary *SFCollectIosDeviceProperties(); \ No newline at end of file diff --git a/Sift/Sift.h b/Sift/Sift.h index b70c1ff..75d688a 100644 --- a/Sift/Sift.h +++ b/Sift/Sift.h @@ -5,8 +5,8 @@ #import #import -#import "SFEvent.h" -#import "SFQueueConfig.h" +#import "SiftEvent.h" +#import "SiftQueueConfig.h" /** * This is the main interface you interact with Sift. @@ -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. @@ -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. diff --git a/Sift/Sift.m b/Sift/Sift.m index b9235fa..f225fd3 100644 --- a/Sift/Sift.m +++ b/Sift/Sift.m @@ -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" @@ -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. }; @@ -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 { @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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]]; } diff --git a/Sift/SFCircularBuffer.h b/Sift/SiftCircularBuffer.h similarity index 86% rename from Sift/SFCircularBuffer.h rename to Sift/SiftCircularBuffer.h index 0056f44..aa02a7f 100644 --- a/Sift/SFCircularBuffer.h +++ b/Sift/SiftCircularBuffer.h @@ -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; diff --git a/Sift/SFCircularBuffer.m b/Sift/SiftCircularBuffer.m similarity index 94% rename from Sift/SFCircularBuffer.m rename to Sift/SiftCircularBuffer.m index 1aaf3f3..8c9e7f6 100644 --- a/Sift/SFCircularBuffer.m +++ b/Sift/SiftCircularBuffer.m @@ -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; diff --git a/Sift/SFCompatibility.h b/Sift/SiftCompatibility.h similarity index 100% rename from Sift/SFCompatibility.h rename to Sift/SiftCompatibility.h diff --git a/Sift/SFDebug.h b/Sift/SiftDebug.h similarity index 100% rename from Sift/SFDebug.h rename to Sift/SiftDebug.h diff --git a/Sift/SFEvent+Private.h b/Sift/SiftEvent+Private.h similarity index 71% rename from Sift/SFEvent+Private.h rename to Sift/SiftEvent+Private.h index 20a46ca..89ee20c 100644 --- a/Sift/SFEvent+Private.h +++ b/Sift/SiftEvent+Private.h @@ -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; @@ -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; diff --git a/Sift/SFEvent.h b/Sift/SiftEvent.h similarity index 82% rename from Sift/SFEvent.h rename to Sift/SiftEvent.h index ff057c8..d6c596f 100644 --- a/Sift/SFEvent.h +++ b/Sift/SiftEvent.h @@ -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 +@interface SiftEvent : NSObject /** 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. */ diff --git a/Sift/SFEvent.m b/Sift/SiftEvent.m similarity index 95% rename from Sift/SFEvent.m rename to Sift/SiftEvent.m index 8ce191d..21ccf2b 100644 --- a/Sift/SFEvent.m +++ b/Sift/SiftEvent.m @@ -3,16 +3,16 @@ @import Foundation; @import UIKit; -#import "SFDebug.h" -#import "SFUtils.h" +#import "SiftDebug.h" +#import "SiftUtils.h" -#import "SFEvent.h" -#import "SFEvent+Private.h" +#import "SiftEvent.h" +#import "SiftEvent+Private.h" -@implementation SFEvent +@implementation SiftEvent -+ (SFEvent *)eventWithType:(NSString *)type path:(NSString *)path fields:(NSDictionary *)fields { - SFEvent *event = [SFEvent new]; ++ (SiftEvent *)eventWithType:(NSString *)type path:(NSString *)path fields:(NSDictionary *)fields { + SiftEvent *event = [SiftEvent new]; if (type) { event.type = type; } @@ -42,7 +42,7 @@ - (instancetype)init { return self; } -- (BOOL)isEssentiallyEqualTo:(SFEvent *)event { +- (BOOL)isEssentiallyEqualTo:(SiftEvent *)event { return event && ((!_type && !event.type) || [_type isEqualToString:event.type]) && ((!_path && !event.path) || [_path isEqualToString:event.path]) && @@ -110,7 +110,7 @@ - (void)encodeWithCoder:(NSCoder *)encoder { + (NSData *)listRequest:(NSArray *)events { NSMutableArray *data = [NSMutableArray new]; - for (SFEvent *event in events) { + for (SiftEvent *event in events) { NSMutableDictionary *eventRequest = [NSMutableDictionary new]; [eventRequest setObject:[NSNumber numberWithUnsignedLongLong:event.time] forKey:@"time"]; if (!SFAddToRequest(eventRequest, @"mobile_event_type", event.type) || diff --git a/Sift/SFHtDictionary.h b/Sift/SiftHtDictionary.h similarity index 86% rename from Sift/SFHtDictionary.h rename to Sift/SiftHtDictionary.h index 67c04f9..cbab5c1 100644 --- a/Sift/SFHtDictionary.h +++ b/Sift/SiftHtDictionary.h @@ -2,7 +2,7 @@ @import Foundation; -#import "SFCompatibility.h" +#import "SiftCompatibility.h" /** * Heterogeneous-typed dictionary. @@ -10,7 +10,7 @@ * Each heterogeneous-typed dictionary instance has a entryTypes dictionary * specifying what keys and what type of values it takes. */ -@interface SFHtDictionary : NSObject +@interface SiftHtDictionary : NSObject - (instancetype)initWithEntryTypes:(SF_GENERICS(NSDictionary, NSString *, Class) *)entryTypes; diff --git a/Sift/SFHtDictionary.m b/Sift/SiftHtDictionary.m similarity index 88% rename from Sift/SFHtDictionary.m rename to Sift/SiftHtDictionary.m index 3e1caec..a26f92a 100644 --- a/Sift/SFHtDictionary.m +++ b/Sift/SiftHtDictionary.m @@ -1,11 +1,11 @@ // Copyright (c) 2016 Sift Science. All rights reserved. -#import "SFCompatibility.h" -#import "SFDebug.h" +#import "SiftCompatibility.h" +#import "SiftDebug.h" -#import "SFHtDictionary.h" +#import "SiftHtDictionary.h" -@implementation SFHtDictionary +@implementation SiftHtDictionary - (instancetype)initWithEntryTypes:(SF_GENERICS(NSDictionary, NSString *, Class) *)entryTypes { self = [super init]; @@ -20,10 +20,10 @@ - (BOOL)isEqual:(id)object { if (self == object) { return YES; } - if (![object isKindOfClass:SFHtDictionary.class]) { + if (![object isKindOfClass:SiftHtDictionary.class]) { return NO; } - SFHtDictionary *other = object; + SiftHtDictionary *other = object; return [self.entries isEqualToDictionary:other.entries]; } diff --git a/Sift/SiftIosAppState.h b/Sift/SiftIosAppState.h new file mode 100644 index 0000000..8da48e1 --- /dev/null +++ b/Sift/SiftIosAppState.h @@ -0,0 +1,21 @@ +// Copyright (c) 2016 Sift Science. All rights reserved. + +@import CoreLocation; +@import CoreMotion; +@import Foundation; + +#import "SiftHtDictionary.h" +#import "SiftUtils.h" + +SiftHtDictionary *SFMakeEmptyIosAppState(); + +SiftHtDictionary *SFCollectIosAppState(CLLocationManager *locationManager, NSString *title); + +SiftHtDictionary *SFCLHeadingToDictionary(CLHeading *heading); + +SiftHtDictionary *SFCLLocationToDictionary(CLLocation *data); + +SiftHtDictionary *SFCMDeviceMotionToDictionary(CMDeviceMotion *data, SFTimestamp now); +SiftHtDictionary *SFCMAccelerometerDataToDictionary(CMAccelerometerData *data, SFTimestamp now); +SiftHtDictionary *SFCMGyroDataToDictionary(CMGyroData *data, SFTimestamp now); +SiftHtDictionary *SFCMMagnetometerDataToDictionary(CMMagnetometerData *data, SFTimestamp now); diff --git a/Sift/SFIosAppState.m b/Sift/SiftIosAppState.m similarity index 89% rename from Sift/SFIosAppState.m rename to Sift/SiftIosAppState.m index 9daa72e..95b3b44 100644 --- a/Sift/SFIosAppState.m +++ b/Sift/SiftIosAppState.m @@ -8,14 +8,14 @@ #include #include -#import "SFCompatibility.h" -#import "SFDebug.h" -#import "SFUtils.h" +#import "SiftCompatibility.h" +#import "SiftDebug.h" +#import "SiftUtils.h" #import "Sift.h" -#import "SFIosAppState.h" +#import "SiftIosAppState.h" -SFHtDictionary *SFMakeEmptyIosAppState() { +SiftHtDictionary *SFMakeEmptyIosAppState() { static SF_GENERICS(NSMutableDictionary, NSString *, Class) *entryTypes; static dispatch_once_t once; dispatch_once(&once, ^{ @@ -46,10 +46,10 @@ #undef ENTRY_TYPE }); - return [[SFHtDictionary alloc] initWithEntryTypes:entryTypes]; + return [[SiftHtDictionary alloc] initWithEntryTypes:entryTypes]; } -static SFHtDictionary *SFMakeLocation() { +static SiftHtDictionary *SFMakeLocation() { static SF_GENERICS(NSMutableDictionary, NSString *, Class) *entryTypes; static dispatch_once_t once; dispatch_once(&once, ^{ @@ -70,10 +70,10 @@ #undef ENTRY_TYPE }); - return [[SFHtDictionary alloc] initWithEntryTypes:entryTypes]; + return [[SiftHtDictionary alloc] initWithEntryTypes:entryTypes]; } -static SFHtDictionary *SFMakeHeading() { +static SiftHtDictionary *SFMakeHeading() { static SF_GENERICS(NSMutableDictionary, NSString *, Class) *entryTypes; static dispatch_once_t once; dispatch_once(&once, ^{ @@ -93,10 +93,10 @@ #undef ENTRY_TYPE }); - return [[SFHtDictionary alloc] initWithEntryTypes:entryTypes]; + return [[SiftHtDictionary alloc] initWithEntryTypes:entryTypes]; } -static SFHtDictionary *SFMakeIosDeviceMotion() { +static SiftHtDictionary *SFMakeIosDeviceMotion() { static SF_GENERICS(NSMutableDictionary, NSString *, Class) *entryTypes; static dispatch_once_t once; dispatch_once(&once, ^{ @@ -128,10 +128,10 @@ #undef ENTRY_TYPE }); - return [[SFHtDictionary alloc] initWithEntryTypes:entryTypes]; + return [[SiftHtDictionary alloc] initWithEntryTypes:entryTypes]; } -static SFHtDictionary *SFMakeIosDeviceAccelerometerData() { +static SiftHtDictionary *SFMakeIosDeviceAccelerometerData() { static SF_GENERICS(NSMutableDictionary, NSString *, Class) *entryTypes; static dispatch_once_t once; dispatch_once(&once, ^{ @@ -146,10 +146,10 @@ #undef ENTRY_TYPE }); - return [[SFHtDictionary alloc] initWithEntryTypes:entryTypes]; + return [[SiftHtDictionary alloc] initWithEntryTypes:entryTypes]; } -static SFHtDictionary *SFMakeIosDeviceGyroData() { +static SiftHtDictionary *SFMakeIosDeviceGyroData() { static SF_GENERICS(NSMutableDictionary, NSString *, Class) *entryTypes; static dispatch_once_t once; dispatch_once(&once, ^{ @@ -164,10 +164,10 @@ #undef ENTRY_TYPE }); - return [[SFHtDictionary alloc] initWithEntryTypes:entryTypes]; + return [[SiftHtDictionary alloc] initWithEntryTypes:entryTypes]; } -static SFHtDictionary *SFMakeIosDeviceMagnetometerData() { +static SiftHtDictionary *SFMakeIosDeviceMagnetometerData() { static SF_GENERICS(NSMutableDictionary, NSString *, Class) *entryTypes; static dispatch_once_t once; dispatch_once(&once, ^{ @@ -182,13 +182,13 @@ #undef ENTRY_TYPE }); - return [[SFHtDictionary alloc] initWithEntryTypes:entryTypes]; + return [[SiftHtDictionary alloc] initWithEntryTypes:entryTypes]; } #pragma mark - Converters -SFHtDictionary *SFCMDeviceMotionToDictionary(CMDeviceMotion *data, SFTimestamp now) { - SFHtDictionary *dict = SFMakeIosDeviceMotion(); +SiftHtDictionary *SFCMDeviceMotionToDictionary(CMDeviceMotion *data, SFTimestamp now) { + SiftHtDictionary *dict = SFMakeIosDeviceMotion(); [dict setEntry:@"time" value:[NSNumber numberWithUnsignedLongLong:now]]; [dict setEntry:@"attitude_roll" value:[NSNumber numberWithDouble:data.attitude.roll]]; [dict setEntry:@"attitude_pitch" value:[NSNumber numberWithDouble:data.attitude.pitch]]; @@ -222,8 +222,8 @@ return dict; } -SFHtDictionary *SFCMAccelerometerDataToDictionary(CMAccelerometerData *data, SFTimestamp now) { - SFHtDictionary *dict = SFMakeIosDeviceAccelerometerData(); +SiftHtDictionary *SFCMAccelerometerDataToDictionary(CMAccelerometerData *data, SFTimestamp now) { + SiftHtDictionary *dict = SFMakeIosDeviceAccelerometerData(); [dict setEntry:@"time" value:[NSNumber numberWithUnsignedLongLong:now]]; [dict setEntry:@"acceleration_x" value:[NSNumber numberWithDouble:data.acceleration.x]]; [dict setEntry:@"acceleration_y" value:[NSNumber numberWithDouble:data.acceleration.y]]; @@ -231,8 +231,8 @@ return dict; } -SFHtDictionary *SFCMGyroDataToDictionary(CMGyroData *data, SFTimestamp now) { - SFHtDictionary *dict = SFMakeIosDeviceGyroData(); +SiftHtDictionary *SFCMGyroDataToDictionary(CMGyroData *data, SFTimestamp now) { + SiftHtDictionary *dict = SFMakeIosDeviceGyroData(); [dict setEntry:@"time" value:[NSNumber numberWithUnsignedLongLong:now]]; [dict setEntry:@"rotation_rate_x" value:[NSNumber numberWithDouble:data.rotationRate.x]]; [dict setEntry:@"rotation_rate_y" value:[NSNumber numberWithDouble:data.rotationRate.y]]; @@ -240,8 +240,8 @@ return dict; } -SFHtDictionary *SFCMMagnetometerDataToDictionary(CMMagnetometerData *data, SFTimestamp now) { - SFHtDictionary *dict = SFMakeIosDeviceMagnetometerData(); +SiftHtDictionary *SFCMMagnetometerDataToDictionary(CMMagnetometerData *data, SFTimestamp now) { + SiftHtDictionary *dict = SFMakeIosDeviceMagnetometerData(); [dict setEntry:@"time" value:[NSNumber numberWithUnsignedLongLong:now]]; [dict setEntry:@"magnetic_field_x" value:[NSNumber numberWithDouble:data.magneticField.x]]; [dict setEntry:@"magnetic_field_y" value:[NSNumber numberWithDouble:data.magneticField.y]]; @@ -253,8 +253,8 @@ static SF_GENERICS(NSArray, NSString *) *getIpAddresses(); -SFHtDictionary *SFCollectIosAppState(CLLocationManager *locationManager, NSString *title) { - SFHtDictionary *iosAppState = SFMakeEmptyIosAppState(); +SiftHtDictionary *SFCollectIosAppState(CLLocationManager *locationManager, NSString *title) { + SiftHtDictionary *iosAppState = SFMakeEmptyIosAppState(); [iosAppState setEntry:@"sdk_version" value:[Sift sharedInstance].sdkVersion]; @@ -333,8 +333,8 @@ #pragma mark - Helper functions. -SFHtDictionary *SFCLLocationToDictionary(CLLocation *location) { - SFHtDictionary *dict = SFMakeLocation(); +SiftHtDictionary *SFCLLocationToDictionary(CLLocation *location) { + SiftHtDictionary *dict = SFMakeLocation(); [dict setEntry:@"time" value:[NSNumber numberWithLongLong:(location.timestamp.timeIntervalSince1970 * 1000)]]; if (location.horizontalAccuracy >= 0) { @@ -358,8 +358,8 @@ return dict; } -SFHtDictionary *SFCLHeadingToDictionary(CLHeading *heading) { - SFHtDictionary *dict = SFMakeHeading(); +SiftHtDictionary *SFCLHeadingToDictionary(CLHeading *heading) { + SiftHtDictionary *dict = SFMakeHeading(); [dict setEntry:@"time" value:[NSNumber numberWithLongLong:(heading.timestamp.timeIntervalSince1970 * 1000)]]; if (heading.headingAccuracy >= 0) { [dict setEntry:@"magnetic_heading" value:[NSNumber numberWithDouble:heading.magneticHeading]]; diff --git a/Sift/SFIosAppStateCollector.h b/Sift/SiftIosAppStateCollector.h similarity index 95% rename from Sift/SFIosAppStateCollector.h rename to Sift/SiftIosAppStateCollector.h index 0457cb7..cfccac1 100644 --- a/Sift/SFIosAppStateCollector.h +++ b/Sift/SiftIosAppStateCollector.h @@ -4,7 +4,7 @@ @import Foundation; /** Collect app states behind the scene. */ -@interface SFIosAppStateCollector : NSObject +@interface SiftIosAppStateCollector : NSObject - (instancetype)initWithArchivePath:(NSString *)archivePath; diff --git a/Sift/SFIosAppStateCollector.m b/Sift/SiftIosAppStateCollector.m similarity index 90% rename from Sift/SFIosAppStateCollector.m rename to Sift/SiftIosAppStateCollector.m index 2d403ac..1a09e91 100644 --- a/Sift/SFIosAppStateCollector.m +++ b/Sift/SiftIosAppStateCollector.m @@ -5,17 +5,17 @@ @import Foundation; @import UIKit; -#import "SFCircularBuffer.h" -#import "SFCompatibility.h" -#import "SFDebug.h" -#import "SFEvent.h" -#import "SFEvent+Private.h" -#import "SFIosAppState.h" -#import "SFTokenBucket.h" -#import "SFUtils.h" +#import "SiftCircularBuffer.h" +#import "SiftCompatibility.h" +#import "SiftDebug.h" +#import "SiftEvent.h" +#import "SiftEvent+Private.h" +#import "SiftIosAppState.h" +#import "SiftTokenBucket.h" +#import "SiftUtils.h" #import "Sift.h" -#import "SFIosAppStateCollector.h" +#import "SiftIosAppStateCollector.h" // We rate limit to no more than 30 collections in 1 minute. static const double SF_COLLECTION_RATE_LIMIT_NUM_COLLECTIONS = 30; @@ -34,7 +34,7 @@ static const NSUInteger SF_MOTION_SENSOR_NUM_READINGS = 10; // Keep at most 10 readings. static const NSTimeInterval SF_MOTION_SENSOR_INTERVAL = 0.5; // Unit: second. -@interface SFIosAppStateCollector () +@interface SiftIosAppStateCollector () /** Load archived data. */ - (void)unarchive; @@ -56,7 +56,7 @@ - (void)collectWithTitle:(NSString *)title andTimestamp:(SFTimestamp)now; @end -@implementation SFIosAppStateCollector { +@implementation SiftIosAppStateCollector { // Use serial queue as an alternative to locking. dispatch_queue_t _serial; dispatch_source_t _source; @@ -70,13 +70,13 @@ @implementation SFIosAppStateCollector { CMMotionManager *_motionManager; int _numMotionStarted; NSOperationQueue *_operationQueue; - SF_GENERICS(SFCircularBuffer, CMDeviceMotion *) *_deviceMotionReadings; - SF_GENERICS(SFCircularBuffer, CMAccelerometerData *) *_accelerometerReadings; - SF_GENERICS(SFCircularBuffer, CMGyroData *) *_gyroReadings; - SF_GENERICS(SFCircularBuffer, CMMagnetometerData *) *_magnetometerReadings; + SF_GENERICS(SiftCircularBuffer, CMDeviceMotion *) *_deviceMotionReadings; + SF_GENERICS(SiftCircularBuffer, CMAccelerometerData *) *_accelerometerReadings; + SF_GENERICS(SiftCircularBuffer, CMGyroData *) *_gyroReadings; + SF_GENERICS(SiftCircularBuffer, CMMagnetometerData *) *_magnetometerReadings; //// Archived states. - SFTokenBucket *_bucket; // Control the rate of requestCollection. + SiftTokenBucket *_bucket; // Control the rate of requestCollection. SFTimestamp _lastCollectedAt; // Control the rate of checkAndCollectWhenNoneRecently. } @@ -100,7 +100,7 @@ - (instancetype)initWithArchivePath:(NSString *)archivePath { // Also check periodically. _source = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, _serial); dispatch_source_set_timer(_source, dispatch_time(DISPATCH_TIME_NOW, 0), SF_MAX_COLLECTION_PERIOD * NSEC_PER_MSEC, 10 * NSEC_PER_SEC); - SFIosAppStateCollector * __weak weakSelf = self; + SiftIosAppStateCollector * __weak weakSelf = self; dispatch_source_set_event_handler(_source, ^{ [weakSelf checkAndCollectWhenNoneRecently:SFCurrentTime()]; }); @@ -117,10 +117,10 @@ - (instancetype)initWithArchivePath:(NSString *)archivePath { _numMotionStarted = 0; _operationQueue = [NSOperationQueue new]; - _deviceMotionReadings = [[SFCircularBuffer alloc] initWithSize:SF_MOTION_SENSOR_NUM_READINGS]; - _accelerometerReadings = [[SFCircularBuffer alloc] initWithSize:SF_MOTION_SENSOR_NUM_READINGS]; - _gyroReadings = [[SFCircularBuffer alloc] initWithSize:SF_MOTION_SENSOR_NUM_READINGS]; - _magnetometerReadings = [[SFCircularBuffer alloc] initWithSize:SF_MOTION_SENSOR_NUM_READINGS]; + _deviceMotionReadings = [[SiftCircularBuffer alloc] initWithSize:SF_MOTION_SENSOR_NUM_READINGS]; + _accelerometerReadings = [[SiftCircularBuffer alloc] initWithSize:SF_MOTION_SENSOR_NUM_READINGS]; + _gyroReadings = [[SiftCircularBuffer alloc] initWithSize:SF_MOTION_SENSOR_NUM_READINGS]; + _magnetometerReadings = [[SiftCircularBuffer alloc] initWithSize:SF_MOTION_SENSOR_NUM_READINGS]; } return self; } @@ -159,9 +159,9 @@ - (void)viewControllerDidChange:(NSNotification *)notification { - (void)requestCollectionWithTitle:(NSString *)title { // We don't care whether the remaining requests are executed if we are gone. - SFIosAppStateCollector * __weak weakSelf = self; + SiftIosAppStateCollector * __weak weakSelf = self; dispatch_async(_serial, ^{ - SFIosAppStateCollector *strongSelf = weakSelf; + SiftIosAppStateCollector *strongSelf = weakSelf; if (!strongSelf) { return; } @@ -198,7 +198,7 @@ - (void)checkAndCollectWhenNoneRecently:(SFTimestamp)now { - (void)collectWithTitle:(NSString *)title andTimestamp:(SFTimestamp)now { dispatch_async(dispatch_get_main_queue(), ^{ SF_DEBUG(@"Collect app state..."); - SFEvent *event = [SFEvent new]; + SiftEvent *event = [SiftEvent new]; event.time = now; event.iosAppState = SFCollectIosAppState(_locationManager, title); @@ -261,7 +261,7 @@ - (void)collectWithTitle:(NSString *)title andTimestamp:(SFTimestamp)now { // Don't schedule a check in the future if you are in the background. if (foreground) { // We don't care whether the remaining requests are executed if we are gone. - SFIosAppStateCollector * __weak weakSelf = self; + SiftIosAppStateCollector * __weak weakSelf = self; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, SF_MAX_COLLECTION_PERIOD * NSEC_PER_MSEC), _serial, ^{ [weakSelf checkAndCollectWhenNoneRecently:SFCurrentTime()]; }); @@ -290,7 +290,7 @@ - (void)unarchive { _bucket = archive[SF_BUCKET]; _lastCollectedAt = ((NSNumber *)archive[SF_LAST_COLLECTED_AT]).unsignedLongLongValue; } else { - _bucket = [[SFTokenBucket alloc] initWithNumTokens:SF_COLLECTION_RATE_LIMIT_NUM_COLLECTIONS interval:SF_COLLECTION_RATE_LIMIT_PERIOD]; + _bucket = [[SiftTokenBucket alloc] initWithNumTokens:SF_COLLECTION_RATE_LIMIT_NUM_COLLECTIONS interval:SF_COLLECTION_RATE_LIMIT_PERIOD]; _lastCollectedAt = 0; } }); @@ -435,7 +435,7 @@ - (void)stopMotionSensors { } } -- (void)addReadingsToIosAppState:(SFHtDictionary *)iosAppState { +- (void)addReadingsToIosAppState:(SiftHtDictionary *)iosAppState { SF_GENERICS(NSArray, NSDictionary *) *motion = [self convertReadings:_deviceMotionReadings converter:SFCMDeviceMotionToDictionary]; if (motion.count) { [iosAppState setEntry:@"motion" value:motion]; @@ -454,14 +454,14 @@ - (void)addReadingsToIosAppState:(SFHtDictionary *)iosAppState { } } -- (SF_GENERICS(NSArray, NSDictionary *) *)convertReadings:(SFCircularBuffer *)buffer converter:(void *)converter { +- (SF_GENERICS(NSArray, NSDictionary *) *)convertReadings:(SiftCircularBuffer *)buffer converter:(void *)converter { SF_GENERICS(NSMutableArray, NSDictionary *) *readings = [NSMutableArray new]; NSDate *uptime = [NSDate dateWithTimeIntervalSinceNow:-NSProcessInfo.processInfo.systemUptime]; @synchronized (buffer) { for (CMLogItem *reading in [buffer shallowCopy]) { // CMLogItem records timestamp since device boot. SFTimestamp timestamp = [[uptime dateByAddingTimeInterval:reading.timestamp] timeIntervalSince1970] * 1000; - [readings addObject:((SFHtDictionary *(*)(CMLogItem *, SFTimestamp))converter)(reading, timestamp).entries]; + [readings addObject:((SiftHtDictionary *(*)(CMLogItem *, SFTimestamp))converter)(reading, timestamp).entries]; } [buffer removeAllObjects]; } diff --git a/Sift/SiftIosDeviceProperties.h b/Sift/SiftIosDeviceProperties.h new file mode 100644 index 0000000..1243412 --- /dev/null +++ b/Sift/SiftIosDeviceProperties.h @@ -0,0 +1,9 @@ +// Copyright (c) 2016 Sift Science. All rights reserved. + +@import Foundation; + +#import "SiftHtDictionary.h" + +SiftHtDictionary *SFMakeEmptyIosDeviceProperties(); + +SiftHtDictionary *SFCollectIosDeviceProperties(); diff --git a/Sift/SFIosDeviceProperties.m b/Sift/SiftIosDeviceProperties.m similarity index 98% rename from Sift/SFIosDeviceProperties.m rename to Sift/SiftIosDeviceProperties.m index 0d7f8b1..562d814 100644 --- a/Sift/SFIosDeviceProperties.m +++ b/Sift/SiftIosDeviceProperties.m @@ -9,13 +9,13 @@ #include -#import "SFCompatibility.h" -#import "SFDebug.h" +#import "SiftCompatibility.h" +#import "SiftDebug.h" #import "Sift.h" -#import "SFIosDeviceProperties.h" +#import "SiftIosDeviceProperties.h" -SFHtDictionary *SFMakeEmptyIosDeviceProperties() { +SiftHtDictionary *SFMakeEmptyIosDeviceProperties() { static SF_GENERICS(NSMutableDictionary, NSString *, Class) *entryTypes; static dispatch_once_t once; dispatch_once(&once, ^{ @@ -113,7 +113,7 @@ #undef ENTRY_TYPE }); - return [[SFHtDictionary alloc] initWithEntryTypes:entryTypes]; + return [[SiftHtDictionary alloc] initWithEntryTypes:entryTypes]; } #pragma mark - Device properties collection. @@ -126,8 +126,8 @@ static BOOL SFIsUrlSchemeWhitelisted(NSString *targetScheme); -SFHtDictionary *SFCollectIosDeviceProperties() { - SFHtDictionary *iosDeviceProperties = SFMakeEmptyIosDeviceProperties(); +SiftHtDictionary *SFCollectIosDeviceProperties() { + SiftHtDictionary *iosDeviceProperties = SFMakeEmptyIosDeviceProperties(); NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; [iosDeviceProperties setEntry:@"app_name" value:[infoDictionary objectForKey:(NSString *)kCFBundleNameKey]]; diff --git a/Sift/SFIosDevicePropertiesCollector.h b/Sift/SiftIosDevicePropertiesCollector.h similarity index 75% rename from Sift/SFIosDevicePropertiesCollector.h rename to Sift/SiftIosDevicePropertiesCollector.h index 50a8b45..ed229f3 100644 --- a/Sift/SFIosDevicePropertiesCollector.h +++ b/Sift/SiftIosDevicePropertiesCollector.h @@ -3,7 +3,7 @@ @import Foundation; /** Collect device properties. */ -@interface SFIosDevicePropertiesCollector : NSObject +@interface SiftIosDevicePropertiesCollector : NSObject // Nothing here - a collector is autonomous. diff --git a/Sift/SFIosDevicePropertiesCollector.m b/Sift/SiftIosDevicePropertiesCollector.m similarity index 85% rename from Sift/SFIosDevicePropertiesCollector.m rename to Sift/SiftIosDevicePropertiesCollector.m index e719611..09b5076 100644 --- a/Sift/SFIosDevicePropertiesCollector.m +++ b/Sift/SiftIosDevicePropertiesCollector.m @@ -3,35 +3,35 @@ @import Foundation; @import UIKit; -#import "SFDebug.h" -#import "SFEvent.h" -#import "SFEvent+Private.h" -#import "SFIosDeviceProperties.h" -#import "SFQueueConfig.h" +#import "SiftDebug.h" +#import "SiftEvent.h" +#import "SiftEvent+Private.h" +#import "SiftIosDeviceProperties.h" +#import "SiftQueueConfig.h" #import "Sift.h" -#import "SFIosDevicePropertiesCollector.h" +#import "SiftIosDevicePropertiesCollector.h" /** * Device properties are sent to their own queue, which is configured to * record only difference (we assume that device properties are rarely * changed). */ -static const SFQueueConfig SFIosDevicePropertiesCollectorQueueConfig = { +static const SiftQueueConfig SFIosDevicePropertiesCollectorQueueConfig = { .uploadWhenMoreThan = 0, .acceptSameEventAfter = 3600 // 1 hour }; static NSString * const SFIosDevicePropertiesCollectorQueueIdentifier = @"sift-devprops"; -@interface SFIosDevicePropertiesCollector () +@interface SiftIosDevicePropertiesCollector () /** Collect device properties through its own queue. */ - (void)collect; @end -@implementation SFIosDevicePropertiesCollector +@implementation SiftIosDevicePropertiesCollector - (instancetype)init { self = [super init]; @@ -63,7 +63,7 @@ - (void)collect { } } - SFEvent *event = [SFEvent new]; + SiftEvent *event = [SiftEvent new]; event.iosDeviceProperties = SFCollectIosDeviceProperties(); SF_DEBUG(@"Collect device properties: %@", event.iosDeviceProperties.entries); [sift appendEvent:event toQueue:SFIosDevicePropertiesCollectorQueueIdentifier]; diff --git a/Sift/SFQueue.h b/Sift/SiftQueue.h similarity index 76% rename from Sift/SFQueue.h rename to Sift/SiftQueue.h index 581ee11..c5c0ff1 100644 --- a/Sift/SFQueue.h +++ b/Sift/SiftQueue.h @@ -2,17 +2,17 @@ @import Foundation; -#import "SFEvent.h" -#import "SFQueueConfig.h" +#import "SiftEvent.h" +#import "SiftQueueConfig.h" #import "Sift.h" /** * A queue is simply a `NSArray` of `SFEvent` objects with an * `SFQueueConfig` policy object. */ -@interface SFQueue : NSObject +@interface SiftQueue : NSObject -- (instancetype)initWithIdentifier:(NSString *)identifier config:(SFQueueConfig)config archivePath:(NSString *)archivePath sift:(Sift *)sift; +- (instancetype)initWithIdentifier:(NSString *)identifier config:(SiftQueueConfig)config archivePath:(NSString *)archivePath sift:(Sift *)sift; /** * Persist events to disk (call this when app enters into background). @@ -22,7 +22,7 @@ - (void)archive; /** Append an event to the queue. */ -- (void)append:(SFEvent *)event; +- (void)append:(SiftEvent *)event; /** @return YES if queued events are ready for upload. */ - (BOOL)readyForUpload; diff --git a/Sift/SFQueue.m b/Sift/SiftQueue.m similarity index 92% rename from Sift/SFQueue.m rename to Sift/SiftQueue.m index a88e0f2..d3febe9 100644 --- a/Sift/SFQueue.m +++ b/Sift/SiftQueue.m @@ -3,26 +3,26 @@ @import Foundation; @import UIKit; -#import "SFDebug.h" -#import "SFEvent.h" -#import "SFEvent+Private.h" -#import "SFUtils.h" +#import "SiftDebug.h" +#import "SiftEvent.h" +#import "SiftEvent+Private.h" +#import "SiftUtils.h" #import "Sift.h" -#import "SFQueue.h" +#import "SiftQueue.h" -@implementation SFQueue { +@implementation SiftQueue { NSString *_identifier; NSMutableArray *_queue; - SFQueueConfig _config; - SFEvent *_lastEvent; + SiftQueueConfig _config; + SiftEvent *_lastEvent; SFTimestamp _lastUploadTimestamp; NSString *_archivePath; // Weak reference back to the parent. Sift * __weak _sift; } -- (instancetype)initWithIdentifier:(NSString *)identifier config:(SFQueueConfig)config archivePath:(NSString *)archivePath sift:(Sift *)sift { +- (instancetype)initWithIdentifier:(NSString *)identifier config:(SiftQueueConfig)config archivePath:(NSString *)archivePath sift:(Sift *)sift { self = [super init]; if (self) { _identifier = identifier; @@ -35,7 +35,7 @@ - (instancetype)initWithIdentifier:(NSString *)identifier config:(SFQueueConfig) return self; } -- (void)append:(SFEvent *)event { +- (void)append:(SiftEvent *)event { @synchronized(self) { if (!event) { return; // Don't append nil. diff --git a/Sift/SFQueueConfig.h b/Sift/SiftQueueConfig.h similarity index 97% rename from Sift/SFQueueConfig.h rename to Sift/SiftQueueConfig.h index b43bd86..cc5d75c 100644 --- a/Sift/SFQueueConfig.h +++ b/Sift/SiftQueueConfig.h @@ -22,4 +22,4 @@ typedef struct { /** Upload events when the last upload time is older than this number of seconds. */ NSTimeInterval uploadWhenOlderThan; -} SFQueueConfig; +} SiftQueueConfig; diff --git a/Sift/SFTokenBucket.h b/Sift/SiftTokenBucket.h similarity index 90% rename from Sift/SFTokenBucket.h rename to Sift/SiftTokenBucket.h index bff6c75..a786105 100644 --- a/Sift/SFTokenBucket.h +++ b/Sift/SiftTokenBucket.h @@ -2,7 +2,7 @@ @import Foundation; -@interface SFTokenBucket : NSObject +@interface SiftTokenBucket : NSObject /** Create a token bucket that you may acquire at most `numToken` within `interval` of time. */ - (instancetype)initWithNumTokens:(double)numTokens interval:(NSTimeInterval)interval; diff --git a/Sift/SFTokenBucket.m b/Sift/SiftTokenBucket.m similarity index 97% rename from Sift/SFTokenBucket.m rename to Sift/SiftTokenBucket.m index f1efa96..75bbf15 100644 --- a/Sift/SFTokenBucket.m +++ b/Sift/SiftTokenBucket.m @@ -2,9 +2,9 @@ @import Foundation; -#import "SFTokenBucket.h" +#import "SiftTokenBucket.h" -@implementation SFTokenBucket { +@implementation SiftTokenBucket { // Bucket parameters. double _numTokens; NSTimeInterval _interval; @@ -82,4 +82,4 @@ - (void)encodeWithCoder:(NSCoder *)coder { [coder encodeDouble:_lastAcquire forKey:SF_LAST_ACQUIRE]; } -@end \ No newline at end of file +@end diff --git a/Sift/SFUploader.h b/Sift/SiftUploader.h similarity index 84% rename from Sift/SFUploader.h rename to Sift/SiftUploader.h index fa350fb..fc8aa3c 100644 --- a/Sift/SFUploader.h +++ b/Sift/SiftUploader.h @@ -4,7 +4,7 @@ #import "Sift.h" -@interface SFUploader : NSObject +@interface SiftUploader : NSObject - (instancetype)initWithArchivePath:(NSString *)archivePath sift:(Sift *)sift; diff --git a/Sift/SFUploader.m b/Sift/SiftUploader.m similarity index 96% rename from Sift/SFUploader.m rename to Sift/SiftUploader.m index 7e59982..ad76ff7 100644 --- a/Sift/SFUploader.m +++ b/Sift/SiftUploader.m @@ -4,13 +4,13 @@ @import UIKit; #import "Vendor/NSData+GZIP.h" -#import "SFDebug.h" -#import "SFEvent.h" -#import "SFEvent+Private.h" +#import "SiftDebug.h" +#import "SiftEvent.h" +#import "SiftEvent+Private.h" -#import "SFUploader.h" +#import "SiftUploader.h" -@implementation SFUploader { +@implementation SiftUploader { // Use serial queue as an alternative to locking. dispatch_queue_t _serial; dispatch_source_t _source; @@ -54,7 +54,7 @@ - (instancetype)initWithArchivePath:(NSString *)archivePath sift:(Sift *)sift co _source = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, _serial); dispatch_source_set_timer(_source, dispatch_time(DISPATCH_TIME_NOW, 0), SF_CHECK_UPLOAD_PERIOD, SF_CHECK_UPLOAD_LEEWAY); - SFUploader * __weak weakSelf = self; + SiftUploader * __weak weakSelf = self; dispatch_source_set_event_handler(_source, ^{[weakSelf doUpload];}); dispatch_resume(_source); } @@ -185,7 +185,7 @@ - (void)doUpload { _responseBody = [NSMutableData new]; if (_batches && _batches.count && [_batches objectAtIndex:0]) { - NSData *body = [[SFEvent listRequest:[_batches objectAtIndex:0]] gzippedData]; + NSData *body = [[SiftEvent listRequest:[_batches objectAtIndex:0]] gzippedData]; _uploadTask = [_session uploadTaskWithRequest:request fromData:body]; [_uploadTask resume]; SF_IMPORTANT(@"Upload a batch of %ld events to server", (unsigned long)[[_batches objectAtIndex:0] count]); diff --git a/Sift/SFUtils.h b/Sift/SiftUtils.h similarity index 100% rename from Sift/SFUtils.h rename to Sift/SiftUtils.h diff --git a/Sift/SFUtils.m b/Sift/SiftUtils.m similarity index 97% rename from Sift/SFUtils.m rename to Sift/SiftUtils.m index 3bec2f5..435c4ae 100644 --- a/Sift/SFUtils.m +++ b/Sift/SiftUtils.m @@ -4,8 +4,8 @@ #import "ctype.h" -#import "SFDebug.h" -#import "SFUtils.h" +#import "SiftDebug.h" +#import "SiftUtils.h" SFTimestamp SFCurrentTime(void) { return [[NSDate date] timeIntervalSince1970] * 1000.0; diff --git a/SiftTests/SFQueueTests.m b/SiftTests/SFQueueTests.m deleted file mode 100644 index 228ad3d..0000000 --- a/SiftTests/SFQueueTests.m +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright (c) 2016 Sift Science. All rights reserved. - -@import XCTest; - -#import "SFUtils.h" - -#import "SFQueue.h" - -@interface SFEventQueueTests : XCTestCase - -@end - -@implementation SFEventQueueTests { - NSString *_archivePath; -} - -- (void)setUp { - [super setUp]; - NSString *rootDirName = [NSString stringWithFormat:@"testdata-%07d", arc4random_uniform(1 << 20)]; - _archivePath = [SFCacheDirPath() stringByAppendingPathComponent:rootDirName]; -} - -- (void)tearDown { - [[NSFileManager defaultManager] removeItemAtPath:_archivePath error:nil]; - [super tearDown]; -} - -- (void)testAppend { - SFQueueConfig config = { - .uploadWhenMoreThan = 65536, - .uploadWhenOlderThan = 3600, - }; - SFQueue *queue = [self makeQueue:config]; - - [queue append:[SFEvent eventWithType:nil path:@"path-0" fields:nil]]; - [queue append:[SFEvent eventWithType:nil path:@"path-1" fields:nil]]; - [queue append:[SFEvent eventWithType:nil path:@"path-2" fields:nil]]; - - NSArray *events = [queue transfer]; - XCTAssertEqual(events.count, 3); - XCTAssertEqualObjects([(SFEvent *)[events objectAtIndex:0] path], @"path-0"); - XCTAssertEqualObjects([(SFEvent *)[events objectAtIndex:1] path], @"path-1"); - XCTAssertEqualObjects([(SFEvent *)[events objectAtIndex:2] path], @"path-2"); -} - -- (void)testArchive { - SFQueueConfig config = { - .uploadWhenMoreThan = 65536, - .uploadWhenOlderThan = 3600, - }; - SFQueue *queue = [self makeQueue:config]; - - [queue append:[SFEvent eventWithType:nil path:@"path-0" fields:nil]]; - [queue append:[SFEvent eventWithType:nil path:@"path-1" fields:nil]]; - [queue append:[SFEvent eventWithType:nil path:@"path-2" fields:nil]]; - [queue archive]; - - // Append after archive... - [queue append:[SFEvent eventWithType:nil path:@"path-3" fields:nil]]; - [queue append:[SFEvent eventWithType:nil path:@"path-4" fields:nil]]; - - SFQueue *anotherQueue = [self makeQueue:config]; - NSArray *events = [anotherQueue transfer]; - XCTAssertEqual(events.count, 3); - XCTAssertEqualObjects([(SFEvent *)[events objectAtIndex:0] path], @"path-0"); - XCTAssertEqualObjects([(SFEvent *)[events objectAtIndex:1] path], @"path-1"); - XCTAssertEqualObjects([(SFEvent *)[events objectAtIndex:2] path], @"path-2"); -} - -- (void)testReadyForUploadMoreThan { - SFQueueConfig config = { - .uploadWhenMoreThan = 1, - .uploadWhenOlderThan = 3600, - }; - SFQueue *queue = [self makeQueue:config]; - XCTAssertFalse(queue.readyForUpload); - - // We expect the first event to be uploaded immediately - [queue append:[SFEvent eventWithType:nil path:@"path-0" fields:nil]]; - // We have to manually transfer because we don't have a Sift instance - [queue transfer]; - - // After the queue is flushed, it should not be ready after 1 event - [queue append:[SFEvent eventWithType:nil path:@"path-0" fields:nil]]; - XCTAssertFalse(queue.readyForUpload); - - // Now that it's exceeded 1, we expect it to be ready - [queue append:[SFEvent eventWithType:nil path:@"path-0" fields:nil]]; - XCTAssertTrue(queue.readyForUpload); -} - -- (void)testReadyForUploadAfterWait { - SFQueueConfig config = { - .uploadWhenMoreThan = 5, - .uploadWhenOlderThan = 1, - }; - SFQueue *queue = [self makeQueue:config]; - XCTAssertFalse(queue.readyForUpload); - - // We expect the first event to be uploaded immediately - [queue append:[SFEvent eventWithType:nil path:@"path-0" fields:nil]]; - // Don't manually transfer so that the queue holds one item - - // Sleep for 1.1 seconds (in excess of TTL) - [NSThread sleepForTimeInterval:1.1]; - - // Now the queue should be ready for upload - XCTAssertTrue(queue.readyForUpload); -} - -- (void)testReadyForUploadNoWait { - SFQueueConfig config = { - .uploadWhenMoreThan = 5, - .uploadWhenOlderThan = 1, - }; - SFQueue *queue = [self makeQueue:config]; - XCTAssertFalse(queue.readyForUpload); - - // We expect the first event to be uploaded immediately - [queue append:[SFEvent eventWithType:nil path:@"path-0" fields:nil]]; - [queue transfer]; - - // Should not have uploaded the second event (not stale enough) - [queue append:[SFEvent eventWithType:nil path:@"path-0" fields:nil]]; - XCTAssertFalse(queue.readyForUpload); -} - -- (void)testReadyForUploadOlderThan { - SFQueueConfig config = { - .uploadWhenMoreThan = 65536, - .uploadWhenOlderThan = 1, - }; - SFQueue *queue = [self makeQueue:config]; - XCTAssertFalse(queue.readyForUpload); - - [queue append:[SFEvent eventWithType:nil path:@"path-0" fields:nil]]; - XCTAssertFalse(queue.readyForUpload); - [NSThread sleepForTimeInterval:1.1]; - XCTAssertTrue(queue.readyForUpload); -} - -- (void)testAppendSameEventImmediately { - SFQueueConfig config = { - .uploadWhenMoreThan = 65536, - .uploadWhenOlderThan = 3600, - }; - SFQueue *queue = [self makeQueue:config]; - - [queue append:[SFEvent eventWithType:nil path:@"path" fields:nil]]; - [queue append:[SFEvent eventWithType:nil path:@"path" fields:nil]]; - [queue append:[SFEvent eventWithType:nil path:@"path" fields:nil]]; - - NSArray *events = [queue transfer]; - XCTAssertEqual(events.count, 3); - XCTAssertEqualObjects([(SFEvent *)[events objectAtIndex:0] path], @"path"); - XCTAssertEqualObjects([(SFEvent *)[events objectAtIndex:1] path], @"path"); - XCTAssertEqualObjects([(SFEvent *)[events objectAtIndex:2] path], @"path"); - - [queue append:[SFEvent eventWithType:nil path:@"path" fields:nil]]; - [queue append:[SFEvent eventWithType:nil path:@"path" fields:nil]]; - [queue append:[SFEvent eventWithType:nil path:@"path" fields:nil]]; - - events = [queue transfer]; - XCTAssertEqual(events.count, 3); - XCTAssertEqualObjects([(SFEvent *)[events objectAtIndex:0] path], @"path"); - XCTAssertEqualObjects([(SFEvent *)[events objectAtIndex:1] path], @"path"); - XCTAssertEqualObjects([(SFEvent *)[events objectAtIndex:2] path], @"path"); -} - -- (SFQueue *)makeQueue:(SFQueueConfig)config { - return [[SFQueue alloc] initWithIdentifier:@"id" config:config archivePath:_archivePath - sift:nil]; -} - -@end diff --git a/SiftTests/SFCircularBufferTests.m b/SiftTests/SiftCircularBufferTests.m similarity index 87% rename from SiftTests/SFCircularBufferTests.m rename to SiftTests/SiftCircularBufferTests.m index 7319577..3e1d1ee 100644 --- a/SiftTests/SFCircularBufferTests.m +++ b/SiftTests/SiftCircularBufferTests.m @@ -2,21 +2,21 @@ @import XCTest; -#import "SFCompatibility.h" +#import "SiftCompatibility.h" -#import "SFCircularBuffer.h" +#import "SiftCircularBuffer.h" -@interface SFCircularBufferTests : XCTestCase +@interface SiftCircularBufferTests : XCTestCase @end -@implementation SFCircularBufferTests +@implementation SiftCircularBufferTests - (void)testCircularBuffer { - SF_GENERICS(SFCircularBuffer, NSNumber *) *buffer; + SF_GENERICS(SiftCircularBuffer, NSNumber *) *buffer; SF_GENERICS(NSArray, NSNumber *) *data; - buffer = [[SFCircularBuffer alloc] initWithSize:1]; + buffer = [[SiftCircularBuffer alloc] initWithSize:1]; XCTAssertEqual(1, buffer.size); XCTAssertEqual(0, buffer.count); XCTAssertNil(buffer.firstObject); @@ -37,7 +37,7 @@ - (void)testCircularBuffer { XCTAssertEqualObjects(@100, buffer.lastObject); XCTAssertEqualObjects(@[@100], [buffer shallowCopy]); - buffer = [[SFCircularBuffer alloc] initWithSize:2]; + buffer = [[SiftCircularBuffer alloc] initWithSize:2]; XCTAssertEqual(2, buffer.size); XCTAssertEqual(0, buffer.count); XCTAssertNil(buffer.firstObject); diff --git a/SiftTests/SFEventTests.m b/SiftTests/SiftEventTests.m similarity index 83% rename from SiftTests/SFEventTests.m rename to SiftTests/SiftEventTests.m index 03e2e5f..e18457c 100644 --- a/SiftTests/SFEventTests.m +++ b/SiftTests/SiftEventTests.m @@ -5,26 +5,26 @@ @import CoreLocation; @import UIKit; -#import "SFIosAppState.h" -#import "SFIosDeviceProperties.h" +#import "SiftIosAppState.h" +#import "SiftIosDeviceProperties.h" -#import "SFEvent.h" -#import "SFEvent+Private.h" +#import "SiftEvent.h" +#import "SiftEvent+Private.h" -@interface SFEventTests : XCTestCase +@interface SiftEventTests : XCTestCase @end -@implementation SFEventTests +@implementation SiftEventTests - (void)testCollect { CLLocationManager *locationManager = [CLLocationManager new]; - SFEvent *event = [SFEvent new]; + SiftEvent *event = [SiftEvent new]; event.iosAppState = SFCollectIosAppState(locationManager, @"SiftViewController"); event.iosDeviceProperties = SFCollectIosDeviceProperties(); - NSData *listRequest = [SFEvent listRequest:@[event]]; + NSData *listRequest = [SiftEvent listRequest:@[event]]; // Verify JSON object generated on simulator. @@ -119,7 +119,7 @@ - (void)testCollect { } - (void)testEvent { - SFEvent *event = [SFEvent eventWithType:@"type" path:@"path" fields:@{@"key": @"value"}]; + SiftEvent *event = [SiftEvent eventWithType:@"type" path:@"path" fields:@{@"key": @"value"}]; XCTAssertNotNil(event); XCTAssertGreaterThan(event.time, 0); @@ -135,11 +135,11 @@ - (void)testEvent { } - (void)testCoder { - SFEvent *expect = [SFEvent eventWithType:@"type" path:@"path" fields:@{@"key": @"value"}]; + SiftEvent *expect = [SiftEvent eventWithType:@"type" path:@"path" fields:@{@"key": @"value"}]; XCTAssertNotNil(expect); NSData *data = [NSKeyedArchiver archivedDataWithRootObject:expect]; - SFEvent *actual = [NSKeyedUnarchiver unarchiveObjectWithData:data]; + SiftEvent *actual = [NSKeyedUnarchiver unarchiveObjectWithData:data]; XCTAssertTrue([expect isEssentiallyEqualTo:actual]); XCTAssertEqual(actual.time, expect.time); @@ -151,22 +151,22 @@ - (void)testListRequest { events = @[]; expect = @{@"data": @[]}; - actual = [NSJSONSerialization JSONObjectWithData:[SFEvent listRequest:events] options:0 error:nil]; + actual = [NSJSONSerialization JSONObjectWithData:[SiftEvent listRequest:events] options:0 error:nil]; XCTAssertEqualObjects(expect, actual); - events = SFBeNice(@[[SFEvent eventWithType:@"some-type" path:@"some-path" fields:nil], - [SFEvent eventWithType:nil path:nil fields:@{@"key": @"value"}], - [SFEvent eventWithType:nil path:nil fields:@{@1: @"value"}], // Key is not string typed. - [SFEvent eventWithType:nil path:nil fields:@{@"key": @1}]]); // Value is not string typed. + events = SFBeNice(@[[SiftEvent eventWithType:@"some-type" path:@"some-path" fields:nil], + [SiftEvent eventWithType:nil path:nil fields:@{@"key": @"value"}], + [SiftEvent eventWithType:nil path:nil fields:@{@1: @"value"}], // Key is not string typed. + [SiftEvent eventWithType:nil path:nil fields:@{@"key": @1}]]); // Value is not string typed. NSString *ifv = UIDevice.currentDevice.identifierForVendor.UUIDString; expect = @{@"data": @[@{@"time": @0, @"mobile_event_type": @"some-type", @"path": @"some-path", @"user_id": @"some-id", @"installation_id": ifv}, @{@"time": @0, @"user_id": @"some-id", @"installation_id": ifv, @"fields": @{@"key": @"value"}}]}; - actual = [NSJSONSerialization JSONObjectWithData:[SFEvent listRequest:events] options:0 error:nil]; + actual = [NSJSONSerialization JSONObjectWithData:[SiftEvent listRequest:events] options:0 error:nil]; XCTAssertEqualObjects(expect, actual); } static NSArray *SFBeNice(NSArray *events) { - for (SFEvent *event in events) { + for (SiftEvent *event in events) { event.userId = @"some-id"; event.time = 0; } diff --git a/SiftTests/SFHtDictionaryTests.m b/SiftTests/SiftHtDictionaryTests.m similarity index 76% rename from SiftTests/SFHtDictionaryTests.m rename to SiftTests/SiftHtDictionaryTests.m index ac47865..a4e3a6b 100644 --- a/SiftTests/SFHtDictionaryTests.m +++ b/SiftTests/SiftHtDictionaryTests.m @@ -2,15 +2,15 @@ @import XCTest; -#import "SFCompatibility.h" +#import "SiftCompatibility.h" -#import "SFHTDictionary.h" +#import "SiftHtDictionary.h" -@interface SFHtDictionaryTests : XCTestCase +@interface SiftHtDictionaryTests : XCTestCase @end -@implementation SFHtDictionaryTests +@implementation SiftHtDictionaryTests - (void)testDictEquality { SF_GENERICS(NSDictionary, NSString *, Class) *entryTypes = @{ @@ -19,8 +19,8 @@ - (void)testDictEquality { @"array": NSArray.class, }; - SFHtDictionary *d1 = [[SFHtDictionary alloc] initWithEntryTypes:entryTypes]; - SFHtDictionary *d2 = [[SFHtDictionary alloc] initWithEntryTypes:entryTypes]; + SiftHtDictionary *d1 = [[SiftHtDictionary alloc] initWithEntryTypes:entryTypes]; + SiftHtDictionary *d2 = [[SiftHtDictionary alloc] initWithEntryTypes:entryTypes]; XCTAssertEqualObjects(d1, d2); XCTAssertTrue([d1 setEntry:@"number" value:[NSNumber numberWithBool:NO]]); @@ -41,7 +41,7 @@ - (void)testSetEntry { SF_GENERICS(NSDictionary, NSString *, Class) *entryTypes = @{ @"number": NSNumber.class, }; - SFHtDictionary *d = [[SFHtDictionary alloc] initWithEntryTypes:entryTypes]; + SiftHtDictionary *d = [[SiftHtDictionary alloc] initWithEntryTypes:entryTypes]; XCTAssertFalse([d setEntry:@"number" value:nil]); XCTAssertFalse([d setEntry:@"number" value:[NSNumber numberWithDouble:NAN]]); XCTAssertFalse([d setEntry:@"number" value:[NSNumber numberWithDouble:INFINITY]]); diff --git a/SiftTests/SFIosAppStateTests.m b/SiftTests/SiftIosAppStateTests.m similarity index 50% rename from SiftTests/SFIosAppStateTests.m rename to SiftTests/SiftIosAppStateTests.m index 48798b9..f8706a3 100644 --- a/SiftTests/SFIosAppStateTests.m +++ b/SiftTests/SiftIosAppStateTests.m @@ -4,18 +4,18 @@ @import CoreLocation; -#import "SFDebug.h" +#import "SiftDebug.h" -#import "SFIosAppState.h" +#import "SiftIosAppState.h" -@interface SFIosAppStateTests : XCTestCase +@interface SiftIosAppStateTests : XCTestCase @end -@implementation SFIosAppStateTests +@implementation SiftIosAppStateTests - (void)testCollect { - SFHtDictionary *actual = SFCollectIosAppState([CLLocationManager new], nil); + SiftHtDictionary *actual = SFCollectIosAppState([CLLocationManager new], nil); SF_DEBUG(@"Collect app state: %@", actual.entries); XCTAssertNotNil(actual); } diff --git a/SiftTests/SFIosDevicePropertiesTests.m b/SiftTests/SiftIosDevicePropertiesTests.m similarity index 81% rename from SiftTests/SFIosDevicePropertiesTests.m rename to SiftTests/SiftIosDevicePropertiesTests.m index 5e3e966..c9562c3 100644 --- a/SiftTests/SFIosDevicePropertiesTests.m +++ b/SiftTests/SiftIosDevicePropertiesTests.m @@ -2,24 +2,24 @@ @import XCTest; -#import "SFDebug.h" +#import "SiftDebug.h" -#import "SFIosDeviceProperties.h" +#import "SiftIosDeviceProperties.h" -@interface SFIosDevicePropertiesTests : XCTestCase +@interface SiftIosDevicePropertiesTests : XCTestCase @end -@implementation SFIosDevicePropertiesTests +@implementation SiftIosDevicePropertiesTests - (void)testCollect { - SFHtDictionary *actual = SFCollectIosDeviceProperties(); + SiftHtDictionary *actual = SFCollectIosDeviceProperties(); SF_DEBUG(@"Collect device properties: %@", actual.entries); XCTAssertNotNil(actual); } - (void)testCoder { - SFHtDictionary *expect, *actual; + SiftHtDictionary *expect, *actual; NSData *data; // Test empty object. @@ -50,15 +50,15 @@ - (void)testCoder { } - (void)testWithRandomData { - SFHtDictionary *z = SFMakeEmptyIosDeviceProperties(); // Empty object. - SFHtDictionary *p = [self generateRandomProperties]; // Random object 1. - SFHtDictionary *q = [self generateRandomProperties]; // Random object 2. + SiftHtDictionary *z = SFMakeEmptyIosDeviceProperties(); // Empty object. + SiftHtDictionary *p = [self generateRandomProperties]; // Random object 1. + SiftHtDictionary *q = [self generateRandomProperties]; // Random object 2. XCTAssertNotEqualObjects(z, p); XCTAssertNotEqualObjects(z, q); XCTAssertNotEqualObjects(p, q); - SFHtDictionary *actual; + SiftHtDictionary *actual; NSData *data; data = [NSKeyedArchiver archivedDataWithRootObject:p]; @@ -70,8 +70,8 @@ - (void)testWithRandomData { XCTAssertEqualObjects(q, actual); } -- (SFHtDictionary *)generateRandomProperties { - SFHtDictionary *properties = SFMakeEmptyIosDeviceProperties(); +- (SiftHtDictionary *)generateRandomProperties { + SiftHtDictionary *properties = SFMakeEmptyIosDeviceProperties(); for (NSString *name in properties.entryTypes) { Class entryType = [properties.entryTypes objectForKey:name]; id value = nil; diff --git a/SiftTests/SiftQueueTests.m b/SiftTests/SiftQueueTests.m new file mode 100644 index 0000000..7980afc --- /dev/null +++ b/SiftTests/SiftQueueTests.m @@ -0,0 +1,175 @@ +// Copyright (c) 2016 Sift Science. All rights reserved. + +@import XCTest; + +#import "SiftUtils.h" + +#import "SiftQueue.h" + +@interface SiftEventQueueTests : XCTestCase + +@end + +@implementation SiftEventQueueTests { + NSString *_archivePath; +} + +- (void)setUp { + [super setUp]; + NSString *rootDirName = [NSString stringWithFormat:@"testdata-%07d", arc4random_uniform(1 << 20)]; + _archivePath = [SFCacheDirPath() stringByAppendingPathComponent:rootDirName]; +} + +- (void)tearDown { + [[NSFileManager defaultManager] removeItemAtPath:_archivePath error:nil]; + [super tearDown]; +} + +- (void)testAppend { + SiftQueueConfig config = { + .uploadWhenMoreThan = 65536, + .uploadWhenOlderThan = 3600, + }; + SiftQueue *queue = [self makeQueue:config]; + + [queue append:[SiftEvent eventWithType:nil path:@"path-0" fields:nil]]; + [queue append:[SiftEvent eventWithType:nil path:@"path-1" fields:nil]]; + [queue append:[SiftEvent eventWithType:nil path:@"path-2" fields:nil]]; + + NSArray *events = [queue transfer]; + XCTAssertEqual(events.count, 3); + XCTAssertEqualObjects([(SiftEvent *)[events objectAtIndex:0] path], @"path-0"); + XCTAssertEqualObjects([(SiftEvent *)[events objectAtIndex:1] path], @"path-1"); + XCTAssertEqualObjects([(SiftEvent *)[events objectAtIndex:2] path], @"path-2"); +} + +- (void)testArchive { + SiftQueueConfig config = { + .uploadWhenMoreThan = 65536, + .uploadWhenOlderThan = 3600, + }; + SiftQueue *queue = [self makeQueue:config]; + + [queue append:[SiftEvent eventWithType:nil path:@"path-0" fields:nil]]; + [queue append:[SiftEvent eventWithType:nil path:@"path-1" fields:nil]]; + [queue append:[SiftEvent eventWithType:nil path:@"path-2" fields:nil]]; + [queue archive]; + + // Append after archive... + [queue append:[SiftEvent eventWithType:nil path:@"path-3" fields:nil]]; + [queue append:[SiftEvent eventWithType:nil path:@"path-4" fields:nil]]; + + SiftQueue *anotherQueue = [self makeQueue:config]; + NSArray *events = [anotherQueue transfer]; + XCTAssertEqual(events.count, 3); + XCTAssertEqualObjects([(SiftEvent *)[events objectAtIndex:0] path], @"path-0"); + XCTAssertEqualObjects([(SiftEvent *)[events objectAtIndex:1] path], @"path-1"); + XCTAssertEqualObjects([(SiftEvent *)[events objectAtIndex:2] path], @"path-2"); +} + +- (void)testReadyForUploadMoreThan { + SiftQueueConfig config = { + .uploadWhenMoreThan = 1, + .uploadWhenOlderThan = 3600, + }; + SiftQueue *queue = [self makeQueue:config]; + XCTAssertFalse(queue.readyForUpload); + + // We expect the first event to be uploaded immediately + [queue append:[SiftEvent eventWithType:nil path:@"path-0" fields:nil]]; + // We have to manually transfer because we don't have a Sift instance + [queue transfer]; + + // After the queue is flushed, it should not be ready after 1 event + [queue append:[SiftEvent eventWithType:nil path:@"path-0" fields:nil]]; + XCTAssertFalse(queue.readyForUpload); + + // Now that it's exceeded 1, we expect it to be ready + [queue append:[SiftEvent eventWithType:nil path:@"path-0" fields:nil]]; + XCTAssertTrue(queue.readyForUpload); +} + +- (void)testReadyForUploadAfterWait { + SiftQueueConfig config = { + .uploadWhenMoreThan = 5, + .uploadWhenOlderThan = 1, + }; + SiftQueue *queue = [self makeQueue:config]; + XCTAssertFalse(queue.readyForUpload); + + // We expect the first event to be uploaded immediately + [queue append:[SiftEvent eventWithType:nil path:@"path-0" fields:nil]]; + // Don't manually transfer so that the queue holds one item + + // Sleep for 1.1 seconds (in excess of TTL) + [NSThread sleepForTimeInterval:1.1]; + + // Now the queue should be ready for upload + XCTAssertTrue(queue.readyForUpload); +} + +- (void)testReadyForUploadNoWait { + SiftQueueConfig config = { + .uploadWhenMoreThan = 5, + .uploadWhenOlderThan = 1, + }; + SiftQueue *queue = [self makeQueue:config]; + XCTAssertFalse(queue.readyForUpload); + + // We expect the first event to be uploaded immediately + [queue append:[SiftEvent eventWithType:nil path:@"path-0" fields:nil]]; + [queue transfer]; + + // Should not have uploaded the second event (not stale enough) + [queue append:[SiftEvent eventWithType:nil path:@"path-0" fields:nil]]; + XCTAssertFalse(queue.readyForUpload); +} + +- (void)testReadyForUploadOlderThan { + SiftQueueConfig config = { + .uploadWhenMoreThan = 65536, + .uploadWhenOlderThan = 1, + }; + SiftQueue *queue = [self makeQueue:config]; + XCTAssertFalse(queue.readyForUpload); + + [queue append:[SiftEvent eventWithType:nil path:@"path-0" fields:nil]]; + XCTAssertFalse(queue.readyForUpload); + [NSThread sleepForTimeInterval:1.1]; + XCTAssertTrue(queue.readyForUpload); +} + +- (void)testAppendSameEventImmediately { + SiftQueueConfig config = { + .uploadWhenMoreThan = 65536, + .uploadWhenOlderThan = 3600, + }; + SiftQueue *queue = [self makeQueue:config]; + + [queue append:[SiftEvent eventWithType:nil path:@"path" fields:nil]]; + [queue append:[SiftEvent eventWithType:nil path:@"path" fields:nil]]; + [queue append:[SiftEvent eventWithType:nil path:@"path" fields:nil]]; + + NSArray *events = [queue transfer]; + XCTAssertEqual(events.count, 3); + XCTAssertEqualObjects([(SiftEvent *)[events objectAtIndex:0] path], @"path"); + XCTAssertEqualObjects([(SiftEvent *)[events objectAtIndex:1] path], @"path"); + XCTAssertEqualObjects([(SiftEvent *)[events objectAtIndex:2] path], @"path"); + + [queue append:[SiftEvent eventWithType:nil path:@"path" fields:nil]]; + [queue append:[SiftEvent eventWithType:nil path:@"path" fields:nil]]; + [queue append:[SiftEvent eventWithType:nil path:@"path" fields:nil]]; + + events = [queue transfer]; + XCTAssertEqual(events.count, 3); + XCTAssertEqualObjects([(SiftEvent *)[events objectAtIndex:0] path], @"path"); + XCTAssertEqualObjects([(SiftEvent *)[events objectAtIndex:1] path], @"path"); + XCTAssertEqualObjects([(SiftEvent *)[events objectAtIndex:2] path], @"path"); +} + +- (SiftQueue *)makeQueue:(SiftQueueConfig)config { + return [[SiftQueue alloc] initWithIdentifier:@"id" config:config archivePath:_archivePath + sift:nil]; +} + +@end diff --git a/SiftTests/SFStubHttpProtocol.h b/SiftTests/SiftStubHttpProtocol.h similarity index 93% rename from SiftTests/SFStubHttpProtocol.h rename to SiftTests/SiftStubHttpProtocol.h index 33d1a2b..b2bd44a 100644 --- a/SiftTests/SFStubHttpProtocol.h +++ b/SiftTests/SiftStubHttpProtocol.h @@ -2,7 +2,7 @@ @import Foundation; -#import "SFCompatibility.h" +#import "SiftCompatibility.h" NSURLSessionConfiguration *SFMakeStubConfig(void); diff --git a/SiftTests/SFStubHttpProtocol.m b/SiftTests/SiftStubHttpProtocol.m similarity index 98% rename from SiftTests/SFStubHttpProtocol.m rename to SiftTests/SiftStubHttpProtocol.m index 9908c36..19b76d8 100644 --- a/SiftTests/SFStubHttpProtocol.m +++ b/SiftTests/SiftStubHttpProtocol.m @@ -2,7 +2,7 @@ @import Foundation; -#import "SFStubHttpProtocol.h" +#import "SiftStubHttpProtocol.h" @implementation SFHttpStub @@ -73,4 +73,4 @@ - (void)stopLoading { // Nothing yet... } -@end \ No newline at end of file +@end diff --git a/SiftTests/SiftTests.m b/SiftTests/SiftTests.m index 27caaa1..f6e73b6 100644 --- a/SiftTests/SiftTests.m +++ b/SiftTests/SiftTests.m @@ -2,7 +2,7 @@ @import XCTest; -#import "SFUtils.h" +#import "SiftUtils.h" #import "Sift.h" #import "Sift+Private.h" @@ -30,10 +30,10 @@ - (void)tearDown { - (void)testAppendEvent { [_sift unsetUserId]; - XCTAssertTrue([_sift appendEvent:[SFEvent eventWithType:nil path:nil fields:nil]]); + XCTAssertTrue([_sift appendEvent:[SiftEvent eventWithType:nil path:nil fields:nil]]); [_sift setUserId:@"1234"]; - XCTAssertTrue([_sift appendEvent:[SFEvent eventWithType:nil path:nil fields:nil]]); + XCTAssertTrue([_sift appendEvent:[SiftEvent eventWithType:nil path:nil fields:nil]]); } @end diff --git a/SiftTests/SFTokenBucketTests.m b/SiftTests/SiftTokenBucketTests.m similarity index 76% rename from SiftTests/SFTokenBucketTests.m rename to SiftTests/SiftTokenBucketTests.m index 4e9da27..f6b2483 100644 --- a/SiftTests/SFTokenBucketTests.m +++ b/SiftTests/SiftTokenBucketTests.m @@ -2,18 +2,18 @@ @import XCTest; -#import "SFTokenBucket.h" +#import "SiftTokenBucket.h" -@interface SFTokenBucketTests : XCTestCase +@interface SiftTokenBucketTests : XCTestCase @end -@implementation SFTokenBucketTests +@implementation SiftTokenBucketTests - (void)testTokenBucket { - SFTokenBucket *bucket; + SiftTokenBucket *bucket; - bucket = [[SFTokenBucket alloc] initWithNumTokens:1 interval:10]; + bucket = [[SiftTokenBucket alloc] initWithNumTokens:1 interval:10]; XCTAssertTrue([bucket tryAcquire:1 at:1001]); @@ -29,7 +29,7 @@ - (void)testTokenBucket { XCTAssertTrue([bucket tryAcquire:1 at:1011]); - bucket = [[SFTokenBucket alloc] initWithNumTokens:2 interval:10]; + bucket = [[SiftTokenBucket alloc] initWithNumTokens:2 interval:10]; XCTAssertTrue( [bucket tryAcquire:1 at:1001]); XCTAssertFalse([bucket tryAcquire:2 at:1002]); // Exceeding allowance! XCTAssertTrue( [bucket tryAcquire:1 at:1003]); diff --git a/SiftTests/SFUploaderTests.m b/SiftTests/SiftUploaderTests.m similarity index 80% rename from SiftTests/SFUploaderTests.m rename to SiftTests/SiftUploaderTests.m index 7c246ea..c6a4017 100644 --- a/SiftTests/SFUploaderTests.m +++ b/SiftTests/SiftUploaderTests.m @@ -2,21 +2,21 @@ @import XCTest; -#import "SFEvent.h" +#import "SiftEvent.h" #import "Sift.h" #import "Sift+Private.h" -#import "SFUploader.h" +#import "SiftUploader.h" -#import "SFStubHttpProtocol.h" +#import "SiftStubHttpProtocol.h" -@interface SFEventFileUploaderTests : XCTestCase +@interface SiftEventFileUploaderTests : XCTestCase @end -@implementation SFEventFileUploaderTests { +@implementation SiftEventFileUploaderTests { Sift *_sift; - SFUploader *_uploader; + SiftUploader *_uploader; } - (void)setUp { @@ -29,7 +29,7 @@ - (void)setUp { _sift.serverUrlFormat = @"mock+https://127.0.0.1/v3/accounts/%@/mobile_events"; // Disable exponential backoff with baseoffBase = 0. - _uploader = [[SFUploader alloc] initWithArchivePath:nil sift:_sift config:SFMakeStubConfig() backoffBase:0]; + _uploader = [[SiftUploader alloc] initWithArchivePath:nil sift:_sift config:SFMakeStubConfig() backoffBase:0]; SFHttpStub *stub = [SFHttpStub sharedInstance]; [stub.stubbedStatusCodes removeAllObjects]; @@ -50,7 +50,7 @@ - (void)testUpload { [stub.stubbedStatusCodes addObject:@200]; - NSArray *events = @[[SFEvent eventWithType:nil path:@"path" fields:nil]]; + NSArray *events = @[[SiftEvent eventWithType:nil path:@"path" fields:nil]]; [_uploader upload:events]; [self waitForExpectationsWithTimeout:5.0 handler:nil]; @@ -72,7 +72,7 @@ - (void)testUploadRejected { [stub.stubbedStatusCodes addObject:@500]; [stub.stubbedStatusCodes addObject:@500]; - NSArray *events = @[[SFEvent eventWithType:nil path:@"path" fields:nil]]; + NSArray *events = @[[SiftEvent eventWithType:nil path:@"path" fields:nil]]; [_uploader upload:events]; [self waitForExpectationsWithTimeout:5.0 handler:nil]; @@ -91,7 +91,7 @@ - (void)testUploadHttpError { [stub.stubbedStatusCodes addObject:@400]; - NSArray *events = @[[SFEvent eventWithType:nil path:@"path" fields:nil]]; + NSArray *events = @[[SiftEvent eventWithType:nil path:@"path" fields:nil]]; [_uploader upload:events]; [self waitForExpectationsWithTimeout:5.0 handler:nil]; diff --git a/SiftTests/SFUtilsTests.m b/SiftTests/SiftUtilsTests.m similarity index 93% rename from SiftTests/SFUtilsTests.m rename to SiftTests/SiftUtilsTests.m index 1d3fdf4..1b47c95 100644 --- a/SiftTests/SFUtilsTests.m +++ b/SiftTests/SiftUtilsTests.m @@ -2,13 +2,13 @@ #import -#import "SFUtils.h" +#import "SiftUtils.h" -@interface SFUtilsTests : XCTestCase +@interface SiftUtilsTests : XCTestCase @end -@implementation SFUtilsTests +@implementation SiftUtilsTests - (void)testCamelCaseToSnakeCase { XCTAssert([@"hello" isEqualToString:SFCamelCaseToSnakeCase(@"Hello")]);