blipit 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26c9f309ac743a11246ec29e103453393f9de8090a776825084447ab62b65a70
4
- data.tar.gz: 5478afcc59b160311c19bd95979c5e199c7b24450923df33915d5ee073c308ef
3
+ metadata.gz: e3b3f5df2c1e54476b7900840749686a2fb0d3428f41722ccfe507431d52bbf7
4
+ data.tar.gz: 509a9d7e0673ea9a82600a798e6f4f71e8d5341633b46754b1e6292a2e4d94b2
5
5
  SHA512:
6
- metadata.gz: 7645f41801bf2e2bde5f645ac1388f28f8b8cb9497c423792b1f0c4857e0dd06dd65724e48f79d7ba7659dc5ce17efebb73925feab767fc357698c9c7441f0ff
7
- data.tar.gz: c81edf9b9a303104f76da895e5d02698a4dd66936e121f1a47a69ab24a364fe054ac8bb811572fb79d4c885a8bf208a8e2e56657687d281ed760d0390f821b17
6
+ metadata.gz: 8039c976e246061ceb6144765687e628708c7b317d414fc0e5cc6aa33231f4f857fe8d0b284457ace8abdaf11c8ab9eb974216ceabcbadfc1da4b7ac4513719b
7
+ data.tar.gz: 554c68f653f4c30640355ffc67353e386d81a0271a62aa699780d9af6446543305a381d188c6d8f2c0ae72f3344cc5aee9557dfe79cd33c8872b919e1b7b1bdb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.2.1
2
+
3
+ - Events carry the `gem:blipit` package and version, so the dashboard can show when this project runs an old Blipit SDK. A `before_send` you set still runs after it.
4
+ - In development (`environment: "development"` or `debug: true`) the SDK warns once per process when a newer version is out: `[blipit] 0.2.2 is available (you have 0.2.1) — <why> — bundle update blipit`. It reads a header on the responses to events it already sends (no extra request); a custom `transport_class` is left alone. Nothing is printed in production.
5
+
1
6
  ## 0.2.0
2
7
 
3
8
  - `Blipit.init` with an empty key or project id prints a warning, returns false and leaves Blipit off instead of raising ArgumentError.
data/README.md CHANGED
@@ -65,3 +65,7 @@ Both forms work. Without a kind or an actor it prints a warning and sends nothin
65
65
  Pass `traces_sample_rate: 0.2` to `init` and requests show up on the Performance page.
66
66
 
67
67
  Docs: https://docs.blipit.io/ruby
68
+
69
+ ## Updates
70
+
71
+ In development Blipit prints one line when a newer version is out, with the reason and the command. Update with `bundle update blipit`. Details: https://docs.blipit.io/updates
@@ -1,3 +1,3 @@
1
1
  module Blipit
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/blipit.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require "sentry-ruby"
2
+ require "json"
3
+ require "uri"
2
4
  require_relative "blipit/version"
3
5
 
4
6
  if defined?(::Rails::Railtie)
@@ -24,6 +26,18 @@ module Blipit
24
26
  "(Rails rescues them before they reach Ruby). Add gem \"sentry-rails\" to your Gemfile next to gem \"blipit\" " \
25
27
  "and run bundle install."
26
28
  MISSING_ACTOR_WARNING = "[blipit] capture_security needs a kind and an actor, so this login attempt was not sent."
29
+ UPDATE_COMMAND = "bundle update blipit"
30
+ PACKAGE = { "name" => "gem:blipit", "version" => VERSION }.freeze
31
+
32
+ if Sentry::HTTPTransport.method_defined?(:do_request)
33
+ class NoticeTransport < Sentry::HTTPTransport
34
+ def do_request(*args)
35
+ response = super
36
+ Blipit.notice(response)
37
+ response
38
+ end
39
+ end
40
+ end
27
41
 
28
42
  class << self
29
43
  def dsn(key, project, endpoint = DEFAULT_ENDPOINT)
@@ -52,10 +66,53 @@ module Blipit
52
66
  config.send_default_pii = false
53
67
  options.each { |name, value| config.public_send("#{name}=", value) }
54
68
  yield config if block_given?
69
+ user_before_send = config.before_send
70
+ config.before_send = lambda do |event, hint|
71
+ with_identity(event)
72
+ user_before_send ? user_before_send.call(event, hint) : event
73
+ end
74
+ if (config.environment == "development" || config.debug) && config.transport.transport_class.nil? && defined?(NoticeTransport)
75
+ config.transport.transport_class = NoticeTransport
76
+ end
55
77
  end
56
78
  true
57
79
  end
58
80
 
81
+ def update_notice(header, current = VERSION)
82
+ latest = JSON.parse(URI.decode_www_form_component(header.to_s.gsub("+", "%2B")))
83
+ version = latest.is_a?(Hash) ? latest["version"] : nil
84
+ return nil unless version.is_a?(String) && !version.empty? && version != current
85
+
86
+ note = latest["note"].is_a?(String) ? latest["note"].strip : ""
87
+ why = note.empty? ? "" : " — #{note}"
88
+ "[blipit] #{version} is available (you have #{current})#{why} — #{UPDATE_COMMAND}"
89
+ rescue StandardError
90
+ nil
91
+ end
92
+
93
+ def notice(response)
94
+ return if @noticed
95
+
96
+ header = response["x-blipit-latest"]
97
+ line = header && update_notice(header)
98
+ return unless line
99
+
100
+ @noticed = true
101
+ warn(line)
102
+ rescue StandardError
103
+ nil
104
+ end
105
+
106
+ def with_identity(event)
107
+ sdk = event.sdk.is_a?(Hash) ? event.sdk : {}
108
+ packages = Array(sdk["packages"] || sdk[:packages])
109
+ return if packages.any? { |p| p.is_a?(Hash) && (p["name"] || p[:name]) == PACKAGE["name"] }
110
+
111
+ event.sdk = sdk.merge("packages" => packages + [PACKAGE.dup])
112
+ rescue StandardError
113
+ nil
114
+ end
115
+
59
116
  def capture_exception(error, **options)
60
117
  Sentry.capture_exception(error, **options)
61
118
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blipit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louward Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-11 00:00:00.000000000 Z
11
+ date: 2026-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logger