-
Notifications
You must be signed in to change notification settings - Fork 218
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
Analytics event: CHANGE_CONTENT_TYPE
#1151
Conversation
CHANGE_CONTENT_TYPE
analytics event
Size Change: -17.3 kB (-2%) Total Size: 845 kB
ℹ️ View Unchanged
|
Full-stack documentation: https://docs.openverse.org/_preview/1151 Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again. You can check the GitHub pages deployment action list to see the current status of the deployments. |
@zackkrida Is this PR blocked? |
@WordPress/openverse-frontend apologies but I am going to need to hand this off to someone else. We can assign in the team meeting tomorrow 👍 |
1fed6b4
to
a2ea4e9
Compare
CHANGE_CONTENT_TYPE
analytics eventCHANGE_CONTENT_TYPE
analytics event
247593d
to
e62dd0b
Compare
CHANGE_CONTENT_TYPE
analytics eventCHANGE_CONTENT_TYPE
Thanks for working on this, @obulat 😄 |
7c2b8de
to
17f38f7
Compare
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.
LGTM! I have one non-blocking suggestion.
@@ -64,6 +66,7 @@ export const useAnalytics = () => { | |||
name: T, | |||
payload: Events[T] | |||
) => { | |||
log(`Analytics event: ${name}`, payload) |
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.
Nice addition, very helpful.
*/ | ||
export const useComponentName = () => { | ||
const vm = getCurrentInstance() | ||
return vm?.proxy.$options.name |
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 don't think name
is a required property so having a fallback in case it's undefined
might be a good idea. A lint check to ensure all our components have names would be a better idea but that might be more work.
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.
Another thought: should useComponentName
raise an error if it's used in a context where no component name exists? That would keep the return value stable string
not undefined | string
, but would be much stricter than this implementation.
Falling back to "Unknown" without it being intentional, especially if this is used to disambiguate events, doesn't seem like a good long-term practice.
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 would like to have a stricter implementation, but when we test the use-search-type
in unit tests, there is no component, so this will throw errors. Maybe we could create a new issue to see if we have many "Unknown" components in analytics reports, and if we do - fix it?
analytics.sendCustomEvent("CHANGE_CONTENT_TYPE", { | ||
previous: previousSearchType.value, | ||
next: searchType, | ||
component: componentName ?? "Unknown", |
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.
?? "Unknown"
should be moved to the composable itself.
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 works fine locally, but as with the other event PRs, I have some questions about the payload data, what we're trying to identify with them, and whether we need to tighten the requirements for the useComponentName
composable or choose a different approach altogether for disambiguating this particular event.
/** The name of the Vue component used to switch content types. */ | ||
component: string |
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 kind of wonder about using the Vue component name here rather than more stable names. We don't change component names often but the header dropdown I think has had its components changed during the redesign. In cases like that, the name of the component might change, even though the interaction area stayed the same 🤔
This also makes me wonder whether we should send the feature flag state in the payload for all events? If we have a feature flag that toggles a particular bit of UI or a feature on or off and it suddenly changes how a custom event trends, it would be nice to see if the feature flag preferences were changed for those events.
It isn't an issue now because I don't think we have any feature flags that would qualify for that, but something to consider for the future, especially if we use things like component names which are not necessarily stable, even if the UI area they're inside of remains stable.
On the other hand, using the component name might be a good way to tell the same cases as those feature flags, but probably contingent on the implementation.
No real suggestion for a change here, just some musings about how to find stable identifiers and thing carefully about exactly what each payload item is meant to help us do. If we ask the question, why do we want to know the component name for this event, does the answer lead us to think that a different approach to this payload field would be appropriate?
*/ | ||
export const useComponentName = () => { | ||
const vm = getCurrentInstance() | ||
return vm?.proxy.$options.name |
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.
Another thought: should useComponentName
raise an error if it's used in a context where no component name exists? That would keep the return value stable string
not undefined | string
, but would be much stricter than this implementation.
Falling back to "Unknown" without it being intentional, especially if this is used to disambiguate events, doesn't seem like a good long-term practice.
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 was able to test both search type changes locally and see that they appeared in the logs, great idea adding that!
17f38f7
to
5724117
Compare
Size Change: -17.5 kB (-2%) Total Size: 840 kB
ℹ️ View Unchanged
|
@obulat this has two approving reviews despite some dangling feedback from Sara. Could you review and merge, making any necessary follow-up issues? |
5724117
to
2960306
Compare
I'll open a new issue for the points raised by Sara
Fixes
Fixes #1071 by @dhruvkb
Description
useComponentName
composableCHANGE_CONTENT_TYPE
event and fires it on use of theVSearchType
andVContentLink
componentssendCustomEvent
methodTODO
VLink
click event situationTesting Instructions
Checklist
Update index.md
).main
) ora parent feature branch.
errors.
Developer Certificate of Origin
Developer Certificate of Origin