omnitrack-rb 0.1.0 → 2.0.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/AI_GEM_SETUP.md +25 -0
- data/CHANGELOG.md +8 -0
- data/README.md +3 -1
- data/lib/omnitrack/compat/hash_compact_backport.rb +12 -0
- data/lib/omnitrack/context.rb +11 -3
- data/lib/omnitrack/registry.rb +2 -2
- data/lib/omnitrack/version.rb +1 -1
- data/lib/omnitrack.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aa0f487b57d4c47c6a3168bb0b2583982926b1361f30d95a4d349f3a3bae9834
|
|
4
|
+
data.tar.gz: 2c5c0967326204f7e9e83f5e43b80c05ee97b1ea414af87ada2fb785b11d2211
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a27d997c0372cb36c36c4c84816739c66ddf886b6953985ebb27f940fb6f2babf5f2111e8d36555aae09e90c8a10138478d0ba6fc0eca79c11dbc6476c2234fa
|
|
7
|
+
data.tar.gz: c1bb1d889f61bfdd656ab0ede5b7d2ccc7b432fcf4b7db335c63789d709736caa8dd3cb1d8fe614ec5c7214e46fe28c8cc85ba306fb0cef69b82c48c9ca9db60
|
data/AI_GEM_SETUP.md
CHANGED
|
@@ -4,6 +4,30 @@ Use this document when **adding `omnitrack-rb` to an existing Rails 6+ app** so
|
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
+
## 0. Ruby version (including 2.7.8)
|
|
8
|
+
|
|
9
|
+
The gem declares **`required_ruby_version >= 2.7.0`** and is written to run on **Ruby 2.7.8** without Ruby 3-only syntax. Your **host app** should use a supported Ruby and lock it so CI and production match.
|
|
10
|
+
|
|
11
|
+
**Example in the host `Gemfile` (optional but recommended):**
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
ruby "2.7.8" # or "3.0.6", "3.2.2", etc. — must be >= 2.7.0
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Check locally:**
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
ruby -v # should be 2.7.8 or newer
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Rails:** use **Rails 6.x or 7.x** (or newer) with a Ruby version that Rails supports for that release. If the app is stuck on **Ruby 2.7.8**, keep **Rails 6.1.x** (or the last 6.x line you use) unless you have verified a newer stack.
|
|
24
|
+
|
|
25
|
+
**Bundler:** Bundler 2.x is typical; run `bundle install` with the same Ruby the app uses in production.
|
|
26
|
+
|
|
27
|
+
Nothing else is required for 2.7.8 specifically — no extra `require` in `application.rb`; the Railtie loads OmniTrack like any other Rails engine/gem.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
7
31
|
## 1. Gemfile (required)
|
|
8
32
|
|
|
9
33
|
In the **host** application `Gemfile`:
|
|
@@ -128,6 +152,7 @@ Until `Omnitrack::Jobs::TrackingJob` and ActiveJob are loaded, the gem runs sync
|
|
|
128
152
|
|
|
129
153
|
| Symptom | What to do |
|
|
130
154
|
|--------|------------|
|
|
155
|
+
| `ruby` version error from Bundler | Host `Gemfile` `ruby "x.y.z"` must match your runtime; use `ruby -v` and align RVM/rbenv/asdf. |
|
|
131
156
|
| `uninitialized constant Omnitrack` | Run `bundle install`; ensure `config/application.rb` loads Bundler default group; boot with `bin/rails c`. |
|
|
132
157
|
| `ENV[...] is nil` in logs | Adapters with `enabled: true` but missing tokens may log or skip; set `*_ENABLED=false` until credentials exist. |
|
|
133
158
|
| Job errors when `async: true` | Set `config.async = false` until ActiveJob and queue are configured, or add queue adapter. |
|
data/CHANGELOG.md
CHANGED
|
@@ -2,18 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [2.0.0] - 2026-04-26
|
|
6
|
+
|
|
5
7
|
### Added
|
|
6
8
|
- `AI_GEM_SETUP.md` — step-by-step integration for host apps (Bundler, initializer, ENV, ActiveJob, pitfalls)
|
|
7
9
|
- `.env.example` — variable names matching the install template; install generator copies `env.example` → `.env.example` when missing
|
|
8
10
|
- `USAGE.md` — concrete ERB/Ruby examples for layout, HTML/API controllers, and a service object
|
|
11
|
+
- `lib/omnitrack/compat/hash_compact_backport` — `Hash#compact` on Rubies before 3.1 (e.g. 2.7.x, 3.0)
|
|
9
12
|
|
|
10
13
|
### Fixed
|
|
14
|
+
- **Ruby 2.7.8** and **Ruby 3.0** compatibility: no endless `def` or `filter_map` (require Ruby 3+ in core for those); compatible `Enumerable` + `Hash#compact` usage
|
|
11
15
|
- Conventional `lib/omnitrack` gem layout, loadable `require "omnitrack"`
|
|
12
16
|
- `rails generate omnitrack:install` generator at `lib/generators/omnitrack/install/`
|
|
13
17
|
- `Omnitrack::Controller` as an alias of `Omnitrack::Concerns::Controller`
|
|
14
18
|
- Default `adapter_name` for adapters uses `underscore` (snake_case) so config keys (e.g. `google_ads`) match the registry; `Omnitrack.reset!` re-registers first-party adapters in tests
|
|
15
19
|
- `activesupport` as a direct runtime dependency; explicit requires for `ActiveSupport` extensions used at load time
|
|
16
20
|
|
|
21
|
+
### Upgrade from 0.1.0
|
|
22
|
+
- In the host `Gemfile`, pin `gem "omnitrack-rb", "~> 2.0"` and run `bundle update omnitrack-rb`
|
|
23
|
+
- If you had relied on a mis-registered adapter key (`:googleads` from an old build), use **`google_ads`** in `config.adapters` (and env-driven flags) to match the registry
|
|
24
|
+
|
|
17
25
|
## [0.1.0] - 2024-01-15
|
|
18
26
|
|
|
19
27
|
### Added
|
data/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# OmniTrack-rb 🎯
|
|
2
2
|
|
|
3
3
|
[](https://rubygems.org/gems/omnitrack-rb)
|
|
4
|
-
[](https://www.ruby-lang.org)
|
|
5
5
|
[](https://rubyonrails.org)
|
|
6
6
|
[](LICENSE.txt)
|
|
7
7
|
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
OmniTrack dispatches events to multiple ad/analytics platforms through a clean adapter pattern — works identically in full-stack and API-only Rails apps, never crashes your main application, and emits structured JSON logs to a dedicated file.
|
|
11
11
|
|
|
12
|
+
Runtime: **Ruby ≥ 2.7** (including **2.7.8**) and **Rails ≥ 6**. No Ruby 3-only syntax in the gem runtime.
|
|
13
|
+
|
|
12
14
|
**Practical usage (file placement + method examples):** [USAGE.md](USAGE.md)
|
|
13
15
|
**Add the gem to any Rails app without boot errors (ENV, jobs, checklists):** [AI_GEM_SETUP.md](AI_GEM_SETUP.md)
|
|
14
16
|
**ENV variable names (copy into host `.env.example`):** [.env.example](.env.example)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Hash#compact was added in Ruby 3.1. This gem supports Ruby 2.7+ and runs on
|
|
4
|
+
# Ruby 3.0 with no core Hash#compact, so we backport only when missing.
|
|
5
|
+
|
|
6
|
+
unless {}.respond_to?(:compact)
|
|
7
|
+
class Hash
|
|
8
|
+
def compact
|
|
9
|
+
select { |_, v| !v.nil? }
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
data/lib/omnitrack/context.rb
CHANGED
|
@@ -54,9 +54,17 @@ module Omnitrack
|
|
|
54
54
|
self
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
def gclid
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
def gclid
|
|
58
|
+
click_ids[:gclid]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def fbclid
|
|
62
|
+
click_ids[:fbclid]
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def ttclid
|
|
66
|
+
click_ids[:ttclid]
|
|
67
|
+
end
|
|
60
68
|
|
|
61
69
|
# Full context as a hash — passed into adapter payloads
|
|
62
70
|
def to_h
|
data/lib/omnitrack/registry.rb
CHANGED
|
@@ -38,7 +38,7 @@ module Omnitrack
|
|
|
38
38
|
# Instantiate all *enabled* adapters based on current configuration.
|
|
39
39
|
# @return [Array<Omnitrack::Adapters::Base>]
|
|
40
40
|
def enabled_adapters
|
|
41
|
-
MUTEX.synchronize { @adapters.dup }.
|
|
41
|
+
MUTEX.synchronize { @adapters.dup }.map do |adapter_name, klass|
|
|
42
42
|
cfg = Omnitrack.config.adapter_config(adapter_name)
|
|
43
43
|
next unless cfg.fetch(:enabled, false)
|
|
44
44
|
|
|
@@ -47,7 +47,7 @@ module Omnitrack
|
|
|
47
47
|
Omnitrack.logger.error("registry.init_error",
|
|
48
48
|
adapter: adapter_name, message: e.message)
|
|
49
49
|
nil
|
|
50
|
-
end
|
|
50
|
+
end.compact
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
# Clear all registrations (useful in tests)
|
data/lib/omnitrack/version.rb
CHANGED
data/lib/omnitrack.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: omnitrack-rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Your Name
|
|
@@ -164,6 +164,7 @@ files:
|
|
|
164
164
|
- lib/omnitrack/adapters/meta.rb
|
|
165
165
|
- lib/omnitrack/adapters/snapchat.rb
|
|
166
166
|
- lib/omnitrack/adapters/tiktok.rb
|
|
167
|
+
- lib/omnitrack/compat/hash_compact_backport.rb
|
|
167
168
|
- lib/omnitrack/concerns/controller.rb
|
|
168
169
|
- lib/omnitrack/configuration.rb
|
|
169
170
|
- lib/omnitrack/context.rb
|