Fyipe SDK

A fyipe sdk for application logger that can be used to send logs about your applications created on your fypie dashboard which can also used for error tracking

Installation

Gem Install

Via Gem

 gem install fyipe

Basic Usage for Logging

require 'fyipe'

# constructor
logger = FyipeLogger.new(
    'API_URL', # https://fyipe.com/api
    'APPLICATION_LOG_ID',
    'APPLICATION_LOG_KEY'
)


# Sending a string log to the server
item = 'This is a simple log'

response = logger.log(item)

# response after logging a request
puts response


# Sending an object log to the server
item = {
    "name" => "Tony Lewinsky",
    "location" => "Liverpool"
}

response = logger.log(item)
# response after logging a request
puts response

# alternatively, tags can be added to the logged item.
item = 'This is a simple log'
# using a tag string
tag = 'server-side-error'
response = logger.log(item, tag)
# response after logging a request
puts response

# Using an array of strings
tags = ['error', 'server']
response = logger.log(item, tags)
# response after logging a request
puts response

Basic Usage for Tracking

require 'fyipe'

# set up tracking configurations
options = {
    "maxTimeline": 50,
    "captureCodeSnippet": true
}

# constructor
tracker = FyipeLogger.new(
    'API_URL', # https://fyipe.com/api
    'ERROR_TRACKER_ID',
    'ERROR_TRACKER_KEY',
    options # optional
)

# capturing a timeline manually
timelineContent = {}

timelineContent["account"] = "debit"
timelineContent["amount"] = "6000.00"
timelineContent["userId"] = 471
tracker.addToTimeline('payment', timelineContent, 'info')

# setting custom tags
tracker.setTag('category', 'QA Tester') # a single tag

# multiple tags
tags = []

# create two tags
tagOne = {}
tagOne["key"] = 'type'
tagOne["value"] = 'notification'
tagTwo = {}
tagTwo["key"] = 'location'
tagTwo["value"] = 'Oslo'

# add the two items to the array
tags = [tagOne, tagTwo]

# setting the array of tags
tracker.setTags(tags)


# all error exception captured are sent to your fyipe dashboard

# capturing errors in a begin and rescue
begin
    # some code that might fail
    result = 5/0 # Should throw a division by zero error
rescue => ex
    tracker.captureException(ex)
end

# capturing errors using the message signature
tracker.captureMessage('some error text')

# capturing errors authomatically
NonExistingMethod() # calling this will trigger an error and its sent to your fyipe dashboard

API Documentation

Main API to send logs to the server.

Author: HackerBay, Inc.

FyipeLogger.new(apiUrl, applicationId, applicationKey)

Create a constructor from the class, which will be used to send logs to the server.

Kind: Constructor Returns: null

Param Type Description
\apiUrl string The Server URL.
\applicationId string The Application Log ID.
\applicationKey string The Application Log Key.

logger.log(log, \tags)

Logs a request of type info to the server.

Kind: method of FyipeLogger.new Returns: Object - An object response of a success or failure.

Param Type Description
\log string \ Object
\tags string \ Array

logger.warning(warning, \tags)

Logs a request of type warning to the server.

Kind: method of FyipeLogger.new Returns: Object - An object response of a success or failure.

Param Type Description
\warning string \ Object
\tags string \ Array

logger.error(error, \tags)

Logs a request of type error to the server.

Kind: method of FyipeLogger.new Returns: Object - An object response of a success or failure.

Param Type Description
\error string \ Object
\tags string \ Array

FyipeTracker.new(apiUrl, errorTrackerId, errorTrackerKey)

Create a constructor from the class, which will be used to track errors sent to the server.

Kind: Constructor Returns: null

Param Type Description
apiUrl string The Server URL.
errorTrackerId string The Error Tracker ID.
errorTrackerKey string The Error Tracker Key.
option object The options to be considred by the tracker.

options

Param Type Description
maxTimeline int The total amount of timeline that should be captured, defaults to 5
captureCodeSnippet boolean When set as true stack traces are automatically attached to all error sent to your fyipe dashboard.

tracker.setTag(key, value)

Set tag for the error to be sent to the server.

Kind: method of FyipeTracker Returns: null

Param Type Description
key string The key for the tag.
value string The value for the tag.

tracker.setTags([value])

Set multiple tags for the error to be sent to the server. Takes in a list

Kind: method of FyipeTracker Returns: null

Param Type Description
key string The key for the tag.
value string The value for the tag.

tracker.setFingerprint(fingerprint)

Set fingerprint for the next error to be captured.

Kind: method of FyipeTracker Returns: null

Param Type Description
fingerprint string \ list of strings

tracker.addToTimeline(category, content, type)

Add a custom timeline element to the next error to be sent to the server

Kind: method of FyipeTracker Returns: null

Param Type Description
category string The category of the timeline event.
content string \ object
type string The type of timeline event.

tracker.captureMessage(message)

Capture a custom error message to be sent to the server

Kind: method of FyipeTracker Returns: Promise

Param Type Description
message string The message to be sent to the server.

tracker.captureException(error)

Capture a custom error object to be sent to the server

Kind: method of FyipeTracker Returns: Promise

Param Type Description
error Exception object The Error Object to be sent to the server.

Contribution

  • Clone repository
  • run cd ruby-sdk/fyipe
  • run bundle install to install dependencies
  • run bundle exec rspec to run tests