mbuzz 0.10.1 → 0.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71d8b00de3facb7fd1290c03f1493edf09586333ad6ea44e1de03ebba375805f
4
- data.tar.gz: 69eac0945b4b2630038753770fd398154cc1d407e15e9e8ff0d1770fb53bf95d
3
+ metadata.gz: ff302e119aa981ced654677a020929b3b2065055961e253b08e106b52750fed4
4
+ data.tar.gz: ed21ef016dcbac2bb9918a07f03efcce264b9f01046a1ada510e526a107c7ed1
5
5
  SHA512:
6
- metadata.gz: 5f0a99184a1860342c7088c1642495d11db115ecbd7571bfffd6f29ea8fc770d6d0ea3d473f1ae7a6681eadb19d8b387ce86968df369d5e785301a1f157b2ad3
7
- data.tar.gz: 3ba3d4419fa579e5840a46e398202637f4d7f5b119fbc2815b1cac5db1504f4d0f69a5d68481ad1075bb875d42e0121aa9f06696bf9cc9a254accb9c7a1a0aab
6
+ metadata.gz: 6f9e1ff36c152c2eaa085892b41f7e18e995f7de122413d6d42cc4d44d2199f6e8fa3096ce2e06be4b87a6b2a8daaebcaf80d037e11e85df9298d9b3a33f7e27
7
+ data.tar.gz: 1a18bdf46411b450c247396d595e094404d6b8f7ef487560c8af697c65317f2f6efcf1969a0a86b3a9b349a95f89fd0dce5b546a4d9d5307dd99cf0a3b9d3f85
data/CHANGELOG.md CHANGED
@@ -5,6 +5,24 @@ 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.11.0] - 2026-10-14
9
+
10
+ ### Added
11
+
12
+ - **Meta's `_fbp` is forwarded on the session call.** The SDK reads the `_fbp` cookie the customer's
13
+ Meta Pixel already set and sends it as `fbp` on the session payload, on both paths (the session
14
+ endpoint and the tracking middleware). Meta merges a server event with the browser Pixel's event on
15
+ `event_name` + `fbp` when the event IDs differ, so without it every server `Lead` counted as a
16
+ second one. Accepts Meta's `fb.<n>.<ts>.<random>` and the optional appendix its server-side
17
+ Parameter Builder adds (`...AQECAQIB`); anything else is dropped. Never written, never invented.
18
+ The key is omitted, not null, when the cookie is absent or malformed. No install change needed.
19
+
20
+ ### Fixed
21
+
22
+ - **A session call made outside Rack/Rails failed silently.** `SessionRequest` called
23
+ `Time#iso8601` without `require "time"`; Rack and Rails load it, a plain script did not, and the
24
+ `NoMethodError` was rescued to `false`.
25
+
8
26
  ## [0.10.1] - 2026-09-17
9
27
 
10
28
  ### Fixed — the visitor's IP now reaches mbuzz on session create
@@ -1,5 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Time#iso8601 lives here, not in core. Rack and Rails load it; a plain script
4
+ # did not, and the session call then failed silently (rescued to false).
5
+ require "time"
6
+
3
7
  module Mbuzz
4
8
  class Client
5
9
  class SessionRequest
@@ -13,7 +17,7 @@ module Mbuzz
13
17
  ACCEPTED_STATUS = "accepted"
14
18
 
15
19
  def initialize(visitor_id:, session_id:, url:, referrer: nil, device_fingerprint: nil,
16
- user_agent: nil, started_at: nil, ip: nil)
20
+ user_agent: nil, started_at: nil, ip: nil, fbp: nil)
17
21
  @visitor_id = visitor_id
18
22
  @session_id = session_id
19
23
  @url = url
@@ -22,6 +26,7 @@ module Mbuzz
22
26
  @user_agent = user_agent
23
27
  @started_at = started_at
24
28
  @ip = ip
29
+ @fbp = fbp
25
30
  end
26
31
 
27
32
  def call
@@ -35,7 +40,7 @@ module Mbuzz
35
40
  private
36
41
 
37
42
  attr_reader :visitor_id, :session_id, :url, :referrer, :device_fingerprint, :user_agent,
38
- :started_at, :ip
43
+ :started_at, :ip, :fbp
39
44
 
40
45
  def valid?
41
46
  present?(visitor_id) && present?(session_id) && present?(url)
@@ -59,6 +64,9 @@ module Mbuzz
59
64
  device_fingerprint: device_fingerprint,
60
65
  user_agent: user_agent,
61
66
  ip: ip,
67
+ # Meta's browser id, already format-checked by Mbuzz::Fbp. Dropped by
68
+ # .compact when absent: omitted, not null.
69
+ fbp: fbp,
62
70
  started_at: started_at || Time.now.utc.iso8601
63
71
  }.compact
64
72
  end
data/lib/mbuzz/client.rb CHANGED
@@ -33,7 +33,7 @@ module Mbuzz
33
33
  end
34
34
 
