-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
feat: distinguish app vs launchpad utm_source when using utm params #21424
Conversation
Thanks for taking the time to open a PR!
|
Test summaryRun details
View run in Cypress Dashboard ➡️ Flakiness
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
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.
Updated links look good, tested in app/launchpad. Couple things to note:
- I noticed that our changelog links don't have UTM params in 10.0, whereas they do in develop. For example:
https://docs.cypress.io/guides/references/changelog?source=dgui_footer&utm_medium=Footer&utm_campaign=Changelog&utm_source=Test%20Runner
. Not sure if that was intentionally scoped out, but we do launch those from both launchpad and app. - This isn't new to your PR, but we have logic in our openExternal mutation that can also append query params. Seems like this could conflict with our
getUrlWithParams
implementation if that arg is ever enabled, but it doesn't look like it is 🤷♂️ Would be worth removing if it's unused, especially if using it will result in bugs.
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.
Two comments
@@ -5,6 +5,15 @@ export type LinkWithParams = { | |||
|
|||
export const getUrlWithParams = (link: LinkWithParams) => { | |||
let result = link.url | |||
const hasUtmParams = Object.keys(link.params).find((param) => param.startsWith('utm_')) |
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.
Can use some
to be more clear about the intention. When using find
I usually expect the found variable is used, or an error is throw if it's not found. This is more "does it exist" in a true/false sense.
const hasUtmParams = Object.keys(link.params).find((param) => param.startsWith('utm_')) | |
const hasUtmParams = Object.keys(link.params).some((param) => param.startsWith('utm_')) |
This is how Lodash's findKey
works. https://github.com/lodash/lodash/blob/master/findKey.js#L23-L36
Or, if you want to be optimal and save a loop...
function keyStartsWith (o, key) {
for (const k in o) {
if (k.startsWith(key)) return true
}
return false
}
I think some
is the best candidate among findKey
, find
or the for loop.
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.
oh that's awesome, I always forget about some
but it's ideal here
|
||
return require('electron').shell.openExternal(url.href) | ||
export const openExternal = (url: string) => { | ||
return require('electron').shell.openExternal(url) |
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 reason we inline the require
instead of a top level import
?
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.
if (args.includeGraphqlPort && process.env.CYPRESS_INTERNAL_GRAPHQL_PORT) { | ||
url = `${args.url}?port=${process.env.CYPRESS_INTERNAL_GRAPHQL_PORT}` | ||
const joinCharacter = args.url.includes('?') ? '&' : '?' |
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.
@estrada9166 I made this small change, might as well future proof this for possible other params. @tbiethman I added a comment about the purpose of this, Alejandro showed me that it is actually used.
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.
Seems fine to me - CI looks a bit red, but once that's fixed, we are good to go.
* 10.0-release: (22 commits) fix: migrate multiples projects when in global mode (#21458) test: fix flaky cy-in-cy selector validity test (#21360) chore: remove unused codeGenGlobs (#21438) fix: use correct path for scaffolding spec on CT (#21411) fix: remove breaking options from testing type on migration (#21437) fix: test-recording instructions in Component Test mode (#21422) feat: distinguish app vs launchpad utm_source when using utm params (#21424) chore: update stubbed cloud types (#21451) chore: change to yarn registry fix(sessions): refactor flows, fix grouping bugs and align validation fail text (#21379) chore(sessions): more driver tests (#21378) chore: rename domain_fn to origin_fn (#21413) chore: release 9.6.1 (#21404) fix: ensure that proxy logs are updated after the xhr has actually completed (#21373) chore: Re-organize tests in assertions_spec.js (#21283) chore: Distribute tests to desktop-gui containers. Make `desktop-gui` tests faster! (#21305) chore(sessions): add additional tests (#21338) fix: Allow submit button to be outside of the form for implicit submission (#21279) fix(launcher): support Firefox as a snap (#21328) chore(sessions): break out sessions manager code and add unit tests (#21268) ...
Closes https://cypress-io.atlassian.net/browse/UNIFY-1436
User facing changelog
No user facing changes, but onlinks that previously had no
utm_source
, now correctly set a source of 'Binary: App' and 'Binary: Launchpad' depending on where they were clicked.Additional details
In 9.x the
utm_source
query param ofTest Runner
was added on the server as a part ofopenExternal
. This PR removes that functionality completely from the server, and instead applies the same rule on the client side, in ourgetUrlWithParams
helper function, to add theutm_source
automatically to URLs that already include any other utm params.Among other things, this makes the full length URL testable from the client side, and allows us to continue having well-formed links with accurate
href
attributes.This PR covers all links in the docs menu and the growth prompt that's part of it, and any future links that use utm params will have the correct source appended automatically.
How to test manually
Click any links in the docs menu in the launchpad and app and verify that when they take you to the docs pages, the utm params are present in the page URL and include the correct utm_source -
Binary: App
for the app andBinary: Launchpad
for the browser.PR Tasks
cypress-documentation
?type definitions
?cypress.schema.json
?