Skip to content

Commit

Permalink
Merge pull request #118 from Microsoft/develop
Browse files Browse the repository at this point in the history
Release 0.1.3
  • Loading branch information
jaeklim authored Oct 24, 2016
2 parents f269bb1 + 184cfda commit fa31404
Show file tree
Hide file tree
Showing 74 changed files with 1,311 additions and 590 deletions.
25 changes: 23 additions & 2 deletions Demo/Demo/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#import "AppDelegate.h"
#import "Constants.h"
#import <Foundation/Foundation.h>

@import SonomaCore;
@import SonomaCrashes;
@import SonomaAnalytics;

@interface AppDelegate ()
@interface AppDelegate () <SNMCrashesDelegate>

@end

Expand All @@ -19,6 +18,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[SNMSonoma setLogLevel:SNMLogLevelVerbose];
[SNMSonoma setServerUrl:@"http://in-integration.dev.avalanch.es:8081"];
[SNMSonoma start:[[NSUUID UUID] UUIDString] withFeatures:@[[SNMAnalytics class], [SNMCrashes class]]];
[SNMCrashes setDelegate:self];

// Print the install Id.
NSLog(@"%@ Install Id: %@", kDEMLogTag, [[SNMSonoma installId] UUIDString]);
Expand Down Expand Up @@ -55,4 +55,25 @@ - (void)applicationWillTerminate:(UIApplication *)application {
// applicationDidEnterBackground:.
}

#pragma mark - SNMCrashesDelegate

- (BOOL)crashes:(SNMCrashes *)crashes shouldProcessErrorReport:(SNMErrorReport *)errorReport {
return YES;
}

- (SNMErrorAttachment *)attachmentWithCrashes:(SNMCrashes *)crashes forErrorReport:(SNMErrorReport *)errorReport {
return [SNMErrorAttachment attachmentWithText:@"Text Attachment"
andBinaryData:[@"Hello World" dataUsingEncoding:NSUTF8StringEncoding]
filename:@"binary.txt" mimeType:@"text/plain"];
}

- (void)crashes:(SNMCrashes *)crashes willSendErrorReport:(SNMErrorReport *)errorReport {
}

- (void)crashes:(SNMCrashes *)crashes didSucceedSendingErrorReport:(SNMErrorReport *)errorReport {
}

- (void)crashes:(SNMCrashes *)crashes didFailSendingErrorReport:(SNMErrorReport *)errorReport withError:(NSError *)error {
}

@end
8 changes: 6 additions & 2 deletions Puppet/Puppet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
0461BBD11DB68EAD001B4555 /* Main.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0461BBD01DB68EAD001B4555 /* Main.strings */; };
6EC99A211D4151A00016C325 /* CrashReporter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EC99A201D4151A00016C325 /* CrashReporter.framework */; };
6EC99A281D4152FA0016C325 /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EC99A271D4152FA0016C325 /* libc++.tbd */; };
E82E1B641D1CA58D00D281C1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E82E1B631D1CA58D00D281C1 /* main.m */; };
Expand Down Expand Up @@ -89,6 +90,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
0461BBD01DB68EAD001B4555 /* Main.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = Main.strings; sourceTree = "<group>"; };
384959D81D4972DA008F6B3A /* Constants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Constants.h; sourceTree = "<group>"; };
6EC99A201D4151A00016C325 /* CrashReporter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CrashReporter.framework; path = ../../Vendor/PLCrashReporter/CrashReporter.framework; sourceTree = "<group>"; };
6EC99A251D4152EB0016C325 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -173,6 +175,7 @@
E82E1B701D1CA58D00D281C1 /* LaunchScreen.storyboard */,
E82E1B731D1CA58D00D281C1 /* Info.plist */,
E82E1B631D1CA58D00D281C1 /* main.m */,
0461BBD01DB68EAD001B4555 /* Main.strings */,
);
name = "Supporting Files";
sourceTree = "<group>";
Expand Down Expand Up @@ -318,7 +321,7 @@
E82E1B8A1D1CA63000D281C1 /* SonomaCoreTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = SonomaCoreTests.xctest;
path = SonomaCore.xctest;
remoteRef = E82E1B891D1CA63000D281C1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
Expand All @@ -332,7 +335,7 @@
E85548051D2D6C8D002DF6E2 /* SonomaAnalyticsTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = SonomaAnalyticsTests.xctest;
path = SonomaAnalytics.xctest;
remoteRef = E85548041D2D6C8D002DF6E2 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
Expand All @@ -351,6 +354,7 @@
buildActionMask = 2147483647;
files = (
E82E1B721D1CA58D00D281C1 /* LaunchScreen.storyboard in Resources */,
0461BBD11DB68EAD001B4555 /* Main.strings in Resources */,
E82E1B6F1D1CA58D00D281C1 /* Assets.xcassets in Resources */,
E82E1B6D1D1CA58D00D281C1 /* Main.storyboard in Resources */,
);
Expand Down
68 changes: 66 additions & 2 deletions Puppet/Puppet/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
#import "SonomaAnalytics.h"
#import "SonomaCore.h"
#import "SonomaCrashes.h"
#import "SNMCrashesDelegate.h"