35
35
  def self.session(visitor_id:, session_id:, url:, referrer: nil, device_fingerprint: nil,
36
- user_agent: nil, started_at: nil, ip: nil)
36
+ user_agent: nil, started_at: nil, ip: nil, fbp: nil)
37
37
  SessionRequest.new(
38
38
  visitor_id: visitor_id,
39
39
  session_id: session_id,
@@ -42,7 +42,8 @@ module Mbuzz
42
42
  device_fingerprint: device_fingerprint,
43
43
  user_agent: user_agent,
44
44
  started_at: started_at,
45
- ip: ip
45
+ ip: ip,
46
+ fbp: fbp
46
47
  ).call
47
48
  end
48
49
  end
data/lib/mbuzz/fbp.rb ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mbuzz
4
+ # Meta's browser id, written client-side by the customer's Meta Pixel. Read
5
+ # only, never set: forwarded on the session call so Meta can merge mbuzz's
6
+ # server event with the Pixel's browser event.
7
+ module Fbp
8
+ # Meta's documented shape, fb.<subdomainIndex>.<creationTime>.<random>, plus
9
+ # the optional appendix Meta's server-side Parameter Builder adds
10
+ # (fb.1.<ts>.<random>.AQECAQIB). Both are valid to Meta. \A…\z, not ^…$:
11
+ # `$` matches before a trailing newline.
12
+ FORMAT = /\Afb\.\d+\.\d+\.\d+(?:\.[A-Za-z0-9_-]+)?\z/
13
+
14
+ # The Pixel's _fbp, or nil when absent or not in Meta's format. mbuzz never
15
+ # invents one and never rewrites what it forwards.
16
+ def self.read(value)
17
+ value if value.is_a?(String) && FORMAT.match?(value)
18
+ end
19
+ end
20
+ end
@@ -67,6 +67,7 @@ module Mbuzz
67
67
  referrer: payload["referrer"],
68
68
  ip: ip,
69
69
  user_agent: user_agent,
70
+ fbp: Fbp.read(request.cookies[FBP_COOKIE_NAME]),
70
71
  device_fingerprint: Digest::SHA256.hexdigest("#{ip}|#{user_agent}")[0, 32]
71
72
  }.freeze
72
73
  end
@@ -94,7 +95,8 @@ module Mbuzz
94
95
  referrer: context[:referrer],
95
96
  device_fingerprint: context[:device_fingerprint],
96
97
  user_agent: context[:user_agent],
97
- ip: context[:ip]
98
+ ip: context[:ip],
99
+ fbp: context[:fbp]
98
100
  )
99
101
  rescue StandardError => e
100
102
  log_error("Session creation failed: #{e.message}") if Mbuzz.config.debug
@@ -102,6 +102,7 @@ module Mbuzz
102
102
  referrer: request.referer,
103
103
  ip: ip,
104
104
  user_agent: user_agent,
105
+ fbp: Fbp.read(request.cookies[FBP_COOKIE_NAME]),
105
106
  device_fingerprint: Digest::SHA256.hexdigest("#{ip}|#{user_agent}")[0, 32]
106
107
  }.freeze
107
108
  end
@@ -134,7 +135,8 @@ module Mbuzz
134
135
  referrer: context[:referrer],
135
136
  device_fingerprint: context[:device_fingerprint],
136
137
  user_agent: context[:user_agent],
137
- ip: context[:ip]
138
+ ip: context[:ip],
139
+ fbp: context[:fbp]
138
140
  )
139
141
  end
140
142
 
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.10.1"
4
+ VERSION = "0.11.0"
5
5
  end
data/lib/mbuzz.rb CHANGED
@@ -4,6 +4,7 @@ require_relative "mbuzz/version"
4
4
  require_relative "mbuzz/configuration"
5
5
  require_relative "mbuzz/dropped_call"
6
6
  require_relative "mbuzz/visitor/identifier"
7
+ require_relative "mbuzz/fbp"
7
8
  require_relative "mbuzz/request_context"
8
9
  require_relative "mbuzz/api"
9
10
  require_relative "mbuzz/client"
@@ -29,6 +30,9 @@ module Mbuzz
29
30
  VISITOR_COOKIE_PATH = "/"
30
31
  VISITOR_COOKIE_SAME_SITE = "Lax"
31
32
 
33
+ # Meta Pixel's browser id. Read only; see Mbuzz::Fbp.
34
+ FBP_COOKIE_NAME = "_fbp"
35
+
32
36
  # The one request a cached page always sends to the app. Kept off /api and
33
37
  # /assets so host-app routing and cache rules don't shadow it.
34
38
  SESSION_ENDPOINT_PATH = "/_mbuzz/session"
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.10.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mbuzz team
@@ -47,6 +47,7 @@ files:
47
47
  - lib/mbuzz/controller_helpers.rb
48
48
  - lib/mbuzz/current.rb
49
49
  - lib/mbuzz/dropped_call.rb
50
+ - lib/mbuzz/fbp.rb
50
51
  - lib/mbuzz/middleware/session_endpoint.rb
51
52
  - lib/mbuzz/middleware/tracking.rb
52
53
  - lib/mbuzz/railtie.rb