mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-18 18:26:24 +00:00
Add User Metrics features to CrashOnly build
This commit is contained in:
@@ -60,6 +60,19 @@ BOOL bit_isRunningInAppExtension(void);
|
||||
NSString *bit_URLEncodedString(NSString *inputString);
|
||||
NSString *bit_base64String(NSData * data, unsigned long length);
|
||||
|
||||
/* Context helpers */
|
||||
NSString *bit_utcDateString(NSDate *date);
|
||||
NSString *bit_devicePlatform(void);
|
||||
NSString *bit_devicePlatform(void);
|
||||
NSString *bit_deviceType(void);
|
||||
NSString *bit_osVersionBuild(void);
|
||||
NSString *bit_osName(void);
|
||||
NSString *bit_deviceLocale(void);
|
||||
NSString *bit_deviceLanguage(void);
|
||||
NSString *bit_screenSize(void);
|
||||
NSString *bit_sdkVersion(void);
|
||||
NSString *bit_appVersion(void);
|
||||
|
||||
#if !defined (HOCKEYSDK_CONFIGURATION_ReleaseCrashOnly) && !defined (HOCKEYSDK_CONFIGURATION_ReleaseCrashOnlyExtensions)
|
||||
/* AppIcon helper */
|
||||
NSString *bit_validAppIconStringFromIcons(NSBundle *resourceBundle, NSArray *icons);
|
||||
@@ -75,17 +88,4 @@ UIImage *bit_imageWithContentsOfResolutionIndependentFile(NSString * path);
|
||||
UIImage *bit_imageNamed(NSString *imageName, NSString *bundleName);
|
||||
UIImage *bit_screenshot(void);
|
||||
UIImage *bit_appIcon(void);
|
||||
|
||||
/* Context helpers */
|
||||
NSString *bit_utcDateString(NSDate *date);
|
||||
NSString *bit_devicePlatform(void);
|
||||
NSString *bit_devicePlatform(void);
|
||||
NSString *bit_deviceType(void);
|
||||
NSString *bit_osVersionBuild(void);
|
||||
NSString *bit_osName(void);
|
||||
NSString *bit_deviceLocale(void);
|
||||
NSString *bit_deviceLanguage(void);
|
||||
NSString *bit_screenSize(void);
|
||||
NSString *bit_sdkVersion(void);
|
||||
NSString *bit_appVersion(void);
|
||||
#endif
|
||||
|
||||
@@ -373,6 +373,148 @@ NSString *bit_base64String(NSData * data, unsigned long length) {
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark Context helpers
|
||||
|
||||
// Return ISO 8601 string representation of the date
|
||||
NSString *bit_utcDateString(NSDate *date){
|
||||
static NSDateFormatter *dateFormatter;
|
||||
|
||||
// NSDateFormatter is not thread-safe prior to iOS 7
|
||||
if (bit_isPreiOS7Environment()) {
|
||||
NSMutableDictionary *threadDictionary = [NSThread currentThread].threadDictionary;
|
||||
dateFormatter = threadDictionary[kBITUtcDateFormatter];
|
||||
|
||||
if (!dateFormatter) {
|
||||
dateFormatter = [NSDateFormatter new];
|
||||
NSLocale *enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
|
||||
dateFormatter.locale = enUSPOSIXLocale;
|
||||
dateFormatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
|
||||
dateFormatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
|
||||
threadDictionary[kBITUtcDateFormatter] = dateFormatter;
|
||||
}
|
||||
|
||||
NSString *dateString = [dateFormatter stringFromDate:date];
|
||||
|
||||
return dateString;
|
||||
}
|
||||
|
||||
static dispatch_once_t dateFormatterToken;
|
||||
dispatch_once(&dateFormatterToken, ^{
|
||||
NSLocale *enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
|
||||
dateFormatter = [NSDateFormatter new];
|
||||
dateFormatter.locale = enUSPOSIXLocale;
|
||||
dateFormatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
|
||||
dateFormatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
|
||||
});
|
||||
|
||||
NSString *dateString = [dateFormatter stringFromDate:date];
|
||||
|
||||
return dateString;
|
||||
}
|
||||
|
||||
NSString *bit_devicePlatform(void) {
|
||||
|
||||
size_t size;
|
||||
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
|
||||
char *answer = (char*)malloc(size);
|
||||
if (answer == NULL)
|
||||
return @"";
|
||||
sysctlbyname("hw.machine", answer, &size, NULL, 0);
|
||||
NSString *platform = [NSString stringWithCString:answer encoding: NSUTF8StringEncoding];
|
||||
free(answer);
|
||||
return platform;
|
||||
}
|
||||
|
||||
NSString *bit_deviceType(void){
|
||||
|
||||
UIUserInterfaceIdiom idiom = [UIDevice currentDevice].userInterfaceIdiom;
|
||||
|
||||
switch (idiom) {
|
||||
case UIUserInterfaceIdiomPad:
|
||||
return @"Tablet";
|
||||
case UIUserInterfaceIdiomPhone:
|
||||
return @"Phone";
|
||||
default:
|
||||
return @"Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
NSString *bit_osVersionBuild(void) {
|
||||
void *result = NULL;
|
||||
size_t result_len = 0;
|
||||
int ret;
|
||||
|
||||
/* If our buffer is too small after allocation, loop until it succeeds -- the requested destination size
|
||||
* may change after each iteration. */
|
||||
do {
|
||||
/* Fetch the expected length */
|
||||
if ((ret = sysctlbyname("kern.osversion", NULL, &result_len, NULL, 0)) == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Allocate the destination buffer */
|
||||
if (result != NULL) {
|
||||
free(result);
|
||||
}
|
||||
result = malloc(result_len);
|
||||
|
||||
/* Fetch the value */
|
||||
ret = sysctlbyname("kern.osversion", result, &result_len, NULL, 0);
|
||||
} while (ret == -1 && errno == ENOMEM);
|
||||
|
||||
/* Handle failure */
|
||||
if (ret == -1) {
|
||||
int saved_errno = errno;
|
||||
|
||||
if (result != NULL) {
|
||||
free(result);
|
||||
}
|
||||
|
||||
errno = saved_errno;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NSString *osBuild = [NSString stringWithCString:result encoding:NSUTF8StringEncoding];
|
||||
free(result);
|
||||
|
||||
NSString *osVersion = [[UIDevice currentDevice] systemVersion];
|
||||
|
||||
return [NSString stringWithFormat:@"%@ (%@)", osVersion, osBuild];
|
||||
}
|
||||
|
||||
NSString *bit_osName(void){
|
||||
return [[UIDevice currentDevice] systemName];
|
||||
}
|
||||
|
||||
NSString *bit_deviceLocale(void) {
|
||||
NSLocale *locale = [NSLocale currentLocale];
|
||||
return [locale objectForKey:NSLocaleIdentifier];
|
||||
}
|
||||
|
||||
NSString *bit_deviceLanguage(void) {
|
||||
return [[NSBundle mainBundle] preferredLocalizations][0];
|
||||
}
|
||||
|
||||
NSString *bit_screenSize(void){
|
||||
CGFloat scale = [UIScreen mainScreen].scale;
|
||||
CGSize screenSize = [UIScreen mainScreen].bounds.size;
|
||||
return [NSString stringWithFormat:@"%dx%d",(int)(screenSize.height * scale), (int)(screenSize.width * scale)];
|
||||
}
|
||||
|
||||
NSString *bit_sdkVersion(void){
|
||||
return [NSString stringWithFormat:@"ios:%@", [NSString stringWithUTF8String:hockeyapp_library_info.bit_version]];
|
||||
}
|
||||
|
||||
NSString *bit_appVersion(void){
|
||||
NSString *build = [[NSBundle mainBundle] infoDictionary][@"CFBundleVersion"];
|
||||
NSString *version = [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"];
|
||||
|
||||
if(version){
|
||||
return [NSString stringWithFormat:@"%@ (%@)", version, build];
|
||||
}else{
|
||||
return build;
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined (HOCKEYSDK_CONFIGURATION_ReleaseCrashOnly) && !defined (HOCKEYSDK_CONFIGURATION_ReleaseCrashOnlyExtensions)
|
||||
|
||||
@@ -912,147 +1054,4 @@ UIImage *bit_screenshot(void) {
|
||||
return image;
|
||||
}
|
||||
|
||||
#pragma mark Context helpers
|
||||
|
||||
// Return ISO 8601 string representation of the date
|
||||
NSString *bit_utcDateString(NSDate *date){
|
||||
static NSDateFormatter *dateFormatter;
|
||||
|
||||
// NSDateFormatter is not thread-safe prior to iOS 7
|
||||
if (bit_isPreiOS7Environment()) {
|
||||
NSMutableDictionary *threadDictionary = [NSThread currentThread].threadDictionary;
|
||||
dateFormatter = threadDictionary[kBITUtcDateFormatter];
|
||||
|
||||
if (!dateFormatter) {
|
||||
dateFormatter = [NSDateFormatter new];
|
||||
NSLocale *enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
|
||||
dateFormatter.locale = enUSPOSIXLocale;
|
||||
dateFormatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
|
||||
dateFormatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
|
||||
threadDictionary[kBITUtcDateFormatter] = dateFormatter;
|
||||
}
|
||||
|
||||
NSString *dateString = [dateFormatter stringFromDate:date];
|
||||
|
||||
return dateString;
|
||||
}
|
||||
|
||||
static dispatch_once_t dateFormatterToken;
|
||||
dispatch_once(&dateFormatterToken, ^{
|
||||
NSLocale *enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
|
||||
dateFormatter = [NSDateFormatter new];
|
||||
dateFormatter.locale = enUSPOSIXLocale;
|
||||
dateFormatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
|
||||
dateFormatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
|
||||
});
|
||||
|
||||
NSString *dateString = [dateFormatter stringFromDate:date];
|
||||
|
||||
return dateString;
|
||||
}
|
||||
|
||||
NSString *bit_devicePlatform(void) {
|
||||
|
||||
size_t size;
|
||||
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
|
||||
char *answer = (char*)malloc(size);
|
||||
if (answer == NULL)
|
||||
return @"";
|
||||
sysctlbyname("hw.machine", answer, &size, NULL, 0);
|
||||
NSString *platform = [NSString stringWithCString:answer encoding: NSUTF8StringEncoding];
|
||||
free(answer);
|
||||
return platform;
|
||||
}
|
||||
|
||||
NSString *bit_deviceType(void){
|
||||
|
||||
UIUserInterfaceIdiom idiom = [UIDevice currentDevice].userInterfaceIdiom;
|
||||
|
||||
switch (idiom) {
|
||||
case UIUserInterfaceIdiomPad:
|
||||
return @"Tablet";
|
||||
case UIUserInterfaceIdiomPhone:
|
||||
return @"Phone";
|
||||
default:
|
||||
return @"Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
NSString *bit_osVersionBuild(void) {
|
||||
void *result = NULL;
|
||||
size_t result_len = 0;
|
||||
int ret;
|
||||
|
||||
/* If our buffer is too small after allocation, loop until it succeeds -- the requested destination size
|
||||
* may change after each iteration. */
|
||||
do {
|
||||
/* Fetch the expected length */
|
||||
if ((ret = sysctlbyname("kern.osversion", NULL, &result_len, NULL, 0)) == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Allocate the destination buffer */
|
||||
if (result != NULL) {
|
||||
free(result);
|
||||
}
|
||||
result = malloc(result_len);
|
||||
|
||||
/* Fetch the value */
|
||||
ret = sysctlbyname("kern.osversion", result, &result_len, NULL, 0);
|
||||
} while (ret == -1 && errno == ENOMEM);
|
||||
|
||||
/* Handle failure */
|
||||
if (ret == -1) {
|
||||
int saved_errno = errno;
|
||||
|
||||
if (result != NULL) {
|
||||
free(result);
|
||||
}
|
||||
|
||||
errno = saved_errno;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NSString *osBuild = [NSString stringWithCString:result encoding:NSUTF8StringEncoding];
|
||||
free(result);
|
||||
|
||||
NSString *osVersion = [[UIDevice currentDevice] systemVersion];
|
||||
|
||||
return [NSString stringWithFormat:@"%@ (%@)", osVersion, osBuild];
|
||||
}
|
||||
|
||||
NSString *bit_osName(void){
|
||||
return [[UIDevice currentDevice] systemName];
|
||||
}
|
||||
|
||||
NSString *bit_deviceLocale(void) {
|
||||
NSLocale *locale = [NSLocale currentLocale];
|
||||
return [locale objectForKey:NSLocaleIdentifier];
|
||||
}
|
||||
|
||||
NSString *bit_deviceLanguage(void) {
|
||||
return [[NSBundle mainBundle] preferredLocalizations][0];
|
||||
}
|
||||
|
||||
NSString *bit_screenSize(void){
|
||||
CGFloat scale = [UIScreen mainScreen].scale;
|
||||
CGSize screenSize = [UIScreen mainScreen].bounds.size;
|
||||
return [NSString stringWithFormat:@"%dx%d",(int)(screenSize.height * scale), (int)(screenSize.width * scale)];
|
||||
}
|
||||
|
||||
NSString *bit_sdkVersion(void){
|
||||
return [NSString stringWithFormat:@"ios:%@", [NSString stringWithUTF8String:hockeyapp_library_info.bit_version]];
|
||||
}
|
||||
|
||||
NSString *bit_appVersion(void){
|
||||
NSString *build = [[NSBundle mainBundle] infoDictionary][@"CFBundleVersion"];
|
||||
NSString *version = [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"];
|
||||
|
||||
if(version){
|
||||
return [NSString stringWithFormat:@"%@ (%@)", version, build];
|
||||
}else{
|
||||
return build;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* HOCKEYSDK_CONFIGURATION_ReleaseCrashOnly && HOCKEYSDK_CONFIGURATION_ReleaseCrashOnlyExtensions */
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
# define HOCKEYSDK_FEATURE_UPDATES 1
|
||||
#endif /* HOCKEYSDK_FEATURE_UPDATES */
|
||||
|
||||
|
||||
/**
|
||||
* If true, include support for auto collecting metrics data such as sessions and user
|
||||
*
|
||||
|
||||
@@ -32,6 +32,7 @@ Pod::Spec.new do |s|
|
||||
|
||||
s.subspec 'CrashOnlyLib' do |ss|
|
||||
ss.frameworks = 'UIKit'
|
||||
ss.libraries = 'z'
|
||||
ss.resource_bundle = { 'HockeySDKResources' => ['HockeySDK-iOS/HockeySDK.embeddedframework/HockeySDK.framework/Versions/A/Resources/HockeySDKResources.bundle/*.lproj'] }
|
||||
ss.vendored_frameworks = 'HockeySDK-iOS/HockeySDKCrashOnly/HockeySDK.framework'
|
||||
end
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -86,13 +86,14 @@
|
||||
# define HOCKEYSDK_FEATURE_UPDATES 0
|
||||
#endif /* HOCKEYSDK_FEATURE_UPDATES */
|
||||
|
||||
|
||||
/**
|
||||
* If true, include support for auto collecting telemetry data such as sessions and user
|
||||
* If true, include support for auto collecting metrics data such as sessions and user
|
||||
*
|
||||
* _Default_: Enabled
|
||||
*/
|
||||
#ifndef HOCKEYSDK_FEATURE_TELEMETRY
|
||||
# define HOCKEYSDK_FEATURE_TELEMETRY 0
|
||||
#endif /* HOCKEYSDK_FEATURE_TELEMETRY */
|
||||
#ifndef HOCKEYSDK_FEATURE_METRICS
|
||||
# define HOCKEYSDK_FEATURE_METRICS 1
|
||||
#endif /* HOCKEYSDK_FEATURE_METRICS */
|
||||
|
||||
#endif /* HockeySDK_HockeySDKFeatureConfig_h */
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#include "release.xcconfig"
|
||||
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) HOCKEYSDK_CONFIGURATION_$(CONFIGURATION) HOCKEYSDK_FEATURE_CRASH_REPORTER=1 HOCKEYSDK_FEATURE_FEEDBACK=0 HOCKEYSDK_FEATURE_STORE_UPDATES=0 HOCKEYSDK_FEATURE_AUTHENTICATOR=0 HOCKEYSDK_FEATURE_UPDATES=0 HOCKEYSDK_FEATURE_METRICS=0 BITHOCKEY_VERSION="@\""$(VERSION_STRING)"\"" BITHOCKEY_BUILD="@\""$(BUILD_NUMBER)"\"" BITHOCKEY_C_VERSION="\""$(VERSION_STRING)"\"" BITHOCKEY_C_BUILD="\""$(BUILD_NUMBER)"\""
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) HOCKEYSDK_CONFIGURATION_$(CONFIGURATION) HOCKEYSDK_FEATURE_CRASH_REPORTER=1 HOCKEYSDK_FEATURE_FEEDBACK=0 HOCKEYSDK_FEATURE_STORE_UPDATES=0 HOCKEYSDK_FEATURE_AUTHENTICATOR=0 HOCKEYSDK_FEATURE_UPDATES=0 HOCKEYSDK_FEATURE_METRICS=1 BITHOCKEY_VERSION="@\""$(VERSION_STRING)"\"" BITHOCKEY_BUILD="@\""$(BUILD_NUMBER)"\"" BITHOCKEY_C_VERSION="\""$(VERSION_STRING)"\"" BITHOCKEY_C_BUILD="\""$(BUILD_NUMBER)"\""
|
||||
|
||||
@@ -9,4 +9,5 @@ framework module HockeySDK {
|
||||
link framework "SystemConfiguration"
|
||||
link framework "UIKit"
|
||||
link "c++"
|
||||
link "z"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user