mbuzz 0.6.2

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.
@@ -0,0 +1,519 @@
1
+ # mbuzz-ruby v0.2.0 - Breaking Changes & Migration Guide
2
+
3
+ **Status**: Ready to Implement
4
+ **Priority**: P0 - Blocking UAT
5
+ **Created**: 2025-11-25
6
+ **Target Release**: v0.2.0
7
+
8
+ ---
9
+
10
+ ## Overview
11
+
12
+ Version 0.2.0 fixes critical inconsistencies between the gem and backend API that prevent events from being tracked. These are **breaking changes** that require existing users to update their code.
13
+
14
+ **Impact**: Current gem (v0.1.0) sends incorrectly formatted data that will be rejected by the backend.
15
+
16
+ ---
17
+
18
+ ## Breaking Changes
19
+
20
+ ### 1. Parameter Name: `event` → `event_type` 🔴 BREAKING
21
+
22
+ **Issue**: Gem sends `event:` but backend expects `event_type:`
23
+
24
+ **Current (v0.1.0)**:
25
+ ```ruby
26
+ Mbuzz.track(
27
+ user_id: current_user.id,
28
+ event: 'Signup', # ❌ Backend rejects this
29
+ properties: { plan: 'pro' }
30
+ )
31
+ ```
32
+
33
+ **New (v0.2.0)**:
34
+ ```ruby
35
+ Mbuzz.track(
36
+ user_id: current_user.id,
37
+ event_type: 'Signup', # ✅ Matches backend API
38
+ properties: { plan: 'pro' }
39
+ )
40
+ ```
41
+
42
+ **Files to Change**:
43
+ - `lib/mbuzz/client.rb` - Update method signature and payload
44
+ - `lib/mbuzz.rb` - Update public API method
45
+ - `test/mbuzz/client_test.rb` - Update all tests
46
+ - `README.md` - Update all examples
47
+ - `SPECIFICATION.md` - Update parameter documentation
48
+
49
+ ---
50
+
51
+ ### 2. Timestamp Format: Unix Epoch → ISO8601 🔴 BREAKING
52
+
53
+ **Issue**: Gem sends Unix timestamp (integer) but backend expects ISO8601 string
54
+
55
+ **Current (v0.1.0)**:
56
+ ```ruby
57
+ # lib/mbuzz/client.rb
58
+ {
59
+ event_type: event_type,
60
+ timestamp: Time.now.to_i # ❌ Sends: 1732550400
61
+ }
62
+ ```
63
+
64
+ **New (v0.2.0)**:
65
+ ```ruby
66
+ # lib/mbuzz/client.rb
67
+ {
68
+ event_type: event_type,
69
+ timestamp: Time.now.utc.iso8601 # ✅ Sends: "2025-11-25T10:30:00Z"
70
+ }
71
+ ```
72
+
73
+ **Why UTC?**
74
+ - Backend stores all timestamps in UTC
75
+ - Avoids timezone confusion
76
+ - ISO8601 format with 'Z' suffix is standard
77
+
78
+ **Files to Change**:
79
+ - `lib/mbuzz/client.rb` - Change `Time.now.to_i` → `Time.now.utc.iso8601`
80
+ - `test/mbuzz/client_test.rb` - Update timestamp assertions
81
+
82
+ ---
83
+
84
+ ### 3. Documentation: `anonymous_id` → `visitor_id` 📝 NON-BREAKING
85
+
86
+ **Issue**: SPECIFICATION.md says `anonymous_id` but implementation uses `visitor_id`
87
+
88
+ **Current**:
89
+ ```markdown
90
+ # SPECIFICATION.md
91
+ - anonymous_id - Visitor ID from cookies (required if no user_id)
92
+ ```
93
+
94
+ **New**:
95
+ ```markdown
96
+ # SPECIFICATION.md
97
+ - visitor_id - Visitor ID from cookies (required if no user_id)
98
+ ```
99
+
100
+ **Note**: This is documentation-only. The gem implementation already uses `visitor_id` correctly.
101
+
102
+ **Files to Change**:
103
+ - `SPECIFICATION.md` - Find/replace `anonymous_id` → `visitor_id`
104
+
105
+ ---
106
+
107
+ ## Implementation Checklist
108
+
109
+ ### Step 1: Update Client Code
110
+
111
+ **File**: `lib/mbuzz/client.rb`
112
+
113
+ **Current Code** (lines ~10-16, ~25-30):
114
+ ```ruby
115
+ def track(user_id: nil, visitor_id: nil, event:, properties: {})
116
+ Api.post(EVENTS_PATH, {
117
+ user_id: user_id,
118
+ visitor_id: visitor_id,
119
+ event: event, # ❌ Wrong parameter name
120
+ properties: properties,
121
+ timestamp: Time.now.to_i # ❌ Wrong format
122
+ })
123
+ end
124
+ ```
125
+
126
+ **New Code**:
127
+ ```ruby
128
+ def track(user_id: nil, visitor_id: nil, event_type:, properties: {})
129
+ Api.post(EVENTS_PATH, {
130
+ user_id: user_id,
131
+ visitor_id: visitor_id,
132
+ event_type: event_type, # ✅ Correct parameter name
133
+ properties: properties,
134
+ timestamp: Time.now.utc.iso8601 # ✅ ISO8601 format
135
+ })
136
+ end
137
+ ```
138
+
139
+ ---
140
+
141
+ ### Step 2: Update Public API
142
+
143
+ **File**: `lib/mbuzz.rb`
144
+
145
+ **Current Code**:
146
+ ```ruby
147
+ def self.track(event:, **options)
148
+ client.track(event: event, **options)
149
+ end
150
+ ```
151
+
152
+ **New Code**:
153
+ ```ruby
154
+ def self.track(event_type:, **options)
155
+ client.track(event_type: event_type, **options)
156
+ end
157
+ ```
158
+
159
+ ---
160
+
161
+ ### Step 3: Update Tests
162
+
163
+ **File**: `test/mbuzz/client_test.rb`
164
+
165
+ **Update all test cases**:
166
+ ```ruby
167
+ # Before
168
+ test "track sends event with correct payload" do
169
+ Mbuzz.track(
170
+ user_id: 1,
171
+ event: 'Test Event',
172
+ properties: { foo: 'bar' }
173
+ )
174
+
175
+ assert_requested :post, "#{base_url}/events", body: hash_including(
176
+ 'event' => 'Test Event',
177
+ 'timestamp' => kind_of(Integer)
178
+ )
179
+ end
180
+
181
+ # After
182
+ test "track sends event with correct payload" do
183
+ Mbuzz.track(
184
+ user_id: 1,
185
+ event_type: 'Test Event',
186
+ properties: { foo: 'bar' }
187
+ )
188
+
189
+ assert_requested :post, "#{base_url}/events", body: hash_including(
190
+ 'event_type' => 'Test Event',
191
+ 'timestamp' => match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/) # ISO8601
192
+ )
193
+ end
194
+ ```
195
+
196
+ ---
197
+
198
+ ### Step 4: Update README.md
199
+
200
+ **Find and replace ALL examples**:
201
+
202
+ ```ruby
203
+ # Before (v0.1.0)
204
+ Mbuzz.track(
205
+ user_id: current_user.id,
206
+ event: 'Signup',
207
+ properties: { plan: 'pro' }
208
+ )
209
+
210
+ # After (v0.2.0)
211
+ Mbuzz.track(
212
+ user_id: current_user.id,
213
+ event_type: 'Signup',
214
+ properties: { plan: 'pro' }
215
+ )
216
+ ```
217
+
218
+ **Add Migration Section**:
219
+ ```markdown
220
+ ## Upgrading from v0.1.x to v0.2.0
221
+
222
+ ⚠️ **Breaking Changes**
223
+
224
+ v0.2.0 fixes critical bugs that prevent events from being tracked. You MUST update your code.
225
+
226
+ ### 1. Rename `event:` parameter to `event_type:`
227
+
228
+ ```ruby
229
+ # Before
230
+ Mbuzz.track(event: 'Signup', user_id: 1)
231
+
232
+ # After
233
+ Mbuzz.track(event_type: 'Signup', user_id: 1)
234
+ ```
235
+
236
+ ### 2. No action required for timestamps
237
+
238
+ The gem now automatically sends timestamps in the correct format (ISO8601). If you were manually setting timestamps, ensure they're ISO8601 strings:
239
+
240
+ ```ruby
241
+ # Good - ISO8601 string
242
+ Mbuzz.track(event_type: 'Signup', timestamp: '2025-11-25T10:30:00Z')
243
+
244
+ # Bad - Unix epoch (no longer supported)
245
+ Mbuzz.track(event_type: 'Signup', timestamp: 1732550400)
246
+ ```
247
+
248
+ ### Find and Replace
249
+
250
+ Search your codebase for:
251
+ ```
252
+ Mbuzz.track\(
253
+ (.*?)event: '
254
+ ```
255
+
256
+ Replace with:
257
+ ```
258
+ Mbuzz.track(
259
+ $1event_type: '
260
+ ```
261
+ ```
262
+
263
+ ---
264
+
265
+ ### Step 5: Update SPECIFICATION.md
266
+
267
+ **Changes**:
268
+ 1. Find/replace `anonymous_id` → `visitor_id`
269
+ 2. Update timestamp documentation to show ISO8601
270
+ 3. Update parameter name `event` → `event_type`
271
+
272
+ **Example updates**:
273
+ ```markdown
274
+ # Before
275
+ - event (required) - The name of the event
276
+ - timestamp (optional) - Unix timestamp of when the event occurred
277
+
278
+ # After
279
+ - event_type (required) - The name of the event
280
+ - timestamp (optional) - ISO8601 timestamp of when the event occurred (defaults to now)
281
+
282
+ ## Example
283
+
284
+ ```ruby
285
+ Mbuzz.track(
286
+ user_id: 1,
287
+ event_type: 'Purchase Completed', # Changed from 'event'
288
+ properties: {
289
+ order_id: 'order_123',
290
+ amount: 99.99
291
+ },
292
+ timestamp: '2025-11-25T10:30:00Z' # ISO8601 format
293
+ )
294
+ ```
295
+ ```
296
+
297
+ ---
298
+
299
+ ### Step 6: Update Gemspec Version
300
+
301
+ **File**: `mbuzz.gemspec`
302
+
303
+ ```ruby
304
+ Gem::Specification.new do |spec|
305
+ spec.name = "mbuzz"
306
+ spec.version = "0.2.0" # Bump from 0.1.0
307
+ spec.summary = "Multi-touch attribution for Ruby applications"
308
+ spec.description = "Server-side event tracking with automatic visitor and session management. v0.2.0 includes breaking changes - see CHANGELOG.md"
309
+ # ...
310
+ end
311
+ ```
312
+
313
+ ---
314
+
315
+ ### Step 7: Create CHANGELOG.md
316
+
317
+ **File**: `CHANGELOG.md`
318
+
319
+ ```markdown
320
+ # Changelog
321
+
322
+ All notable changes to this project will be documented in this file.
323
+
324
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
325
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
326
+
327
+ ## [0.2.0] - 2025-11-26
328
+
329
+ ### ⚠️ BREAKING CHANGES
330
+
331
+ This release fixes critical bugs that prevented events from being tracked. You MUST update your code to use this version.
332
+
333
+ ### Changed
334
+
335
+ - **BREAKING**: Renamed `event:` parameter to `event_type:` to match backend API (#1)
336
+ - Before: `Mbuzz.track(event: 'Signup', user_id: 1)`
337
+ - After: `Mbuzz.track(event_type: 'Signup', user_id: 1)`
338
+ - Migration: Search/replace `event:` → `event_type:` in all `Mbuzz.track()` calls
339
+
340
+ - **BREAKING**: Changed timestamp format from Unix epoch to ISO8601 (#2)
341
+ - Before: Sent `1732550400` (integer)
342
+ - After: Sends `"2025-11-25T10:30:00Z"` (ISO8601 string)
343
+ - Migration: No action required - gem handles this automatically
344
+
345
+ ### Fixed
346
+
347
+ - Events are now correctly formatted and accepted by backend
348
+ - Timestamps are now in UTC with ISO8601 format
349
+ - Documentation now correctly refers to `visitor_id` instead of `anonymous_id`
350
+
351
+ ### Documentation
352
+
353
+ - Updated README.md with new parameter names
354
+ - Updated SPECIFICATION.md with correct parameter names and formats
355
+ - Added migration guide for v0.1.x → v0.2.0
356
+
357
+ ## [0.1.0] - 2025-11-XX
358
+
359
+ ### Added
360
+
361
+ - Initial release
362
+ - Event tracking with `Mbuzz.track()`
363
+ - Automatic visitor and session management
364
+ - Rails middleware for automatic page view tracking
365
+ - Rack middleware support
366
+
367
+ ---
368
+
369
+ ## [Unreleased]
370
+
371
+ ### Planned for v0.3.0
372
+
373
+ - User identification with `Mbuzz.identify()`
374
+ - Visitor aliasing with `Mbuzz.alias()`
375
+ - Batch event sending
376
+ - Offline queueing
377
+
378
+ [0.2.0]: https://github.com/multibuzz/mbuzz-ruby/compare/v0.1.0...v0.2.0
379
+ [0.1.0]: https://github.com/multibuzz/mbuzz-ruby/releases/tag/v0.1.0
380
+ ```
381
+
382
+ ---
383
+
384
+ ## Testing Checklist
385
+
386
+ ### Unit Tests
387
+
388
+ - [ ] All existing tests pass with new parameter names
389
+ - [ ] Test timestamp format is ISO8601
390
+ - [ ] Test that `event_type` is sent in payload
391
+ - [ ] Test that `event` parameter is NOT in payload
392
+ - [ ] Test visitor_id is correctly included
393
+ - [ ] Test properties are correctly merged
394
+
395
+ ### Integration Tests (Against Backend)
396
+
397
+ - [ ] Create new test Rails app
398
+ - [ ] Install gem from local source: `gem 'mbuzz', path: '../mbuzz-ruby'`
399
+ - [ ] Configure with test API key
400
+ - [ ] Track event with `event_type:` parameter
401
+ - [ ] Verify event appears in backend (check logs or database)
402
+ - [ ] Verify timestamp is stored correctly
403
+ - [ ] Test with missing `timestamp` (should default to now)
404
+ - [ ] Test with custom `timestamp` (ISO8601 string)
405
+
406
+ ### Manual Testing
407
+
408
+ ```bash
409
+ # In test app console
410
+ rails console
411
+
412
+ # Track an event
413
+ Mbuzz.track(
414
+ user_id: 1,
415
+ event_type: 'Test Event',
416
+ properties: { source: 'rails_console' }
417
+ )
418
+
419
+ # Check what was sent (enable debug mode)
420
+ Mbuzz.configure do |config|
421
+ config.debug = true
422
+ end
423
+
424
+ Mbuzz.track(event_type: 'Debug Test', user_id: 1)
425
+ # Should see request body with event_type and ISO8601 timestamp
426
+ ```
427
+
428
+ ---
429
+
430
+ ## Release Process
431
+
432
+ ### Pre-Release
433
+
434
+ 1. [ ] Complete all code changes
435
+ 2. [ ] Update all documentation
436
+ 3. [ ] All tests pass locally
437
+ 4. [ ] Manual testing complete
438
+ 5. [ ] CHANGELOG.md updated
439
+ 6. [ ] README.md migration guide added
440
+ 7. [ ] Version bumped to 0.2.0 in gemspec
441
+
442
+ ### Release
443
+
444
+ 1. [ ] Create git tag: `git tag -a v0.2.0 -m "Release v0.2.0 - Breaking changes"`
445
+ 2. [ ] Push tag: `git push origin v0.2.0`
446
+ 3. [ ] Build gem: `gem build mbuzz.gemspec`
447
+ 4. [ ] Publish to RubyGems: `gem push mbuzz-0.2.0.gem`
448
+ 5. [ ] Create GitHub release with changelog
449
+ 6. [ ] Announce breaking changes to users (email/blog/Discord)
450
+
451
+ ### Post-Release
452
+
453
+ 1. [ ] Update backend docs (mbuzz.co) to reference v0.2.0
454
+ 2. [ ] Update getting started guide with new examples
455
+ 3. [ ] Monitor for issues in first 48 hours
456
+ 4. [ ] Respond to user migration questions
457
+
458
+ ---
459
+
460
+ ## User Communication Template
461
+
462
+ **Subject**: mbuzz-ruby v0.2.0 Released - Breaking Changes Required
463
+
464
+ **Body**:
465
+ ```
466
+ Hi mbuzz users,
467
+
468
+ We've released v0.2.0 of the mbuzz-ruby gem with critical bug fixes. This release includes breaking changes that require you to update your code.
469
+
470
+ ⚠️ What's broken?
471
+
472
+ v0.1.0 sends incorrectly formatted data that is rejected by the backend. No events are being tracked with v0.1.0.
473
+
474
+ ✅ What's fixed?
475
+
476
+ v0.2.0 fixes the parameter names and timestamp format to match the backend API. Events will now be tracked correctly.
477
+
478
+ 🔧 How to upgrade:
479
+
480
+ 1. Update your Gemfile:
481
+ gem 'mbuzz', '~> 0.2.0'
482
+
483
+ 2. Run bundle update:
484
+ bundle update mbuzz
485
+
486
+ 3. Find and replace in your codebase:
487
+ - Change: Mbuzz.track(event: 'Name', ...)
488
+ - To: Mbuzz.track(event_type: 'Name', ...)
489
+
490
+ That's it! The gem handles everything else automatically.
491
+
492
+ 📖 Full migration guide:
493
+ https://github.com/multibuzz/mbuzz-ruby#upgrading-from-v01x-to-v020
494
+
495
+ Questions? Reply to this email or open a GitHub issue.
496
+
497
+ Thanks for using mbuzz!
498
+ ```
499
+
500
+ ---
501
+
502
+ ## Success Criteria
503
+
504
+ - [ ] Gem v0.2.0 published to RubyGems
505
+ - [ ] All parameter names match backend API exactly
506
+ - [ ] Timestamps are ISO8601 format
507
+ - [ ] All tests pass
508
+ - [ ] Documentation updated
509
+ - [ ] Migration guide available
510
+ - [ ] Backend successfully accepts events from gem
511
+ - [ ] No breaking changes for users who follow migration guide
512
+
513
+ ---
514
+
515
+ ## Related Documentation
516
+
517
+ - Backend API Contract: `multibuzz/lib/docs/sdk/api_contract.md`
518
+ - Backend Bug Spec: `multibuzz/lib/specs/bug_fixes_critical_inconsistencies.md`
519
+ - SDK Registry: `multibuzz/lib/docs/sdk/sdk_registry.md`