"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.exampleIntegration = exports.RAGPoisoningTracker = void 0;
/**
 * Example integration of Mixpanel tracking in RAG Poisoning service
 * This shows how to add tracking to existing functionality
 */
const index_1 = require("./index");
// Example: Add tracking to RAG poisoning service
class RAGPoisoningTracker {
    /**
     * Track when a user starts the RAG poisoning process
     */
    static async trackPoisoningStarted(userId, fileType, goal) {
        await (0, index_1.track)('RAG Poisoning Started', {
            user_id: userId,
            file_type: fileType,
            goal,
            timestamp: new Date().toISOString(),
        }, userId);
    }
    /**
     * Track when RAG poisoning completes successfully
     */
    static async trackPoisoningCompleted(userId, fileType, poisonedFilesCount, processingTime) {
        await (0, index_1.track)('RAG Poisoning Completed', {
            user_id: userId,
            file_type: fileType,
            poisoned_files_count: poisonedFilesCount,
            processing_time_ms: processingTime,
            timestamp: new Date().toISOString(),
        }, userId);
    }
    /**
     * Track when RAG poisoning fails
     */
    static async trackPoisoningFailed(userId, fileType, error, goal) {
        await (0, index_1.track)('RAG Poisoning Failed', {
            user_id: userId,
            file_type: fileType,
            error,
            goal,
            timestamp: new Date().toISOString(),
        }, userId);
    }
    /**
     * Track file upload events
     */
    static async trackFileUpload(userId, fileType, fileSize, uploadType) {
        await (0, index_1.track)('File Uploaded for Poisoning', {
            user_id: userId,
            file_type: fileType,
            file_size_bytes: fileSize,
            upload_type: uploadType, // 'single', 'zip', 'multiple'
            timestamp: new Date().toISOString(),
        }, userId);
    }
    /**
     * Track document download events
     */
    static async trackDocumentDownload(userId, fileType, attackType) {
        await (0, index_1.track)('Poisoned Document Downloaded', {
            user_id: userId,
            file_type: fileType,
            attack_type: attackType,
            timestamp: new Date().toISOString(),
        }, userId);
    }
}
exports.RAGPoisoningTracker = RAGPoisoningTracker;
// Example: How to integrate in the actual service
exports.exampleIntegration = {
    // In poisonDocuments function
    async poisonDocuments(files, goal, type, token, userId) {
        const startTime = Date.now();
        try {
            // Track start
            if (userId) {
                await RAGPoisoningTracker.trackPoisoningStarted(userId, type, goal);
            }
            // Your existing poisoning logic here...
            // Replace this with your actual poisoning service call
            const result = { poisonedFiles: [] }; // Placeholder - replace with actual service call
            // Track completion
            if (userId) {
                const processingTime = Date.now() - startTime;
                await RAGPoisoningTracker.trackPoisoningCompleted(userId, type, result.poisonedFiles.length, processingTime);
            }
            return result;
        }
        catch (error) {
            // Track failure
            if (userId) {
                await RAGPoisoningTracker.trackPoisoningFailed(userId, type, error instanceof Error ? error.message : String(error), goal);
            }
            throw error;
        }
    },
    // In file upload handler
    async handleFileUpload(file, userId) {
        if (userId) {
            await RAGPoisoningTracker.trackFileUpload(userId, file.mimetype, file.size, 'single');
        }
    },
    // In download handler
    async handleDocumentDownload(file, userId) {
        if (userId) {
            await RAGPoisoningTracker.trackDocumentDownload(userId, file.originalName.split('.').pop(), file.attack);
        }
    },
};
//# sourceMappingURL=integration-example.js.map