Repository navigation
Let the analytics service work out the visitor's location - #2214
subodhr258 wants to merge 4 commits into
Conversation
The page params that GoDAM prints on every front-end page no longer carry `locationIP`, and the analytics request body no longer has a `location_ip` field. The analytics service works out the location from the request itself. Merge after the analytics service reads the address from the request (rtCamp/godam-analytics#364, item 1). Tests: the request-body helper and the page params are both checked for the absence of the address, including a page cached by an older version.
🔍 WordPress Plugin Check Report
📊 Report
|
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
620 |
WordPress.DB.SlowDBQuery.slow_db_query_meta_key | Detected usage of meta_key, possible slow query. |
📁 readme.txt (2 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
mismatched_plugin_name | Plugin name "GoDAM - Organize WordPress Media Library & File Manager with Unlimited Folders for Images, Videos & more" is different from the name declared in plugin header "GoDAM". |
0 |
trademarked_term | The plugin name includes a restricted term. Your chosen plugin name - "GoDAM - Organize WordPress Media Library & File Manager with Unlimited Folders for Images, Videos & more" - contains the restricted term "wordpress" which cannot be used at all in your plugin name. |
📁 inc/classes/class-video-sitemap-core-provider.php (1 warning)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
73 |
WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound | Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "wp_sitemaps_index_entry". |
📁 assets/build/css/main.css (1 warning)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedStylesScope | This style is being loaded in all contexts. |
📁 assets/src/libs/analytics.min.js (5 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedScriptsScope | This script is being loaded in all frontend contexts. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880 (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/2026/10/20/hello-world/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/sample-page/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-attachment-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
📁 assets/build/js/main.min.js (5 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedScriptsScope | This script is being loaded in all frontend contexts. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880 (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/2026/10/20/hello-world/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/sample-page/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-attachment-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check
Move the new location tests to the end of the file and leave the shared fixture lines untouched, so this branch and the one that stops sending the viewer's email do not conflict in the test file.
Code reviewVerdict: LGTM on the code — but release ordering is the real gate. The diff itself is minimal and correct: 1.
|
# Conflicts: # assets/src/js/godam-player/analytics-helpers.js
Nothing in GoDAM calls it after this PR; it stays as a public helper. Addresses review: #2214 (comment)
|
Thanks Kuldip.
|
|
Thanks for the review. Taking the three points in order:
|
Do not merge until rtCamp/godam-analytics#365 (item 1 of rtCamp/godam-analytics#364) is live on the analytics service the site posts to, and the visitor-IP check passes (a browser event sent through the live proxy is stored with the visitor's own address and country). After that change the service takes the address of browser-sent events (page load, heatmap, layer, Reel Pop and Shoppable events) from the request itself, accepts events with no
location_ip, and ignores the field when the request has an address. Events the store's server posts (assisted add to cart, order revenue) keep their payload value. This PR does nothing useful before that.Review packet
In one line: The page params (the
videoAnalyticsParamsobject printed on every front-end page) and the analytics events no longer carry thelocationIP/location_ipfield; the analytics service works out the location from the request itself. No issue; planned in rtCamp/godam-analytics#364 (item 1).1. Criteria and proof
locationIP(before: the address the server saw for the request)VisitorLocationParamTest::test_page_params_carry_no_location_field; capture S01location_ipkey (before: it held that address)sends no location field, even when the page still carries one; capture S01locationIP, does not make the player send itlocationIP: '10.0.0.1'on purpose)test_page_params_keep_what_analytics_still_needs; JS teststill sends the browser language2. Before and after
A signed-in subscriber opens a page with videos on godam-dev in Chrome and plays one for 6 seconds. Before is
develop(2.4.0) with the current analytics service; after is this branch with the analytics change from rtCamp/godam-analytics#365 (its headcce9ea8when tested). The test machine has no proxy in front of the analytics service, so the capture addsX-Forwarded-For: 8.8.8.8to the analytics requests, the way the proxy does in production. Captures are verbatim from the browser and from the analytics service's database.locationIPinvideoAnalyticsParams8.8.8.8location_ipin the play request8.8.8.88.8.8.8, 6 of 68.8.8.8, 6 of 6 (taken from the request by the service)US, 6 of 6US, 6 of 63. Tests
tests/php/VisitorLocationParamTest.php. It builds the page params and asserts there is nolocationIPkey (test_page_params_carry_no_location_field), and thatuserId,siteId,endpoint,tokenandpostIdare still there. Each test runs in its own process, and loads its stubs there, because loadinggodam-transcoder-functions.phpregisters hooks andEarlyTranslationHooksTestchecks exactly that on first load.assets/src/js/godam-player/analytics-helpers.test.js(nolocation_ipkey and no trace of the address in the body even when the page still carrieslocationIP; the browser language is still sent).tests/stubs/template-tags.php, the page-tag stubs the PHP test needs (is_single,get_the_titleand similar). It is identical to the file in the sibling PR rtCamp/godam#2213 (stops sending the signed-in viewer's email), so the two merge cleanly in either order.tests/stubs/engagement-functions.php. The current-user stub now also returnsIDanddata->user_email(an emptydatawhen nobody is signed in), as WordPress does. Same change as Stop sending the signed-in viewer's email with video analytics #2213. The Engagement tests that use it still pass: 426 PHP tests, 1408 assertions, in normal, reversed and random order.test_page_params_carry_no_location_fieldfails with "Failed asserting that an array does not have the key 'locationIP'", and the JS test fails withExpected path: not "location_ip",Received value: "10.0.0.1".4. Risk flags
No risk flags fired on #2214. Nothing in the diff touched the watched areas.
5. Independent review
A separate review pass saw only the task and the diff.
RTGODAM_ANALYTICS_BASEconstant reached every other testsetUp(), in the separate process. The suite passes in normal, reversed and random order.location_ipgodam-for-wooadd-on readslocationIP(two senders; they will send an emptylocation_ip, which the service ignores for browser-sent events).rtgodam_get_user_ip()had no other caller in the plugin. No PHP code posts the address to the analytics service.userIdstays in the same objectanalytics-helpers.js(see Merging).composer.jsonpinsphpunit/phpunitto^9.6. Revisit on an upgrade.6. Not verified
X-Forwarded-Forheader itself. If a proxy in front of the analytics service does not pass it, the service sees no usable address and the country is empty, so the analytics environment has to be checked for this before release.godam-for-wooadd-on sendslocation_iptoo. After this PR its Reel Pop events carry an empty one (seen in capture S02, type 4): the service ignores it for browser events and stores the request's address. Its server-sent events (order revenue) are not part of this change. Checked by reading its code and by that one capture.location_ip, until caches expire or sites update. The analytics release has to cope with both (it does: for browser events it ignores the field when the request has an address).7. Scope
None.
rtgodam_get_user_ip()is kept, though nothing in the plugin calls it any more, in case an add-on does; its docblock now says so (e10c7bb).Merging
#2213 (stops sending the signed-in viewer's email) is merged, and
developis merged into this branch. The one conflict, inanalytics-helpers.jswhere the two removed lines sat next to each other, was resolved by keeping both removals, so this diff now only removeslocationIPandlocation_ip.What changed
rtgodam_get_localize_array()no longer setslocationIP.buildAnalyticsRequestBody()no longer readslocationIPor sendslocation_ip.How to check by hand
videoAnalyticsParams: the object has nolocationIP.analytics, play the video. The request payload has nolocation_ipkey.