Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/4.0.0-beta.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
lumaxis committed Mar 31, 2016
2 parents dad4b60 + 056484a commit e878468
Show file tree
Hide file tree
Showing 62 changed files with 3,689 additions and 76 deletions.
24 changes: 24 additions & 0 deletions Classes/BITHockeyManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

@class BITCrashManager;
@class BITFeedbackManager;
@class BITMetricsManager;
@protocol BITHockeyManagerDelegate;

/**
Expand Down Expand Up @@ -205,6 +206,29 @@
@property (nonatomic, getter = isFeedbackManagerDisabled) BOOL disableFeedbackManager;


/**
Reference to the initialized BITMetricsManager module
Returns the BITMetricsManager instance initialized by BITHockeyManager
*/
@property (nonatomic, strong, readonly) BITMetricsManager *metricsManager;

/**
Flag the determines whether the BITMetricsManager should be disabled
If this flag is enabled, then sending metrics data such as sessions and users
will be turned off!
Please note that the BITMetricsManager instance will be initialized anyway!
@warning This property needs to be set before calling `startManager`
*Default*: _NO_
@see metricsManager
*/
@property (nonatomic, getter = isMetricsManagerDisabled) BOOL disableMetricsManager;


///-----------------------------------------------------------------------------
/// @name Configuration
///-----------------------------------------------------------------------------
Expand Down
16 changes: 15 additions & 1 deletion Classes/BITHockeyManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#import "BITHockeyBaseManagerPrivate.h"
#import "BITCrashManagerPrivate.h"
#import "BITFeedbackManagerPrivate.h"
#import "BITMetricsManagerPrivate.h"
#import "BITCategoryContainer.h"
#import "BITHockeyHelper.h"
#import "BITHockeyAppClient.h"

Expand Down Expand Up @@ -65,6 +67,7 @@ - (id) init {

_disableCrashManager = NO;
_disableFeedbackManager = NO;
_disableMetricsManager = NO;

_startManagerIsInvoked = NO;

Expand Down Expand Up @@ -216,6 +219,13 @@ - (void)startManager {
[_feedbackManager performSelector:@selector(startManager) withObject:nil afterDelay:1.0f];
}

// start MetricsManager
if (!self.disableMetricsManager) {
BITHockeyLog(@"INFO: Start MetricsManager");
[_metricsManager startManager];
[BITCategoryContainer activateCategory];
}

NSString *integrationFlowTime = [self integrationFlowTimeString];
if (integrationFlowTime && [self integrationFlowStartedWithTimeString:integrationFlowTime]) {
[self pingServerForIntegrationStartWorkflowWithTimeString:integrationFlowTime];
Expand Down Expand Up @@ -325,8 +335,12 @@ - (void)initializeModules {
} else {
BITHockeyLog(@"INFO: Setup FeedbackManager");
_feedbackManager = [[BITFeedbackManager alloc] initWithAppIdentifier:_appIdentifier];

BITHockeyLog(@"INFO: Setup MetricsManager");
NSString *iKey = bit_appIdentifierToGuid(_appIdentifier);
_metricsManager = [[BITMetricsManager alloc] initWithAppIdentifier:iKey];
}
if ([self isCrashManagerDisabled])
_crashManager.crashManagerActivated = NO;
}
Expand Down
36 changes: 29 additions & 7 deletions Classes/CrashReporting/BITCrashReportTextFormatter.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@

#import "CrashReporter.h"

#import "HockeySDK.h"
#import "HockeySDKPrivate.h"

#import <mach-o/dyld.h>
#import <mach-o/getsect.h>
#import <mach-o/ldsyms.h>
Expand All @@ -45,7 +48,7 @@
#define SEL_NAME_SECT "__cstring"
#endif

#import "BITCrashReportTextFormatter.h"
#import "BITCrashReportTextFormatterPrivate.h"

/*
* XXX: The ARM64 CPU type, and ARM_V7S and ARM_V8 Mach-O CPU subtypes are not
Expand Down Expand Up @@ -373,10 +376,7 @@ + (NSString *)stringValueForCrashReport:(BITPLCrashReport *)report crashReporter
processPath = report.processInfo.processPath;

/* Remove username from the path */
if ([processPath length] > 0)
processPath = [processPath stringByAbbreviatingWithTildeInPath];
if ([processPath length] > 0 && [[processPath substringToIndex:1] isEqualToString:@"~"])
processPath = [NSString stringWithFormat:@"/Users/USER%@", [processPath substringFromIndex:1]];
processPath = [self anonymizedProcessPathFromProcessPath:processPath];
}

/* Parent Process Name */
Expand Down Expand Up @@ -580,7 +580,6 @@ + (NSString *)stringValueForCrashReport:(BITPLCrashReport *)report crashReporter
imageName];
}


return text;
}

Expand Down Expand Up @@ -694,6 +693,30 @@ + (BITBinaryImageType)bit_imageTypeForImagePath:(NSString *)imagePath processPat
return imageType;
}

/**
* Remove the user's name from a crash's process path.
* This is only necessary when sending crashes from the simulator as the path
* then contains the username of the Mac the simulator is running on.
*
* @param processPath A string containing the username
*
* @return An anonymized string where the real username is replaced by "USER"
*/
+ (NSString *)anonymizedProcessPathFromProcessPath:(NSString *)processPath {

NSString *anonymizedProcessPath = [NSString string];

if (([processPath length] > 0) && [processPath hasPrefix:@"/Users/"]) {
NSError *error = nil;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(/Users/[^/]+/)" options:0 error:&error];
anonymizedProcessPath = [regex stringByReplacingMatchesInString:processPath options:0 range:NSMakeRange(0, [processPath length]) withTemplate:@"/Users/USER/"];
if (error) {
BITHockeyLog("ERROR: String replacing failed - %@", error.localizedDescription);
}
}
return anonymizedProcessPath;
}

@end


Expand Down Expand Up @@ -849,5 +872,4 @@ + (NSString *)bit_formatStackFrame: (BITPLCrashReportStackFrameInfo *) frameInfo
lp64 ? 16 : 8, frameInfo.instructionPointer,
symbolString];
}

@end
12 changes: 12 additions & 0 deletions Classes/CrashReporting/BITCrashReportTextFormatterPrivate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#import "BITCrashReportTextFormatter.h"

#ifndef BITCrashReportTextFormatterPrivate_h
#define BITCrashReportTextFormatterPrivate_h

@interface BITCrashReportTextFormatter ()

+ (NSString *)anonymizedProcessPathFromProcessPath:(NSString *)processPath;

@end

#endif /* BITCrashReportTextFormatterPrivate_h */
16 changes: 16 additions & 0 deletions Classes/Helper/BITHockeyHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,28 @@
NSString *bit_URLEncodedString(NSString *inputString);
NSString *bit_URLDecodedString(NSString *inputString);
NSComparisonResult bit_versionCompare(NSString *stringA, NSString *stringB);
NSString *bit_mainBundleIdentifier(void);
NSString *bit_appIdentifierToGuid(NSString *appIdentifier);
NSString *bit_appName(NSString *placeHolderString);

NSString *bit_appAnonID(BOOL forceNewAnonID);
NSString *bit_UUID(void);

NSString *bit_settingsDir(void);

BOOL bit_addStringValueToKeychain(NSString *stringValue, NSString *key);
NSString *bit_stringValueFromKeychainForKey(NSString *key);
BOOL bit_removeKeyFromKeychain(NSString *key);

/* 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);
Loading

0 comments on commit e878468

Please sign in to comment.