fix: constrain analytics app field characters on event type writes#28895
fix: constrain analytics app field characters on event type writes#28895pedroccastro wants to merge 3 commits intomainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis pull request introduces a new utility function 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
What does this PR do?
Adds a character allowlist for analytics app fields (
trackingId,trackingEvent,SITE_ID, etc.) that are interpolated into inline script templates rendered byBookingPageTagManager. Applied on event type create, update, and duplicate so that stored values consistently match the expected format.Changes
New
packages/app-store/_utils/sanitize-analytics-value.tshelper withsanitizeAnalyticsApps(metadata)— strips any character outside[a-zA-Z0-9\-._/:]from template fields of known analytics apps (ga4,gtm,metapixel,fathom,plausible,posthog,umami,matomo,databuddy,insihts,twipla)Wraps
metadatawithsanitizeAnalyticsAppsin:create.handler.ts,update.handler.ts,duplicate.handler.tsUnit test coverage for valid values, empty strings, null metadata, non-analytics apps, and odd inputs
Context
Analytics app fields are substituted into script templates via
parseValue. This normalizes stored values to the character set the templates expect, avoiding mismatched or ambiguous substitutions across integrations. The allowlist was derived from the shapes of each provider'sscript.contentandzod.ts.How should this be tested?
Manual
Mandatory Tasks