<commit_before>import Foundation

class AnalyticsKitMixpanelProvider: NSObject, AnalyticsKitProvider {

    init(withAPIKey apiKey: String) {
        Mixpanel.sharedInstance(withToken: apiKey)
    }

    // Lifecycle
    func applicationWillEnterForeground() { }
    func applicationDidEnterBackground() { }
    func applicationWillTerminate() { }

    func uncaughtException(_ exception: NSException) {
        Mixpanel.sharedInstance().track("Uncaught Exceptions", properties: [
            "ename" : exception.name,
            "reason" : exception.reason ?? "nil",
            "userInfo" : exception.userInfo ?? "nil"
        ] as [AnyHashable: Any])
    }

    // Logging
    func logScreen(_ screenName: String) {
        logEvent("Screen - \(screenName)")
    }

    func logScreen(_ screenName: String, withProperties properties: [String: Any]) {
        logEvent("Screen - \(screenName)", withProperties: properties)
    }

    func logEvent(_ event: String) {
        Mixpanel.sharedInstance().track(event)
    }

    func logEvent(_ event: String, withProperty key: String, andValue value: String) {
        logEvent(event, withProperties: [key: value])
    }

    func logEvent(_ event: String, withProperties properties: [String: Any]) {
        Mixpanel.sharedInstance().track(event, properties: properties)
    }

    func logEvent(_ event: String, timed: Bool) {
        if timed {
            Mixpanel.sharedInstance().timeEvent(event)
        } else {
            Mixpanel.sharedInstance().track(event)
        }
    }

    func logEvent(_ event: String, withProperties properties: [String: Any], timed: Bool) {
        if timed {
            Mixpanel.sharedInstance().timeEvent(event)
        } else {
            Mixpanel.sharedInstance().track(event, properties: properties)
        }
    }

    func endTimedEvent(_ event: String, withProperties properties: [String: Any]) {
        // Mixpanel documentation: timeEvent followed by a track with the same event name would record the duration
        Mixpanel.sharedInstance().track(event, properties: properties)
    }

    func logError(_ name: String, message: String?, exception: NSException?) {
        Mixpanel.sharedInstance().track("Exceptions", properties: [
            "name" : name,
            "message" : message,
            "ename" : exception?.name ?? "nil",
            "reason" : exception?.reason ?? "nil",
            "userInfo" : exception?.userInfo ?? "nil"
        ] as [AnyHashable: Any])
    }

    func logError(_ name: String, message: String?, error: NSError?) {
        Mixpanel.sharedInstance().track("Errors", properties: [
            "name" : name,
            "message" : message,
            "description" : error?.localizedDescription ?? "nil",
            "code" : "\(error?.code ?? 0)",
            "domain" : error?.domain  ?? "nil",
            "userInfo" : error?.userInfo.description  ?? "nil"
        ] as [AnyHashable: Any])
    }
    
}<commit_msg>Update Mixpanel provider to omit property keys instead of passing "nil" strings as values<commit_after>import Foundation

class AnalyticsKitMixpanelProvider: NSObject, AnalyticsKitProvider {

    init(withAPIKey apiKey: String) {
        Mixpanel.sharedInstance(withToken: apiKey)
    }

    // Lifecycle
    func applicationWillEnterForeground() { }
    func applicationDidEnterBackground() { }
    func applicationWillTerminate() { }

    func uncaughtException(_ exception: NSException) {
        Mixpanel.sharedInstance().track("Uncaught Exceptions", properties: [
            "ename" : exception.name,
            "reason" : exception.reason ?? "nil",
            "userInfo" : exception.userInfo ?? "nil"
        ] as [AnyHashable: Any])
    }

    // Logging
    func logScreen(_ screenName: String) {
        logEvent("Screen - \(screenName)")
    }

    func logScreen(_ screenName: String, withProperties properties: [String: Any]) {
        logEvent("Screen - \(screenName)", withProperties: properties)
    }

    func logEvent(_ event: String) {
        Mixpanel.sharedInstance().track(event)
    }

    func logEvent(_ event: String, withProperty key: String, andValue value: String) {
        logEvent(event, withProperties: [key: value])
    }

    func logEvent(_ event: String, withProperties properties: [String: Any]) {
        Mixpanel.sharedInstance().track(event, properties: properties)
    }

    func logEvent(_ event: String, timed: Bool) {
        if timed {
            Mixpanel.sharedInstance().timeEvent(event)
        } else {
            Mixpanel.sharedInstance().track(event)
        }
    }

    func logEvent(_ event: String, withProperties properties: [String: Any], timed: Bool) {
        if timed {
            Mixpanel.sharedInstance().timeEvent(event)
        } else {
            Mixpanel.sharedInstance().track(event, properties: properties)
        }
    }

    func endTimedEvent(_ event: String, withProperties properties: [String: Any]) {
        // Mixpanel documentation: timeEvent followed by a track with the same event name would record the duration
        Mixpanel.sharedInstance().track(event, properties: properties)
    }

    func logError(_ name: String, message: String?, exception: NSException?) {
        var properties = [AnyHashable: Any]()
        properties["name"] = name
        properties["message"] = message
        if let exception = exception {
            properties["ename"] = exception.name
            properties["reason"] = exception.reason
            properties["userInfo"] = exception.userInfo
        }

        Mixpanel.sharedInstance().track("Exceptions", properties: properties)
    }

    func logError(_ name: String, message: String?, error: NSError?) {
        var properties = [AnyHashable: Any]()
        properties["name"] = name
        properties["message"] = message
        if let error = error {
            properties["description"] = error.localizedDescription
            properties["code"] = error.code
            properties["domain"] = error.domain
            properties["userInfo"] = error.userInfo.description
        }

        Mixpanel.sharedInstance().track("Errors", properties: properties)
    }
    
}
{'fraction_non_alphanumeric': 0.11609455958549222, 'fraction_numerical': 0.00016191709844559586, 'mean_word_length': 2.678975580702799, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2490775', 'n_tokens_mistral': 1631, 'n_tokens_neox': 1579, 'n_words': 408}