blipit 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +19 -3
- data/lib/blipit/version.rb +1 -1
- data/lib/blipit.rb +43 -3
- metadata +7 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 26c9f309ac743a11246ec29e103453393f9de8090a776825084447ab62b65a70
|
|
4
|
+
data.tar.gz: 5478afcc59b160311c19bd95979c5e199c7b24450923df33915d5ee073c308ef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7645f41801bf2e2bde5f645ac1388f28f8b8cb9497c423792b1f0c4857e0dd06dd65724e48f79d7ba7659dc5ce17efebb73925feab767fc357698c9c7441f0ff
|
|
7
|
+
data.tar.gz: c81edf9b9a303104f76da895e5d02698a4dd66936e121f1a47a69ab24a364fe054ac8bb811572fb79d4c885a8bf208a8e2e56657687d281ed760d0390f821b17
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
## 0.2.0
|
|
2
|
+
|
|
3
|
+
- `Blipit.init` with an empty key or project id prints a warning, returns false and leaves Blipit off instead of raising ArgumentError.
|
|
4
|
+
- Rails: `sentry-rails` is loaded automatically when it is in the Gemfile, so controller and job errors are reported; without it `Blipit.init` warns that controller errors will not be sent.
|
|
5
|
+
- `capture_security` takes `kind` and `actor` positionally or as keywords; a missing actor prints a warning instead of raising.
|
data/README.md
CHANGED
|
@@ -20,11 +20,24 @@ require "blipit"
|
|
|
20
20
|
Blipit.init(key: "<public key>", project: <project id>, environment: "production", release: "myapp@1.4.2")
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
Both values are on the project's Keys page at app.blipit.io. Unhandled exceptions are reported on their own.
|
|
23
|
+
Both values are on the project's Keys page at app.blipit.io. Unhandled exceptions are reported on their own. If the key or project id is empty (for example an unset environment variable), `init` prints a warning, returns `false` and Blipit stays off; it never raises, so a missing key cannot stop the app from booting.
|
|
24
24
|
|
|
25
25
|
## Rails
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
Rails rescues controller and job errors before they reach Ruby, so Rails apps need `sentry-rails` next to `blipit`:
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
gem "blipit"
|
|
31
|
+
gem "sentry-rails"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Then put the `Blipit.init` call in `config/initializers/blipit.rb`:
|
|
35
|
+
|
|
36
|
+
```ruby
|
|
37
|
+
Blipit.init(key: ENV["BLIPIT_KEY"], project: ENV["BLIPIT_PROJECT"], environment: Rails.env, release: ENV["GIT_SHA"])
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`blipit` loads `sentry-rails` on its own when Rails is running, and `Blipit.init` configures it, so controller errors, job errors and request context are reported. Without `sentry-rails` in the Gemfile, `Blipit.init` prints a warning saying controller errors will not be sent.
|
|
28
41
|
|
|
29
42
|
## Manual capture
|
|
30
43
|
|
|
@@ -40,9 +53,12 @@ Blipit.add_breadcrumb("cache cleared", category: "cache")
|
|
|
40
53
|
|
|
41
54
|
```ruby
|
|
42
55
|
Blipit.capture_security("login_failed", email, outcome: "wrong password", ip: request.remote_ip, user_agent: request.user_agent)
|
|
56
|
+
Blipit.capture_security(kind: "login_failed", actor: email, ip: request.remote_ip)
|
|
43
57
|
```
|
|
44
58
|
|
|
45
|
-
|
|
59
|
+
Both forms work. Without a kind or an actor it prints a warning and sends nothing instead of raising.
|
|
60
|
+
|
|
61
|
+
`kind` is one of `login_failed`, `login_blocked`, `login_succeeded`, `password_reset_requested` or `privilege_granted`; any other kind arrives as a plain message. Login attempts need the project's secret key (init with it on the server) and the Scale plan; with the public key ingest refuses them with 403 `security_needs_secret_key`.
|
|
46
62
|
|
|
47
63
|
## Performance
|
|
48
64
|
|
data/lib/blipit/version.rb
CHANGED
data/lib/blipit.rb
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
require "sentry-ruby"
|
|
2
2
|
require_relative "blipit/version"
|
|
3
3
|
|
|
4
|
+
if defined?(::Rails::Railtie)
|
|
5
|
+
begin
|
|
6
|
+
require "sentry-rails"
|
|
7
|
+
rescue LoadError
|
|
8
|
+
nil
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
4
12
|
module Blipit
|
|
5
13
|
DEFAULT_ENDPOINT = "https://in.blipit.io"
|
|
6
14
|
WARNING_KINDS = %w[login_failed login_blocked].freeze
|
|
15
|
+
PUBLIC_KEY_WARNING = "[blipit] login attempts need the project's secret key (blipit_sk_...). " \
|
|
16
|
+
"This SDK was started with the public key, so capture_security sends nothing. " \
|
|
17
|
+
"Use the secret key on the server."
|
|
18
|
+
MISSING_KEY_WARNING = "[blipit] Blipit.init got no key, so Blipit is off and nothing is sent. " \
|
|
19
|
+
"Pass the project's key (app.blipit.io, Keys), for example from ENV[\"BLIPIT_KEY\"]; " \
|
|
20
|
+
"with Rails config caching, check that the value is set where the app boots."
|
|
21
|
+
MISSING_PROJECT_WARNING = "[blipit] Blipit.init got no project id, so Blipit is off and nothing is sent. " \
|
|
22
|
+
"Pass project: with the id from the project's Keys page at app.blipit.io."
|
|
23
|
+
RAILS_WARNING = "[blipit] Rails is loaded but sentry-rails is not, so errors raised in controllers and jobs are not reported " \
|
|
24
|
+
"(Rails rescues them before they reach Ruby). Add gem \"sentry-rails\" to your Gemfile next to gem \"blipit\" " \
|
|
25
|
+
"and run bundle install."
|
|
26
|
+
MISSING_ACTOR_WARNING = "[blipit] capture_security needs a kind and an actor, so this login attempt was not sent."
|
|
7
27
|
|
|
8
28
|
class << self
|
|
9
29
|
def dsn(key, project, endpoint = DEFAULT_ENDPOINT)
|
|
@@ -13,8 +33,16 @@ module Blipit
|
|
|
13
33
|
end
|
|
14
34
|
|
|
15
35
|
def init(key:, project:, environment: nil, release: nil, traces_sample_rate: 0.0, endpoint: DEFAULT_ENDPOINT, **options)
|
|
16
|
-
|
|
17
|
-
|
|
36
|
+
if key.nil? || key.to_s.strip.empty?
|
|
37
|
+
warn(MISSING_KEY_WARNING)
|
|
38
|
+
return false
|
|
39
|
+
end
|
|
40
|
+
if project.nil? || project.to_s.strip.empty?
|
|
41
|
+
warn(MISSING_PROJECT_WARNING)
|
|
42
|
+
return false
|
|
43
|
+
end
|
|
44
|
+
@public_key = key.to_s.start_with?("blipit_pk_")
|
|
45
|
+
warn(RAILS_WARNING) if defined?(::Rails::Railtie) && !defined?(::Sentry::Rails)
|
|
18
46
|
|
|
19
47
|
Sentry.init do |config|
|
|
20
48
|
config.dsn = dsn(key, project, endpoint)
|
|
@@ -25,6 +53,7 @@ module Blipit
|
|
|
25
53
|
options.each { |name, value| config.public_send("#{name}=", value) }
|
|
26
54
|
yield config if block_given?
|
|
27
55
|
end
|
|
56
|
+
true
|
|
28
57
|
end
|
|
29
58
|
|
|
30
59
|
def capture_exception(error, **options)
|
|
@@ -47,7 +76,18 @@ module Blipit
|
|
|
47
76
|
Sentry.add_breadcrumb(Sentry::Breadcrumb.new(message: message, category: category, level: level, data: data))
|
|
48
77
|
end
|
|
49
78
|
|
|
50
|
-
def capture_security(kind, actor, outcome: nil, actor_id: nil, ip: nil, user_agent: nil, target: nil)
|
|
79
|
+
def capture_security(kind_arg = nil, actor_arg = nil, kind: nil, actor: nil, outcome: nil, actor_id: nil, ip: nil, user_agent: nil, target: nil)
|
|
80
|
+
kind ||= kind_arg
|
|
81
|
+
actor ||= actor_arg
|
|
82
|
+
if kind.to_s.empty? || actor.to_s.strip.empty?
|
|
83
|
+
warn(MISSING_ACTOR_WARNING)
|
|
84
|
+
return
|
|
85
|
+
end
|
|
86
|
+
if @public_key
|
|
87
|
+
warn(PUBLIC_KEY_WARNING) unless @public_key_warned
|
|
88
|
+
@public_key_warned = true
|
|
89
|
+
return
|
|
90
|
+
end
|
|
51
91
|
payload = {
|
|
52
92
|
kind: kind,
|
|
53
93
|
actor: actor,
|
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: blipit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Louward Labs
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: bin
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
11
|
+
date: 2026-10-11 00:00:00.000000000 Z
|
|
11
12
|
dependencies:
|
|
12
13
|
- !ruby/object:Gem::Dependency
|
|
13
14
|
name: logger
|
|
@@ -72,6 +73,7 @@ executables: []
|
|
|
72
73
|
extensions: []
|
|
73
74
|
extra_rdoc_files: []
|
|
74
75
|
files:
|
|
76
|
+
- CHANGELOG.md
|
|
75
77
|
- README.md
|
|
76
78
|
- lib/blipit.rb
|
|
77
79
|
- lib/blipit/version.rb
|
|
@@ -83,6 +85,7 @@ metadata:
|
|
|
83
85
|
documentation_uri: https://docs.blipit.io/ruby
|
|
84
86
|
changelog_uri: https://blipit.io/changelog
|
|
85
87
|
rubygems_mfa_required: 'true'
|
|
88
|
+
post_install_message:
|
|
86
89
|
rdoc_options: []
|
|
87
90
|
require_paths:
|
|
88
91
|
- lib
|
|
@@ -97,7 +100,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
97
100
|
- !ruby/object:Gem::Version
|
|
98
101
|
version: '0'
|
|
99
102
|
requirements: []
|
|
100
|
-
rubygems_version:
|
|
103
|
+
rubygems_version: 3.5.22
|
|
104
|
+
signing_key:
|
|
101
105
|
specification_version: 4
|
|
102
106
|
summary: Blipit error monitoring for Ruby and Rails
|
|
103
107
|
test_files: []
|