-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Gutenboarding: Add TrainTracks events for domain picker #41173
Gutenboarding: Add TrainTracks events for domain picker #41173
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~813 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
@@ -28,13 +40,47 @@ const DomainPickerSuggestionItem: FunctionComponent< Props > = ( { | |||
const domainName = domain.slice( 0, dotPos ); | |||
const domainTld = domain.slice( dotPos ); | |||
|
|||
const { domainSearch } = useSelect( select => select( STORE_KEY ).getState() ); | |||
const fetchAlgo = `/domains/search/${ DOMAIN_SUGGESTION_VENDOR }/${ FLOW_ID }`; |
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.
Just checking: this is enough to differentiate a gutenboarding domain search, right? (As opposed to a standard Calypso signup one).
That is, we won't need to send any additional flow info?
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.
From re-reading PCYsg-bor-p2 I think we can pass in another param ui_algo
to denote where in the flow the search results appear. So something like /gutenboarding/domain-popover
might be a good identifier?
Hi @daledupreez @klimeryk ! This PR is just the first pass of adding analytics to domain dropdown in new onboarding. We would love your insights from tracking the domains in general. Thanks! |
query: domainSearch, | ||
railcarId, | ||
result: isRecommended ? domain + '#recommended' : domain, | ||
uiPosition, |
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 is the domain's position on the list — to me, "ui position" sounds a little bit like the position of the whole suggestion list.
We'll have the same list appear in few places, in immediate future we'll have the domain dropdown (what we have now in master
) and "more domains modal" (#41081). Possibly some additional domain steps and other places as well. We should likely include that info in tracking event?
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.
Absolutely. I think if we add another param listed in PCYsg-bor-p2 ui_algo
we can use that to denote the unique place where the list appears. E.g. we could have:
/gutenboarding/domain-popover
/gutenboarding/domain-expanded
/gutenboarding/domain-step
Etc.
|
||
useEffect( () => { | ||
// Only record TrainTracks render event when the domain name changes | ||
if ( domain !== previousDomain || previousRailcarId !== railcarId ) { |
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.
Do the TrainTracks events fire too frequently, too infrequently, or are they just right?
I don't yet know what's causing it, or even if it's a problem, but it seems strange that making one request to v1.1/domains/suggestions
(which yields five results) triggers 10 calypso_traintracks_render
calls.
The first five 10 calypso_traintracks_render
calls are for the default suggested domains, the next five are the query results. That makes sense.
But when I clear the domain search field, it triggers another 10 calypso_traintracks_render
calls. This time the first five 10 calypso_traintracks_render
calls are for the previous query results, the next five are the default suggested domains.
Seems like it's too many when I compare it with https://wordpress.com/start/domains
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.
Thanks for testing! Yes, that sounds like too many. From what I've been looking at so far, for each rendered suggestion item we should have 1 network request. So the desired behaviour (I think!) is that once the debounce finishes and we have a fresh set of suggestions, we call calypso_traintracks_render
, but then don't render again unless the results are fresh. I'll have another go.
The properties/values being sent look good to me. The recommended domain gets a The vendor variation is passed to Just a couple of questions, mainly around the render frequency |
High-level question, is there any chance we can keep the actual train tracks logic out of the domain picker component? @sirreal and I were at some point hoping to keep the domain picker generic and reusable, and eventually maybe even extract it into a "smart components" package (components that are connected to a data store) for better separation of concerns, and re-usability. To that end, it'd be great if we didn't embed analyitics stuff deeply in it. I haven't deeply checked this diff, but would it be a lot of hassle to add some rather generic event handler-style props to the domain picker, and use those to pass in the railcar logic? |
@ockham I don't think there is an instance where we'd want it to shoot different events, or no events at all? |
Fair point. We normally have at least some amount of contextual information in our tracking (e.g. event names reflecting the area of Calypso an event is happening; here's an example for the present PR), but maybe it'd be enough to make those things (event names, or even just prefixes/infixes) into props. I'd just rather avoid too-domain specific analytics get in the way of component reusability. The latter is IMO a problem that we've seen a lot in Calypso, and it'd be great if we could avoid it this time around. |
Side note, the fact that TrainTracks expects an event upon render is... interesting (see PCYsg-bor-p2):
That doesn't sound like something that's particularly easy to pull off in React; in order to avoid duplication, there needs to be component lifecycle logic in place that compares before/after props, and that's notoriously easy to miss when e.g. adding new props, making the whole system rather fragile. I wonder how reliable our TrainTracks data obtained from across Calypso is. It might be better to replace render-based events firing by user input-based firing (changed search term etc), but that's an architectural question for TrainTracks. Edit: Tentatively cc'ing @sirino |
I agree that would be important — tho event names themself cannot be built from variables (so that it's possible to find them via code search), but additional event props would be possible and could be made required. |
26e5c8f
to
7ccaeec
Compare
I've rebased this to fix the package-lock conflicts. |
This is spot-on. It's definitely possible to do this correctly, but it's much easier to get it completely wrong unless you're carefully examining your components' lifecycles. I'm not sure how to make it any easier at the moment, unfortunately.
How might this work? Perhaps we could fire an event when we receive the search results instead of when we render the search results? I suppose we still have to contend with how we're going to relay values like |
Thanks for the great feedback and suggestions, everyone! Today I've:
I'm on maintenance rotation for the next two weeks so likely won't have enough time to progress on this myself. I'll unassign myself from the PR, so feel free to pick this up anyone who would like to (@Automattic/ganon). Some next steps might include:
I think that's all for now, I'll keep an eye on this PR where I can though, so please let me know if there's anything else I've missed! |
If my PR gets merged first, I'll help rebase this PR. Let the race begins! #41212 |
7432dcb
to
e4b34ef
Compare
Rebased with changes from #41212! |
9f0fbd7
to
b48db30
Compare
The railcarId is now only updated when the domain suggestions change (and are not empty), and the domain suggestion itself has changed.
…ract away train tracks calls
Considered using function overloading so `recordTrainTracksEvent` would take a different payload depending on the first argument, but I think it's considered best practice not to use overloading in new code.
8c32a75
to
ac6c90c
Compare
@andrewserong do you have time to quickly double check my work? I haven't had to really change the code much except for small things to make the typings work. The |
Thanks so much for all this @p-jackson, the types and tests are looking great, and even though things will likely change in the future, this feels like a good level of test coverage so far and will be a useful point of reference for anyone making changes to this component in the future. Manual testing still shows the events are being fired as I'd expect them to. Good idea P2ing the event firing behaviour. From my searches, it looks like the traintracks events are being hidden from live view, etc, but it sounds like they should still be queryable. I think we'll need some guidance on the best way to extract the data, but for now, I think it looks like everything is set up correctly according to the documentation. The only change I think we still need to make is to move the analytics into |
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've retested and can approve :)
Subject to rebase
I'm planning to move functions and delete @ramonjd what's the rebase for? My GH UI sais no conflicts. |
Oh sorry @p-jackson 🤦 "rebase" was the wrong word. Andy said it right:
We moved analytics into So you could copy pasta your stuff over there. The suggestion was that utils contains functions that don't have any side effects. |
Util functions should be side-effect free
Makes sense. I've refactored the functions into |
Thanks @jsnmoon for your reply, sorry for my delay in getting back to you!
Firing upon receiving the search results might be better if we can do that from Redux/ I'm not very familiar with TrainTracks, so I guess the big question is if we can cleanly pass information such as |
This PR adds in TrainTracks events in the domain picker in Gutenboarding. It should fire off events when the search results are rendered in the domain picker, when the search results are updated, and an interact event when a user selects one of the domain suggestions.
More info: PCYsg-bor-p2
Changes proposed in this Pull Request
render
andinteract
in the domain picker following PCYsg-bor-p2 and referencing the logic in the existing domain step in the legacy signup flow.gutenboarding
in the vendor name.@types/uuid
Testing instructions
/new
and open up the Domain Picker and examine requests in the network inspector in devtoolsrailcarId
matches the patternuuid-suggestion0
where the final number is incremented based on its position in the search results — this allows theinteract
event to map to the render event.E.g. in the following screenshot, the highlighted event is
domain_selected
and has the same railcar id as the rendered suggestionQuestions:
Part of #41059