|
| 1 | +# Project Summary |
| 2 | + |
| 3 | +## Objective |
| 4 | +Implemented the `todo.md` GA4 backlog in this repository without executing runtime tracking flows. |
| 5 | + |
| 6 | +## What was implemented |
| 7 | + |
| 8 | +### 1) Event payload correctness and completeness |
| 9 | +- Fixed event serialization so `session_id` and `engagement_time_msec` are now included in event `params`. |
| 10 | +- Added event-level timestamp override support (`event.timestamp_micros`) via `setEventTimestampMicros(...)`. |
| 11 | +- Added campaign parameter setters and merge support in event helpers: |
| 12 | + - `campaign_source`, `campaign_medium`, `campaign_name`, `campaign_term`, `campaign_content`, `campaign_id`. |
| 13 | + |
| 14 | +### 2) Top-level Measurement Protocol request fields |
| 15 | +- Added support for top-level request fields in both Analytics and Firebase payload models: |
| 16 | + - `non_personalized_ads` |
| 17 | + - `validation_behavior` |
| 18 | + - `ip_override` |
| 19 | + - `user_location` |
| 20 | + - `device` |
| 21 | +- Added public setters for the above in both models. |
| 22 | + |
| 23 | +### 3) User properties and user data |
| 24 | +- Added user property timestamp support via `setTimestampMicros(...)`, serialized as `set_timestamp_micros`. |
| 25 | +- Removed hard gate that only allowed `user_data` when `user_id` was present; payload now includes `user_data` when provided. |
| 26 | +- Improved phone normalization API to accept `int|string` and sanitize formatted inputs to E.164-compatible hashing format. |
| 27 | + |
| 28 | +### 4) Cookie/session integration helpers |
| 29 | +- Improved session cookie parsing (`parseSessionCookie`) for GS1/GS2 formats: |
| 30 | + - fixed `timestamp` key typo |
| 31 | + - normalized GS2 values by removing token prefixes |
| 32 | + - added version/domain metadata consistently |
| 33 | +- Added client ID extraction helpers: |
| 34 | + - `parseClientIdFromGaCookie(...)` |
| 35 | + - `parseClientIdFromCookies(...)` |
| 36 | + - `parseGaCookies(...)` |
| 37 | + |
| 38 | +### 5) Required-parameter audit updates |
| 39 | +- Tightened required params for selected events based on GA4 recommended semantics used in backlog: |
| 40 | + - `EarnVirtualCurrency`: requires `virtual_currency_name`, `value` |
| 41 | + - `JoinGroup`: requires `group_id` |
| 42 | + - `LevelUp`: requires `level` |
| 43 | + - `Search`: requires `search_term` |
| 44 | + |
| 45 | +### 6) Tests and backlog tracking |
| 46 | +- Updated and extended tests for: |
| 47 | + - event timestamp override |
| 48 | + - campaign serialization |
| 49 | + - top-level request fields |
| 50 | + - user property timestamp |
| 51 | + - cookie parsing normalization and client ID helpers |
| 52 | + - formatted phone normalization |
| 53 | +- Marked `todo.md` tasks complete. |
| 54 | + |
| 55 | +## Files added |
| 56 | +- `agent.md` |
| 57 | + |
| 58 | +## Notable files updated |
| 59 | +- `src/Helper/EventMainHelper.php` |
| 60 | +- `src/Helper/EventHelper.php` |
| 61 | +- `src/Helper/EventParamsHelper.php` |
| 62 | +- `src/Analytics.php` |
| 63 | +- `src/Firebase.php` |
| 64 | +- `src/Helper/UserPropertyHelper.php` |
| 65 | +- `src/UserProperty.php` |
| 66 | +- `src/Helper/UserDataHelper.php` |
| 67 | +- `src/Helper/ConvertHelper.php` |
| 68 | +- `src/Event/EarnVirtualCurrency.php` |
| 69 | +- `src/Event/JoinGroup.php` |
| 70 | +- `src/Event/LevelUp.php` |
| 71 | +- `src/Event/Search.php` |
| 72 | +- `src/Facade/Type/AnalyticsType.php` |
| 73 | +- `src/Facade/Type/FirebaseType.php` |
| 74 | +- `src/Facade/Type/DefaultEventParamsType.php` |
| 75 | +- `src/Facade/Type/UserPropertyType.php` |
| 76 | +- `test/Unit/EventTest.php` |
| 77 | +- `test/Unit/AnalyticsTest.php` |
| 78 | +- `test/Unit/FirebaseTest.php` |
| 79 | +- `test/Unit/HelperTest.php` |
| 80 | +- `test/Unit/UserDataTest.php` |
| 81 | +- `test/Unit/UserPropertyTest.php` |
| 82 | +- `todo.md` |
| 83 | + |
| 84 | +## Validation status |
| 85 | +- Runtime test/lint execution was not completed because `php` is unavailable in this environment (`php: command not found`). |
0 commit comments