Skip to content

ksearch: upgrade to Events API #508

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

ksearch: upgrade to Events API #508

wants to merge 4 commits into from

Conversation

Fondryext
Copy link
Contributor

This PR upgrades our analytics calls to the next major version, also called the Events API. As part of this work, analytics calls have changed shape, and some deprecated properties have been dropped.
J=WAT-4651
TEST=auto,manual

Updated auto tests. Ran test site locally and saw events all the way to snowflake.

Fondryext and others added 2 commits April 7, 2025 12:53
This PR upgrades our analytics calls to the next major
version, also called the Events API. As part of this
work, analytics calls have changed shape, and some deprecated
properties have been dropped.
J=WAT-4651
TEST=auto,manual

Updated auto tests. Ran test site locally and saw events all the
way to snowflake.
Copy link
Contributor

github-actions bot commented Apr 7, 2025

Current unit coverage is 91.4992993928071%
Current visual coverage is 77.20391807658059%
Current combined coverage is 92.01680672268908%

@@ -1,5 +1,5 @@
import React, { PropsWithChildren } from 'react';
import { provideAnalytics, AnalyticsConfig } from '@yext/analytics';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This AnalyticsConfig has changed shape in the new analytics, the old one was actually very search specific and had properties like experienceKey - the new one is very high level and only requires an auth type and an auth key. I think because of this alone this is breaking.

queryId,
verticalKey: verticalKey || '',
url,
fieldName,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we drop 'searcher' and 'fieldName'

verticalKey: verticalKey,
newPage,
currentPage,
totalPageCount
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We drop all three of these page-related values.

currentPage: number,
totalPageCount: number
) => void {
export function usePaginationAnalytics(): () => void {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function changes signature

analytics?.report({
type: 'AUTO_COMPLETE_SELECTION',
...(queryId && { queryId }),
suggestedSearchText
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We drop suggestedSearchText

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's interesting, seems like it'd be a pretty relevant piece of data for this

Copy link
Contributor Author

@Fondryext Fondryext Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you mean? Interesting that analytics dropped it from their new system, or that I followed it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting that analytics dropped it. We should ofc follow whatever their system supports / expects

@coveralls
Copy link

coveralls commented Apr 7, 2025

Coverage Status

coverage: 86.688% (-0.5%) from 87.142%
when pulling 6ae8d8e on dev/events-api
into 055c51d on main.

@@ -90,10 +93,19 @@ export function SectionHeader(props: SectionHeaderProps): JSX.Element {
console.error('Unable to report a vertical view all event. Missing field: queryId.');
return;
}
if (!experienceKey) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a check for locale or searchId? Or are those automatically set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

locale can be unset in the event payload so passing it possible undefined is ok. For searchId we could also add error handling if the searchId is not present.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm as I think about it, our analytics are all based off query id now right? Probably not necessary to require the search id if we don't see that changing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually trying to send an analytics event without search id crashes out, as I recall. My understanding was that the events are based on the first search id of a query, which is the same as the query id.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, so it seems necessary, but also that it should be automatically set elsewhere correct? Therefore not requiring any extra check here?

Copy link
Contributor Author

@Fondryext Fondryext Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree a check would be nice, and I will add it. Could you elaborate the second comment? What should be set, the searchId? Isn't that pulled from the meta state? I'm not sure we have any guarantees about that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry maybe I was misunderstanding your prior comment. The way I read it was that the search id was being set as the query id by default somewhere up the chain in the SDK somewhere. Feel free to disregard. I agree adding a check is good then

analytics?.report({
type: 'AUTO_COMPLETE_SELECTION',
...(queryId && { queryId }),
suggestedSearchText
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's interesting, seems like it'd be a pretty relevant piece of data for this

@@ -1,6 +1,6 @@
{
"name": "@yext/search-ui-react",
"version": "1.8.2",
"version": "1.8.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My debounce change is 1.8.3 so this will have to change - I assume to 2.0.0 since this has breaking changes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this change is a draft.

@@ -90,10 +93,19 @@ export function SectionHeader(props: SectionHeaderProps): JSX.Element {
console.error('Unable to report a vertical view all event. Missing field: queryId.');
return;
}
if (!experienceKey) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, so it seems necessary, but also that it should be automatically set elsewhere correct? Therefore not requiring any extra check here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants