-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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 extraUrlParams and extraUrlParamsReplaceMap to amp-analytics #1932
Conversation
var i = 0; | ||
for (const keyrule in this.config_['customVarsMap']) { | ||
var replacerule = this.config_['customVarsMap'][keyrule]; | ||
alert ("keyrule = " + keyrule + ";replacerule = " + replacerule); |
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.
I'd recommend using console.log :)
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.
Will remove - that was for debugging
Looks great. Just some simple questions and nits. Run |
who are we building this for? can you point to some examples on who would use/need these? |
This is for Adobe Analytics |
I see. a few general concerns:
|
Maybe I second Avi's concern about the replace being really weird, since people could just use the output instead. But I'm happy to make things easy for Adobe customers. |
|
I'm not worried about runtime performance. Code size and complexity is the only worry. Lets call them |
c337838
to
66337b9
Compare
I did:
I did not:
PTAL |
} | ||
|
||
// only allow word chars | ||
replaceMapKey = extraUrlParamsReplaceMapKey.replace(/(\W)/g, '\$1'); |
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.
not sure what extraUrlParamsReplaceMapKey
is.
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.
good catch. corrected and tested.
agreed with @cramforce on code complexity. Plus I still feel that this is too specific a solution and that #1701 is a more generic replacement of this. Having said that, I am still not completely sure about how this is going to be used. I am not sure there will be multiple vendor Since I don't understand the usecase, I think I am okay with committing this and keeping an eye on how this will be used. |
I've given this some thought and I think, more broadly, the need for the extraUrlParams is introduced because the request URLs have the variables built into the string. Rather than push this one through, and adding that as technical debt for later, let's grab some time to brainstorm the right approach and move forward appropriately. |
I have the same questions as @avimehta, but I also want to get this resolved quickly. Main question is whether the replace list itself needs to be configured by clients or is there a single one. I think the |
talked offline. Iets continue with this PR. I don't think we are painting ourselves is a bad corner with this. Overall, this is a positive this for analytics and should be done. Jordan has some great ideas about how to make requests more flexible. Lets talk about those outside of this PR. |
66337b9
to
d572fe2
Compare
Final revisions made. PTAL @cramforce before merge |
// of params to String.replace to allow aliasing of the keys in | ||
// extraUrlParams. | ||
let count = 0; | ||
const MAX_REPLACES = 16; |
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.
This should be defined near the top of the file and come with an explanation.
One comment. Please rebase. |
d572fe2
to
27339f7
Compare
fixed & rebased |
Rebasing appears to not have been successful. Maybe you forgot to pull down master? |
} | ||
|
||
// only allow word chars | ||
replaceMapKey = replaceMapKey.replace(/(\W)/g, '\$1'); |
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 this preventing?
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.
early iterations treated the key as a regex. It's now just a string, though. I'll remove the line as it's irrelevant now.
8864386
to
409bb62
Compare
409bb62
to
42726fc
Compare
LGTM |
Add extraUrlParams and extraUrlParamsReplaceMap to amp-analytics
Implements #1881