Code Monkey home page Code Monkey logo

raven-objc's Introduction

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) {
    RavenCaptureException(exception);
}

You can also capture errors:

NSError *error;
[[NSFileManager defaultManager] removeItemAtPath:@"some/path" error:&error];
RavenCaptureError(error);

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 Mac OS X 10.6.

Issues and questions

Have a bug? Please create an issue on GitHub!

https://github.com/getsentry/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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.