Socket
Book a DemoInstallSign in
Socket

trakerr_client

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trakerr_client

2.0.0
bundlerRubygems
Version published
Maintainers
2
Created
Source

Trakerr-ruby API client

Get your application events and errors to Trakerr via the Trakerr API.

You will need your API key to send events to trakerr.

Overview

  • REST API version: 2.0.0
  • Package (SDK) version: 2.0.0

Requirements.

Ruby 1.9.3+ and git 2.0+

Installation & Usage

1) Install git and curl

You will need git for the gem to work properly. If you do not have it installed, we recomment installing it from your package manager. You can use your package manager to install it on unix based machines. For machines using apt (ex: Ubuntu)

apt install git

For machines using yum (ex: centOS)

yum install git

For Windows, or if you aren't using a package manager, visit https://git-scm.com/ and download and install it manually. Make sure it is added to your path (open your command prompt and type git --version. If it works, you're set.)

If you are on Windows, you may also need to install curl and configure your ruby to use it. Trakerr uses typhous to actually send the exception to us. Follow the instructions on the curl website for more information and Typhous's project page to finish setup.

2) gem install

Install bundler and then you can issue this command to get the freshest version:

gem "trakerr_client", :git => "git://github.com/trakerr-io/trakerr-ruby.git"

You can also install from ruby gems:

gem install trakerr_client

for the latest stable release.

Then import the package:

require 'trakerr/lib/trakerr'

Getting Started

Please follow the installation procedure and you're set to add Trakerr to your project. All of these examples are included in test_app.rb.

If you would like to generate some quick sample events, you may download test_app.rb and run it from the command line like so:

ruby test_app.rb <api key here>

Sending Data

Require the package:

require 'trakerr/lib/trakerr'

Option 1: Sending a default error to Trakerr

A trivial case would involve calling log for a caught exception.

def main()
    testApp = Trakerr::TrakerrClient.new("Api key here", "Application version number", "deployment type")
    begin
        raise ZeroDivisionError, "Oh no!"
    rescue ZeroDivisionError => exception
        #You can leave the hash empty if you would like to use the default values.
        #We recommend that you supply a user and a session for all events,
        #and supplying an "evntname" and "evntmessage" for non errors.
        testApp.log({"user"=>"jack@trakerr.io", "session"=>"7"}, exception) 
    end
end

Along with the "user" and "session"; the hash can also take "evntname" and "evntmessage". Note that these two will be filled in automatically for errors you rescue if you do not provide them, so we suggest giving them for non-errors.

log may also take in a log_level and a classification (We recommend you providing this especially if you send a warning or below), but will otherwise default all of the AppEvent properties.

Option 2: Sending an error to Trakerr with Custom Data

If you want to populate the AppEvent fully with custom properties (log only accepts the minimum set of useful custom properties to utilize Trakerr's rich feature set), you can manually create an AppEvent and populate it's fields. Pass it to the SendEvent to then send the AppEvent to Trakerr. See the AppEvent API for more information on it's properties.

def main()
    testApp = Trakerr::TrakerrClient.new("Api key here", "Application version number", "deployment type")
    begin
        raise ArgumentError
    rescue Exception => e
        appev = testApp.CreateAppEvent(e)
        appev.event_user = "john@trakerr.io"
        appev.event_session = "5"

        testApp.SendEvent(appev)
    end
end

Option 3: Send a non-exception to Trakerr

Trakerr accepts events that aren't errors. To do so, pass false to the CreateAppEvent Exception field to not attach a stacktrace to the event (if you don't need it). Be sure to pass values in to the rest of the parameters since the default values will most likely not be useful for you if you don't have a stacktrace!

def main()
    testApp = Trakerr::TrakerrClient.new("Api key here", "Application version number", "deployment type")
    
    #Send a non Exception to Trakerr.
    appev2 = testApp.CreateAppEvent(false, "Info", "User failed auth", "Passwords are different", "User error")
    appev2.event_user = "jill@trakerr.io"
    appev2.event_session = "3"

    testApp.SendEvent(appev2)
end

An in-depth look at TrakerrClient's properties

TrakerrClient's constructor initalizes the default values to all of TrakerrClient's properties.

 def initialize(def initialize(apiKey,
                   contextAppVersion = "1.0",
                   contextDeploymentStage = "development")

The TrakerrClient class however has a lot of exposed properties. The benefit to setting these immediately after after you create the TrakerrClient is that AppEvent will default it's values against the TrakerClient that created it. This way if there is a value that all your AppEvents uses, and the constructor default value currently doesn't suit you; it may be easier to change it in TrakerrClient as it will become the default value for all AppEvents created after. A lot of these are populated by default value by the constructor, but you can populate them with whatever string data you want. The following table provides an in-depth look at each of those.

NameTypeDescriptionNotes
apiKeystringAPI key generated for the application
contextAppVersionstringApplication version information.Default value: "1.0"
contextDevelopmentStagestringOne of development, staging, production; or a custom string.Default Value: "develoment"
contextEnvLanguagestringConstant string representing the language the application is in.Default value: "ruby"
contextEnvNamestringName of the interpreter the program is run on.Default Value: ruby if ruby MRI or jruby if jruby
contextEnvVersionstringVersion of ruby this program is running on.Default Value: JRUBY_VERSION if jruby or RUBY_VERSION if ruby MRI
contextEnvHostnamestringHostname or ID of environment.Default value: Socket.gethostname
contextAppOSstringOS the application is running on.Default value: OS name (ie. Windows, MacOS).
contextAppOSVersionstringOS Version the application is running on.Default value: System architecture string.
contextAppOSBrowserstringAn optional string browser name the application is running on.Defaults to nil
contextAppOSBrowserVersionstringAn optional string browser version the application is running on.Defaults to nil
contextDataCenterstringData center the application is running on or connected to.Defaults to nil
contextDataCenterRegionstringData center region.Defaults to nil

Documentation For Models

Author

RM

FAQs

Package last updated on 27 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.