-
Notifications
You must be signed in to change notification settings - Fork 496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ga dimension for config cookie #515
Add ga dimension for config cookie #515
Conversation
Signed-off-by: Everett Ross <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #515 +/- ##
==========================================
- Coverage 92.92% 92.85% -0.08%
==========================================
Files 197 197
Lines 4808 4814 +6
Branches 1160 1162 +2
==========================================
+ Hits 4468 4470 +2
- Misses 299 303 +4
Partials 41 41 Continue to review full report at Codecov.
|
@@ -45,6 +45,13 @@ const gaID = _get(config, 'tracking.gaID'); | |||
export const isGaEnabled = isTest || isDebugMode || (isProd && Boolean(gaID)); | |||
const isErrorsEnabled = isDebugMode || (isGaEnabled && Boolean(_get(config, 'tracking.trackErrors'))); | |||
|
|||
const cookieToDimension = _get(config, 'tracking.cookieToDimension'); | |||
if (cookieToDimension) { | |||
const match = ` ${document.cookie}`.match(new RegExp(`[; ]${cookieToDimension.cookie}=([^\\s;]*)`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- what is the meaning of the leading space?
- are you forced to use regexp because there is no structured API to access cookies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Leading space because the regex looks for
;
and/ordocument.cookie
string. - Correct. There are npm libraries for this (of course) but a library for a simple RegEx is overkill, and libraries may make certain assumptions about the cookies that aren't relevant here, meanwhile it's easy to know what our own RegEx is precisely doing.
Signed-off-by: Everett Ross <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any tests we should add?
The other code in the file run on JS load is also untested. I'm not sure of a good approach for it, so I'd leave it for now. I'll dogfood it in staging w/ the config change before landing. |
Signed-off-by: Everett Ross <[email protected]>
Dogfooded successfully. |
* Add ga dimension for config cookie * Update cookiesToDimensions to an array * Move when cookie dimensions are set Signed-off-by: Everett Ross <[email protected]> Signed-off-by: vvvprabhakar <[email protected]>
Which problem is this PR solving?
Short description of the changes