Skip to content

Nyvra/raven-objc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

raven-objc

Objective-c client for Sentry.

Installation

The easiest way is to use CocoaPods. It takes care of all required frameworks and third party dependencies:

pod 'Raven'

Alternatively, you can install manually.

  1. Get the code: git clone git://github.com/getsentry/raven-objc
  2. Drag the Raven subfolder to your project. Check both "copy items into destination group's folder" and your target.

Alternatively you can add this code as a Git submodule:

  1. cd [your project root]
  2. git submodule add git://github.com/getsentry/raven-objc
  3. Drag the Raven subfolder to your project. Uncheck the "copy items into destination group's folder" box, do check your target.

How to get started

While you are free to initialize as many instances of RavenClient as is appropriate for your application, there is a shared singleton instance that is globally available. This singleton instance is often configured in your app delegate's application:didFinishLaunchingWithOptions: method:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [RavenClient clientWithDSN:@"[SENTRY_DSN]"];
    // [...]
    return YES;
}

The first RavenClient that is initialized is automatically configured as the singleton instance and becomes available via the sharedClient singleton method:

NSLog(@"I am your RavenClient singleton : %@", [RavenClient sharedClient]);

Sending messages

// Sending a basic message (note, does not include a stacktrace):
[[RavenClient sharedClient] captureMessage:@"TEST 1 2 3"];

// Sending a message with another level and a stacktrace:
[[RavenClient sharedClient] captureMessage:@"TEST 1 2 3" level:kRavenLogLevelDebugInfo method:__FUNCTION__ file:__FILE__ line:__LINE__];

// Recommended macro to send a message with automatic stacktrace:
RavenCaptureMessage(@"TEST %i %@ %f", 1, @"2", 3.0);

Handling exceptions

Setup a global exception handler:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [RavenClient clientWithDSN:@"https://[public]:[secret]@[server]/[project id]"];
    [[RavenClient sharedClient] setupExceptionHandler];
    // [...]
    return YES;
}

Or, capture a single exception:

@try {
    [self performSelector:@selector(nonExistingSelector)];
}
@catch (NSException *exception) {
    [[RavenClient sharedClient] captureException:exception];
}

Note: when using the global exception handler, exceptions will be sent the next time the app is started.

Requirements

JSON

raven-objc uses NSJSONSerialization to generate the JSON payload, if it is available. If your app targets a platform where this class is not available (i.e. iOS < 5.0) you can include one of the following JSON libraries to your project for raven-objc to automatically detect and use.

ARC Support

raven-objc requires ARC support and should run on iOS 4.0 and higher.

Issues and questions

Have a bug? Please create an issue on GitHub!

https://github.com/kevinrenskers/raven-objc/issues

Contributing

raven-objc is an open source project and your contribution is very much appreciated.

  1. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug.
  2. Fork the repository on Github and make your changes.
  3. Make sure to add yourself to AUTHORS and send a pull request.

License

raven-objc is available under the MIT license. See the LICENSE file for more info.

About

Objective-c client for Sentry

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 98.8%
  • Ruby 1.2%