UNPKG

optivise

Version:

Optivise - The Ultimate Optimizely Development Assistant with AI-powered features, zero-config setup, and comprehensive development support

39 lines 1.07 kB
export class SessionMemoryService { logger; recentProducts = []; recentFiles = []; recentTools = []; maxItems = 10; constructor(logger) { this.logger = logger; } recordInteraction(data) { if (data.products?.length) { data.products.forEach(p => this.pushUnique(this.recentProducts, p)); } if (data.files?.length) { data.files.forEach(f => this.pushUnique(this.recentFiles, f)); } if (data.toolName) { this.pushUnique(this.recentTools, data.toolName); } } getSnapshot() { return { recentProducts: [...this.recentProducts], recentFiles: [...this.recentFiles], recentTools: [...this.recentTools] }; } pushUnique(arr, value) { const idx = arr.indexOf(value); if (idx !== -1) { arr.splice(idx, 1); } arr.unshift(value); if (arr.length > this.maxItems) { arr.pop(); } } } //# sourceMappingURL=session-memory.js.map