Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "environment" and "release" fields, optionally send event fingerprints #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions raven/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ local catcher_trace_level = 4
-- find a sender suitable with your application
-- @field level Set the message level (string), defaults to `"error"`
-- @field logger Sets the message logger (string), defaults to `"root"`
-- @field release Sets the release id for message, defaults to `SENTRY_RELEASE`
-- environment variable
-- @field environment Sets the environment id for message, default to
-- `SENTRY_ENVIRONMENT` environment variable
-- @field tags Defaults tags for sent messages, defaults to `{}`. Example:
-- `{ "foo"="bar", ... }`
-- @field extra Default extra data sent with messages, defaults to `{}`
Expand Down Expand Up @@ -128,12 +132,16 @@ _M.capture_error_handler = capture_error_handler
-- },
-- tags = { foo = "bar", abc = "def" },
-- logger = "foo",
-- release = "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83",
-- environment = "staging",
-- }
function _M.new(conf)
local obj = {
sender = assert(conf.sender, "sender is required"),
level = conf.level or "error",
logger = conf.logger or "root",
release = conf.release or os.getenv("SENTRY_RELEASE"),
environment = conf.environment or os.getenv("SENTRY_ENVIRONMENT"),
tags = conf.tags or nil,
extra = conf.extra or nil,
}
Expand All @@ -160,6 +168,10 @@ end
-- useless frames. The internal raven frames are automatically skipped, so a
-- level of `1` is means that the direct caller will be reported as culprit.
--
-- @field fingerprint Event fingerprint array. See:
-- - https://docs.sentry.io/development/sdk-dev/attributes/
-- - https://docs.sentry.io/data-management/rollups/?platform=javascript#custom-grouping
--
-- @table report_conf


Expand Down Expand Up @@ -301,6 +313,8 @@ function raven_mt:send_report(json, conf)
json.level = self.level
json.platform = "lua"
json.logger = self.logger
json.release = self.release
json.environment = self.environment

if conf then
json.tags = merge_tables(conf.tags, self.tags)
Expand All @@ -309,6 +323,9 @@ function raven_mt:send_report(json, conf)
if conf.level then
json.level = conf.level
end
if conf.fingerprint then
json.fingerprint = conf.fingerprint
end
else
json.tags = self.tags
json.extra = self.extra
Expand Down