mbuzz 0.6.6 → 0.6.8

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: 8ea1fdea339cb1fef16425236d55c76bfd987a197f55d9262e43c18ccea24fcb
4
- data.tar.gz: c6f65a334a2bf5235275d00a6e887e1f08773c2e5716f104c33b43fea5ba66cd
3
+ metadata.gz: 0f4cc2a9e5dd77624d8c645e32752658da3ba5ce9464ade31c55571c96abd060
4
+ data.tar.gz: c26d4c8262ba89782b429e685d082c38688dea435ecb35cfb861ec7c97173b3b
5
5
  SHA512:
6
- metadata.gz: 6500201afc07182c1fadc0d229c5ff30a53034cfa0823037bfaca09b62e9e5c202213a57779524f4731b158d2c134ba87ec8637a2e289026f8f57e8b9d951709
7
- data.tar.gz: e888f57e931d43399c06640a7b9f7f2a497fe0d690dc7e56bf6138278c2f9754e9a4a1a8d98282814ef3a37aa75fd4829dda5704bc19f58334d196a60326f8c7
6
+ metadata.gz: 28ad02efc0768a343e259f7beb5828974fc8c818073f46e2f37d36b85e813806f158d66a3d2890aa208ba501b2236c06e863201b4297d3c4266f404cf138eabd
7
+ data.tar.gz: c410f3fa9c054560f14578c5618af4735359a793b63ecf3435e33653eeaa7ad13624003d9e00ca874660443ed1eb32bbec63ba2c40ec6a4ca45866b6263dc6e5
data/CHANGELOG.md CHANGED
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.6.8] - 2025-12-30
9
+
10
+ ### Added
11
+
12
+ - **Server-side session resolution support** - SDK now forwards `ip` and `user_agent` to the API for server-side session identification
13
+ - `ip` and `user_agent` parameters on `Mbuzz::Client.track()`
14
+ - `RequestContext#ip` method with proxy header support (X-Forwarded-For, X-Real-IP)
15
+ - `Mbuzz.event` automatically extracts and forwards ip/user_agent from request context
16
+
17
+ ### Technical Details
18
+
19
+ - IP extraction priority: `X-Forwarded-For` (first IP) > `X-Real-IP` > direct IP
20
+ - Enables accurate session tracking without client-side cookies
21
+ - Backwards compatible - ip/user_agent are optional parameters
22
+
8
23
  ## [0.6.0] - 2025-12-05
9
24
 
10
25
  ### Added
@@ -3,12 +3,14 @@
3
3
  module Mbuzz
4
4
  class Client
5
5
  class TrackRequest
6
- def initialize(user_id, visitor_id, session_id, event_type, properties)
6
+ def initialize(user_id, visitor_id, session_id, event_type, properties, ip = nil, user_agent = nil)
7
7
  @user_id = user_id
8
8
  @visitor_id = visitor_id
9
9
  @session_id = session_id
10
10
  @event_type = event_type
11
11
  @properties = properties
12
+ @ip = ip
13
+ @user_agent = user_agent
12
14
  end
13
15
 
14
16
  def call
@@ -39,6 +41,8 @@ module Mbuzz
39
41
  session_id: @session_id,
40
42
  event_type: @event_type,
41
43
  properties: @properties,
44
+ ip: @ip,
45
+ user_agent: @user_agent,
42
46
  timestamp: Time.now.utc.iso8601
43
47
  }.compact
44
48
  end
data/lib/mbuzz/client.rb CHANGED
@@ -7,8 +7,8 @@ require_relative "client/session_request"
7
7
 
8
8
  module Mbuzz
9
9
  class Client
10
- def self.track(user_id: nil, visitor_id: nil, session_id: nil, event_type:, properties: {})
11
- TrackRequest.new(user_id, visitor_id, session_id, event_type, properties).call
10
+ def self.track(user_id: nil, visitor_id: nil, session_id: nil, event_type:, properties: {}, ip: nil, user_agent: nil)
11
+ TrackRequest.new(user_id, visitor_id, session_id, event_type, properties, ip, user_agent).call
12
12
  end
13
13
 
14
14
  def self.identify(user_id:, visitor_id: nil, traits: {})
@@ -33,6 +33,12 @@ module Mbuzz
33
33
  @request.user_agent
34
34
  end
35
35
 
36
+ def ip
37
+ @request.env["HTTP_X_FORWARDED_FOR"]&.split(",")&.first&.strip ||
38
+ @request.env["HTTP_X_REAL_IP"] ||
39
+ @request.ip
40
+ end
41
+
36
42
  def enriched_properties(custom = {})
37
43
  { url: url, referrer: referrer }.compact.merge(custom)
38
44
  end
data/lib/mbuzz/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mbuzz
4
- VERSION = "0.6.6"
4
+ VERSION = "0.6.8"
5
5
  end
data/lib/mbuzz.rb CHANGED
@@ -104,7 +104,9 @@ module Mbuzz
104
104
  session_id: session_id,
105
105
  user_id: user_id,
106
106
  event_type: event_type,
107
- properties: enriched_properties(properties)
107
+ properties: enriched_properties(properties),
108
+ ip: current_ip,
109
+ user_agent: current_user_agent
108
110
  )
109
111
  end
110
112
 
@@ -176,4 +178,14 @@ module Mbuzz
176
178
  RequestContext.current.enriched_properties(custom_properties)
177
179
  end
178
180
  private_class_method :enriched_properties
181
+
182
+ def self.current_ip
183
+ RequestContext.current&.ip
184
+ end
185
+ private_class_method :current_ip
186
+
187
+ def self.current_user_agent
188
+ RequestContext.current&.user_agent
189
+ end
190
+ private_class_method :current_user_agent
179
191
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mbuzz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
4
+ version: 0.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - mbuzz team