import { sendUserContext } from "navi-web";
// Page load context
useEffect(() => {
sendUserContext(`User on ${window.location.pathname}, referrer: ${document.referrer}`);
}, []);
// User authentication context
useEffect(() => {
if (user) {
sendUserContext(`User logged in: ${user.email}, account type: ${user.type}`);
}
}, [user]);
// Product interaction context
const handleProductView = (product) => {
sendUserContext(`Viewing ${product.name}, price: $${product.price}, in stock: ${product.stock > 0}`);
};
const handleAddToCart = (product) => {
sendUserContext(`Added ${product.name} to cart, cart now has ${cartItems.length + 1} items`);
};
// Search context
const handleSearch = (query) => {
sendUserContext(`Searching for: "${query}"`);
};
// Error context
const handleError = (error, context) => {
sendUserContext(`Error in ${context}: ${error.message}`);
};
// User help request
const handleHelpRequest = () => {
sendUserContext("I need help finding the right product for my needs", { silent: false });
};