#import "SNMErrorAttachment.h"
#import "SNMErrorBinaryAttachment.h"
#import "SNMErrorReport.h"

@interface AppDelegate ()
@interface AppDelegate () <SNMCrashesDelegate>

@end

Expand All @@ -18,13 +20,34 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// Start Sonoma SDK.
[SNMSonoma setLogLevel:SNMLogLevelVerbose];

[SNMSonoma start:@"7dfb022a-17b5-4d4a-9c75-12bc3ef5e6b7" withFeatures:@[ [SNMAnalytics class], [SNMCrashes class] ]];
[SNMSonoma start:@"7dfb022a-17b5-4d4a-9c75-12bc3ef5e6b7" withFeatures:@[[SNMAnalytics class], [SNMCrashes class]]];

if ([SNMCrashes hasCrashedInLastSession]) {
SNMErrorReport *errorReport = [SNMCrashes lastSessionCrashReport];
NSLog(@"We crashed with Signal: %@", errorReport.signal);
SNMDevice *device = [errorReport device];
NSString *osVersion = [device osVersion];
NSString *appVersion = [device appVersion];
NSString *appBuild = [device appBuild];
NSLog(@"OS Version is: %@", osVersion);
NSLog(@"App Version is: %@", appVersion);
NSLog(@"App Build is: %@", appBuild);
}

[SNMCrashes setDelegate:self];
[SNMCrashes setUserConfirmationHandler:(^(NSArray<SNMErrorReport *> *errorReports) {

[[[UIAlertView alloc] initWithTitle:NSLocalizedStringFromTable(@"crash_alert_title", @"Main", @"")
message:NSLocalizedStringFromTable(@"crash_alert_message", @"Main", @"")
delegate:self
cancelButtonTitle:NSLocalizedStringFromTable(@"crash_alert_do_not_send", @"Main", @"")
otherButtonTitles:NSLocalizedStringFromTable(@"crash_alert_always_send", @"Main", @""),
NSLocalizedStringFromTable(@"crash_alert_send", @"Main", @""),
nil]
show];
return YES;
})];

// Print the install Id.
NSLog(@"%@ Install Id: %@", kPUPLogTag, [[SNMSonoma installId] UUIDString]);
return YES;
Expand Down Expand Up @@ -60,4 +83,45 @@ - (void)applicationWillTerminate:(UIApplication *)application {
// applicationDidEnterBackground:.
}

#pragma mark - UIAlertViewDelegate

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
switch (buttonIndex) {
case 0:[SNMCrashes notifyWithUserConfirmation:SNMUserConfirmationDontSend];
break;
case 1:[SNMCrashes notifyWithUserConfirmation:SNMUserConfirmationAlways];
break;
case 2:[SNMCrashes notifyWithUserConfirmation:SNMUserConfirmationSend];
break;
}
}

#pragma mark - SNMCrashesDelegate

- (BOOL)crashes:(SNMCrashes *)crashes shouldProcessErrorReport:(SNMErrorReport *)errorReport {
NSLog(@"Should process error report with: %@", errorReport.exceptionReason);
return YES;
}

