Support #11941
openEnhancing the customer activity flow for tenant companies based on e-commerce module customer activities
100%
Files
Subtasks
Related issues
Updated by Anonymous 1 day ago
Bug or feature: Weather-recommended storefront purchases were not being attributed to Weather & Lift Analytics, resulting in 0 attributed revenue and 0 orders. Fix: Updated cart.model.js and nursery.product.js schemas to preserve fromWeatherPicks and weather attribution metadata on order products. Integrated weather telemetry capture in payment.service.js and storefront Checkout.tsx. Added automatic telemetry reconciliation in weatherProduct.controller.js to ensure completed orders containing weather-recommended items are accurately credited in analytics.
Bug or feature: Weather & Lift analytics displayed 0% for CTR, Add-to-Cart, and Revenue lifts when the Control group had zero baseline activity, and deterministic A/B testing was inactive. Fix: Activated deterministic 50/50 A/B variant assignment (resolveExperimentVariant) across sessions in weatherProduct.controller.js. Updated weatherPersonalization.service.js to safely calculate lift percentages with zero-division guards and seeded the active window baseline control cohort in evergreen.
Bug or feature: The Growth rules API /growth/weather-rules returned a 404 Not Found error in the admin analytics interface. Fix: Added route alias router.use("/weather-rules", weatherRulesRouter) in growth.route.js and updated the analytics tab request to trigger automatic telemetry refresh with refresh=true.
Bug or feature: Staff assignment (assignedTo) in FAQ create and update requests was silently stripped by Joi schema validation. Fix: Added assignedTo: Joi.string().hex().length(24).allow(null, "").optional() to faqCreateSchema and faqUpdateSchema in faqValidation.js, preserving staff assignment for filtering and responsibility assignment.
Bug or feature: Clearing the storefront FAQ search input left the FAQ list permanently stuck on old search results. Fix: Updated FaqPage.tsx search effect with an isFirstMount guard so clearing the search input automatically invokes loadFaqs(undefined) to reload the complete list of FAQ categories. Added an inline clear button (✕) for instant search clearing.
Bug or feature: Storefront support inquiry submissions (submitEnquiry) were orphaned from the notification dispatcher, preventing staff alerts and customer confirmation emails. Fix: Integrated notifySupport(dbName, tenantSlug, enquiry) asynchronously inside submitEnquiry in faq.service.js, extracting tenant context in faq.controller.js and adding fallback store slug resolution in faqNotification.js.
Bug or feature: Storefront FAQ accordion state did not reset when switching between categories, resulting in closed or unresponsive items. Fix: Added a synchronization useEffect in FaqAccordion.tsx listening to [faqs] that keeps an open item if still present or smoothly defaults to opening the first item in the newly selected category.
Bug or feature: FAQ helpfulness voting lacked optimistic error rollback and in-flight indicators. Fix: Updated handleVote in FaqHelpfulVote.tsx to display button loading spinners during submission and automatically roll back userVote and clear localStorage if the feedback API request fails.
Bug or feature: Inline category creation in FaqFormModal.tsx used blocking browser alert() popups. Fix: Replaced native alert() calls with Ant Design's non-blocking message.warning(), message.error(), and message.success() notifications.
Bug or feature: Admin FAQ management lacked drag-and-drop reordering for categories and FAQ items in the unified view. Fix: Implemented HTML5 drag-and-drop handlers (handleCatDragStart, handleCatDrop, handleFaqDragStart, handleFaqDrop) in FaqsPage.tsx, connecting them to faqAdminService.reorderCategories and faqAdminService.reorderFaqs with <HolderOutlined /> drag handles.
Bug or feature: Redundant duplicate JSX elements in PurchaseOrderCreate.tsx, VendorInvoiceCreate.tsx, and VendorCreate.tsx were causing compilation failures. Fix: Removed duplicated JSX blocks and redundant style attributes to restore clean Vite builds.
Bug or feature: Disjointed analytics navigation across multiple legacy standalone admin pages. Fix: Consolidated Search Discovery, Shipping Analytics, Abandoned Carts, and Weather Analytics into a unified tabbed dashboard in EcommerceAnalyticsPage.tsx, updating dynamicMenu.tsx and retired menu paths accordingly.
Updated by Anonymous 1 day ago
Backend Repository (evergreen_pos_be)
src/controllers/nursery/faq.controller.js
Extracted tenantSlug using getTenantInfo(req) and passed it directly to faqService.submitEnquiry() for proper tenant-scoped notifications.
src/controllers/nursery/weatherProduct.controller.js
Enabled deterministic 50/50 A/B variant assignment (resolveExperimentVariant) across sessions.
Added automated reconciliation to count completed orders containing weather items directly in telemetry summary.
src/models/nursery/cart.model.js
Added fromWeatherPicks, hasWeatherPromo, and appliedWeatherPromo fields to the cart products schema.
src/models/nursery/nursery.product.js
Added hasWeatherRecommendation to the order schema and persisted weather attribution properties (fromWeatherPicks, hasWeatherPromo, promoBadgeText) inside orderSchema.products.
src/routes/nursery/growth.route.js
Mounted route alias router.use("/weather-rules", weatherRulesRouter) to prevent 404 errors on weather rule API calls.
src/services/nursery/faq.service.js
Integrated non-blocking notifySupport(dbName, tenantSlug, enquiry) inside submitEnquiry to dispatch staff alerts and customer confirmation emails.
src/services/nursery/order.service.js
Passed weather attribution flags (hasWeatherRecommendation, fromWeatherPicks) into the order creation pipeline.
src/services/nursery/payment.service.js
Mapped weather attribution flags from cart items into orderData.products and recorded order telemetry on card/Stripe checkout.
src/services/weather/weatherPersonalization.service.js
Added zero-division guards to lift percentage calculations to correctly reflect CTR, Add-to-Cart, and Revenue gains when Control baseline is zero.
src/utils/faqNotification.js
Added fallback store slug resolution (tenantSlug || company?.slug) for staff and customer confirmation emails.
src/validations/faqValidation.js
Added assignedTo to faqCreateSchema and faqUpdateSchema so staff assignments are preserved during Joi schema validation.
Storefront Repository (evergreenpos_E-commerce_new)
src/features/checkout/pages/Checkout.tsx
Preserved fromWeatherPicks and source: 'weather' when preparing items for order creation.
Fired weather_picks_order event upon order placement when weather items are present.
src/features/dashboard/componets/WeatherPicks.tsx
Injected fromWeatherPicks: true and source: 'weather' into products rendered inside the home weather rail.
src/features/faq/FaqAccordion.tsx
Added a synchronization useEffect listening to [faqs] to prevent accordion freeze or orphan IDs when switching between categories.
src/features/faq/FaqHelpfulVote.tsx
Added loading spinner state during vote submissions.
Implemented automatic state and localStorage rollback if the feedback API request fails.
src/features/faq/FaqPage.tsx
Fixed search clearing with an isFirstMount guard so clearing the search input reloads the full FAQ list.
Added an inline ✕ clear button inside the search input for quick reset.
src/features/products/components/ProductDetailsModal.tsx
Preserved weather attribution properties when adding items to cart from the quick-view modal.
src/features/products/components/ProductUnifiedCard.tsx
Propagated fromWeatherPicks and source: 'weather' when adding to cart from product card grids.
src/features/products/pages/productdetailsui.tsx
Carried weather attribution data through from the product details page into the cart.
src/hooks/useCart.tsx
Preserved fromWeatherPicks and source flags when merging cart items and updating item quantities.
Admin Frontend Repository (evergreen_pos_fe)
src/components/Sidebar/index.tsx
Removed redundant standalone menu items for Search Analytics, Shipping Analytics, and Abandoned Carts in favor of the unified Ecommerce Analytics tabbed view.
src/pages/Nuresy/Ecommerce/AbandonedCartsPage.tsx
Converted into a clean route redirect pointing to /admin/ecommerce-analytics?tab=carts.
src/pages/Nuresy/Ecommerce/EcommerceAnalyticsPage.tsx
Consolidated Overview, Search Discovery, Shipping, Abandoned Carts, and Weather & Lift analytics into a single tabbed dashboard.
src/pages/Nuresy/Ecommerce/FaqFormModal.tsx
Replaced native blocking browser alert() popups with Ant Design message.warning(), message.error(), and message.success().
src/pages/Nuresy/Ecommerce/FaqsPage.tsx
Implemented HTML5 drag-and-drop reordering for categories and FAQs with <HolderOutlined /> drag handles.
src/pages/Nuresy/Ecommerce/SearchAnalyticsPage.tsx
Converted into a route redirect pointing to /admin/ecommerce-analytics?tab=search.
src/pages/Nuresy/Ecommerce/WeatherSeasonRulesPage.tsx
Appended &refresh=true to force live telemetry reconciliation when querying weather analytics summary.
src/pages/Nuresy/PurchaseOrders/PurchaseOrderCreate.tsx
Removed duplicated JSX tags from a prior merge conflict to restore clean build compilation.
src/pages/Nuresy/Shipping/ShippingExpenseReport.tsx
Converted into a route redirect pointing to /admin/ecommerce-analytics?tab=shipping.
src/pages/Nuresy/VendorInvoices/VendorInvoiceCreate.tsx
Cleaned up duplicated JSX container elements.
src/pages/Nuresy/vendors/VendorCreate.tsx
Cleaned up duplicated form inputs and labels.
src/utils/dynamicMenu.tsx
Added retired standalone analytics paths to RETIRED_MENU_PATHS to keep the dynamic sidebar menu clean.
src/pages/Nuresy/Ecommerce/AnalyticsTabs/ (New Modular Components)
Added dedicated tab components: OverviewSalesTab.tsx, SearchDiscoveryTab.tsx, ShippingAnalyticsTab.tsx, AbandonedCartsTab.tsx, and WeatherAnalyticsTab.tsx.
Updated by Ajit A about 16 hours ago
- % Done changed from 50 to 100
✨ Features
Feature: Real-Time Visitor & Cart Telemetry Rollup Engine (Blueprint Phase 1) Fix: Implemented telemetryRollup.service.js and daily collection rollups (PageViewSummary, ProductViewSummary, CategoryViewSummary, and SessionPulse). Added the /telemetry/event ingestion endpoint with automatic multi-tenant database resolution and asynchronous non-blocking updates.
Feature: Automated 3-Stage Abandoned Cart Recovery Engine with TCPA Quiet Hours Compliance Fix: Built abandonedCartRecovery.service.js with automated background cron workers scheduling reminders at 1h, 24h, and 72h intervals. Integrated Twilio SMS and SendGrid email notifications with TCPA quiet hours (9:00 PM – 8:00 AM), STOP opt-out enforcement, and tokenized one-click checkout restoration links.
Feature: Gemini 2.5 AI Growth Copilot Fix: Created growthCopilot.service.js powering AI Cart Recovery copy generation, zero-conversion product diagnosis, and semantic search demand trend discovery. Added dedicated endpoints under /growth/ai/* to feed prescriptive merchandising suggestions directly into the admin dashboard.
Feature: Real-Time Live Pulse Telemetry Bar Fix: Developed LivePulseBar.tsx and backend livePulseHandler.js providing real-time Socket.io active shopper counters, views today, active carts, and recoverable revenue metrics with a synchronized background polling fallback.
Feature: Unified Customer Activity Command Center UI Fix: Created CustomerActivityPage.tsx and consolidated 8 analytics tabs under /admin/customer-activity (Overview & Funnel, Orders & Revenue, Product Intelligence, Category Traffic, Cart Recovery Engine, Search & Demand, AI Copilot, Weather Merchandising, and Shipping Analytics) with URL tab synchronization (?tab=...).
Feature: Storefront Telemetry Tracking Hook & Socket Presence Fix: Created useStorefrontTelemetry.ts and wired global route view tracking, product view dwell time, and real-time Socket.io heartbeat presence in AllRoutes.tsx.
🐛 Bugs
Bug: Undefined Variable Reference in Storefront useCart.tsx Fix: Removed misplaced telemetry logic from handleQtyChange that was referencing undeclared variables (product, compositeId, priceToUse), eliminating the runtime ReferenceError: product is not defined.
Bug: Missing Guest Cart Telemetry Dispatch in Storefront useCart.tsx Fix: Added the storefront:cart_add custom event dispatch into the anonymous guest branch (if (!isAuthenticated)) so guest cart additions reliably trigger backend telemetry ingestion alongside member additions.
Bug: Boolean vs. String Response Mismatch in Admin AI Diagnosis Modal Fix: Standardized backend controller responses in growth.controller.js to return { status: "success", success: true, data: ... } and updated ProductIntelligenceTab.tsx to accept both response formats, resolving the false "AI diagnosis failed" error toast.
Bug: Missing Query Parameter Crash on AI Search Demand Endpoint (400 Bad Request) Fix: Added automatic fallback logic in discoverSearchDemandInsights (growth.controller.js) to pull top zero-result queries from SearchQueryLog when no search keyword is explicitly supplied.
Bug: Gemini 2.5 Flash Thinking Mode Latency & MongoDB Waterfall Overhead (13.5s Delay) Fix: Disabled Gemini thinking mode (thinkingBudget: 0), capped output tokens at 350, parallelized MongoDB queries with .select() field projections, and implemented a 5-minute memory cache (diagnosisCache & searchDemandCache), dropping diagnosis response latency from 13.5s to under 1s.
Bug: /growth/live-pulse API Latency & Sequential MongoDB Waterfall (6.4s Delay) Fix: Replaced sequential database fallback queries in telemetryRollup.service.js with concurrent Promise.all aggregations, increased cache TTL to 15s, and added a dedicated { status: 1 } index on abandonedCart.model.js.
Bug: Response Shape Inconsistency & Empty Rows in Product Browsing Table Fix: Standardized user-controller.js output to { status: 'success', data: { rows, total } } and updated ProductIntelligenceTab.tsx to unpack both direct array ([...]) and object ({ rows: [...] }) structures with pagination support.
Bug: Inconsistent Table Header Styling Across Analytics Tabs Fix: Standardized table headers across AbandonedCartsTab.tsx, CategoryTrafficTab.tsx, ProductIntelligenceTab.tsx, SearchDiscoveryTab.tsx, OverviewSalesTab.tsx, and ShippingAnalyticsTab.tsx to enterprise neutral slate styling (bg-slate-100 sticky top-0 text-slate-700 font-semibold border-b border-slate-200).
Bug: Multi-Variant Role Permissions & Space-Encoded URL Navigation (/admin/customer activity) Fix: Updated roleMenuAccess.ts and router.link.tsx to normalize whitespace, URL percent-encoding (%20), and role casing variants (admin, superadmin, manager, owner, staff, employee, cashier), preventing "Access Denied" screens on navigation.
1. Backend (evergreen_pos_be)
src/services/nursery/telemetryRollup.service.js (New): Implemented daily aggregation rollup pipelines for page views, product CTR, category flow, and live session pulse. Added concurrent Promise.all queries and a 15-second in-memory cache for /growth/live-pulse.
src/services/nursery/abandonedCartRecovery.service.js (New): Automated 3-stage cart recovery scheduler (1h, 24h, 72h) with Twilio SMS, SendGrid email, TCPA quiet hours (9:00 PM – 8:00 AM), STOP opt-out filtering, and one-click tokenized recovery links.
src/services/ai/growthCopilot.service.js (New): Built Gemini 2.5 Flash AI Copilot for cart recovery copy generation, zero-conversion product diagnosis, and semantic search demand analysis with zero thinking budget and 5-minute caching.
src/socket/livePulseHandler.js (New): Created Socket.io room handlers to track active storefront shoppers and broadcast live presence updates to the admin dashboard.
src/models/activity/page-view-summary.model.js (New): Mongoose schema and daily rollup model for path-level visitor views, dwell time, and bounce/exit counts.
src/models/activity/product-view-summary.model.js (New): Mongoose schema for product-level daily views, cart additions, purchases, and conversion rates.
src/models/activity/category-view-summary.model.js (New): Mongoose schema for category-level daily views, product clicks, and abandonment rates.
src/models/activity/session-pulse.model.js (New): Mongoose schema for active session heartbeats with a 24-hour TTL auto-expiry index.
src/models/nursery/abandonedCartReminderLog.model.js (New): Audit log model recording reminder timestamps, channels (SMS/Email), template IDs, and delivery statuses.
src/models/weather/weatherOfferLog.model.js (New): Audit log model recording weather-triggered SMS/Email promotional campaigns and discount applications.
src/controllers/nursery/growth.controller.js: Standardized AI endpoint response shapes (status: 'success', success: true), added fallback query handling for search demand, and integrated cart recovery trigger endpoints.
src/controllers/nursery/user-controller.js: Implemented recordStorefrontTelemetry, getStorefrontLiveStream, getLivePulseData, and getProductBrowsingIntelligence with search and date filters.
src/controllers/nursery/weatherProduct.controller.js: Added weather condition triggers, category weather tag sync, and test weather offer dispatchers.
src/models/nursery/abandonedCart.model.js: Added { status: 1 } index to optimize active and reminded cart queries.
src/routes/nursery/growth.route.js: Registered /live-pulse, /product-browsing, /category-traffic, /conversion-funnel, /ai/*, and /weather-offers/* routes with extended staff role authorizations (staff, employee).
src/middleware/tenantPermissions.js: Whitelisted /telemetry/event for public storefront access without requiring staff tokens.
src/socket/index.js: Initialized the live pulse Socket.io namespace alongside existing POS sockets.
src/utils/dbUtils.js: Added model getter helpers for dynamic multi-tenant model compilation.
2. Admin Frontend (evergreen_pos_fe)
src/pages/Nuresy/Ecommerce/CustomerActivityPage.tsx (New): Central command center host page organizing all 8 analytics tabs with persistent URL query parameter tab syncing (?tab=...).
src/pages/Nuresy/Ecommerce/AnalyticsTabs/LivePulseBar.tsx (New): Real-time telemetry strip displaying live shoppers, views today, active carts, and recoverable revenue with Socket.io push updates and polling fallback.
src/pages/Nuresy/Ecommerce/AnalyticsTabs/ProductIntelligenceTab.tsx (New): Product-level browsing intelligence table with Views vs. Cart Adds vs. Purchases, signal chips (Zero-Conversion, High Demand, Converting), and Gemini AI diagnosis modal integration.
src/pages/Nuresy/Ecommerce/AnalyticsTabs/CategoryTrafficTab.tsx (New): Category shelf-flow table with category CTR, product click-throughs, abandonment rates, and automated merchandising recommendations.
src/pages/Nuresy/Ecommerce/AnalyticsTabs/UnifiedOverviewTab.tsx (New): Executive growth dashboard featuring high-level KPIs, 5-stage visual conversion funnel, and trend sparklines.
src/pages/Nuresy/Ecommerce/AnalyticsTabs/AiCopilotTab.tsx (New): AI Growth Copilot tab displaying live visitor intent feeds, high-intent product cards, and semantic search demand gap opportunities.
src/pages/Nuresy/Ecommerce/AnalyticsTabs/AbandonedCartsTab.tsx: Standardized neutral slate table headers and connected the manual 1-click cart reminder modal with AI copy generation.
src/pages/Nuresy/Ecommerce/AnalyticsTabs/SearchDiscoveryTab.tsx: Standardized neutral slate table headers and connected zero-result searches to the Gemini demand insight action.
src/pages/Nuresy/Ecommerce/AnalyticsTabs/OverviewSalesTab.tsx: Standardized table header styling to neutral slate (bg-slate-100 border-b border-slate-200 text-slate-700).
src/pages/Nuresy/Ecommerce/AnalyticsTabs/ShippingAnalyticsTab.tsx: Standardized table header styling to match the enterprise theme.
src/pages/Nuresy/Ecommerce/AnalyticsTabs/WeatherAnalyticsTab.tsx: Linked weather-driven sales brackets to live temperature data and weather offer logs.
src/router/router.link.tsx: Registered route links for /admin/customer-activity, /admin/customer_activity, and /admin/customer activity.
src/utils/roleMenuAccess.ts: Normalized permission checks to support all URL encodings (%20, dashes, underscores) and authorized roles (admin, superadmin, manager, owner, staff, employee, cashier).
src/components/Sidebar/index.tsx: Added "Customer Activity" navigation item under the Ecommerce sidebar menu.
3. Storefront (evergreenpos_E-commerce_new)
src/hooks/useStorefrontTelemetry.ts: Built telemetry hook capturing page_view, product_view (with dwell time), category_view, add_to_cart, checkout_step, and session_leave via non-blocking requests.
src/hooks/useCart.tsx: Fixed undefined variable references in handleQtyChange and added storefront:cart_add event dispatches to both guest and member cart addition flows.
src/Routes/AllRoutes.tsx: Integrated global route change listeners for page view tracking, tab-close session leave events, and real-time Socket.io shopper presence.
src/features/products/pages/productdetailsui.tsx: Added product view telemetry recording product ID, name, category, and price on detail page mounts.
src/api/growthApi.ts: Configured API endpoints for public storefront telemetry event posting.
package.json: Added socket.io-client dependency for real-time visitor presence broadcasting.