Feature #10741
openTo implement search analyticas and recommendations & reviews section enhancement
Added by Ajit A 14 days ago. Updated 11 days ago.
Subtasks
Related issues
Updated by Ajit A 14 days ago
Here is a summary of the changes we made today that you can use to update your Redmine ticket:
1. Search Analytics Layout Updates (SearchAnalyticsPage.tsx)
Reorganized Filter Controls: Removed the global search bar from the top header and consolidated all controls (Search Input, Period Filter dropdown, and Refresh button) into a single, unified row directly below the "Search Analytics" title and above the data table.
Input Sizing: Removed the full-width stretch (flexGrow) from the search input and applied a fixed maximum width for a cleaner, more balanced UI.
2. Product Details - Review Filtering (ProductReviewsPanel.tsx)
New Review Filters: Implemented a new dropdown filter above the product reviews list with options to sort/filter by: Most Recent, Highest Rating, Lowest Rating, Only Pictures, Pictures First, Videos First, and Most Helpful.
Client-Side Sorting Logic: Added useMemo logic to dynamically re-sort and filter the displayed reviews on the frontend based on the selected filter without needing additional API calls.
Premium Custom Dropdown: Replaced the native HTML <select> element with a custom-built Tailwind CSS dropdown component. This new dropdown is fully green-themed to match the storefront's aesthetic and includes smooth animations, active state checkmarks, and an invisible overlay to handle click-away closing.
Updated by Ajit A 14 days ago
Bug Fixes & Refactoring
Search Results Accuracy: Fixed an issue where the search bar was returning incorrect, unrelated products for specific search terms (like "egg").
Search Debounce Added: Implemented a debounce on the search input to optimize performance and prevent excessive API calls while typing.
Search Count Data Mismatch: Fixed a discrepancy where the search counts displayed in the "Top Popular Searches" cards did not match the actual counts shown in the data list below.
Unique User Count Bug: Fixed a bug where the unique user count was incorrectly incrementing on every search by the same logged-in user. (Note: The unique user metric was subsequently removed from the UI entirely based on your later request).
Server-Side Pagination Fix: Refactored the analytics list to use true server-side pagination. Instead of fetching all 100 records upfront, the frontend now dynamically requests data page-by-page from the backend API.
UI & Layout Enhancements
Search Analytics Layout: Reorganized the dashboard layout by moving the Search bar, Period filter, and Refresh button into a single, aligned row above the data table.
Search Input Sizing: Fixed a layout issue where the search input field was stretching too far across the screen by applying a fixed max-width.
Product Review Filters: Built and integrated a new filter system on the Product Details page to allow users to sort reviews (e.g., Most Recent, Highest Rating, Lowest Rating, Only Pictures, etc.).
Custom Dropdown Design: Replaced the native HTML select menu for the review filters with a custom-built, green-themed Tailwind dropdown featuring smooth animations and an invisible click-away overlay for a more premium feel.
Updated by Ajit A 11 days ago
- Status changed from In Progress to Resolved
- % Done changed from 40 to 100
Recently Viewed is now per-user and persisted to DB — Previously, recently viewed products were stored only in localStorage with a single global key, meaning different users on the same device shared the same history. Now each logged-in user gets a namespaced key (ecom_recently_viewed_{userId}) and views are also saved to the backend DB via a new POST /v1/growth/recently-viewed API.
Recently Viewed section now uses ProductUnifiedCard — The old custom inline card rendering in RecentlyViewedSection was replaced with the shared ProductUnifiedCard component, giving consistent add-to-cart, pre-order, and pricing behavior across all product rails.
User-based product recommendations added — A new GET /v1/growth/user-recommendations endpoint returns personalized product suggestions based on the user's search history. The RecentlyViewedSection merges these recommendations after the user's actual viewed items to fill the rail.
Search queries are now logged to backend — trackSearchQuery() now fires a non-blocking POST /v1/growth/search-log call, enabling the recommendation engine to use search history data.
Product Q&A section layout restructured — The Q&A section on the product details page was restructured into a cleaner card-based layout with scrollable Q&A list, badge count, and a dashed-border "ask a question" form area.
Stock quantity handling fixed for partial product payloads — ProductUnifiedCard now checks for explicit stock fields (quantity, stock, Qnt, availableStock) and defaults to "available" (999) when stock fields are omitted in partial payloads (e.g., from recently viewed storage), preventing products from incorrectly showing as out of stock.
Pre-order API path missing leading slash fixed — preorderCatalogValidation.ts had API calls missing the leading / in the URL path (v1/nus-shop/catalogEcom/... → /v1/nus-shop/catalogEcom/...), which could cause request failures depending on the base URL configuration.
Cart route "already in cart" button guard fixed — The in-cart quantity stepper in ProductUnifiedCard now skips displaying on the cart route itself (!isCartRoute check added), preventing confusing duplicate controls when the card is rendered inside the cart page.
Duplicate pre-order line removed from ProductUnifiedCard — The preorderLine element was being rendered redundantly above the add-to-cart button in both card layouts; these duplicate renders were removed.
type prop made optional on ProductUnifiedCard — The type prop now defaults to "product", so callers like RecentlyViewedSection don't need to specify it explicitly.
RecentlyViewed model & DB utility registered — New RecentlyViewed Mongoose model with schema added and registered in dbUtils.js for multi-tenant DB access.