- (SNMErrorAttachment *)attachmentWithCrashes:(SNMCrashes *)crashes forErrorReport:(SNMErrorReport *)errorReport {
NSLog(@"Attach additional information to error report with: %@", errorReport.exceptionReason);
return [SNMErrorAttachment attachmentWithText:@"Text Attachment"
andBinaryData:[@"Hello World" dataUsingEncoding:NSUTF8StringEncoding]
filename:@"binary.txt" mimeType:@"text/plain"];
}

- (void)crashes:(SNMCrashes *)crashes willSendErrorReport:(SNMErrorReport *)errorReport {
NSLog(@"Will send error report with: %@", errorReport.exceptionReason);
}

- (void)crashes:(SNMCrashes *)crashes didSucceedSendingErrorReport:(SNMErrorReport *)errorReport {
NSLog(@"Did succeed error report sending with: %@", errorReport.exceptionReason);
}

- (void)crashes:(SNMCrashes *)crashes didFailSendingErrorReport:(SNMErrorReport *)errorReport withError:(NSError *)error {
NSLog(@"Did fail sending report with: %@, and error %@",
errorReport.exceptionReason,
error.localizedDescription);
}

@end
9 changes: 9 additions & 0 deletions Puppet/Puppet/Main.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
Main.strings
Puppet
*/
"crash_alert_title" = "Unexpected crash found";
"crash_alert_message" = "Would you like to send an anonymous report so we can fix the problem?";
"crash_alert_do_not_send" = "Don't Send";
"crash_alert_always_send" = "Always Send";
"crash_alert_send" = "Send";
12 changes: 6 additions & 6 deletions SonomaAnalytics/SonomaAnalytics.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@
buildSettings = {
"ARCHS[sdk=iphonesimulator*]" = "$(SNM_SIM_ARCHS)";
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
OTHER_LDFLAGS = "";
PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include;
PRODUCT_BUNDLE_IDENTIFIER = com.microsoft.sonoma.SonomaAnalytics;
PRODUCT_NAME = SonomaAnalytics;
Expand All @@ -653,7 +653,7 @@
buildSettings = {
"ARCHS[sdk=iphonesimulator*]" = "$(SNM_SIM_ARCHS)";
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
OTHER_LDFLAGS = "";
PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include;
PRODUCT_BUNDLE_IDENTIFIER = com.microsoft.sonoma.SonomaAnalytics;
PRODUCT_NAME = SonomaAnalytics;
Expand Down Expand Up @@ -692,7 +692,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
FRAMEWORK_SEARCH_PATHS = "\"$(SRCROOT)/../Vendor\"/**";
HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../Vendor\"/**";
INFOPLIST_FILE = SonomaCrashesTests/Info.plist;
INFOPLIST_FILE = SonomaAnalyticsTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../Vendor\"/**";
Expand All @@ -702,8 +702,8 @@
Foundation,
"-ObjC",
);
PRODUCT_BUNDLE_IDENTIFIER = com.microsoft.sonoma.SonomaCrashesTests;
PRODUCT_NAME = SonomaCrashes;
PRODUCT_BUNDLE_IDENTIFIER = com.microsoft.sonoma.SonomaAnalyticsTests;
PRODUCT_NAME = SonomaAnalytics;
USER_HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../SonomaCore/SonomaCore\"/**";
};
name = Release;
Expand Down Expand Up @@ -739,7 +739,7 @@
buildSettings = {
ARCHS = "$(ARCHS_STANDARD)";
OTHER_CFLAGS = "";
PRODUCT_NAME = SonomaCrashes;
PRODUCT_NAME = SonomaAnalytics;
USER_HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../SonomaCore/SonomaCore\"";
VALID_ARCHS = "";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E85547D41D2D6723002DF6E2"
BuildableName = "SonomaAnalyticsTests.xctest"
BuildableName = "SonomaAnalytics.xctest"
BlueprintName = "SonomaAnalyticsTests"
ReferencedContainer = "container:SonomaAnalytics.xcodeproj">
</BuildableReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#import "SonomaCore+Internal.h"
#import <Foundation/Foundation.h>

@interface SNMSessionTracker : NSObject <SNMLogManagerListener>
@interface SNMSessionTracker : NSObject <SNMLogManagerDelegate>

/**
* Session tracker delegate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#import "SNMSessionTracker.h"
#import "SNMStartSessionLog.h"
#import "SonomaCore+Internal.h"
#import <UIKit/UIKit.h>
#import "SNMAnalytics.h"
#import "SNMAnalyticsPrivate.h"

static NSTimeInterval const kSNMSessionTimeOut = 20;
static NSString *const kSNMPastSessionsKey = @"kSNMPastSessionsKey";
Expand Down Expand Up @@ -81,7 +81,7 @@ - (NSString *)sessionId {
// Persist the session history in NSData format.
[kSNMUserDefaults setObject:[NSKeyedArchiver archivedDataWithRootObject:self.pastSessions]
forKey:kSNMPastSessionsKey];
SNMLogVerbose(@"INFO:new session ID: %@", _sessionId);
SNMLogInfo([SNMAnalytics getLoggerTag], @"New session ID: %@", _sessionId);

// Create a start session log.
SNMStartSessionLog *log = [[SNMStartSessionLog alloc] init];
Expand Down Expand Up @@ -157,7 +157,7 @@ - (void)applicationWillEnterForeground {
self.lastEnteredForegroundTime = [NSDate date];
}

#pragma mark - SNMLogManagerListener
#pragma mark - SNMLogManagerDelegate

- (void)onProcessingLog:(id<SNMLog>)log withPriority:(SNMPriority)priority {

Expand Down
17 changes: 9 additions & 8 deletions SonomaAnalytics/SonomaAnalytics/SNMAnalytics.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
#import "SNMEventLog.h"
#import "SNMFeatureAbstractProtected.h"
#import "SNMPageLog.h"
#import "SNMSonoma.h"
#import "SNMSonomaInternal.h"
#import "SonomaCore+Internal.h"

/**
* Feature storage key name.
Expand Down Expand Up @@ -48,17 +45,21 @@ + (instancetype)sharedInstance {
return sharedInstance;
}

+ (NSString *)getLoggerTag {
return @"SonomaAnalytics";
}

- (void)startFeature {
[super startFeature];

// Add listener to log manager.
[self.logManager addListener:_sessionTracker];
// Add delegate to log manager.
[self.logManager addDelegate:_sessionTracker];

// Enabled auto page tracking
if (self.autoPageTrackingEnabled) {
[SNMAnalyticsCategory activateCategory];
}
SNMLogVerbose(@"SNMAnalytics: Started analytics module");
SNMLogVerbose([SNMAnalytics getLoggerTag], @"Started analytics module");
}

- (NSString *)storageKey {
Expand All @@ -74,9 +75,9 @@ - (SNMPriority)priority {
- (void)setEnabled:(BOOL)isEnabled {
if (isEnabled) {
[self.sessionTracker start];
[self.logManager addListener:self.sessionTracker];
[self.logManager addDelegate:self.sessionTracker];
} else {
[self.logManager removeListener:self.sessionTracker];
[self.logManager removeDelegate:self.sessionTracker];
[self.sessionTracker stop];
[self.sessionTracker clearSessions];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "SonomaAnalytics.xcconfig"

BUILD_NUMBER = 1
VERSION_STRING = 0.1.2
VERSION_STRING = 0.1.3
SDK_NAME = sonoma.ios
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) $(SONOMA_GCC_PREPROCESSOR_DEFINITIONS) SONOMA_CONFIGURATION_$(CONFIGURATION) SONOMA_NAME="@\""$(SDK_NAME)"\"" SONOMA_VERSION="@\""$(VERSION_STRING)"\"" SONOMA_BUILD="@\""$(BUILD_NUMBER)"\"" SONOMA_C_NAME="\""$(SDK_NAME)"\"" SONOMA_C_VERSION="\""$(VERSION_STRING)"\"" SONOMA_C_BUILD="\""$(BUILD_NUMBER)"\""
SNM_ARM_ARCHS = armv7 armv7s arm64
Expand Down
Loading

0 comments on commit fa31404

Please sign in to comment.