fix(common-utils): forward original arguments in debounce - #7920
fix(common-utils): forward original arguments in debounce#7920Kropiunig wants to merge 2 commits into
Conversation
|
@Kropiunig is attempting to deploy a commit to the cow-dev Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
WalkthroughThe debounce utility now forwards arguments individually. Trade analytics callers use the corrected convention, and Jest tests cover forwarding, latest-argument behavior, and delayed invocation. ChangesDebounce argument convention
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Thank you!
The change looks valid. I would kindly ask to check the places where the function is in use. I see two places:
debouncedTradeAmountAnalytics([field, Number(typedValue)])this.debouncedPageView(path, params, title)
It looks like with this PR changes debouncedTradeAmountAnalytics call can be simplified.
…bounce arg forwarding fix
|
Good catch, thanks! Simplified the |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Summary
debounceinlibs/common-utils/src/misc.tsinvokes the wrapped function with the collected arguments array as a single first parameter (func(args), line 48) instead of spreading it (func(...args)). Every argument-taking callback wrapped by this util receives an array as its first parameter andundefinedfor the rest:The production consumer,
debouncedPageViewinlibs/analytics/src/gtm/CowAnalyticsGtm.ts:109, declares exactly this 3-parameter callback. Consequences for everypage_viewpushed to the GTM data layer:page_pathis an array (e.g.['/swap']) instead of a string, so any GTM variable/trigger doing type-sensitive matching on it misbehavesparams/titlepassed to the publicsendPageView(path, params, title)API are silently dropped: they end up folded into thepage_patharray whilepage_title/page_paramsbecomeundefinedand are stripped bysanitizeRecordThe fix spreads the arguments (
func(...args)), which matches the declared generic typeF extends (...args: any) => anyand standard debounce semantics.Regression tests added in
libs/common-utils/src/misc.test.ts:develop(received[['/swap?chain=mainnet', ['param'], 'CoW Swap']]), passes with the fixdevelop(received[['second']]), passes with the fixTo Test
npx nx test common-utilsmisc.tsmakes the two new debounce assertions failnpx nx test analyticswindow.enableGaLogging = trueand navigate between pagespage_viewdata-layer push containspage_pathas a string (e.g."/swap"), not an arrayBackground
usePageViewTrackingcurrently passes onlypath, so the most visible damage today is the wrong type forpage_pathin the data layer. ButsendPageViewacceptsparamsandtitleas part of theCowAnalyticsinterface, anddebounceis exported from@cowprotocol/common-utils, so any consumer passing arguments hits the same mangling.Summary by CodeRabbit
(field, amount)values.