<commit_before>//
//  FirebaseProvider.swift
//  Analytical
//
//  Created by <NAME> on 30/05/17.
//  Copyright © 2017 Unified Sense. All rights reserved.
//

import Analytical
import Firebase

public enum FirebaseProperties : String {
    case customOne
    case creativeName
    case creativeSlot
    case groupId
    case index
    case locationId
    
    case numberOfNights
    case numberOfPassengers
    case numberOfRooms
    
    case travelClass
}

public class FirebaseProvider : BaseProvider<Firebase.Analytics>, AnalyticalProvider {
    
    public static let GoogleAppId = "GoogleAppIdKey"
    public static let BundleId = "BundleIdKey"
    public static let GCMSenderId = "GCMSenderID"
    
    public func setup(with properties: Properties?) {
        
        guard let googleAppId = properties?[FirebaseProvider.GoogleAppId] as? String, let gcmSenderId = properties?[FirebaseProvider.GCMSenderId] as? String else {
            return
        }
        
        let options = FirebaseOptions(googleAppID: googleAppId, gcmSenderID: gcmSenderId)
        
        if let bundleId = properties?[FirebaseProvider.BundleId] as? String {
            options.bundleID = bundleId
        }
        
        FirebaseApp.configure(options: options)
    }
    
    public override func event(_ event: AnalyticalEvent) {
        guard let event = update(event: event) else {
            return
        }
        
        switch event.type {
        case .default:
            Analytics.logEvent(event.name, parameters: mergeGlobal(properties: event.properties, overwrite: true))
        case .screen:
            Analytics.setScreenName(event.name, screenClass: nil)
        case .finishTime:
            super.event(event)<commit_msg>Fixed Firebase purchase crash<commit_after>//
//  FirebaseProvider.swift
//  Analytical
//
//  Created by <NAME> on 30/05/17.
//  Copyright © 2017 Unified Sense. All rights reserved.
//

import Analytical
import Firebase

public enum FirebaseProperties : String {
    case customOne
    case creativeName
    case creativeSlot
    case groupId
    case index
    case locationId
    
    case numberOfNights
    case numberOfPassengers
    case numberOfRooms
    
    case travelClass
}

public class FirebaseProvider : BaseProvider<Firebase.Analytics>, AnalyticalProvider {
    
    public static let GoogleAppId = "GoogleAppIdKey"
    public static let BundleId = "BundleIdKey"
    public static let GCMSenderId = "GCMSenderID"
    
    public func setup(with properties: Properties?) {
        
        guard let googleAppId = properties?[FirebaseProvider.GoogleAppId] as? String, let gcmSenderId = properties?[FirebaseProvider.GCMSenderId] as? String else {
            return
        }
        
        let options = FirebaseOptions(googleAppID: googleAppId, gcmSenderID: gcmSenderId)
        
        if let bundleId = properties?[FirebaseProvider.BundleId] as? String {
            options.bundleID = bundleId
        }
        
        FirebaseApp.configure(options: options)
    }
    
    public override func event(_ event: AnalyticalEvent) {
        guard let event = update(event: event) else {
            return
        }
        
        switch event.type {
        case .default, .purchase:
            Analytics.logEvent(event.name, parameters: mergeGlobal(properties: event.properties, overwrite: true))
        case .screen:
            Analytics.setScreenName(event.name, screenClass: nil)
        case .finishTime:
            super.event(event)
{'fraction_non_alphanumeric': 0.071285999429712, 'fraction_numerical': 0.00570287995437696, 'mean_word_length': 2.466403162055336, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3012067', 'n_tokens_mistral': 977, 'n_tokens_neox': 943, 'n_words': 261}