feat: add 14 new smart folder categories (locale-agnostic)

New EmailCategory enum values: Travel, Subscriptions, Parcels,
Recruitment, Events, SecurityAlerts, Healthcare, Education,
NewsMedia, PropertyUtilities, Charity, Government, CryptoInvesting,
FamilySchool.

HeuristicClassifier: locale-agnostic rules using global brand
domains + TLD patterns (.gov.*, .edu, .ac.*) + English subject
keywords — works for international users without relying on
country-specific domains (e.g. gov.uk).

Priority order ensures SecurityAlerts and Government take
precedence over Finance, and Travel/RideSharing/FoodDelivery
fire before Finance to prevent receipt mis-classification.

AnalyticsService: maps all 14 new slugs to category counts.
client.js: folderToRequest() handles all 14 new slugs.
Layout.jsx: SMART_FOLDERS extended with icons and labels.
widgets.jsx: CAT_SLUG updated for dashboard drillthrough.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
cesnimda
2026-06-30 20:44:21 +02:00
parent 95dc835651
commit 21606c5f91
6 changed files with 596 additions and 75 deletions
+17 -2
View File
@@ -98,8 +98,23 @@ function folderToRequest(slug, page, pageSize) {
case 'sales': return { ...base, category: 'SeasonalSales' };
case 'ridesharing': return { ...base, category: 'RideSharing' };
case 'food': return { ...base, category: 'FoodDelivery' };
case 'wellness': return { ...base, category: 'Wellness' };
default: return { ...base };
case 'wellness': return { ...base, category: 'Wellness' };
// New categories
case 'travel': return { ...base, category: 'Travel' };
case 'subscriptions': return { ...base, category: 'Subscriptions' };
case 'parcels': return { ...base, category: 'Parcels' };
case 'recruitment': return { ...base, category: 'Recruitment' };
case 'events': return { ...base, category: 'Events' };
case 'security': return { ...base, category: 'SecurityAlerts' };
case 'healthcare': return { ...base, category: 'Healthcare' };
case 'education': return { ...base, category: 'Education' };
case 'news': return { ...base, category: 'NewsMedia' };
case 'property': return { ...base, category: 'PropertyUtilities' };
case 'charity': return { ...base, category: 'Charity' };
case 'government': return { ...base, category: 'Government' };
case 'crypto': return { ...base, category: 'CryptoInvesting' };
case 'family': return { ...base, category: 'FamilySchool' };
default: return { ...base };
}
}
+25 -10
View File
@@ -32,16 +32,31 @@ const FAV_SPECIALS = {
const DEFAULT_FAV_SLUGS = ['inbox', 'unread', 'large', 'old', 'readlater'];
const SMART_FOLDERS = [
{ slug: 'automated', icon: '🤖', label: 'Automated', countKey: 'automated' },
{ slug: 'noreply', icon: '🔇', label: 'No-Reply', countKey: 'noreply' },
{ slug: 'shopping', icon: '🛍️', label: 'Online Shopping', countKey: 'shopping' },
{ slug: 'gaming', icon: '🎮', label: 'Gaming', countKey: 'gaming' },
{ slug: 'finance', icon: '💳', label: 'Finance & Insurance', countKey: 'finance' },
{ slug: 'sales', icon: '🏷️', label: 'Seasonal Sales', countKey: 'sales' },
{ slug: 'ridesharing', icon: '🚗', label: 'Ride Sharing', countKey: 'ridesharing' },
{ slug: 'food', icon: '🍕', label: 'Food Delivery', countKey: 'food' },
{ slug: 'social', icon: '📱', label: 'Social Notifications',countKey: 'social' },
{ slug: 'wellness', icon: '🏃', label: 'Wellness & Sport', countKey: 'wellness' },
{ slug: 'automated', icon: '🤖', label: 'Automated', countKey: 'automated' },
{ slug: 'noreply', icon: '🔇', label: 'No-Reply', countKey: 'noreply' },
{ slug: 'shopping', icon: '🛍️', label: 'Online Shopping', countKey: 'shopping' },
{ slug: 'gaming', icon: '🎮', label: 'Gaming', countKey: 'gaming' },
{ slug: 'finance', icon: '💳', label: 'Finance & Insurance', countKey: 'finance' },
{ slug: 'sales', icon: '🏷️', label: 'Seasonal Sales', countKey: 'sales' },
{ slug: 'ridesharing', icon: '🚗', label: 'Ride Sharing', countKey: 'ridesharing' },
{ slug: 'food', icon: '🍕', label: 'Food Delivery', countKey: 'food' },
{ slug: 'social', icon: '📱', label: 'Social Notifications', countKey: 'social' },
{ slug: 'wellness', icon: '🏃', label: 'Wellness & Sport', countKey: 'wellness' },
// New categories
{ slug: 'travel', icon: '✈️', label: 'Travel', countKey: 'travel' },
{ slug: 'subscriptions',icon: '🔄', label: 'Subscriptions & SaaS', countKey: 'subscriptions' },
{ slug: 'parcels', icon: '📦', label: 'Parcels & Delivery', countKey: 'parcels' },
{ slug: 'recruitment', icon: '💼', label: 'Recruitment & Jobs', countKey: 'recruitment' },
{ slug: 'events', icon: '🎟️', label: 'Events & Tickets', countKey: 'events' },
{ slug: 'security', icon: '🔐', label: 'Security & Alerts', countKey: 'security' },
{ slug: 'healthcare', icon: '🏥', label: 'Healthcare', countKey: 'healthcare' },
{ slug: 'education', icon: '🎓', label: 'Education', countKey: 'education' },
{ slug: 'news', icon: '📰', label: 'News & Media', countKey: 'news' },
{ slug: 'property', icon: '🏠', label: 'Property & Utilities', countKey: 'property' },
{ slug: 'charity', icon: '❤️', label: 'Charities', countKey: 'charity' },
{ slug: 'government', icon: '🏛️', label: 'Government', countKey: 'government' },
{ slug: 'crypto', icon: '📈', label: 'Crypto & Investing', countKey: 'crypto' },
{ slug: 'family', icon: '👨‍👩‍👧', label: 'Family & School', countKey: 'family' },
];
// ── Helpers ───────────────────────────────────────────────────────────────────
+28 -14
View File
@@ -105,20 +105,34 @@ const DOW = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
// Maps EmailCategory enum name → folder slug or search query
const CAT_SLUG = {
Finance: '/app/folder/finance',
Social: '/app/folder/social',
Notification: '/app/folder/automated',
Promotional: '/app/folder/shopping',
Shopping: '/app/folder/shopping',
Gaming: '/app/folder/gaming',
RideSharing: '/app/folder/ridesharing',
FoodDelivery: '/app/folder/food',
SeasonalSales:'/app/folder/sales',
Wellness: '/app/folder/wellness',
Spam: '/app/folder/spam',
Newsletter: '/app/search?q=newsletter',
Personal: '/app/search?q=is:unread',
Unknown: '/app/folder/allmail',
Finance: '/app/folder/finance',
Social: '/app/folder/social',
Notification: '/app/folder/automated',
Promotional: '/app/folder/shopping',
Shopping: '/app/folder/shopping',
Gaming: '/app/folder/gaming',
RideSharing: '/app/folder/ridesharing',
FoodDelivery: '/app/folder/food',
SeasonalSales: '/app/folder/sales',
Wellness: '/app/folder/wellness',
Travel: '/app/folder/travel',
Subscriptions: '/app/folder/subscriptions',
Parcels: '/app/folder/parcels',
Recruitment: '/app/folder/recruitment',
Events: '/app/folder/events',
SecurityAlerts: '/app/folder/security',
Healthcare: '/app/folder/healthcare',
Education: '/app/folder/education',
NewsMedia: '/app/folder/news',
PropertyUtilities:'/app/folder/property',
Charity: '/app/folder/charity',
Government: '/app/folder/government',
CryptoInvesting: '/app/folder/crypto',
FamilySchool: '/app/folder/family',
Spam: '/app/folder/spam',
Newsletter: '/app/search?q=newsletter',
Personal: '/app/search?q=is:unread',
Unknown: '/app/folder/allmail',
};
export function CategoryHeatmapWidget() {