diff --git a/CHANGELOG.md b/CHANGELOG.md index 50850b3..e721f54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,11 @@ The change log has moved to this repo's [GitHub Releases Page](https://github.co depending on what is more appropriate in each case. ## Release Notes + +**1.10.0** +- feat: resolve #206: Capture Log As Telemetry - Not working? Introducing RollbarLog(...) +- feat: resolve #217: Reimplement Deploys based on the DTOs + **1.9.1** - feat: resolve #215: Change client.os element back to client.ios to fix dSYMs application diff --git a/Examples/macOScmdTool_Workspace/macOScmdTool/main.m b/Examples/macOScmdTool_Workspace/macOScmdTool/main.m index b8a1a56..2e1f707 100644 --- a/Examples/macOScmdTool_Workspace/macOScmdTool/main.m +++ b/Examples/macOScmdTool_Workspace/macOScmdTool/main.m @@ -28,6 +28,7 @@ + (void) causeTrouble { @"Dave", @"Heywood", @"Frank", nil]; + NSLog(@"The crew: %@", crew); // This will throw an exception. NSLog(@"%@", [crew objectAtIndex:10]); } @@ -39,10 +40,14 @@ int main(int argc, const char * argv[]) { // configure Rollbar: RollbarConfiguration *config = [RollbarConfiguration configuration]; config.environment = @"samples"; + config.telemetryEnabled = YES; + config.maximumTelemetryData = 20; + config.captureLogAsTelemetryData = YES; [Rollbar initWithAccessToken:@"2ffc7997ed864dda94f63e7b7daae0f3" configuration:config]; NSLog(@"Hello, World!"); - + NSLog(@"See you in Telemetry!"); + @try { [BuggyClass callTroubleMaker]; } @@ -54,7 +59,7 @@ int main(int argc, const char * argv[]) { } - int i = 100; + int i = 10; while (0 < i--) { [Rollbar info:@"Message from macOScmdTool"]; [NSThread sleepForTimeInterval:1.0f]; diff --git a/Rollbar.podspec b/Rollbar.podspec index 7073674..f2c32a5 100644 --- a/Rollbar.podspec +++ b/Rollbar.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| - s.version = "1.9.1" + s.version = "1.10.0" s.name = "Rollbar" s.summary = "Objective-C library for crash reporting and logging with Rollbar. It works on iOS and macOS." s.description = <<-DESC @@ -32,12 +32,14 @@ Pod::Spec.new do |s| 'Rollbar/RollbarLevel.h', 'Rollbar/RollbarTelemetry.h', 'Rollbar/RollbarTelemetryType.h', + 'Rollbar/RollbarLog.h', 'Rollbar/RollbarKSCrashReportSink.h', 'Rollbar/RollbarKSCrashInstallation.h', 'Rollbar/Deploys/RollbarDeploysProtocol.h', 'Rollbar/Deploys/RollbarDeploysManager.h', 'Rollbar/RollbarJSONFriendlyProtocol.h', 'Rollbar/RollbarJSONFriendlyObject.h', + 'Rollbar/Deploys/DeployApiCallOutcome.h', 'Rollbar/Deploys/Deployment.h', 'Rollbar/Deploys/DeploymentDetails.h', 'Rollbar/Deploys/DeployApiCallResult.h', diff --git a/Rollbar.xcodeproj/project.pbxproj b/Rollbar.xcodeproj/project.pbxproj index bcf1877..24294f6 100644 --- a/Rollbar.xcodeproj/project.pbxproj +++ b/Rollbar.xcodeproj/project.pbxproj @@ -62,6 +62,14 @@ 55178C40234DACFC0081E84A /* RollbarPayload.m in Sources */ = {isa = PBXBuildFile; fileRef = 55178C3A234DACFC0081E84A /* RollbarPayload.m */; }; 55178C41234DACFC0081E84A /* RollbarPayload.m in Sources */ = {isa = PBXBuildFile; fileRef = 55178C3A234DACFC0081E84A /* RollbarPayload.m */; }; 55178C42234DACFC0081E84A /* RollbarPayload.m in Sources */ = {isa = PBXBuildFile; fileRef = 55178C3A234DACFC0081E84A /* RollbarPayload.m */; }; + 5526B34D237B62B300242958 /* RollbarLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 5526B34B237B62B300242958 /* RollbarLog.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 5526B34E237B62B300242958 /* RollbarLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 5526B34B237B62B300242958 /* RollbarLog.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 5526B34F237B62B300242958 /* RollbarLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 5526B34B237B62B300242958 /* RollbarLog.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 5526B350237B62B300242958 /* RollbarLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 5526B34B237B62B300242958 /* RollbarLog.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 5526B351237B62B300242958 /* RollbarLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 5526B34C237B62B300242958 /* RollbarLog.m */; }; + 5526B352237B62B300242958 /* RollbarLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 5526B34C237B62B300242958 /* RollbarLog.m */; }; + 5526B353237B62B300242958 /* RollbarLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 5526B34C237B62B300242958 /* RollbarLog.m */; }; + 5526B354237B62B300242958 /* RollbarLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 5526B34C237B62B300242958 /* RollbarLog.m */; }; 552C3BF022D3E76D00F97C88 /* RollbarFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = 343AB4541CC9AAE600962943 /* RollbarFramework.h */; settings = {ATTRIBUTES = (Public, ); }; }; 552C3BF122D3E76E00F97C88 /* RollbarFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = 343AB4541CC9AAE600962943 /* RollbarFramework.h */; settings = {ATTRIBUTES = (Public, ); }; }; 552F0F0B236B9810006D3CD3 /* RollbarKit_macOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 55454BBD22C6A9CC00D4A414 /* RollbarKit_macOS.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -125,10 +133,10 @@ 55454A2022C69B6900D4A414 /* RollbarLevel.h in Headers */ = {isa = PBXBuildFile; fileRef = B5EDEA7E1FCA679900830C78 /* RollbarLevel.h */; settings = {ATTRIBUTES = (Public, ); }; }; 55454A2122C69B7700D4A414 /* RollbarLevel.m in Sources */ = {isa = PBXBuildFile; fileRef = B5EDEA7F1FCA679900830C78 /* RollbarLevel.m */; }; 55454A2222C69B7900D4A414 /* RollbarLevel.m in Sources */ = {isa = PBXBuildFile; fileRef = B5EDEA7F1FCA679900830C78 /* RollbarLevel.m */; }; - 55454A2322C69B8200D4A414 /* RollbarLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 96AB9E14191C0B4000F0168A /* RollbarLogger.h */; }; - 55454A2422C69B8300D4A414 /* RollbarLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 96AB9E14191C0B4000F0168A /* RollbarLogger.h */; }; - 55454A2522C69B8900D4A414 /* RollbarLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 96AB9E15191C0B4000F0168A /* RollbarLogger.m */; }; - 55454A2622C69B8A00D4A414 /* RollbarLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 96AB9E15191C0B4000F0168A /* RollbarLogger.m */; }; + 55454A2322C69B8200D4A414 /* SdkLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 96AB9E14191C0B4000F0168A /* SdkLog.h */; }; + 55454A2422C69B8300D4A414 /* SdkLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 96AB9E14191C0B4000F0168A /* SdkLog.h */; }; + 55454A2522C69B8900D4A414 /* SdkLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 96AB9E15191C0B4000F0168A /* SdkLog.m */; }; + 55454A2622C69B8A00D4A414 /* SdkLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 96AB9E15191C0B4000F0168A /* SdkLog.m */; }; 55454A2722C69BA400D4A414 /* RollbarNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 96D2223318D8E51600933444 /* RollbarNotifier.h */; settings = {ATTRIBUTES = (Public, ); }; }; 55454A2822C69BA500D4A414 /* RollbarNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 96D2223318D8E51600933444 /* RollbarNotifier.h */; settings = {ATTRIBUTES = (Public, ); }; }; 55454A2922C69BAF00D4A414 /* RollbarNotifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 96D2223418D8E51600933444 /* RollbarNotifier.m */; }; @@ -557,10 +565,10 @@ 55454C0822C6ACAC00D4A414 /* RollbarLevel.h in Headers */ = {isa = PBXBuildFile; fileRef = B5EDEA7E1FCA679900830C78 /* RollbarLevel.h */; settings = {ATTRIBUTES = (Public, ); }; }; 55454C0922C6ACBA00D4A414 /* RollbarLevel.m in Sources */ = {isa = PBXBuildFile; fileRef = B5EDEA7F1FCA679900830C78 /* RollbarLevel.m */; }; 55454C0A22C6ACBB00D4A414 /* RollbarLevel.m in Sources */ = {isa = PBXBuildFile; fileRef = B5EDEA7F1FCA679900830C78 /* RollbarLevel.m */; }; - 55454C0B22C6ACC300D4A414 /* RollbarLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 96AB9E14191C0B4000F0168A /* RollbarLogger.h */; }; - 55454C0C22C6ACC400D4A414 /* RollbarLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 96AB9E14191C0B4000F0168A /* RollbarLogger.h */; }; - 55454C0D22C6ACE600D4A414 /* RollbarLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 96AB9E15191C0B4000F0168A /* RollbarLogger.m */; }; - 55454C0E22C6ACE700D4A414 /* RollbarLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 96AB9E15191C0B4000F0168A /* RollbarLogger.m */; }; + 55454C0B22C6ACC300D4A414 /* SdkLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 96AB9E14191C0B4000F0168A /* SdkLog.h */; }; + 55454C0C22C6ACC400D4A414 /* SdkLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 96AB9E14191C0B4000F0168A /* SdkLog.h */; }; + 55454C0D22C6ACE600D4A414 /* SdkLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 96AB9E15191C0B4000F0168A /* SdkLog.m */; }; + 55454C0E22C6ACE700D4A414 /* SdkLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 96AB9E15191C0B4000F0168A /* SdkLog.m */; }; 55454C0F22C6ACEC00D4A414 /* RollbarNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 96D2223318D8E51600933444 /* RollbarNotifier.h */; settings = {ATTRIBUTES = (Public, ); }; }; 55454C1022C6ACED00D4A414 /* RollbarNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 96D2223318D8E51600933444 /* RollbarNotifier.h */; settings = {ATTRIBUTES = (Public, ); }; }; 55454C1122C6ACF500D4A414 /* RollbarNotifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 96D2223418D8E51600933444 /* RollbarNotifier.m */; }; @@ -1068,6 +1076,14 @@ 55F10FF9236186780043ADC0 /* RollbarProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 55F10FF3236186770043ADC0 /* RollbarProxy.m */; }; 55F10FFA236186780043ADC0 /* RollbarProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 55F10FF3236186770043ADC0 /* RollbarProxy.m */; }; 55F10FFB236186780043ADC0 /* RollbarProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 55F10FF3236186770043ADC0 /* RollbarProxy.m */; }; + 55F7D9502375E81300F9932D /* DeployApiCallOutcome.h in Headers */ = {isa = PBXBuildFile; fileRef = 55F7D94E2375E81300F9932D /* DeployApiCallOutcome.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 55F7D9512375E81300F9932D /* DeployApiCallOutcome.h in Headers */ = {isa = PBXBuildFile; fileRef = 55F7D94E2375E81300F9932D /* DeployApiCallOutcome.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 55F7D9522375E81300F9932D /* DeployApiCallOutcome.h in Headers */ = {isa = PBXBuildFile; fileRef = 55F7D94E2375E81300F9932D /* DeployApiCallOutcome.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 55F7D9532375E81300F9932D /* DeployApiCallOutcome.h in Headers */ = {isa = PBXBuildFile; fileRef = 55F7D94E2375E81300F9932D /* DeployApiCallOutcome.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 55F7D9542375E81300F9932D /* DeployApiCallOutcome.m in Sources */ = {isa = PBXBuildFile; fileRef = 55F7D94F2375E81300F9932D /* DeployApiCallOutcome.m */; }; + 55F7D9552375E81300F9932D /* DeployApiCallOutcome.m in Sources */ = {isa = PBXBuildFile; fileRef = 55F7D94F2375E81300F9932D /* DeployApiCallOutcome.m */; }; + 55F7D9562375E81300F9932D /* DeployApiCallOutcome.m in Sources */ = {isa = PBXBuildFile; fileRef = 55F7D94F2375E81300F9932D /* DeployApiCallOutcome.m */; }; + 55F7D9572375E81300F9932D /* DeployApiCallOutcome.m in Sources */ = {isa = PBXBuildFile; fileRef = 55F7D94F2375E81300F9932D /* DeployApiCallOutcome.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -1145,6 +1161,8 @@ 55178C3A234DACFC0081E84A /* RollbarPayload.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RollbarPayload.m; sourceTree = ""; }; 55250C012345686A0073ABB9 /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = ""; }; 55250C022345686A0073ABB9 /* Rollbar.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = Rollbar.podspec; sourceTree = ""; }; + 5526B34B237B62B300242958 /* RollbarLog.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RollbarLog.h; sourceTree = ""; }; + 5526B34C237B62B300242958 /* RollbarLog.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RollbarLog.m; sourceTree = ""; }; 554549C322C68DBA00D4A414 /* libRollbar.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRollbar.a; sourceTree = BUILT_PRODUCTS_DIR; }; 554549C522C68DBA00D4A414 /* Rollbar_iOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Rollbar_iOS.h; sourceTree = ""; }; 554549C622C68DBA00D4A414 /* Rollbar_iOS.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Rollbar_iOS.m; sourceTree = ""; }; @@ -1197,6 +1215,8 @@ 55F10FE9236135EF0043ADC0 /* RollbarDeveloperOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RollbarDeveloperOptions.m; sourceTree = ""; }; 55F10FF2236186770043ADC0 /* RollbarProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RollbarProxy.h; sourceTree = ""; }; 55F10FF3236186770043ADC0 /* RollbarProxy.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RollbarProxy.m; sourceTree = ""; }; + 55F7D94E2375E81300F9932D /* DeployApiCallOutcome.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DeployApiCallOutcome.h; sourceTree = ""; }; + 55F7D94F2375E81300F9932D /* DeployApiCallOutcome.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DeployApiCallOutcome.m; sourceTree = ""; }; 9630826318DCDDC000256154 /* RollbarConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RollbarConfiguration.h; sourceTree = ""; }; 9630826418DCDDC000256154 /* RollbarConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RollbarConfiguration.m; sourceTree = ""; }; 966CD46C18F4E4C3005A8F2D /* RollbarThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RollbarThread.h; sourceTree = ""; }; @@ -1204,8 +1224,8 @@ 96AB9E06191B10AE00F0168A /* RollbarReachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RollbarReachability.h; sourceTree = ""; }; 96AB9E07191B10AE00F0168A /* RollbarReachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RollbarReachability.m; sourceTree = ""; }; 96AB9E0F191B239700F0168A /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; - 96AB9E14191C0B4000F0168A /* RollbarLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RollbarLogger.h; sourceTree = ""; }; - 96AB9E15191C0B4000F0168A /* RollbarLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RollbarLogger.m; sourceTree = ""; }; + 96AB9E14191C0B4000F0168A /* SdkLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SdkLog.h; sourceTree = ""; }; + 96AB9E15191C0B4000F0168A /* SdkLog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SdkLog.m; sourceTree = ""; }; 96D2220D18D8E40600933444 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 96D2221118D8E40600933444 /* Rollbar-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Rollbar-Prefix.pch"; sourceTree = ""; }; 96D2221218D8E40600933444 /* Rollbar.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Rollbar.h; sourceTree = ""; }; @@ -1474,6 +1494,8 @@ 55143D7C214C5E2200761B20 /* Deploys */ = { isa = PBXGroup; children = ( + 55F7D94E2375E81300F9932D /* DeployApiCallOutcome.h */, + 55F7D94F2375E81300F9932D /* DeployApiCallOutcome.m */, 55143D93214CB35F00761B20 /* DeployApiCallResult.h */, 55143D96214CB39000761B20 /* DeployApiCallResult.m */, 55143D7D214C5F4600761B20 /* RollbarDeploysProtocol.h */, @@ -1653,8 +1675,6 @@ B5D3971C1FB549D7000544DC /* RollbarKSCrashReportSink.m */, B5EDEA7E1FCA679900830C78 /* RollbarLevel.h */, B5EDEA7F1FCA679900830C78 /* RollbarLevel.m */, - 96AB9E14191C0B4000F0168A /* RollbarLogger.h */, - 96AB9E15191C0B4000F0168A /* RollbarLogger.m */, 96D2223318D8E51600933444 /* RollbarNotifier.h */, 96D2223418D8E51600933444 /* RollbarNotifier.m */, 96AB9E06191B10AE00F0168A /* RollbarReachability.h */, @@ -1663,10 +1683,14 @@ B57C558B1FC4F06C00103A8B /* RollbarTelemetry.m */, B5EDEA771FCA66DD00830C78 /* RollbarTelemetryType.h */, B5EDEA781FCA66DD00830C78 /* RollbarTelemetryType.m */, + 5526B34B237B62B300242958 /* RollbarLog.h */, + 5526B34C237B62B300242958 /* RollbarLog.m */, 966CD46C18F4E4C3005A8F2D /* RollbarThread.h */, 966CD46D18F4E4C3005A8F2D /* RollbarThread.m */, 55B568D520F7E37E00052D01 /* RollbarPayloadTruncator.h */, 55B568D320F7E32200052D01 /* RollbarPayloadTruncator.m */, + 96AB9E14191C0B4000F0168A /* SdkLog.h */, + 96AB9E15191C0B4000F0168A /* SdkLog.m */, 96D2221018D8E40600933444 /* Supporting Files */, ); path = Rollbar; @@ -2028,7 +2052,7 @@ 55454B5A22C69DF900D4A414 /* None.h in Headers */, 55454B9022C69E2B00D4A414 /* Malloc.h in Headers */, 55454A1C22C69B5200D4A414 /* RollbarKSCrashReportSink.h in Headers */, - 55454A2422C69B8300D4A414 /* RollbarLogger.h in Headers */, + 55454A2422C69B8300D4A414 /* SdkLog.h in Headers */, 55454B5E22C69DFE00D4A414 /* llvm-config.h in Headers */, 55454A7422C69D9700D4A414 /* NSMutableData+AppendUTF8.h in Headers */, 55454B0222C69DD100D4A414 /* KSSymbolicator.h in Headers */, @@ -2101,6 +2125,7 @@ 55454B1722C69DD100D4A414 /* KSMach.h in Headers */, 55454B2C22C69DD100D4A414 /* KSObjC.h in Headers */, 554549F822C69A2A00D4A414 /* Deployment.h in Headers */, + 55F7D9512375E81300F9932D /* DeployApiCallOutcome.h in Headers */, 55A5588E2356474F00D8898A /* CaptureIpType.h in Headers */, 55454ABF22C69DBC00D4A414 /* KSCrashMonitor_MachException.h in Headers */, 55454B3122C69DD100D4A414 /* KSStackCursor_MachineContext.h in Headers */, @@ -2124,6 +2149,7 @@ 55454B3222C69DD100D4A414 /* KSJSONCodecObjC.h in Headers */, 55454B8622C69E2100D4A414 /* SwiftStrings.h in Headers */, 557A4E242362AD100034BB55 /* RollbarServer.h in Headers */, + 5526B34E237B62B300242958 /* RollbarLog.h in Headers */, 55454B8422C69E1300D4A414 /* KSCrashInstallation.h in Headers */, 55454A0022C69A5F00D4A414 /* RollbarDeploysManager.h in Headers */, 55454B7922C69E1300D4A414 /* KSCrashInstallationQuincyHockey.h in Headers */, @@ -2186,11 +2212,13 @@ 55454B7522C69E1300D4A414 /* KSCrashInstallation.h in Headers */, 55454A0722C69ABF00D4A414 /* Rollbar.h in Headers */, 55454A2F22C69C1000D4A414 /* RollbarTelemetry.h in Headers */, - 55454A2322C69B8200D4A414 /* RollbarLogger.h in Headers */, + 55454A2322C69B8200D4A414 /* SdkLog.h in Headers */, 55454A0B22C69ADF00D4A414 /* RollbarCachesDirectory.h in Headers */, + 5526B34D237B62B300242958 /* RollbarLog.h in Headers */, 55E275A6236787A500BA9BDC /* RollbarLoggingOptions.h in Headers */, 55454AD922C69DD100D4A414 /* KSMemory.h in Headers */, 55454B6222C69E0500D4A414 /* type_traits.h in Headers */, + 55F7D9502375E81300F9932D /* DeployApiCallOutcome.h in Headers */, 55454B7422C69E1300D4A414 /* KSCrashInstallation+Private.h in Headers */, 55454B3B22C69DDD00D4A414 /* KSCrashC.h in Headers */, 5599052F236381FE003C41F3 /* RollbarModule.h in Headers */, @@ -2318,7 +2346,7 @@ 55454C8422C6AE7400D4A414 /* KSCrashC.h in Headers */, 55454D4622C6AEA400D4A414 /* llvm-config.h in Headers */, 55454CFD22C6AE8C00D4A414 /* KSStackCursor_MachineContext.h in Headers */, - 55454C0B22C6ACC300D4A414 /* RollbarLogger.h in Headers */, + 55454C0B22C6ACC300D4A414 /* SdkLog.h in Headers */, 5592708C234EEA8B0087E01F /* Persistent.h in Headers */, 55454C5122C6AE4F00D4A414 /* NSMutableData+AppendUTF8.h in Headers */, 55454D7722C6AEE400D4A414 /* Punycode.h in Headers */, @@ -2332,6 +2360,7 @@ 55454CFE22C6AE8C00D4A414 /* KSJSONCodecObjC.h in Headers */, 55454C6C22C6AE5B00D4A414 /* KSCrashReportSinkQuincyHockey.h in Headers */, 55454BEA22C6ABE100D4A414 /* NSJSONSerialization+Rollbar.h in Headers */, + 55F7D9522375E81300F9932D /* DeployApiCallOutcome.h in Headers */, 559270A423500C950087E01F /* DataTransferObject+Protected.h in Headers */, 55454D4222C6AE9D00D4A414 /* StringRef.h in Headers */, 55454D7822C6AEE400D4A414 /* Fallthrough.h in Headers */, @@ -2370,6 +2399,7 @@ 55454C2C22C6AE3800D4A414 /* KSCrashReportFilterGZip.h in Headers */, 55454CA422C6AE7F00D4A414 /* KSCrashMonitor_Signal.h in Headers */, 55454CFB22C6AE8C00D4A414 /* KSDate.h in Headers */, + 5526B34F237B62B300242958 /* RollbarLog.h in Headers */, 55454BF622C6AC4900D4A414 /* RollbarConfiguration.h in Headers */, 55F10FE2236120190043ADC0 /* RollbarDestination.h in Headers */, 55454C4A22C6AE4100D4A414 /* KSVarArgs.h in Headers */, @@ -2464,7 +2494,7 @@ 55454C9222C6AE7500D4A414 /* KSCrashC.h in Headers */, 55454D4722C6AEA500D4A414 /* llvm-config.h in Headers */, 55454D3622C6AE8D00D4A414 /* KSStackCursor_MachineContext.h in Headers */, - 55454C0C22C6ACC400D4A414 /* RollbarLogger.h in Headers */, + 55454C0C22C6ACC400D4A414 /* SdkLog.h in Headers */, 5592708D234EEA8B0087E01F /* Persistent.h in Headers */, 55454C5D22C6AE5000D4A414 /* NSMutableData+AppendUTF8.h in Headers */, 55454D7F22C6AEE500D4A414 /* Punycode.h in Headers */, @@ -2477,6 +2507,7 @@ 55454C4C22C6AE4200D4A414 /* NSData+GZip.h in Headers */, 55454D3722C6AE8D00D4A414 /* KSJSONCodecObjC.h in Headers */, 55454C7622C6AE5C00D4A414 /* KSCrashReportSinkQuincyHockey.h in Headers */, + 55F7D9532375E81300F9932D /* DeployApiCallOutcome.h in Headers */, 55454BEB22C6ABE200D4A414 /* NSJSONSerialization+Rollbar.h in Headers */, 559270A523500C950087E01F /* DataTransferObject+Protected.h in Headers */, 55454D4522C6AE9F00D4A414 /* StringRef.h in Headers */, @@ -2515,6 +2546,7 @@ 55454C9A22C6AE7500D4A414 /* KSCrashReportStore.h in Headers */, 55454C3A22C6AE3900D4A414 /* KSCrashReportFilterGZip.h in Headers */, 55454CBB22C6AE8000D4A414 /* KSCrashMonitor_Signal.h in Headers */, + 5526B350237B62B300242958 /* RollbarLog.h in Headers */, 55454D3422C6AE8D00D4A414 /* KSDate.h in Headers */, 55454BF722C6AC4A00D4A414 /* RollbarConfiguration.h in Headers */, 55F10FE3236120190043ADC0 /* RollbarDestination.h in Headers */, @@ -2916,6 +2948,7 @@ 55454B4522C69DDD00D4A414 /* KSCrashC.c in Sources */, 5592709C234FC7D00087E01F /* RollbarData.m in Sources */, 55454AFA22C69DD100D4A414 /* KSThread.c in Sources */, + 5526B351237B62B300242958 /* RollbarLog.m in Sources */, 55454A8522C69DA300D4A414 /* KSCrashReportSinkVictory.m in Sources */, 55F10FF8236186780043ADC0 /* RollbarProxy.m in Sources */, 55A558912356474F00D8898A /* CaptureIpType.m in Sources */, @@ -2959,7 +2992,8 @@ 55454AD022C69DD100D4A414 /* KSCPU_x86_32.c in Sources */, 554549C722C68DBA00D4A414 /* Rollbar_iOS.m in Sources */, 55454A2922C69BAF00D4A414 /* RollbarNotifier.m in Sources */, - 55454A2522C69B8900D4A414 /* RollbarLogger.m in Sources */, + 55F7D9542375E81300F9932D /* DeployApiCallOutcome.m in Sources */, + 55454A2522C69B8900D4A414 /* SdkLog.m in Sources */, 55454AE422C69DD100D4A414 /* KSStackCursor.c in Sources */, 557A4E1D236262460034BB55 /* RollbarScrubbingOptions.m in Sources */, 55454A0122C69A6900D4A414 /* RollbarDeploysManager.m in Sources */, @@ -3036,6 +3070,7 @@ 55454B5322C69DDE00D4A414 /* KSCrashC.c in Sources */, 5592709D234FC7D00087E01F /* RollbarData.m in Sources */, 55454B3322C69DD100D4A414 /* KSThread.c in Sources */, + 5526B352237B62B300242958 /* RollbarLog.m in Sources */, 55454A8F22C69DA300D4A414 /* KSCrashReportSinkVictory.m in Sources */, 55F10FF9236186780043ADC0 /* RollbarProxy.m in Sources */, 55A558922356474F00D8898A /* CaptureIpType.m in Sources */, @@ -3079,7 +3114,8 @@ 55454B0922C69DD100D4A414 /* KSCPU_x86_32.c in Sources */, 554549E222C68E8F00D4A414 /* Rollbar_macOS.m in Sources */, 55454A2A22C69BB000D4A414 /* RollbarNotifier.m in Sources */, - 55454A2622C69B8A00D4A414 /* RollbarLogger.m in Sources */, + 55F7D9552375E81300F9932D /* DeployApiCallOutcome.m in Sources */, + 55454A2622C69B8A00D4A414 /* SdkLog.m in Sources */, 55454B1D22C69DD100D4A414 /* KSStackCursor.c in Sources */, 557A4E1E236262460034BB55 /* RollbarScrubbingOptions.m in Sources */, 55454A0222C69A6900D4A414 /* RollbarDeploysManager.m in Sources */, @@ -3119,8 +3155,9 @@ 55454D5722C6AED300D4A414 /* KSCrashInstallation.m in Sources */, 557A4E1F236262460034BB55 /* RollbarScrubbingOptions.m in Sources */, 55454C1922C6AD0E00D4A414 /* RollbarTelemetry.m in Sources */, - 55454C0D22C6ACE600D4A414 /* RollbarLogger.m in Sources */, + 55454C0D22C6ACE600D4A414 /* SdkLog.m in Sources */, 55454C1E22C6AD2100D4A414 /* RollbarTelemetryType.m in Sources */, + 55F7D9562375E81300F9932D /* DeployApiCallOutcome.m in Sources */, 55454CF222C6AE8C00D4A414 /* KSSignalInfo.c in Sources */, 55454C5722C6AE4F00D4A414 /* NSMutableData+AppendUTF8.m in Sources */, 55454CD922C6AE8C00D4A414 /* KSObjC.c in Sources */, @@ -3165,6 +3202,7 @@ 55454C6E22C6AE5B00D4A414 /* KSCrashReportSinkVictory.m in Sources */, 55454CB522C6AE7F00D4A414 /* KSCrashMonitor_CPPException.cpp in Sources */, 55454CED22C6AE8C00D4A414 /* KSDemangle_CPP.cpp in Sources */, + 5526B353237B62B300242958 /* RollbarLog.m in Sources */, 55454BE422C6ABC900D4A414 /* DeploymentDetails.m in Sources */, 55454CFC22C6AE8C00D4A414 /* KSJSONCodec.c in Sources */, 559270B22351A7B50087E01F /* RollbarConfig.m in Sources */, @@ -3253,8 +3291,9 @@ 55454D6622C6AED400D4A414 /* KSCrashInstallation.m in Sources */, 557A4E20236262460034BB55 /* RollbarScrubbingOptions.m in Sources */, 55454C1A22C6AD0F00D4A414 /* RollbarTelemetry.m in Sources */, - 55454C0E22C6ACE700D4A414 /* RollbarLogger.m in Sources */, + 55454C0E22C6ACE700D4A414 /* SdkLog.m in Sources */, 55454C1F22C6AD2200D4A414 /* RollbarTelemetryType.m in Sources */, + 55F7D9572375E81300F9932D /* DeployApiCallOutcome.m in Sources */, 55454D2B22C6AE8D00D4A414 /* KSSignalInfo.c in Sources */, 55454C6322C6AE5000D4A414 /* NSMutableData+AppendUTF8.m in Sources */, 55454D1222C6AE8D00D4A414 /* KSObjC.c in Sources */, @@ -3299,6 +3338,7 @@ 55454C7822C6AE5C00D4A414 /* KSCrashReportSinkVictory.m in Sources */, 55454CCC22C6AE8000D4A414 /* KSCrashMonitor_CPPException.cpp in Sources */, 55454D2622C6AE8D00D4A414 /* KSDemangle_CPP.cpp in Sources */, + 5526B354237B62B300242958 /* RollbarLog.m in Sources */, 55454BE522C6ABCA00D4A414 /* DeploymentDetails.m in Sources */, 55454D3522C6AE8D00D4A414 /* KSJSONCodec.c in Sources */, 559270B32351A7B50087E01F /* RollbarConfig.m in Sources */, @@ -3911,7 +3951,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1.9.1; + CURRENT_PROJECT_VERSION = 1.10.0; DEVELOPMENT_TEAM = LDX6L68VZJ; ENABLE_BITCODE = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -3972,7 +4012,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 1.9.1; + CURRENT_PROJECT_VERSION = 1.10.0; DEVELOPMENT_TEAM = LDX6L68VZJ; ENABLE_BITCODE = YES; ENABLE_NS_ASSERTIONS = NO; diff --git a/Rollbar/DTOs/DataTransferObject+Protected.h b/Rollbar/DTOs/DataTransferObject+Protected.h index 499fba4..00ccd59 100644 --- a/Rollbar/DTOs/DataTransferObject+Protected.h +++ b/Rollbar/DTOs/DataTransferObject+Protected.h @@ -43,6 +43,8 @@ NS_ASSUME_NONNULL_BEGIN - (NSUInteger)safelyGetUIntegerByKey:(NSString *)key; - (void)setUInteger:(NSUInteger)data forKey:(NSString *)key; +- (NSInteger)safelyGetIntegerByKey:(NSString *)key; +- (void)setInteger:(NSInteger)data forKey:(NSString *)key; @end diff --git a/Rollbar/DTOs/DataTransferObject+Protected.m b/Rollbar/DTOs/DataTransferObject+Protected.m index 23789f4..d86f266 100644 --- a/Rollbar/DTOs/DataTransferObject+Protected.m +++ b/Rollbar/DTOs/DataTransferObject+Protected.m @@ -132,4 +132,14 @@ - (void)setUInteger:(NSUInteger)data forKey:(NSString *)key { [self setNumber:number forKey:key]; } +- (NSInteger)safelyGetIntegerByKey:(NSString *)key { + NSNumber *value = [self safelyGetNumberByKey:key]; + return value.integerValue; +} + +- (void)setInteger:(NSInteger)data forKey:(NSString *)key { + NSNumber *number = @(data); + [self setNumber:number forKey:key]; +} + @end diff --git a/Rollbar/DTOs/DataTransferObject.m b/Rollbar/DTOs/DataTransferObject.m index af8eb2a..1051b27 100644 --- a/Rollbar/DTOs/DataTransferObject.m +++ b/Rollbar/DTOs/DataTransferObject.m @@ -7,7 +7,7 @@ // #import "DataTransferObject.h" -#import "RollbarLogger.h" +#import "SdkLog.h" #import #import "objc/runtime.h" @@ -84,10 +84,10 @@ + (NSMutableDictionary *)safeDataFromJSONObject:(id)obj { if (error == nil) { [safeData setObject:[[self class] safeDataFromJSONObject:json] forKey:key]; } else { - RollbarLog(@"Error serializing NSData: %@", [error localizedDescription]); + SdkLog(@"Error serializing NSData: %@", [error localizedDescription]); } } else { - RollbarLog(@"Error serializing class '%@' using NSJSONSerialization", + SdkLog(@"Error serializing class '%@' using NSJSONSerialization", NSStringFromClass([obj class])); } }]; @@ -131,8 +131,8 @@ - (BOOL)deserializeFromJSONData:(NSData *)jsonData { error:&error]; if (!self->_data) { self->_data = [[NSMutableDictionary alloc] initWithCapacity:10]; - RollbarLog(@"Error restoring data from JSON NSData instance: %@", jsonData); - RollbarLog(@"Error details: %@", error); + SdkLog(@"Error restoring data from JSON NSData instance: %@", jsonData); + SdkLog(@"Error details: %@", error); return NO; } return YES; @@ -141,7 +141,7 @@ - (BOOL)deserializeFromJSONData:(NSData *)jsonData { - (BOOL)deserializeFromJSONString:(NSString *)jsonString { NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding]; if (!jsonData) { - RollbarLog(@"Error converting an NSString instance to NSData: %@", jsonString); + SdkLog(@"Error converting an NSString instance to NSData: %@", jsonString); return NO; } return [self deserializeFromJSONData:jsonData]; diff --git a/Rollbar/DTOs/RollbarConfig.m b/Rollbar/DTOs/RollbarConfig.m index 4895ab5..9549ef8 100644 --- a/Rollbar/DTOs/RollbarConfig.m +++ b/Rollbar/DTOs/RollbarConfig.m @@ -23,7 +23,7 @@ #pragma mark - constants -static NSString * const NOTIFIER_VERSION = @"1.9.1"; +static NSString * const NOTIFIER_VERSION = @"1.10.0"; #define NOTIFIER_NAME_PREFIX = @"rollbar-"; #if TARGET_OS_IPHONE diff --git a/Rollbar/Deploys/DeployApiCallOutcome.h b/Rollbar/Deploys/DeployApiCallOutcome.h new file mode 100644 index 0000000..79a402f --- /dev/null +++ b/Rollbar/Deploys/DeployApiCallOutcome.h @@ -0,0 +1,31 @@ +// +// DeployApiCallOutcome.h +// Rollbar +// +// Created by Andrey Kornich on 2019-11-08. +// Copyright © 2019 Rollbar. All rights reserved. +// + +#import + +typedef NS_ENUM(NSInteger, DeployApiCallOutcome) { + DeployApiCallSuccess, + DeployApiCallError, +}; + +NS_ASSUME_NONNULL_BEGIN + +/// Enum to/from NSString conversion utility +@interface DeployApiCallOutcomeUtil : NSObject + +/// Converts DeployApiCallOutcome value into a NSString +/// @param value DeployApiCallOutcome value to convert ++ (NSString *) DeployApiCallOutcomeToString:(DeployApiCallOutcome)value; + +/// Converts NSString into a DeployApiCallOutcome value +/// @param value NSString to convert ++ (DeployApiCallOutcome) DeployApiCallOutcomeFromString:(NSString *)value; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Rollbar/Deploys/DeployApiCallOutcome.m b/Rollbar/Deploys/DeployApiCallOutcome.m new file mode 100644 index 0000000..c76b945 --- /dev/null +++ b/Rollbar/Deploys/DeployApiCallOutcome.m @@ -0,0 +1,37 @@ +// +// DeployApiCallOutcome.m +// Rollbar +// +// Created by Andrey Kornich on 2019-11-08. +// Copyright © 2019 Rollbar. All rights reserved. +// + +#import "DeployApiCallOutcome.h" + +@implementation DeployApiCallOutcomeUtil + ++ (NSString *) DeployApiCallOutcomeToString:(DeployApiCallOutcome)value; { + switch (value) { + case DeployApiCallSuccess: + return @"success"; + case DeployApiCallError: + return @"error"; + default: + return @"unknown"; + } +} + ++ (DeployApiCallOutcome) DeployApiCallOutcomeFromString:(NSString *)value { + + if (NSOrderedSame == [value caseInsensitiveCompare:@"success"]) { + return DeployApiCallSuccess; + } + else if (NSOrderedSame == [value caseInsensitiveCompare:@"error"]) { + return DeployApiCallError; + } + else { + return DeployApiCallError; // default case... + } +} + +@end diff --git a/Rollbar/Deploys/DeployApiCallResult.h b/Rollbar/Deploys/DeployApiCallResult.h index dcec223..dd14a56 100644 --- a/Rollbar/Deploys/DeployApiCallResult.h +++ b/Rollbar/Deploys/DeployApiCallResult.h @@ -1,34 +1,63 @@ // Copyright © 2018 Rollbar. All rights reserved. #import - #import "DeploymentDetails.h" -#import "RollbarJSONFriendlyObject.h" +#import "DataTransferObject.h" +#import "DeployApiCallOutcome.h" + +#pragma mark - DeployApiCallResult -typedef NS_ENUM(NSInteger, DeployApiCallOutcome) { - DeployApiCallSuccess, - DeployApiCallError, -}; +/// Models result of Deploy API call/request +@interface DeployApiCallResult : DataTransferObject -@interface DeployApiCallResult : RollbarJSONFriendlyObject +/// API call's outcome @property (readonly) DeployApiCallOutcome outcome; + +/// API call's result description @property (readonly, copy) NSString *description; -- (id)initWithResponse:(NSHTTPURLResponse*)httpResponse - data:(NSData*)data - error:(NSError*)error - forRequest:(NSURLRequest*)request; +/// Designated initializer +/// @param httpResponse HTTP response object +/// @param data response data +/// @param error error (if any) +/// @param request corresponding HTTP request +- (instancetype)initWithResponse:(NSHTTPURLResponse*)httpResponse + data:(NSData*)data + error:(NSError*)error + forRequest:(NSURLRequest*)request +NS_DESIGNATED_INITIALIZER; + @end +#pragma mark - DeploymentRegistrationResult + +/// Models result of a deployment registration request @interface DeploymentRegistrationResult : DeployApiCallResult + +/// Deployment ID @property (readonly, copy) NSString *deploymentId; + @end +#pragma mark - DeploymentDetailsResult + +/// Models result of a deployment details request @interface DeploymentDetailsResult : DeployApiCallResult + +/// Deployment details object @property (readonly, retain) DeploymentDetails *deployment; + @end +#pragma mark - DeploymentDetailsPageResult + +/// Models result of a deployment details page request @interface DeploymentDetailsPageResult : DeployApiCallResult -@property (readonly, retain) NSSet *deployments; -@property (readonly, copy) NSNumber *pageNumber; + +/// Deployment details objects +@property (readonly, retain) NSArray *deployments; + +/// Deployment details page number +@property (readonly) NSUInteger pageNumber; + @end diff --git a/Rollbar/Deploys/DeployApiCallResult.m b/Rollbar/Deploys/DeployApiCallResult.m index 44ec2f6..d305440 100644 --- a/Rollbar/Deploys/DeployApiCallResult.m +++ b/Rollbar/Deploys/DeployApiCallResult.m @@ -1,181 +1,114 @@ // Copyright © 2018 Rollbar. All rights reserved. #import - #import "DeployApiCallResult.h" +#import "DataTransferObject+Protected.h" + +#pragma mark - DeployApiCallResult @implementation DeployApiCallResult -static NSString * const PROPERTY_outcome = @"outcome"; -static NSString * const PROPERTY_description = @"description"; +static NSString * const DFK_OUTCOME = @"outcome"; +static NSString * const DFK_DESCRIPTION = @"description"; - (DeployApiCallOutcome)outcome { - return [[self.dataDictionary objectForKey:PROPERTY_outcome] intValue]; + return [self safelyGetIntegerByKey:DFK_OUTCOME]; } - (NSString *)description { - return (NSString *) [self.dataDictionary objectForKey:PROPERTY_description]; + return [self safelyGetStringByKey:DFK_DESCRIPTION]; } -// Designated Initializer: -- (id)initWithResponse:(NSHTTPURLResponse*)httpResponse - data:(NSData*)data - error:(NSError*)error - forRequest:(NSURLRequest*)request { - self = [super init]; - if (nil != self) { - if (error) { - [self.dataDictionary setObject:[NSNumber numberWithInt:DeployApiCallError] - forKey:PROPERTY_outcome]; - NSString *description = - [NSString stringWithFormat:@"Rollbar Deploy API communication error: %@",[error localizedDescription]]; - [self.dataDictionary setObject:description - forKey:PROPERTY_description]; +- (instancetype)initWithResponse:(NSHTTPURLResponse*)httpResponse + data:(NSData*)data + error:(NSError*)error + forRequest:(NSURLRequest*)request { + + const NSUInteger dictionaryCapacity = 3; + NSMutableDictionary *dataSeed = [NSMutableDictionary dictionaryWithCapacity:dictionaryCapacity]; + if (error) { + [dataSeed setObject:[NSNumber numberWithInt:DeployApiCallError] forKey:DFK_OUTCOME]; + + NSMutableString *description = + [NSMutableString stringWithFormat:@"Rollbar Deploy API communication error: %@", + [error localizedDescription] + ]; + [dataSeed setObject:description forKey:DFK_DESCRIPTION]; + } + if (nil != httpResponse) { + if (200 == httpResponse.statusCode) { + [dataSeed setObject:[NSNumber numberWithInt:DeployApiCallSuccess] forKey:DFK_OUTCOME]; } - if (nil != httpResponse) { - if (200 == httpResponse.statusCode) { - [self.dataDictionary setObject:[NSNumber numberWithInt:DeployApiCallSuccess] - forKey:PROPERTY_outcome]; - } - else { - [self.dataDictionary setObject:[NSNumber numberWithInt:DeployApiCallError] - forKey:PROPERTY_outcome]; - } - NSMutableString *description = - [NSMutableString stringWithFormat:@"HTTP Status Code: %ldi and Description: %@",(long)httpResponse.statusCode,[NSHTTPURLResponse localizedStringForStatusCode:httpResponse.statusCode]]; - if (data) { - [description appendFormat:@"\n\rResponse data:\n\r\%@",[NSJSONSerialization JSONObjectWithData:data options:0 error:nil]]; - } - [self.dataDictionary setObject:description - forKey:PROPERTY_description]; + else { + [dataSeed setObject:[NSNumber numberWithInt:DeployApiCallError] forKey:DFK_OUTCOME]; } + NSMutableString *description = + [NSMutableString stringWithFormat:@"HTTP Status Code: %ldi and Description: %@", + (long)httpResponse.statusCode, + [NSHTTPURLResponse localizedStringForStatusCode:httpResponse.statusCode] + ]; + if (data) { + [description appendFormat:@"\n\rResponse data:\n\r\%@", + [NSJSONSerialization JSONObjectWithData:data options:0 error:nil] + ]; + } + [dataSeed setObject:description forKey:DFK_DESCRIPTION]; } + + self = [super initWithDictionary:dataSeed]; + return self; } @end +#pragma mark - DeploymentRegistrationResult + @implementation DeploymentRegistrationResult -static NSString * const PROPERTY_deplymentId = @"deploymentId"; +static NSString * const DFK_DEPLOYMENT_ID = @"deploymentId"; - (NSString *)deploymentId { - return (NSString *) [self.dataDictionary objectForKey:PROPERTY_deplymentId]; -} - -// Designated Initializer: -- (id)initWithResponse:(NSHTTPURLResponse*)httpResponse - data:(NSData*)data - error:(NSError*)error - forRequest:(NSURLRequest*)request { - - self = [super initWithResponse:httpResponse - data:data - error:error - forRequest:request - ]; - if (nil != self) { - if ((nil == error) && (nil != httpResponse) && (200 == httpResponse.statusCode)) { - NSDictionary *dataStruct = - [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; - if (nil != dataStruct) { - NSNumber *deploy_id = dataStruct[@"data"][@"deploy_id"]; - [self.dataDictionary setObject:[deploy_id stringValue] - forKey:PROPERTY_deplymentId]; - } - } - } - return self; + return [self safelyGetStringByKey:DFK_DEPLOYMENT_ID]; } @end +#pragma mark - DeploymentDetailsResult + @implementation DeploymentDetailsResult -static NSString * const PROPERTY_deployment = @"deployment"; +static NSString * const DFK_DEPLOYMENT = @"deployment"; - (DeploymentDetails *)deployment { - return (DeploymentDetails *) [self.dataDictionary objectForKey:PROPERTY_deployment]; -} - -// Designated Initializer: -- (id)initWithResponse:(NSHTTPURLResponse*)httpResponse - data:(NSData*)data - error:(NSError*)error - forRequest:(NSURLRequest*)request { - - self = [super initWithResponse:httpResponse - data:data - error:error - forRequest:request - ]; - if (nil != self) { - if ((nil == error) && (nil != httpResponse) && (200 == httpResponse.statusCode)) { - NSDictionary *dataStruct = - [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; - //NSLog(@"%@", dataStruct); - if (nil != dataStruct) { - DeploymentDetails *deploymentDetails = - [[DeploymentDetails alloc] initWithJSONData:dataStruct[@"result"]]; - [self.dataDictionary setObject:deploymentDetails - forKey:PROPERTY_deployment - ]; - } - } - } - return self; + id data = [self safelyGetDictionaryByKey:DFK_DEPLOYMENT]; + id dto = [[DeploymentDetails alloc] initWithDictionary:data]; + return dto; } @end -@implementation DeploymentDetailsPageResult +#pragma mark - DeploymentDetailsPageResult -static NSString * const PROPERTY_deployments = @"deployments"; -static NSString * const PROPERTY_pageNumber = @"page"; +@implementation DeploymentDetailsPageResult -- (NSSet *)deployments { - return (NSSet *) [self.dataDictionary objectForKey:PROPERTY_deployments]; -} -- (NSNumber*)pageNumber { - return (NSNumber*) [self.dataDictionary objectForKey:PROPERTY_pageNumber]; +static NSString * const DFK_DEPLOYMENTS = @"deployments"; +static NSString * const DFK_PAGE_NUMBER = @"page"; + +- (NSArray *)deployments { + NSArray *deploys = [self safelyGetArrayByKey:DFK_DEPLOYMENTS]; + NSMutableArray *deployments = + [NSMutableArray arrayWithCapacity:deploys.count]; + [deploys enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + DeploymentDetails *deploymentDetails = + [[DeploymentDetails alloc] initWithJSONData:obj]; + [deployments addObject:deploymentDetails]; + }]; + return deployments; } -// Designated Initializer: -- (id)initWithResponse:(NSHTTPURLResponse*)httpResponse - data:(NSData*)data - error:(NSError*)error - forRequest:(NSURLRequest*)request { - - self = [super initWithResponse:httpResponse - data:data - error:error - forRequest:request - ]; - if (nil != self) { - if ((nil == error) && (nil != httpResponse) && (200 == httpResponse.statusCode)) { - NSDictionary *dataStruct = - [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; - //NSLog(@"%@", dataStruct); - if (nil != dataStruct) { - NSNumber *pageNumber = dataStruct[@"result"][@"page"]; - [self.dataDictionary setObject:pageNumber - forKey:PROPERTY_pageNumber - ]; - NSArray *deploys = dataStruct[@"result"][@"deploys"]; - NSMutableSet *deployments = - [[NSMutableSet alloc] initWithCapacity:deploys.count]; - [deploys enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - DeploymentDetails *deploymentDetails = - [[DeploymentDetails alloc] initWithJSONData:obj]; - [deployments addObject:deploymentDetails]; - }]; - [self.dataDictionary setObject:deployments - forKey:PROPERTY_deployments - ]; - } - } - } - return self; +- (NSUInteger)pageNumber { + return [self safelyGetUIntegerByKey:DFK_PAGE_NUMBER]; } @end diff --git a/Rollbar/Deploys/Deployment.h b/Rollbar/Deploys/Deployment.h index 821fdf1..7a820f2 100644 --- a/Rollbar/Deploys/Deployment.h +++ b/Rollbar/Deploys/Deployment.h @@ -1,18 +1,40 @@ // Copyright © 2018 Rollbar. All rights reserved. #import -#import "RollbarJSONFriendlyObject.h" +#import "DataTransferObject.h" -@interface Deployment : RollbarJSONFriendlyObject +/// Models a Deployment +@interface Deployment : DataTransferObject + +#pragma mark - properties + +/// Rollbar project environment @property (readonly, retain) NSString *environment; + +/// Comment @property (readonly, retain) NSString *comment; + +/// Revision ID @property (readonly, retain) NSString *revision; + +/// Local user's name @property (readonly, retain) NSString *localUsername; + +/// Rollbar user's name @property (readonly, retain) NSString *rollbarUsername; -- (id)initWithEnvironment:(NSString *)environment - comment:(NSString *)comment - revision:(NSString *)revision - localUserName:(NSString *)localUserName - rollbarUserName:(NSString *)rollbarUserName; +#pragma mark - initializers +/// Designated initializer +/// @param environment Rollbar project environment +/// @param comment Comment +/// @param revision Revision ID +/// @param localUserName local user's name +/// @param rollbarUserName Rollbar user's name +- (instancetype)initWithEnvironment:(NSString *)environment + comment:(NSString *)comment + revision:(NSString *)revision + localUserName:(NSString *)localUserName + rollbarUserName:(NSString *)rollbarUserName +NS_DESIGNATED_INITIALIZER; + @end diff --git a/Rollbar/Deploys/Deployment.m b/Rollbar/Deploys/Deployment.m index 7cd6a90..38bd55e 100644 --- a/Rollbar/Deploys/Deployment.m +++ b/Rollbar/Deploys/Deployment.m @@ -1,64 +1,61 @@ // Copyright © 2018 Rollbar. All rights reserved. #import "Deployment.h" +#import "DataTransferObject+Protected.h" @implementation Deployment -static NSString * const PROPERTY_environment = @"environment"; -static NSString * const PROPERTY_comment = @"comment"; -static NSString * const PROPERTY_revision = @"revision"; -static NSString * const PROPERTY_localUsername = @"local_username"; -static NSString * const PROPERTY_rollbarUsername = @"rollbar_username"; +#pragma mark - data field keys +static NSString * const DFK_ENVIRONMENT = @"environment"; +static NSString * const DFK_COMMENT = @"comment"; +static NSString * const DFK_REVISION = @"revision"; +static NSString * const DFK_LOCAL_USERNAME = @"local_username"; +static NSString * const DFK_ROLLBAR_USERNAME = @"rollbar_username"; +#pragma mark - properties -(NSString *)environment { - return [self.dataDictionary objectForKey:PROPERTY_environment] ; + return [self safelyGetStringByKey:DFK_ENVIRONMENT] ; } -(NSString *)comment { - return [self.dataDictionary objectForKey:PROPERTY_comment] ; + return [self safelyGetStringByKey:DFK_COMMENT] ; } -(NSString *)revision { - return [self.dataDictionary objectForKey:PROPERTY_revision] ; + return [self safelyGetStringByKey:DFK_REVISION] ; } -(NSString *)localUsername { - return [self.dataDictionary objectForKey:PROPERTY_localUsername] ; + return [self safelyGetStringByKey:DFK_LOCAL_USERNAME] ; } -(NSString *)rollbarUsername { - return [self.dataDictionary objectForKey:PROPERTY_rollbarUsername] ; + return [self safelyGetStringByKey:DFK_ROLLBAR_USERNAME] ; } -- (id)initWithEnvironment:(NSString *)environment - comment:(NSString *)comment - revision:(NSString *)revision - localUserName:(NSString *)localUserName - rollbarUserName:(NSString *)rollbarUserName { - self = [super init]; - if (nil != self) { - [self.dataDictionary setObject:environment forKey:PROPERTY_environment]; - [self.dataDictionary setObject:comment forKey:PROPERTY_comment]; - [self.dataDictionary setObject:revision forKey:PROPERTY_revision]; - [self.dataDictionary setObject:localUserName forKey:PROPERTY_localUsername]; - [self.dataDictionary setObject:rollbarUserName forKey:PROPERTY_rollbarUsername]; - } +#pragma mark - initializers + +- (instancetype)initWithEnvironment:(NSString *)environment + comment:(NSString *)comment + revision:(NSString *)revision + localUserName:(NSString *)localUserName + rollbarUserName:(NSString *)rollbarUserName { + self = [super initWithDictionary:@{ + DFK_ENVIRONMENT:environment, + DFK_COMMENT:comment, + DFK_REVISION:revision, + DFK_LOCAL_USERNAME:localUserName, + DFK_ROLLBAR_USERNAME:rollbarUserName, + }]; return self; } -- (id)initWithJSONData:(NSDictionary *)jsonData { - self = [super initWithJSONData:jsonData]; - if (nil != self) { - NSString *revision = jsonData[@"revision"]; - NSString *environment = jsonData[@"environment"]; - NSString *user_id = jsonData[@"user_id"]; - NSString *local_username = jsonData[@"local_username"]; - NSString *comment = jsonData[@"comment"]; - - [self.dataDictionary setObject:environment forKey:PROPERTY_environment]; - [self.dataDictionary setObject:comment forKey:PROPERTY_comment]; - [self.dataDictionary setObject:revision forKey:PROPERTY_revision]; - [self.dataDictionary setObject:local_username forKey:PROPERTY_localUsername]; - [self.dataDictionary setObject:user_id forKey:PROPERTY_rollbarUsername]; - } - return self; + +- (instancetype)initWithJSONData:(NSDictionary *)jsonData { + return [self initWithEnvironment:jsonData[@"environment"] + comment:jsonData[@"environment"] + revision:jsonData[@"revision"] + localUserName:jsonData[@"local_username"] + rollbarUserName:jsonData[@"user_id"] + ]; } -- (id)init { + +- (instancetype)init { return [self initWithEnvironment:nil comment:nil revision:nil diff --git a/Rollbar/Deploys/DeploymentDetails.h b/Rollbar/Deploys/DeploymentDetails.h index 428596c..ab0e8d9 100644 --- a/Rollbar/Deploys/DeploymentDetails.h +++ b/Rollbar/Deploys/DeploymentDetails.h @@ -1,13 +1,24 @@ // Copyright © 2018 Rollbar. All rights reserved. #import - #import "Deployment.h" +/// Models Deployment details @interface DeploymentDetails : Deployment + +/// Deployment ID @property (readonly, copy) NSString *deployId; + +/// Rollbar project ID @property (readonly, copy) NSString *projectId; + +/// Start time @property (readonly, copy) NSDate *startTime; + +/// End time @property (readonly, copy) NSDate *endTime; + +/// Status @property (readonly, copy) NSString *status; + @end diff --git a/Rollbar/Deploys/DeploymentDetails.m b/Rollbar/Deploys/DeploymentDetails.m index 0052083..ccc273d 100644 --- a/Rollbar/Deploys/DeploymentDetails.m +++ b/Rollbar/Deploys/DeploymentDetails.m @@ -3,50 +3,53 @@ #import #import "DeploymentDetails.h" +#import "DataTransferObject+Protected.h" @implementation DeploymentDetails -static NSString * const PROPERTY_deployId = @"id"; -static NSString * const PROPERTY_projectId = @"project_id"; -static NSString * const PROPERTY_startTime = @"start_time"; -static NSString * const PROPERTY_endTime = @"finish_time"; -static NSString * const PROPERTY_status = @"status"; +#pragma mark - data field keys +static NSString * const DFK_DEPLOY_ID = @"id"; +static NSString * const DFK_PROJECT_ID = @"project_id"; +static NSString * const DFK_START_TIME = @"start_time"; +static NSString * const DFK_END_TIME = @"finish_time"; +static NSString * const DFK_STATUS = @"status"; + +#pragma mark - properties -(NSString *)deployId { - return [self.dataDictionary objectForKey:PROPERTY_deployId] ; + return [self safelyGetStringByKey:DFK_DEPLOY_ID] ; } -(NSString *)projectId { - return [self.dataDictionary objectForKey:PROPERTY_projectId] ; + return [self safelyGetStringByKey:DFK_PROJECT_ID] ; } -(NSString *)startTime { - return [self.dataDictionary objectForKey:PROPERTY_startTime] ; + return [self safelyGetStringByKey:DFK_START_TIME] ; } -(NSString *)endTime { - return [self.dataDictionary objectForKey:PROPERTY_endTime] ; + return [self safelyGetStringByKey:DFK_END_TIME] ; } -(NSString *)status { - return [self.dataDictionary objectForKey:PROPERTY_status] ; + return [self safelyGetStringByKey:DFK_STATUS] ; } +#pragma mark - initializers + - (id)initWithJSONData:(NSDictionary *)jsonData { self = [super initWithJSONData:jsonData]; if (nil != self) { - NSNumber *deploy_id = jsonData[@"id"]; - NSNumber *project_id = jsonData[@"project_id"]; - NSNumber *start_time = jsonData[@"start_time"]; - NSNumber *finish_time = jsonData[@"finish_time"]; - NSString *status = jsonData[@"status"]; + NSNumber *deploy_id = jsonData[DFK_DEPLOY_ID]; + NSNumber *project_id = jsonData[DFK_PROJECT_ID]; + NSNumber *start_time = jsonData[DFK_START_TIME]; + NSNumber *finish_time = jsonData[DFK_END_TIME]; + NSString *status = jsonData[DFK_STATUS]; - [self.dataDictionary setObject:[deploy_id stringValue] - forKey:PROPERTY_deployId]; - [self.dataDictionary setObject:[project_id stringValue] - forKey:PROPERTY_projectId]; - [self.dataDictionary setObject:status - forKey:PROPERTY_status]; - [self.dataDictionary setObject:[NSDate dateWithTimeIntervalSince1970:(NSTimeInterval)start_time.doubleValue] - forKey:PROPERTY_startTime]; - [self.dataDictionary setObject:[NSDate dateWithTimeIntervalSince1970:(NSTimeInterval)finish_time.doubleValue] - forKey:PROPERTY_endTime]; + [self setString:[deploy_id stringValue] forKey:DFK_DEPLOY_ID]; + [self setString:[project_id stringValue] forKey:DFK_PROJECT_ID]; + [self setString:status forKey:DFK_STATUS]; + [self setString:[NSDate dateWithTimeIntervalSince1970:(NSTimeInterval)start_time.doubleValue].description + forKey:DFK_START_TIME]; + [self setString:[NSDate dateWithTimeIntervalSince1970:(NSTimeInterval)finish_time.doubleValue].description + forKey:DFK_END_TIME]; } return self; } diff --git a/Rollbar/Deploys/RollbarDeploysManager.h b/Rollbar/Deploys/RollbarDeploysManager.h index de4c37c..8442403 100644 --- a/Rollbar/Deploys/RollbarDeploysManager.h +++ b/Rollbar/Deploys/RollbarDeploysManager.h @@ -1,19 +1,23 @@ // Copyright © 2018 Rollbar. All rights reserved. #import - #import "RollbarDeploysProtocol.h" +/// Rollbar Deploys Manager (a facade client to the Rollbar Deploy APIs) @interface RollbarDeploysManager : NSObject { - NSMutableData *responseData; - NSObject *_deploymentRegistrationObserver; - NSObject *_deploymentDetailsObserver; - NSObject *_deploymentDetailsPageObserver; } -- (id)initWithWriteAccessToken:(NSString *)writeAccessToken - readAccessToken:(NSString *)readAccessToken -deploymentRegistrationObserver:(NSObject*)deploymentRegistrationObserver - deploymentDetailsObserver:(NSObject*)deploymentDetailsObserver - deploymentDetailsPageObserver:(NSObject*)deploymentDetailsPageObserver; +/// Designated initializer +/// @param writeAccessToken write AccessToken +/// @param readAccessToken read AccessToken +/// @param deploymentRegistrationObserver deployment registration observer +/// @param deploymentDetailsObserver deployment details observer +/// @param deploymentDetailsPageObserver deployment details page observer +- (instancetype)initWithWriteAccessToken:(NSString *)writeAccessToken + readAccessToken:(NSString *)readAccessToken + deploymentRegistrationObserver:(NSObject*)deploymentRegistrationObserver + deploymentDetailsObserver:(NSObject*)deploymentDetailsObserver + deploymentDetailsPageObserver:(NSObject*)deploymentDetailsPageObserver +NS_DESIGNATED_INITIALIZER; + @end diff --git a/Rollbar/Deploys/RollbarDeploysManager.m b/Rollbar/Deploys/RollbarDeploysManager.m index 9c11350..0db4d50 100644 --- a/Rollbar/Deploys/RollbarDeploysManager.m +++ b/Rollbar/Deploys/RollbarDeploysManager.m @@ -3,6 +3,7 @@ #include #import "NSJSONSerialization+Rollbar.h" #import "RollbarDeploysManager.h" +#include "Deployment.h" #define IS_IOS7_OR_HIGHER (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) #define IS_MACOS10_10_OR_HIGHER (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber10_10) @@ -12,7 +13,12 @@ @interface RollbarDeploysManager() @property (readwrite, retain) NSString *readAccessToken; @end -@implementation RollbarDeploysManager +@implementation RollbarDeploysManager { + NSMutableData *responseData; + NSObject *_deploymentRegistrationObserver; + NSObject *_deploymentDetailsObserver; + NSObject *_deploymentDetailsPageObserver; +} - (id)initWithWriteAccessToken:(NSString *)writeAccessToken readAccessToken:(NSString *)readAccessToken @@ -59,7 +65,7 @@ - (void)registerDeployment:(Deployment *)deployment { NSString * const url = @"https://api.rollbar.com/api/1/deploy/"; NSMutableDictionary *params = - [[NSMutableDictionary alloc] initWithDictionary:deployment.asJSONData]; + [[NSMutableDictionary alloc] initWithDictionary:deployment.jsonFriendlyData]; [params setObject:self.writeAccessToken forKey:@"access_token" ]; diff --git a/Rollbar/Deploys/RollbarDeploysProtocol.h b/Rollbar/Deploys/RollbarDeploysProtocol.h index dedde26..ef5b4d0 100644 --- a/Rollbar/Deploys/RollbarDeploysProtocol.h +++ b/Rollbar/Deploys/RollbarDeploysProtocol.h @@ -1,34 +1,54 @@ // Copyright © 2018 Rollbar. All rights reserved. #import - #import "Deployment.h" #import "DeploymentDetails.h" #import "DeployApiCallResult.h" -// Deploys Service Response Observer Protocols: +#pragma mark - Deploys Service Response Observer Protocols +/// Deployment reqistration observer protocol @protocol DeploymentRegistrationObserver @required +/// Deployment reqistration observer's callback method +/// @param result deployment registration result object - (void)onRegisterDeploymentCompleted:(DeployApiCallResult *)result; @end +/// Deployment details observer protocol @protocol DeploymentDetailsObserver @required +/// Deployment details observer's callback method +/// @param result result obect - (void)onGetDeploymentDetailsCompleted:(DeploymentDetailsResult *)result; @end +/// Deployment details page observer protocol @protocol DeploymentDetailsPageObserver @required +/// Deployment details page observer's callback method +/// @param result result object - (void)onGetDeploymentDetailsPageCompleted:(DeploymentDetailsPageResult *)result; @end -// Deploys Service Requests Protocol: +#pragma mark - Deploys Service Requests Protocol +/// Rollbar Deploys API protocol @protocol RollbarDeploysProtocol + @required + +/// Register deployment API call +/// @param deployment deployment registration result - (void) registerDeployment:(Deployment *)deployment; + +/// Individual deployment details API call +/// @param deployId deployment ID - (void) getDeploymentWithDeployId:(NSString *)deployId; + +/// Deployment details page request API call +/// @param pageNumber requested page number - (void) getDeploymentsPageNumber:(NSUInteger)pageNumber; + @optional @end diff --git a/Rollbar/NSJSONSerialization+Rollbar.m b/Rollbar/NSJSONSerialization+Rollbar.m index f8eaf79..093c3ce 100644 --- a/Rollbar/NSJSONSerialization+Rollbar.m +++ b/Rollbar/NSJSONSerialization+Rollbar.m @@ -2,7 +2,7 @@ #import "NSJSONSerialization+Rollbar.h" #import "Rollbar.h" -#import "RollbarLogger.h" +#import "SdkLog.h" @implementation NSJSONSerialization (Rollbar) @@ -61,10 +61,10 @@ + (NSMutableDictionary *)safeDataFromJSONObject:(id)obj { if (error == nil) { [safeData setObject:[[self class] safeDataFromJSONObject:json] forKey:key]; } else { - RollbarLog(@"Error serializing NSData: %@", [error localizedDescription]); + SdkLog(@"Error serializing NSData: %@", [error localizedDescription]); } } else { - RollbarLog(@"Error serializing class '%@' using NSJSONSerialization", + SdkLog(@"Error serializing class '%@' using NSJSONSerialization", NSStringFromClass([obj class])); } }]; diff --git a/Rollbar/Rollbar.h b/Rollbar/Rollbar.h index c5b662e..6e99ae1 100644 --- a/Rollbar/Rollbar.h +++ b/Rollbar/Rollbar.h @@ -3,8 +3,8 @@ #import #import "RollbarConfiguration.h" #import "RollbarNotifier.h" -#import "RollbarTelemetry.h" #import "RollbarLevel.h" +#import "RollbarTelemetry.h" #import "RollbarTelemetryType.h" @interface Rollbar : NSObject diff --git a/Rollbar/Rollbar.m b/Rollbar/Rollbar.m index 64e6fae..1c2b87a 100644 --- a/Rollbar/Rollbar.m +++ b/Rollbar/Rollbar.m @@ -1,7 +1,7 @@ // Copyright (c) 2018 Rollbar, Inc. All rights reserved. #import "Rollbar.h" -#import "RollbarLogger.h" +#import "SdkLog.h" #import "RollbarKSCrashInstallation.h" @implementation Rollbar @@ -13,7 +13,7 @@ + (void)enableCrashReporter { [installation install]; [installation sendAllReportsWithCompletion:^(NSArray *filteredReports, BOOL completed, NSError *error) { if (error) { - RollbarLog(@"Could not enable crash reporter: %@", [error localizedDescription]); + SdkLog(@"Could not enable crash reporter: %@", [error localizedDescription]); } else if (completed) { [notifier processSavedItems]; } @@ -37,7 +37,7 @@ + (void)initWithAccessToken:(NSString *)accessToken [RollbarTelemetry sharedInstance]; // Load saved data, if any if (notifier) { - RollbarLog(@"Rollbar has already been initialized."); + SdkLog(@"Rollbar has already been initialized."); } else { notifier = [[RollbarNotifier alloc] initWithAccessToken:accessToken configuration:configuration diff --git a/Rollbar/RollbarLog.h b/Rollbar/RollbarLog.h new file mode 100644 index 0000000..4ef9713 --- /dev/null +++ b/Rollbar/RollbarLog.h @@ -0,0 +1,16 @@ +// +// RollbarLog.h +// Rollbar +// +// Created by Andrey Kornich on 2019-11-12. +// Copyright © 2019 Rollbar. All rights reserved. +// + +#import + +/// Rollbar equivalent of NSLog(...) that also allows capture of the log messages as part of RollbarTelemetry data. +/// NOTE: When this SDK is used from Objective-C codebase NSLog(...) messages get captured by the SDK. +/// However, when used from Swift codebase, all the NSLog(...) calls in Swift need to be replaced +/// with similar RollbarLog(...) calls to be captured as extra telemetry data. +/// @param format <#format description#> +void RollbarLog(NSString *format, ...); diff --git a/Rollbar/RollbarLog.m b/Rollbar/RollbarLog.m new file mode 100644 index 0000000..2d7c523 --- /dev/null +++ b/Rollbar/RollbarLog.m @@ -0,0 +1,17 @@ +// +// RollbarLog.m +// Rollbar +// +// Created by Andrey Kornich on 2019-11-12. +// Copyright © 2019 Rollbar. All rights reserved. +// + +#import "RollbarLog.h" +#import "RollbarTelemetry.h" + +void RollbarLog(NSString *format, ...) { + va_list args; + va_start(args, format); + [RollbarTelemetry NSLogReplacement:[[NSString alloc] initWithFormat:format arguments:args]]; + va_end(args); +} diff --git a/Rollbar/RollbarLogger.h b/Rollbar/RollbarLogger.h deleted file mode 100644 index 150a6fe..0000000 --- a/Rollbar/RollbarLogger.h +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright (c) 2018 Rollbar Inc. All rights reserved. - -#import - -void RollbarLog(NSString *format, ...); diff --git a/Rollbar/RollbarNotifier.m b/Rollbar/RollbarNotifier.m index 9bb74ea..01534b2 100644 --- a/Rollbar/RollbarNotifier.m +++ b/Rollbar/RollbarNotifier.m @@ -4,7 +4,7 @@ #import "RollbarThread.h" #import "RollbarFileReader.h" #import "RollbarReachability.h" -#import "RollbarLogger.h" +#import "SdkLog.h" #if TARGET_OS_IPHONE #import #endif @@ -109,7 +109,7 @@ - (id)initWithAccessToken:(NSString*)accessToken error:nil]; queueState = [state mutableCopy]; } else { - RollbarLog(@"There was an error restoring saved queue state"); + SdkLog(@"There was an error restoring saved queue state"); } } if (!queueState) { @@ -192,7 +192,7 @@ - (void)saveQueueState { error:&error safe:true]; if (error) { - RollbarLog(@"Error: %@", [error localizedDescription]); + SdkLog(@"Error: %@", [error localizedDescription]); } [data writeToFile:stateFilePath atomically:YES]; } @@ -237,7 +237,7 @@ - (void)processSavedItems { NSData *lineData = [line dataUsingEncoding:NSUTF8StringEncoding]; if (!lineData) { // All we can do is ignore this line - RollbarLog(@"Error converting file line to NSData: %@", line); + SdkLog(@"Error converting file line to NSData: %@", line); return; } NSError *error; @@ -247,7 +247,7 @@ - (void)processSavedItems { if (!payload) { // Ignore this line if it isn't valid json and proceed to the next line - RollbarLog(@"Error restoring data from file to JSON: %@", lineData); + SdkLog(@"Error restoring data from file to JSON: %@", lineData); return; } @@ -589,7 +589,7 @@ - (BOOL)sendItem:(NSDictionary*)payload [queueState[@"retry_count"] unsignedIntegerValue]; if (0 == retryCount && YES == self.configuration.logPayload) { - RollbarLog(@"About to send payload: %@", + SdkLog(@"About to send payload: %@", [[NSString alloc] initWithData:jsonPayload encoding:NSUTF8StringEncoding] ); @@ -618,7 +618,7 @@ - (BOOL)sendItem:(NSDictionary*)payload } } else { - RollbarLog( + SdkLog( @"Omitting payload until nextSendTime is reached: %@", [[NSString alloc] initWithData:jsonPayload encoding:NSUTF8StringEncoding] ); @@ -736,17 +736,17 @@ - (BOOL)checkPayloadResponse:(NSURLResponse*)response } if (error) { - RollbarLog(@"There was an error reporting to Rollbar"); - RollbarLog(@"Error: %@", [error localizedDescription]); + SdkLog(@"There was an error reporting to Rollbar"); + SdkLog(@"Error: %@", [error localizedDescription]); } else { NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response; if ([httpResponse statusCode] == 200) { - RollbarLog(@"Success"); + SdkLog(@"Success"); return YES; } else { - RollbarLog(@"There was a problem reporting to Rollbar"); + SdkLog(@"There was a problem reporting to Rollbar"); if (data) { - RollbarLog( + SdkLog( @"Response: %@", [NSJSONSerialization JSONObjectWithData:data options:0 @@ -810,7 +810,7 @@ - (BOOL)shouldIgnorePayload:(NSDictionary*)data { @try { shouldIgnore = self.configuration.checkIgnore(data); } @catch(NSException *e) { - RollbarLog(@"checkIgnore error: %@", e.reason); + SdkLog(@"checkIgnore error: %@", e.reason); // Remove checkIgnore to prevent future exceptions [self.configuration setCheckIgnoreBlock:nil]; diff --git a/Rollbar/RollbarThread.m b/Rollbar/RollbarThread.m index 86e0852..0ba61d2 100644 --- a/Rollbar/RollbarThread.m +++ b/Rollbar/RollbarThread.m @@ -1,7 +1,7 @@ // Copyright (c) 2018 Rollbar, Inc. All rights reserved. #import "RollbarThread.h" -#import "RollbarLogger.h" +#import "SdkLog.h" @implementation RollbarThread { @private RollbarNotifier *_notifier; diff --git a/Rollbar/SdkLog.h b/Rollbar/SdkLog.h new file mode 100644 index 0000000..3f418b0 --- /dev/null +++ b/Rollbar/SdkLog.h @@ -0,0 +1,8 @@ +// Copyright (c) 2018 Rollbar Inc. All rights reserved. + +#import + +/// SDK-wide logging function. +/// Use it for all the development/debugging needs. +/// @param format logged message format +void SdkLog(NSString *format, ...); diff --git a/Rollbar/RollbarLogger.m b/Rollbar/SdkLog.m similarity index 77% rename from Rollbar/RollbarLogger.m rename to Rollbar/SdkLog.m index 9eb2121..2ea9b9f 100644 --- a/Rollbar/RollbarLogger.m +++ b/Rollbar/SdkLog.m @@ -1,8 +1,8 @@ // Copyright (c) 2018 Rollbar Inc. All rights reserved. -#import "RollbarLogger.h" +#import "SdkLog.h" -void RollbarLog(NSString *format, ...) { +void SdkLog(NSString *format, ...) { #ifdef DEBUG va_list args; va_start(args, format); diff --git a/RollbarFramework/RollbarFramework.h b/RollbarFramework/RollbarFramework.h index d38421b..61de8c8 100644 --- a/RollbarFramework/RollbarFramework.h +++ b/RollbarFramework/RollbarFramework.h @@ -18,13 +18,15 @@ FOUNDATION_EXPORT const unsigned char RollbarFrameworkVersionString[]; #import #import #import +#import // Deploys API #import #import -#import -#import +//#import +//#import +#import #import #import #import diff --git a/RollbarTests/RollbarConfigurationTests.m b/RollbarTests/RollbarConfigurationTests.m index ad4a3b3..e1d0a17 100644 --- a/RollbarTests/RollbarConfigurationTests.m +++ b/RollbarTests/RollbarConfigurationTests.m @@ -31,7 +31,7 @@ - (void)testDefaultRollbarConfiguration { - (void)testScrubWhitelistFields { NSString *scrubedContent = @"*****"; - NSArray *keys = @[@"client.os.app_name", @"client.os.os_version", @"body.message.body"]; + NSArray *keys = @[@"client.ios.app_name", @"client.ios.os_version", @"body.message.body"]; // define scrub fields: for (NSString *key in keys) { @@ -294,7 +294,7 @@ - (void)testPayloadModification { - (void)testScrubField { NSString *scrubedContent = @"*****"; - NSArray *keys = @[@"client.os.app_name", @"client.os.os_version", @"body.message.body"]; + NSArray *keys = @[@"client.ios.app_name", @"client.ios.os_version", @"body.message.body"]; for (NSString *key in keys) { [Rollbar.currentConfiguration addScrubField:key]; diff --git a/RollbarTests/RollbarDeploysTests.m b/RollbarTests/RollbarDeploysTests.m index adf1640..7c789cb 100644 --- a/RollbarTests/RollbarDeploysTests.m +++ b/RollbarTests/RollbarDeploysTests.m @@ -15,6 +15,7 @@ @interface RollbarDeploysObserver : NSObject @end @implementation RollbarDeploysObserver + - (void)onRegisterDeploymentCompleted:(DeployApiCallResult *)result { NSLog(@"%@", result); } diff --git a/RollbarTests/RollbarTelemetryTests.m b/RollbarTests/RollbarTelemetryTests.m index 664b80c..a3c5e6b 100644 --- a/RollbarTests/RollbarTelemetryTests.m +++ b/RollbarTests/RollbarTelemetryTests.m @@ -3,6 +3,7 @@ #import #import "Rollbar.h" #import "RollbarTestUtil.h" +#import "RollbarLog.h" @interface RollbarTelemetryTests : XCTestCase @@ -101,4 +102,15 @@ - (void)testTelemetryViewEventScrubbing { XCTAssertTrue([@"My Password" compare:[telemetryEvents[1] valueForKeyPath:@"body.content"]] == NSOrderedSame); } +- (void)testRollbarLog { + Rollbar.currentConfiguration.telemetryEnabled = YES; + Rollbar.currentConfiguration.captureLogAsTelemetryData = YES; + + [RollbarTelemetry.sharedInstance clearAllData]; + NSNumber *counter = [NSNumber numberWithInt:123]; + RollbarLog(@"Logging with telemetry %@", counter); + NSArray *telemetryEvents = [RollbarTelemetry.sharedInstance getAllData]; + XCTAssertEqual(telemetryEvents.count, 1); +} + @end