Skip to content

Commit 6d5f12b

Browse files
vid277densumesh
authored andcommitted
cleanup: use click event for followup query + remove initial question tracking
1 parent 65566fb commit 6d5f12b

File tree

8 files changed

+5
-133
lines changed

8 files changed

+5
-133
lines changed

clients/search-component/src/TrieveModal/Chat/FollowupQueries.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const FollowupQueries = () => {
2626

2727
await trieveSDK.sendAnalyticsEvent({
2828
event_name: `site-followup_query`,
29-
event_type: "followup_query",
29+
event_type: "click",
3030
user_id: fingerprint,
3131
location: window.location.href,
3232
metadata: {

clients/search-component/src/TrieveModal/Chat/SuggestedQuestions.tsx

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const SuggestedQuestions = ({
1616
const { suggestedQuestions, isLoadingSuggestedQueries, getQuestions } =
1717
useSuggestedQuestions();
1818

19-
const { props, trieveSDK, fingerprint } = useModalState();
19+
const { props } = useModalState();
2020
const [parent] = useAutoAnimate({ duration: 100 });
2121

2222
if (messages.length) {
@@ -25,31 +25,7 @@ export const SuggestedQuestions = ({
2525

2626
const handleSuggestedQuestion = async (q: string) => {
2727
setCurrentQuestion(q);
28-
29-
const lastMessage = JSON.parse(
30-
window.localStorage.getItem("lastMessage") ?? "{}",
31-
);
32-
33-
const requestId =
34-
Object.keys(lastMessage)[0] || "00000000-0000-0000-0000-000000000000";
35-
36-
await trieveSDK.sendAnalyticsEvent({
37-
event_name: `site-followup_query`,
38-
event_type: "followup_query",
39-
user_id: fingerprint,
40-
location: window.location.href,
41-
metadata: {
42-
followup_query: q,
43-
component_props: props,
44-
},
45-
request: {
46-
request_id: requestId,
47-
request_type: "rag",
48-
},
49-
});
50-
5128
askQuestion(q);
52-
5329
if (onMessageSend) {
5430
onMessageSend();
5531
}

clients/trieve-shopify-extension/app/components/analytics/chat/PopularSuggestedQueries.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const PopularSuggestedQueries = ({
2121
client.prefetchQuery(
2222
popularSuggestedQueriesQuery(trieve, filters, page + 1),
2323
);
24-
}, [page]);
24+
}, [page, filters]);
2525

2626
const mappedData = data
2727
? data.top_queries.map((query: { query: string; count: number }) => [

clients/ts-sdk/openapi.json

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11582,48 +11582,6 @@
1158211582
}
1158311583
}
1158411584
},
11585-
{
11586-
"type": "object",
11587-
"title": "FollowupQuery",
11588-
"required": [
11589-
"event_name",
11590-
"event_type"
11591-
],
11592-
"properties": {
11593-
"event_name": {
11594-
"type": "string",
11595-
"description": "The name of the event"
11596-
},
11597-
"event_type": {
11598-
"type": "string",
11599-
"enum": [
11600-
"followup_query"
11601-
]
11602-
},
11603-
"location": {
11604-
"type": "string",
11605-
"description": "The location of the event",
11606-
"nullable": true
11607-
},
11608-
"metadata": {
11609-
"description": "Any other metadata associated with the event",
11610-
"nullable": true
11611-
},
11612-
"request": {
11613-
"allOf": [
11614-
{
11615-
"$ref": "#/components/schemas/RequestInfo"
11616-
}
11617-
],
11618-
"nullable": true
11619-
},
11620-
"user_id": {
11621-
"type": "string",
11622-
"description": "The user id of the user who made the followup query",
11623-
"nullable": true
11624-
}
11625-
}
11626-
},
1162711585
{
1162811586
"type": "object",
1162911587
"title": "FilterClicked",
@@ -11931,7 +11889,6 @@
1193111889
"add_to_cart",
1193211890
"purchase",
1193311891
"view",
11934-
"followup_query",
1193511892
"click",
1193611893
"filter_clicked"
1193711894
]

clients/ts-sdk/src/types.gen.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,25 +1549,6 @@ export type EventTypes = {
15491549
* The user id of the user who purchased the items
15501550
*/
15511551
user_id?: (string) | null;
1552-
} | {
1553-
/**
1554-
* The name of the event
1555-
*/
1556-
event_name: string;
1557-
event_type: 'followup_query';
1558-
/**
1559-
* The location of the event
1560-
*/
1561-
location?: (string) | null;
1562-
/**
1563-
* Any other metadata associated with the event
1564-
*/
1565-
metadata?: unknown;
1566-
request?: ((RequestInfo) | null);
1567-
/**
1568-
* The user id of the user who made the followup query
1569-
*/
1570-
user_id?: (string) | null;
15711552
} | {
15721553
/**
15731554
* The name of the event
@@ -1716,7 +1697,7 @@ export type EventTypes = {
17161697

17171698
export type event_type = 'view';
17181699

1719-
export type EventTypesFilter = 'add_to_cart' | 'purchase' | 'view' | 'followup_query' | 'click' | 'filter_clicked';
1700+
export type EventTypesFilter = 'add_to_cart' | 'purchase' | 'view' | 'click' | 'filter_clicked';
17201701

17211702
export type EventsForTopicResponse = {
17221703
events: Array<EventData>;

server/src/data/models.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6977,27 +6977,6 @@ impl EventTypes {
69776977
created_at: OffsetDateTime::now_utc(),
69786978
updated_at: OffsetDateTime::now_utc(),
69796979
}),
6980-
EventTypes::FollowupQuery {
6981-
event_name,
6982-
request,
6983-
user_id,
6984-
metadata,
6985-
location,
6986-
} => EventDataTypes::EventDataClickhouse(EventDataClickhouse {
6987-
id: uuid::Uuid::new_v4(),
6988-
event_type: "followup_query".to_string(),
6989-
event_name,
6990-
request_id: request.clone().unwrap_or_default().request_id.to_string(),
6991-
request_type: request.unwrap_or_default().request_type.to_string(),
6992-
items: vec![],
6993-
user_id: user_id.unwrap_or_default(),
6994-
metadata: serde_json::to_string(&metadata.unwrap_or_default()).unwrap_or_default(),
6995-
is_conversion: false,
6996-
location: location.unwrap_or_default(),
6997-
dataset_id,
6998-
created_at: OffsetDateTime::now_utc(),
6999-
updated_at: OffsetDateTime::now_utc(),
7000-
}),
70016980
EventTypes::Purchase {
70026981
event_name,
70036982
request,
@@ -7288,8 +7267,6 @@ pub enum EventTypesFilter {
72887267
Purchase,
72897268
#[display(fmt = "view")]
72907269
View,
7291-
#[display(fmt = "followup_query")]
7292-
FollowupQuery,
72937270
#[display(fmt = "click")]
72947271
Click,
72957272
#[display(fmt = "filter_clicked")]
@@ -8536,20 +8513,6 @@ pub enum EventTypes {
85368513
/// The location of the event
85378514
location: Option<String>,
85388515
},
8539-
#[display(fmt = "followup_query")]
8540-
#[schema(title = "FollowupQuery")]
8541-
FollowupQuery {
8542-
/// The name of the event
8543-
event_name: String,
8544-
/// The request id of the event to associate it with a request
8545-
request: Option<RequestInfo>,
8546-
/// The user id of the user who made the followup query
8547-
user_id: Option<String>,
8548-
/// Any other metadata associated with the event
8549-
metadata: Option<serde_json::Value>,
8550-
/// The location of the event
8551-
location: Option<String>,
8552-
},
85538516
#[display(fmt = "filter_clicked")]
85548517
#[schema(title = "FilterClicked")]
85558518
FilterClicked {

server/src/operators/analytics_operator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3288,7 +3288,7 @@ pub async fn get_top_followup_queries_query(
32883288
) -> Result<FollowupQueriesResponse, ServiceError> {
32893289
let mut query_string = String::from(
32903290
"SELECT
3291-
JSONExtractString(metadata, 'followup_query') as query,
3291+
DISTINCT JSONExtractString(metadata, 'followup_query') as query,
32923292
COUNT(*) AS count
32933293
FROM
32943294
events

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7094,11 +7094,6 @@ trieve-ts-sdk@^0.0.50:
70947094
resolved "https://registry.yarnpkg.com/trieve-ts-sdk/-/trieve-ts-sdk-0.0.50.tgz#8b16f7a0f7f77d81811aa0e3a7ed7050b5938379"
70957095
integrity sha512-AbV41cEzxNSJ+gXUAOFK5OoMl4Kgu/DGkIU/fRS+k8rH+s0ePwBK6CYSPKBxGvNajbZ9hoqiUgN9/qZJX+k0yA==
70967096

7097-
trieve-ts-sdk@^0.0.69:
7098-
version "0.0.69"
7099-
resolved "https://registry.yarnpkg.com/trieve-ts-sdk/-/trieve-ts-sdk-0.0.69.tgz#837f21890faf7658157a65fdf9069246ee59d81a"
7100-
integrity sha512-I1QOndfsCBcNwPEi7gtO8SNHdt8LZvEAWPNmY38HhEE1Dnxx5lmMmVfjqGogirVaOdS0ZS4JxZ1vlfIjAPgGZg==
7101-
71027097
trim-lines@^3.0.0:
71037098
version "3.0.1"
71047099
resolved "https://registry.yarnpkg.com/trim-lines/-/trim-lines-3.0.1.tgz#d802e332a07df861c48802c04321017b1bd87338"

0 commit comments

Comments
 (0)