<commit_before>/*
*     Copyright 2016 IBM Corp.
*     Licensed under the Apache License, Version 2.0 (the "License");
*     you may not use this file except in compliance with the License.
*     You may obtain a copy of the License at
*     http://www.apache.org/licenses/LICENSE-2.0
*     Unless required by applicable law or agreed to in writing, software
*     distributed under the License is distributed on an "AS IS" BASIS,
*     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*     See the License for the specific language governing permissions and
*     limitations under the License.
*/


import Foundation
import UIKit



// MARK: - Swift 3

#if swift(>=3.0)
    
    
    
public extension BMSAnalytics {
    
    // The device ID for iOS devices, unique to each bundle ID on each device.
    // Apps installed with different bundle IDs on the same device will receive different device IDs.
    internal static let uniqueDeviceId: String? = UIDevice.current.identifierForVendor?.uuidString
    
    // Records the duration of the app's lifecycle from when it enters the foreground to when it goes to the background.
    internal static func startRecordingApplicationLifecycle() {
        
        // By now, the app will have already passed the "will enter foreground" event. Therefore, we must manually start the timer for the current session.
        logSessionStart()
        
        NotificationCenter.default.addObserver(self, selector: #selector(logSessionStart), name: .UIApplicationWillEnterForeground, object: nil)
        
        NotificationCenter.default.addObserver(self, selector: #selector(logSessionEnd), name: .UIApplicationWillEnterForeground, object: nil)
    }
    
    
    // General information about the device that the app is running on.
    // This data gets sent in every network request to the Analytics server
    internal static func getiOSDeviceInfo() -> (String, String, String) {
        
        var osVersion = "", model = "", deviceId = ""
        
        let device = UIDevice.current
        osVersion = device.systemVersion
        model = device.modelName
        deviceId = BMSAnalytics.getDeviceId(from: BMSAnalytics.uniqueDeviceId)
        
        return (osVersion, model, deviceId)
    }
    
}
    <commit_msg>Fixed incorrect NotificationCenter observer for app background events<commit_after>/*
*     Copyright 2016 IBM Corp.
*     Licensed under the Apache License, Version 2.0 (the "License");
*     you may not use this file except in compliance with the License.
*     You may obtain a copy of the License at
*     http://www.apache.org/licenses/LICENSE-2.0
*     Unless required by applicable law or agreed to in writing, software
*     distributed under the License is distributed on an "AS IS" BASIS,
*     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*     See the License for the specific language governing permissions and
*     limitations under the License.
*/


import Foundation
import UIKit



// MARK: - Swift 3

#if swift(>=3.0)
    
    
    
public extension BMSAnalytics {
    
    // The device ID for iOS devices, unique to each bundle ID on each device.
    // Apps installed with different bundle IDs on the same device will receive different device IDs.
    internal static let uniqueDeviceId: String? = UIDevice.current.identifierForVendor?.uuidString
    
    // Records the duration of the app's lifecycle from when it enters the foreground to when it goes to the background.
    internal static func startRecordingApplicationLifecycle() {
        
        // By now, the app will have already passed the "will enter foreground" event. Therefore, we must manually start the timer for the current session.
        logSessionStart()
        
        NotificationCenter.default.addObserver(self, selector: #selector(logSessionStart), name: .UIApplicationWillEnterForeground, object: nil)
        
        NotificationCenter.default.addObserver(self, selector: #selector(logSessionEnd), name: .UIApplicationDidEnterBackground, object: nil)
    }
    
    
    // General information about the device that the app is running on.
    // This data gets sent in every network request to the Analytics server
    internal static func getiOSDeviceInfo() -> (String, String, String) {
        
        var osVersion = "", model = "", deviceId = ""
        
        let device = UIDevice.current
        osVersion = device.systemVersion
        model = device.modelName
        deviceId = BMSAnalytics.getDeviceId(from: BMSAnalytics.uniqueDeviceId)
        
        return (osVersion, model, deviceId)
    }
    
}
    
{'fraction_non_alphanumeric': 0.0670535138620245, 'fraction_numerical': 0.004728132387706856, 'mean_word_length': 2.891304347826087, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1443829', 'n_tokens_mistral': 1277, 'n_tokens_neox': 1183, 'n_words': 489}