shopcircle-orbit 1.2.1 → 1.3.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: e3113ae248462ed96c7df563092cd89e421a4517c0ed6420c2abd5ab18ac9c34
4
- data.tar.gz: f07313a22f1ab5c037f135b42576ee08db436c1e47c72fb4c35e96f33fed276b
3
+ metadata.gz: d9d216746a4630244fb0e572da6096aa4e0755e8dd51149b633d6f052b3e4b1c
4
+ data.tar.gz: d81da736f6c0964d9b30ee64d35c1408577686bb01ca2c0226f4f26ff6d99503
5
5
  SHA512:
6
- metadata.gz: 6227c6ba47b0bd858fae94ce5a745b41e4b0277defe81cfd5c4b789401cc9e2316f1b9343051ec8fe0a5d88a7f588bcee91f80f7ced013260a4688c55fc6e002
7
- data.tar.gz: 828d277ae8d56cf8742dd9648223dea7153917454175ddd07dae3465f3c24ac4f3e7a64222afe948db5d524a509ef012a11a9a83d9ec0697df05a190f58c4bb1
6
+ metadata.gz: 927f107a154501f0db7616e3bdda426826e808142240ff42c344b4f0d574259d8c05d8b21f935c48d610b8dc475b2c97617620e0164eeee0930411132ae62ff4
7
+ data.tar.gz: cab6c08b1f6f39018c9139f4517e6630036c61d595a8a1c08a97fedace37e28d072c4601744a69da3ca4c4d90197eb25dc017cdd377e836f7ec0591c7b7d21a7
data/README.md CHANGED
@@ -162,11 +162,25 @@ class OrderTest < ActiveSupport::TestCase
162
162
  end
163
163
  ```
164
164
 
165
- ## Rails Middleware
165
+ ## Page / screen views
166
166
 
167
- The SDK automatically inserts Rack middleware that tracks `page_view` events for HTML GET requests. Asset paths, XHR, and JSON requests are excluded.
167
+ Page views are the `screen_view` event that's what the dashboard counts under Pages, pageviews and bounce rate. There are three ways to capture them:
168
168
 
169
- To disable:
169
+ 1. **Auto (Rails middleware).** The SDK automatically inserts Rack middleware that tracks `screen_view` for full HTML GET requests (server-rendered navigations). Asset paths, XHR/AJAX and JSON requests are excluded.
170
+
171
+ 2. **AJAX / Turbo / Hotwire / SPA frontends.** These route changes happen in the browser and never reach Rails, so the middleware can't see them. Track those with the browser JS SDK — it hooks the History API and emits `screen_view` on every route change:
172
+
173
+ ```js
174
+ new ShopCircleOrbit({ clientId: "YOUR_CLIENT_ID", trackScreenViews: true })
175
+ ```
176
+
177
+ 3. **Manual (server-side).** To record a screen view yourself (a rendered view, a non-GET flow, or a path the middleware skips), emit the canonical event:
178
+
179
+ ```ruby
180
+ ShopCircle::Orbit.track("screen_view", path: "/pricing")
181
+ ```
182
+
183
+ To disable the auto middleware:
170
184
 
171
185
  ```ruby
172
186
  # config/application.rb
@@ -3,8 +3,13 @@
3
3
  module ShopCircle
4
4
  module Orbit
5
5
  module Rails
6
- # Rack middleware that auto-tracks page_view events for HTML page requests.
7
- # Skips assets, XHR, and non-GET requests.
6
+ # Rack middleware that auto-tracks screen_view events for full HTML page
7
+ # requests (server-rendered navigations). Skips assets, XHR/AJAX, and non-GET
8
+ # requests — client-side SPA/AJAX/Turbo route changes are not visible to the
9
+ # server, so track those with the browser JS SDK (trackScreenViews) instead.
10
+ #
11
+ # Emits "screen_view" (the platform's canonical page/screen-view event) so it
12
+ # is counted in Pages, pageviews, bounce rate and journeys.
8
13
  #
9
14
  # Opt out by removing from the middleware stack:
10
15
  #
@@ -33,7 +38,7 @@ module ShopCircle
33
38
  props[:ip] = request.ip
34
39
  props[:referrer] = request.referrer
35
40
  end
36
- ShopCircle::Orbit.track("page_view", props)
41
+ ShopCircle::Orbit.track("screen_view", props)
37
42
  end
38
43
  rescue StandardError => e
39
44
  ShopCircle::Orbit.configuration.resolved_logger.warn("[shopcircle-orbit] Tracking error: #{e.message}")
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ShopCircle
4
4
  module Orbit
5
- VERSION = "1.2.1"
5
+ VERSION = "1.3.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopcircle-orbit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ShopCircle