Module: LogSnag
- Includes:
- HTTParty
- Defined in:
- lib/logsnag.rb,
lib/logsnag/log.rb,
lib/logsnag/result.rb,
lib/logsnag/insight.rb,
lib/logsnag/version.rb,
lib/logsnag/identify.rb,
lib/logsnag/validator.rb,
lib/logsnag/event_base.rb,
lib/logsnag/configuration.rb
Overview
The main module for the LogSnag gem, containing methods for sending logs to LogSnag.
Defined Under Namespace
Classes: Configuration, EventBase, Identify, Insight, Log, Result, Validator
Constant Summary collapse
- PATHS =
{ LOG: "/log", IDENTIFY: "/identify", INSIGHT: "/insight" }.freeze
- VERSION =
"0.1.1"
Class Attribute Summary collapse
-
.config ⇒ Object
Returns the value of attribute config.
Class Method Summary collapse
-
.configure {|LogSnag::Configuration| ... } ⇒ Object
Configures LogSnag with the provided configuration options.
-
.identify(data = {}) ⇒ LogSnag::Result
Sends an identify log to LogSnag.
-
.insight(data = {}) ⇒ LogSnag::Result
Sends an insight log to LogSnag.
-
.log(data = {}) ⇒ LogSnag::Result
Sends an event log to LogSnag.
-
.mutate_insight(data = {}) ⇒ LogSnag::Result
Mutate an insight to LogSnag.
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
25 26 27 |
# File 'lib/logsnag.rb', line 25 def config @config end |
Class Method Details
.configure {|LogSnag::Configuration| ... } ⇒ Object
Configures LogSnag with the provided configuration options.
29 30 31 32 |
# File 'lib/logsnag.rb', line 29 def configure self.config ||= LogSnag::Configuration.new yield(config) end |
.identify(data = {}) ⇒ LogSnag::Result
Sends an identify log to LogSnag.
The identify endpoint lets you add key-value properties to a user profile. This endpoint is optional and useful for getting a complete picture of a user just by looking at their profile, and additionally, these properties can be used for filtering and searching.
For example, you may add a user’s email address, their plan, last payment date, etc., to their profile and then use these properties to filter and search for users, such as searching for all users on a specific plan.
The data hash MUST include the following keys:
- :user_id [String] The user ID of the user to be identified.
- :properties [Hash] The properties of the user to be identified.
75 76 77 78 |
# File 'lib/logsnag.rb', line 75 def identify(data = {}) event = LogSnag::Identify.new(data, config) execute_post(PATHS[:IDENTIFY], event) end |
.insight(data = {}) ⇒ LogSnag::Result
Sends an insight log to LogSnag.
Insights are real-time widgets that you can add to each of your projects. They are use-case agnostic and can be used to display any information that you want in real-time.
The data hash MUST include the following keys:
- :title [String] The title of the insight.
- :value [String,Numeric] The numerical value of the insight.
92 93 94 95 |
# File 'lib/logsnag.rb', line 92 def insight(data = {}) event = LogSnag::Insight.new(data, config) execute_post(PATHS[:INSIGHT], event) end |
.log(data = {}) ⇒ LogSnag::Result
Sends an event log to LogSnag.
Logs are the core of LogSnag. They are used to track events in your application. These events could be anything from user actions to server events, such as a database running out of space or a server crash.
The data hash MUST include the following keys:
- :channel [String] The channel within the project to which the log belongs.
- :event [String] The name of the event.
The data hash MAY include the following keys:
- :user_id [String] The user ID of the user to be identified.
- :description [String] The description of the event.
- :icon [String] The icon to be displayed with the event.
- :notify [Boolean] Whether or not to send a push notification for the event.
- :tags [Hash] The tags to be associated with the event.
- :parser [String] The parser to be used for the event. One of "text" or "markdown".
- :timestamp [Numeric] The timestamp of the event (in Unix seconds).
54 55 56 57 |
# File 'lib/logsnag.rb', line 54 def log(data = {}) event = LogSnag::Log.new(data, config) execute_post(PATHS[:LOG], event) end |
.mutate_insight(data = {}) ⇒ LogSnag::Result
Mutate an insight to LogSnag. This endpoint allows you to change (mutate) existing numerical insights. The data hash MUST include the following keys:
- :title [String] The title of the insight.
- :value [Numeric] The numerical value of the insight.
The data hash MAY include the following keys:
- :icon [String] The icon to be displayed with the event.
108 109 110 111 |
# File 'lib/logsnag.rb', line 108 def mutate_insight(data = {}) event = LogSnag::Insight.new(data, config, mutate: true) execute_patch(PATHS[:INSIGHT], event) end |