Skip to content

Commit

Permalink
Sprint 11 (#576)
Browse files Browse the repository at this point in the history
* Carthage Support

* Initialize flush timer on the main thread.

* Replace Foundation import with UIKit import (#563)

* Track Campaign Data (#557)

* Update contributing docs (#564)

* Limit Queue size to 1000 (#565)

* Reformat (#566)

* Exclude files from backup (#567)

* Add tvOS Support (#572)

* reformat

* Track Deep Links (#573)

* Fix CI (#574)

* Use vanilla xcodebuild in CI

* use xcpretty in ci

* Update context object with referrer information (#575)

* use 3.2.6 in sample
  • Loading branch information
f2prateek authored Jul 10, 2016
1 parent 05b0a4d commit 581cf3f
Show file tree
Hide file tree
Showing 50 changed files with 495 additions and 293 deletions.
1 change: 1 addition & 0 deletions .clang-format
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ Carthage
# Additionally, we NEED to check it in for Carthage support.
#
# Pods/
.clang-format
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
language: objective-c

osx_image: xcode7
osx_image: xcode7.3

before_install:
- make bootstrap

script:
- make xcbuild xctest lint carthage
- make build-pretty test-pretty lint carthage

before_deploy:
- make archive
Expand Down
1 change: 1 addition & 0 deletions Analytics.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Pod::Spec.new do |s|
s.social_media_url = 'https://twitter.com/segment'

s.ios.deployment_target = '7.0'
s.tvos.deployment_target = '9.0'

s.source_files = 'Analytics/Classes/**/*'
end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGAliasPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
context:(NSDictionary *)context
integrations:(NSDictionary *)integrations;

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGAliasPayload.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ - (instancetype)initWithNewId:(NSString *)newId
return self;
}

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGGroupPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
context:(NSDictionary *)context
integrations:(NSDictionary *)integrations;

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGGroupPayload.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ - (instancetype)initWithGroupId:(NSString *)groupId
return self;
}

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGIdentifyPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
context:(NSDictionary *)context
integrations:(NSDictionary *)integrations;

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGIdentifyPayload.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ - (instancetype)initWithUserId:(NSString *)userId
return self;
}

@end
@end
7 changes: 6 additions & 1 deletion Analytics/Classes/Integrations/SEGIntegration.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
// Flush is invoked when any queued events should be uploaded.
- (void)flush;

// App Delegate Callbacks

// Callbacks for notifications changes.
// ------------------------------------
- (void)receivedRemoteNotification:(NSDictionary *)userInfo;
Expand All @@ -66,4 +68,7 @@
- (void)applicationWillResignActive;
- (void)applicationDidBecomeActive;

@end
- (void)continueUserActivity:(NSUserActivity *)activity;
- (void)openURL:(NSURL *)url options:(NSDictionary *)options;

@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGIntegrationFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
/** The key for which this factory can create an Integration. */
- (NSString *)key;

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

- (instancetype)initWithContext:(NSDictionary *)context integrations:(NSDictionary *)integrations;

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGPayload.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ - (instancetype)initWithContext:(NSDictionary *)context integrations:(NSDictiona
return self;
}

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGScreenPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
context:(NSDictionary *)context
integrations:(NSDictionary *)integrations;

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGScreenPayload.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ - (instancetype)initWithName:(NSString *)name
return self;
}

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGTrackPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
context:(NSDictionary *)context
integrations:(NSDictionary *)integrations;

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGTrackPayload.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ - (instancetype)initWithEvent:(NSString *)event
return self;
}

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Internal/NSData+GZIP.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@

- (nullable NSData *)seg_gzippedData;

@end
@end
14 changes: 7 additions & 7 deletions Analytics/Classes/Internal/NSData+GZIP.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ - (NSData *)seg_gzippedDataWithCompressionLevel:(float)level
if (self.length == 0 || [self seg_isGzippedData]) {
return self;
}

void *libz = seg_libzOpen();
int (*deflateInit2_)(z_streamp, int, int, int, int, int, const char *, int) =
(int (*)(z_streamp, int, int, int, int, int, const char *, int))dlsym(libz, "deflateInit2_");
(int (*)(z_streamp, int, int, int, int, int, const char *, int))dlsym(libz, "deflateInit2_");
int (*deflate)(z_streamp, int) = (int (*)(z_streamp, int))dlsym(libz, "deflate");
int (*deflateEnd)(z_streamp) = (int (*)(z_streamp))dlsym(libz, "deflateEnd");

z_stream stream;
stream.zalloc = Z_NULL;
stream.zfree = Z_NULL;
Expand All @@ -71,9 +71,9 @@ - (NSData *)seg_gzippedDataWithCompressionLevel:(float)level
stream.next_in = (Bytef *)(void *)self.bytes;
stream.total_out = 0;
stream.avail_out = 0;

static const NSUInteger ChunkSize = 16384;

NSMutableData *output = nil;
int compression = (level < 0.0f) ? Z_DEFAULT_COMPRESSION : (int)(roundf(level * 9));
if (deflateInit2(&stream, compression, Z_DEFLATED, 31, 8, Z_DEFAULT_STRATEGY) == Z_OK) {
Expand All @@ -89,7 +89,7 @@ - (NSData *)seg_gzippedDataWithCompressionLevel:(float)level
deflateEnd(&stream);
output.length = stream.total_out;
}

return output;
}

Expand All @@ -104,4 +104,4 @@ - (BOOL)seg_isGzippedData
return (self.length >= 2 && bytes[0] == 0x1f && bytes[1] == 0x8b);
}

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Internal/SEGAnalyticsRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ typedef void (^SEGAnalyticsRequestCompletionBlock)(void);
+ (instancetype)startWithURLRequest:(NSURLRequest *)urlRequest
completion:(SEGAnalyticsRequestCompletionBlock)completion;

@end
@end
5 changes: 4 additions & 1 deletion Analytics/Classes/Internal/SEGAnalyticsRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ - (id)initWithURLRequest:(NSURLRequest *)urlRequest

- (void)start
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
self.connection = [[NSURLConnection alloc] initWithRequest:self.urlRequest
delegate:self
startImmediately:NO];
#pragma clang diagnostic pop
[self.connection setDelegateQueue:[[self class] networkQueue]];
[self.connection start];
}
Expand Down Expand Up @@ -114,4 +117,4 @@ - (NSIndexSet *)acceptableStatusCodes
return _acceptableStatusCodes;
}

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Internal/SEGAnalyticsUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ NSDictionary *SEGCoerceDictionary(NSDictionary *dict);

NSString *SEGIDFA(void);

NSString *SEGEventNameForScreenTitle(NSString *title);
NSString *SEGEventNameForScreenTitle(NSString *title);
32 changes: 16 additions & 16 deletions Analytics/Classes/Internal/SEGAnalyticsUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
NSURL *SEGAnalyticsURLForFilename(NSString *filename)
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(
NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSString *supportPath = [paths firstObject];
if (![[NSFileManager defaultManager] fileExistsAtPath:supportPath
isDirectory:NULL]) {
Expand Down Expand Up @@ -85,7 +85,7 @@ void SEGLog(NSString *format, ...)
{
if (!kAnalyticsLoggerShowLogs)
return;

va_list args;
va_start(args, format);
NSLogv(format, args);
Expand All @@ -103,14 +103,14 @@ static id SEGCoerceJSONObject(id obj)
[obj isKindOfClass:[NSNull class]]) {
return obj;
}

if ([obj isKindOfClass:[NSArray class]]) {
NSMutableArray *array = [NSMutableArray array];
for (id i in obj)
[array addObject:SEGCoerceJSONObject(i)];
return array;
}

if ([obj isKindOfClass:[NSDictionary class]]) {
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
for (NSString *key in obj) {
Expand All @@ -122,13 +122,13 @@ static id SEGCoerceJSONObject(id obj)
}
return dict;
}

if ([obj isKindOfClass:[NSDate class]])
return iso8601FormattedString(obj);

if ([obj isKindOfClass:[NSURL class]])
return [obj absoluteString];

// default to sending the object's description
SEGLog(@"warning: dictionary values should be valid json types. got: %@. "
@"coercing to: %@",
Expand All @@ -142,7 +142,7 @@ static void AssertDictionaryTypes(id dict)
for (id key in dict) {
assert([key isKindOfClass:[NSString class]]);
id value = dict[key];

assert([value isKindOfClass:[NSString class]] ||
[value isKindOfClass:[NSNumber class]] ||
[value isKindOfClass:[NSNull class]] ||
Expand Down Expand Up @@ -170,15 +170,15 @@ static void AssertDictionaryTypes(id dict)
if (identifierManager) {
SEL sharedManagerSelector = NSSelectorFromString(@"sharedManager");
id sharedManager =
((id (*)(id, SEL))
[identifierManager methodForSelector:sharedManagerSelector])(
identifierManager, sharedManagerSelector);
((id (*)(id, SEL))
[identifierManager methodForSelector:sharedManagerSelector])(
identifierManager, sharedManagerSelector);
SEL advertisingIdentifierSelector =
NSSelectorFromString(@"advertisingIdentifier");
NSSelectorFromString(@"advertisingIdentifier");
NSUUID *uuid =
((NSUUID * (*)(id, SEL))
[sharedManager methodForSelector:advertisingIdentifierSelector])(
sharedManager, advertisingIdentifierSelector);
((NSUUID * (*)(id, SEL))
[sharedManager methodForSelector:advertisingIdentifierSelector])(
sharedManager, advertisingIdentifierSelector);
idForAdvertiser = [uuid UUIDString];
}
return idForAdvertiser;
Expand All @@ -187,4 +187,4 @@ static void AssertDictionaryTypes(id dict)
NSString *SEGEventNameForScreenTitle(NSString *title)
{
return [[NSString alloc] initWithFormat:@"Viewed %@ Screen", title];
}
}
2 changes: 1 addition & 1 deletion Analytics/Classes/Internal/SEGBluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
- (BOOL)hasKnownState;
- (BOOL)isEnabled;

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Internal/SEGBluetooth.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ - (BOOL)isEnabled
}

- (void)centralManagerDidUpdateState:(id)central {}
@end
@end
5 changes: 4 additions & 1 deletion Analytics/Classes/Internal/SEGLocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
@property (nonatomic, copy, readonly) NSDictionary *addressDictionary;
@property (nonatomic, assign, readonly) BOOL hasKnownLocation;


#if TARGET_OS_IOS || (TARGET_OS_MAC && !TARGET_OS_IPHONE)
- (void)startUpdatingLocation;
#endif

@end
@end
Loading

0 comments on commit 581cf3f

Please sign in to comment.