Skip to content

Commit 408a679

Browse files
cdxkerskeptrunedev
authored andcommitted
feature: show status field and got all filters working
1 parent 549b534 commit 408a679

11 files changed

Lines changed: 129 additions & 66 deletions

File tree

clients/trieve-shopify-extension/app/components/analytics/AdvancedTableComponent.tsx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
IndexTable,
77
IndexFilters,
88
useSetIndexFiltersMode,
9-
TabProps,
109
useBreakpoints,
1110
IndexFiltersProps,
1211
Icon,
@@ -22,7 +21,6 @@ import {
2221
ViewIcon,
2322
} from "@shopify/polaris-icons";
2423
import { ReactNode } from "react";
25-
import { add } from "date-fns";
2624

2725
export interface Filter {
2826
key: string;
@@ -40,13 +38,11 @@ export interface AdvancedTableComponentProps {
4038
data: AdvancedTableCell[][];
4139
page: number;
4240
setPage: (page: (page: number) => number) => void;
43-
tabs: string[];
4441
label: string;
4542
tableHeadings: { heading: string; tooltip: string; sortCol?: string }[];
4643
sortOptions: IndexFiltersProps["sortOptions"];
4744
sortSelected: string[];
4845
setSortSelected: (sortSelected: string[]) => void;
49-
tooltipContent: string;
5046
hasNext: boolean;
5147
loading: boolean;
5248
appliedFilters: IndexFiltersProps["appliedFilters"];
@@ -67,8 +63,6 @@ export const AdvancedTableComponent = ({
6763
page,
6864
setPage,
6965
label,
70-
tooltipContent,
71-
tabs,
7266
tableHeadings,
7367
hasNext,
7468
loading,
@@ -89,13 +83,6 @@ export const AdvancedTableComponent = ({
8983
}: AdvancedTableComponentProps) => {
9084
const { mode, setMode } = useSetIndexFiltersMode();
9185

92-
const indexTabs: TabProps[] = tabs.map((tab, index) => ({
93-
content: tab,
94-
index,
95-
id: `${tab}-${index}`,
96-
isLocked: index === 0,
97-
}));
98-
9986
return (
10087
<Page title={label} fullWidth={true}>
10188
<Card>

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { Select } from "@shopify/polaris";
2-
import { TopicEventFilter } from "trieve-ts-sdk";
2+
import { TopicEventFilter, EventTypesFilter } from "trieve-ts-sdk";
33
import { Dispatch, SetStateAction } from "react";
4-
import { KnownEventNames } from "app/utils/formatting";
54

65
interface EventFiltersProps {
76
eventsFilters: TopicEventFilter;
87
setEventsFilter: Dispatch<SetStateAction<TopicEventFilter>>;
98
}
109

11-
const AVAILABLE_EVENT_TYPES: { label: string; value: KnownEventNames }[] = [
12-
{ label: "Checkout", value: "site-checkout" },
13-
{ label: "Add to Cart", value: "site-add_to_cart" },
10+
const AVAILABLE_EVENT_TYPES: { label: string; value: EventTypesFilter }[] = [
11+
{ label: "Checkout", value: "purchase" },
12+
{ label: "Add to Cart", value: "add_to_cart" },
13+
{ label: "Click", value: "click" },
1414
];
1515

1616
const eventTypeSelectOptions = [
@@ -29,14 +29,14 @@ export function EventFilters({
2929
}: EventFiltersProps) {
3030
const handleInvertedChange = (selectedValue: string) => {
3131
const isInverted = selectedValue === "excludes";
32-
setEventsFilter((prev) => ({
32+
setEventsFilter((prev: TopicEventFilter) => ({
3333
...prev,
3434
inverted: isInverted,
3535
}));
3636
};
3737

3838
const handleEventTypeChange = (selectedValue: string) => {
39-
setEventsFilter((prev) => ({
39+
setEventsFilter((prev: TopicEventFilter) => ({
4040
...prev,
4141
event_types: selectedValue ? [selectedValue as any] : [],
4242
}));

clients/trieve-shopify-extension/app/components/analytics/search/AllSearchesTable.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ export const AllSearchesTable = () => {
355355
page={page}
356356
setPage={setPage}
357357
label="Searches"
358-
tooltipContent="View and filter all your users' searches."
359358
tableHeadings={[
360359
{ heading: "Query", tooltip: "The search query" },
361360
{ heading: "Search Type", tooltip: "Represents the type of search. Can be Search, Autocomplete, Search Over Groups, or Search Within Groups" },
@@ -367,7 +366,6 @@ export const AllSearchesTable = () => {
367366
{ heading: "Created At", tooltip: "The date and time the search was made" },
368367
]}
369368
hasNext={data?.queries.length == 10}
370-
tabs={tabs}
371369
filters={shopifyFilters}
372370
query={query}
373371
setQuery={setQuery}

clients/trieve-shopify-extension/app/routes/app._dashboard.chats.tsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,13 @@ export default function ChatsPage() {
7676
// TODO: Create badge with "highest ranking event"
7777
let newData: AdvancedTableCell[][] =
7878
data?.topics.map((topic) => {
79+
const topic_events = data?.events?.filter(
80+
(event) => event.event_type === topic.topic_id
81+
);
82+
7983
return [
8084
{ content: topic.name, url: `/app/chatview/${topic.topic_id}` },
85+
{ content: topic.status },
8186
{ content: topic.message_count.toLocaleString() },
8287
{
8388
content: topic.products_shown?.toLocaleString("en-US", {
@@ -97,8 +102,8 @@ export default function ChatsPage() {
97102
{
98103
content: topic.avg_query_rating
99104
? topic.avg_query_rating.toLocaleString("en-US", {
100-
maximumFractionDigits: 2,
101-
})
105+
maximumFractionDigits: 2,
106+
})
102107
: "N/A",
103108
},
104109
{ content: parseCustomDateString(topic.created_at).toLocaleString() },
@@ -452,33 +457,36 @@ export default function ChatsPage() {
452457
page={page}
453458
setPage={setPage}
454459
label="Chat Sessions"
455-
tooltipContent="View and filter all your users' chat sessions."
456460
tableHeadings={[
457461
{
458462
heading: "Name",
459463
tooltip:
460464
"The name created by the chatbot to represent the chat session.",
461465
},
466+
{
467+
heading: "Status",
468+
tooltip: "The last recorded event of the chat session.",
469+
},
462470
{
463471
heading: "Message Count",
464472
tooltip: "The number of messages in the chat session.",
465473
},
466474
{
467-
heading: "Number of Products Shown",
475+
heading: "Products Shown",
468476
tooltip: "The number of products displayed in the chat session.",
469477
},
470478
{
471-
heading: "Avg Top Score",
479+
heading: "Average Score",
472480
tooltip: "The average top score of the chat session.",
473481
sortCol: "top_score",
474482
},
475483
{
476-
heading: "Avg Hallucination Score",
484+
heading: "Hallucination Score",
477485
tooltip: "The average hallucination score of the chat session.",
478486
sortCol: "hallucination_score",
479487
},
480488
{
481-
heading: "Avg Query Rating",
489+
heading: "Query Rating",
482490
tooltip: "The average query rating of the chat session.",
483491
},
484492
{
@@ -488,7 +496,6 @@ export default function ChatsPage() {
488496
},
489497
]}
490498
hasNext={data?.topics.length == 10}
491-
tabs={[]}
492499
filters={shopifyFilters}
493500
query={query}
494501
setQuery={setQuery}

clients/trieve-shopify-extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"react-dom": "^18.2.0",
5353
"tailwind-merge": "^3.1.0",
5454
"tailwindcss": "^3.4.17",
55-
"trieve-ts-sdk": "0.0.76",
55+
"trieve-ts-sdk": "0.0.78",
5656
"vite-tsconfig-paths": "^5.0.1",
5757
"trieve-search-component": "0.4.50"
5858
},

clients/trieve-shopify-extension/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9337,10 +9337,10 @@ trieve-search-component@0.4.50:
93379337
tailwind-merge "^3.0.2"
93389338
trieve-ts-sdk "^0.0.69"
93399339

9340-
trieve-ts-sdk@0.0.76:
9341-
version "0.0.76"
9342-
resolved "https://registry.yarnpkg.com/trieve-ts-sdk/-/trieve-ts-sdk-0.0.76.tgz#7d896d90acbdbc29679fc1ee46031a09794166e2"
9343-
integrity sha512-A92FP8S/1X0Ox4LFij8FfGqVibidFxRN+SUooCFIyq/O+Mxr9HVAeXtIBBGzEGpwy7gpOaRMgS/dW+6q4Pt3MQ==
9340+
trieve-ts-sdk@0.0.78:
9341+
version "0.0.78"
9342+
resolved "https://registry.yarnpkg.com/trieve-ts-sdk/-/trieve-ts-sdk-0.0.78.tgz#624ee877b829a84ffce633423876bb1d4ab49455"
9343+
integrity sha512-tYvJgZJzjTu4sXpdzf+BdcDtjKUxPlX6R0Paw7db0tO8SmE73BYmPoIm1zkMDCye76wyZuIdG/0rIMpR/TKfXA==
93449344

93459345
trieve-ts-sdk@^0.0.69:
93469346
version "0.0.69"

clients/ts-sdk/openapi.json

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9059,7 +9059,8 @@
90599059
"message_count",
90609060
"avg_top_score",
90619061
"avg_hallucination_score",
9062-
"products_shown"
9062+
"products_shown",
9063+
"status"
90639064
],
90649065
"properties": {
90659066
"avg_hallucination_score": {
@@ -9098,6 +9099,9 @@
90989099
"format": "int64",
90999100
"minimum": 0
91009101
},
9102+
"status": {
9103+
"type": "string"
9104+
},
91019105
"topic_id": {
91029106
"type": "string",
91039107
"format": "uuid"
@@ -12129,11 +12133,11 @@
1212912133
"EventTypesFilter": {
1213012134
"type": "string",
1213112135
"enum": [
12132-
"add_to_cart",
12133-
"purchase",
1213412136
"view",
12137+
"filter_clicked",
1213512138
"click",
12136-
"filter_clicked"
12139+
"add_to_cart",
12140+
"purchase"
1213712141
]
1213812142
},
1213912143
"EventsForTopicResponse": {
@@ -20310,16 +20314,9 @@
2031020314
"TopicQueriesResponse": {
2031120315
"type": "object",
2031220316
"required": [
20313-
"topics",
20314-
"events"
20317+
"topics"
2031520318
],
2031620319
"properties": {
20317-
"events": {
20318-
"type": "array",
20319-
"items": {
20320-
"$ref": "#/components/schemas/EventData"
20321-
}
20322-
},
2032320320
"topics": {
2032420321
"type": "array",
2032520322
"items": {

clients/ts-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"files": [
1818
"dist"
1919
],
20-
"version": "0.0.77",
20+
"version": "0.0.79",
2121
"license": "MIT",
2222
"scripts": {
2323
"lint": "eslint 'src/**/*.ts'",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ export type ClickhouseTopicAnalyticsSummary = {
562562
name: string;
563563
owner_id: string;
564564
products_shown: number;
565+
status: string;
565566
topic_id: string;
566567
updated_at: string;
567568
};
@@ -1779,7 +1780,7 @@ export type EventTypes = {
17791780

17801781
export type event_type = 'view';
17811782

1782-
export type EventTypesFilter = 'add_to_cart' | 'purchase' | 'view' | 'click' | 'filter_clicked';
1783+
export type EventTypesFilter = 'view' | 'filter_clicked' | 'click' | 'add_to_cart' | 'purchase';
17831784

17841785
export type EventsForTopicResponse = {
17851786
events: Array<EventData>;
@@ -4106,7 +4107,6 @@ export type TopicEventFilter = {
41064107
};
41074108

41084109
export type TopicQueriesResponse = {
4109-
events: Array<EventData>;
41104110
topics: Array<ClickhouseTopicAnalyticsSummary>;
41114111
};
41124112

server/src/data/models.rs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7281,19 +7281,32 @@ pub struct EventAnalyticsFilter {
72817281
pub metadata_filter: Option<String>,
72827282
}
72837283

7284-
#[derive(Debug, Serialize, Deserialize, ToSchema, Clone, Display)]
7284+
#[derive(Debug, Serialize, Deserialize, ToSchema, Clone, Display, PartialEq, PartialOrd)]
72857285
#[serde(rename_all = "snake_case")]
72867286
pub enum EventTypesFilter {
7287-
#[display(fmt = "add_to_cart")]
7288-
AddToCart,
7289-
#[display(fmt = "purchase")]
7290-
Purchase,
72917287
#[display(fmt = "view")]
72927288
View,
7293-
#[display(fmt = "click")]
7294-
Click,
72957289
#[display(fmt = "filter_clicked")]
72967290
FilterClicked,
7291+
#[display(fmt = "click")]
7292+
Click,
7293+
#[display(fmt = "add_to_cart")]
7294+
AddToCart,
7295+
#[display(fmt = "purchase")]
7296+
Purchase,
7297+
}
7298+
7299+
impl EventTypesFilter {
7300+
pub fn from_string(value: &str) -> EventTypesFilter {
7301+
match value {
7302+
"view" => EventTypesFilter::View,
7303+
"filter_clicked" => EventTypesFilter::FilterClicked,
7304+
"click" => EventTypesFilter::Click,
7305+
"add_to_cart" => EventTypesFilter::AddToCart,
7306+
"purchase" => EventTypesFilter::Purchase,
7307+
_ => EventTypesFilter::View,
7308+
}
7309+
}
72977310
}
72987311

72997312
#[derive(Debug, Serialize, Deserialize, ToSchema, Clone)]
@@ -8040,7 +8053,6 @@ pub struct SearchAverageRatingResponse {
80408053
#[derive(Debug, Row, Serialize, Deserialize, ToSchema)]
80418054
pub struct TopicQueriesResponse {
80428055
pub topics: Vec<ClickhouseTopicAnalyticsSummary>,
8043-
pub events: Vec<EventData>,
80448056
}
80458057

80468058
#[derive(Debug, Row, Serialize, Deserialize, ToSchema)]
@@ -8060,6 +8072,7 @@ pub struct TopicAnalyticsSummaryClickhouse {
80608072
pub avg_hallucination_score: f64,
80618073
pub avg_query_rating: Option<f64>,
80628074
pub products_shown: u64,
8075+
pub status: String,
80638076
}
80648077

80658078
#[derive(Debug, Serialize, Deserialize, ToSchema)]
@@ -8075,6 +8088,7 @@ pub struct ClickhouseTopicAnalyticsSummary {
80758088
pub avg_hallucination_score: f64,
80768089
pub avg_query_rating: Option<f64>,
80778090
pub products_shown: u64,
8091+
pub status: String,
80788092
}
80798093

80808094
impl From<TopicAnalyticsSummaryClickhouse> for ClickhouseTopicAnalyticsSummary {
@@ -8091,6 +8105,7 @@ impl From<TopicAnalyticsSummaryClickhouse> for ClickhouseTopicAnalyticsSummary {
80918105
avg_hallucination_score: value.avg_hallucination_score,
80928106
avg_query_rating: value.avg_query_rating,
80938107
products_shown: value.products_shown,
8108+
status: value.status,
80948109
}
80958110
}
80968111
}

0 commit comments

Comments
 (0)