"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.trackUserLogin = trackUserLogin;
exports.trackFeatureUsage = trackFeatureUsage;
exports.trackError = trackError;
exports.trackRAGPoisoningEvent = trackRAGPoisoningEvent;
exports.trackUserSession = trackUserSession;
exports.trackWithConditionalCheck = trackWithConditionalCheck;
exports.trackAPIUsage = trackAPIUsage;
exports.trackFileUpload = trackFileUpload;
const index_1 = require("./index");
/**
 * Example usage of the Mixpanel utility
 * This file demonstrates various ways to track events
 */
// Example 1: Basic event tracking
async function trackUserLogin(userId, loginMethod) {
    await (0, index_1.track)('User Login', {
        user_id: userId,
        login_method: loginMethod,
        timestamp: new Date().toISOString(),
        platform: 'web',
    }, userId);
}
// Example 2: Feature usage tracking
async function trackFeatureUsage(featureName, userId, metadata) {
    await (0, index_1.track)('Feature Used', {
        feature_name: featureName,
        user_id: userId,
        metadata: metadata || {},
        timestamp: new Date().toISOString(),
    }, userId);
}
// Example 3: Error tracking
async function trackError(errorMessage, errorCode, userId, context) {
    await (0, index_1.track)('Error Occurred', {
        error_message: errorMessage,
        error_code: errorCode,
        user_id: userId,
        context: context || {},
        timestamp: new Date().toISOString(),
    }, userId);
}
// Example 4: RAG Poisoning specific events
async function trackRAGPoisoningEvent(eventType, userId, fileType, goal) {
    await (0, index_1.track)('RAG Poisoning Event', {
        event_type: eventType, // 'file_uploaded', 'poisoning_started', 'poisoning_completed', etc.
        user_id: userId,
        file_type: fileType,
        goal,
        timestamp: new Date().toISOString(),
    }, userId);
}
// Example 5: Batch tracking for user session
async function trackUserSession(userId, sessionData) {
    const events = [
        {
            event: 'Session Started',
            properties: {
                user_id: userId,
                timestamp: new Date().toISOString(),
            },
            distinctId: userId,
        },
        ...sessionData.pageViews.map((page) => ({
            event: 'Page View',
            properties: {
                page,
                user_id: userId,
                timestamp: new Date().toISOString(),
            },
            distinctId: userId,
        })),
        ...sessionData.featuresUsed.map((feature) => ({
            event: 'Feature Used',
            properties: {
                feature_name: feature,
                user_id: userId,
                timestamp: new Date().toISOString(),
            },
            distinctId: userId,
        })),
        ...sessionData.errors.map((error) => ({
            event: 'Error Occurred',
            properties: {
                error_message: error,
                user_id: userId,
                timestamp: new Date().toISOString(),
            },
            distinctId: userId,
        })),
    ];
    await (0, index_1.trackBatch)(events);
}
// Example 6: Conditional tracking based on configuration
async function trackWithConditionalCheck(eventName, properties, userId) {
    if ((0, index_1.isMixpanelConfigured)()) {
        await (0, index_1.track)(eventName, properties, userId);
    }
    else {
        console.log(`Mixpanel not configured. Would have tracked: ${eventName}`, properties);
    }
}
// Example 7: API endpoint usage tracking
async function trackAPIUsage(endpoint, method, userId, responseTime) {
    await (0, index_1.track)('API Endpoint Called', {
        endpoint,
        method,
        user_id: userId,
        response_time_ms: responseTime,
        timestamp: new Date().toISOString(),
    }, userId);
}
// Example 8: File upload tracking
async function trackFileUpload(fileType, fileSize, userId, context) {
    await (0, index_1.track)('File Uploaded', {
        file_type: fileType,
        file_size_bytes: fileSize,
        user_id: userId,
        context: context || 'general',
        timestamp: new Date().toISOString(),
    }, userId);
}
//# sourceMappingURL=examples.js.map