Skip to content

Commit

Permalink
fix: use last query uuid for custom events (#1953)
Browse files Browse the repository at this point in the history
* getLastQueryUID for custom events

* Fix UT
  • Loading branch information
dmbrooke authored Sep 29, 2023
1 parent 374ee5a commit 48a68da
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/rest/CustomEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ export interface ICustomEvent extends IAnalyticsEvent {
* **Example:** `pagerNext`
*/
eventValue: string;

/**
* The searchQueryUid of the last search event that occurred before this event.
*
* **Example:** `74682726-0e20-46eb-85ac-f37259346f57`
*/
lastSearchQueryUid: string;
}
2 changes: 1 addition & 1 deletion src/ui/Analytics/LiveAnalyticsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export class LiveAnalyticsClient implements IAnalyticsClient {
element: HTMLElement
): ICustomEvent {
return this.merge<ICustomEvent>(this.buildAnalyticsEvent(actionCause, metaObject), {
searchQueryUid: this.getLastSearchQueryUid(),
lastSearchQueryUid: this.getLastSearchQueryUid(),
eventType: actionCause.type,
eventValue: actionCause.name,
originLevel2: this.getOriginLevel2(element),
Expand Down
4 changes: 2 additions & 2 deletions unitTests/ui/LiveAnalyticsClientTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,14 @@ export function LiveAnalyticsClientTest() {
expect(analyticsEventReadySpy).toHaveBeenCalled();
});

it('should include searchQueryUid', function (done) {
it('should include lastSearchQueryUid', function (done) {
Simulate.query(env, { promise });
env.queryController.getLastResults = () => results;
_.defer(function () {
client.logCustomEvent<IAnalyticsNoMeta>(analyticsActionCauseList.documentOpen, {}, document.createElement('div'));
expect(endpoint.sendCustomEvent).toHaveBeenCalledWith(
jasmine.objectContaining({
searchQueryUid: results.searchUid
lastSearchQueryUid: results.searchUid
})
);
done();
Expand Down

0 comments on commit 48a68da

Please sign in to comment.