 
         // Build the analytics metadata header
         
+        // Device info
         var osVersion = ""
         var model = ""
         var deviceId = ""

            deviceId = device.identifierForVendor?.UUIDString as String
            model = device.modelName
        #endif

        
        var requestAnalytics: [String: String] = [:]
        
        requestAnalytics["os"] = "ios"
        requestAnalytics["brand"] = "Apple"
        requestAnalytics["osVersion"] = osVersion
        requestAnalytics["model"] = model
        requestAnalytics["deviceID"] = deviceId
        requestAnalytics["mfpAppName"] = "" // TODO: Get from Analytics or Logger initializer
        requestAnalytics["appStoreLabel"] = NSBundle.mainBundle().infoDictionary?["CFBundleName"] as? String ?? ""
        requestAnalytics["appStoreId"] = NSBundle.mainBundle().bundleIdentifier ?? ""
        requestAnalytics["appVersionCode"] = NSBundle.mainBundle().objectForInfoDictionaryKey(kCFBundleVersionKey as String) as? String ?? ""
        requestAnalytics["appVersionDisplay"] = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleShortVersionString") as? String ?? ""

        do {
            let requestAnalyticsJson = try NSJSONSerialization.dataWithJSONObject(requestAnalytics, options: [])
            let requestAnalyticsString = String(data: requestAnalyticsJson, encoding: NSUTF8StringEncoding)
            if requestAnalyticsString != nil {
                self.headers["x-mfp-analytics-metadata"] = requestAnalyticsString
            }
        }
        catch let error {
            Analytics.logger.error("Failed to append analytics metadata to request. Error: \(error)")

    
    internal func logInboundResponse(response: Response, url: String) {
        
        Analytics.logger.debug("Network response inbound")
        
        let endTime = NSDate.timeIntervalSinceReferenceDate()
        let roundTripTime = endTime - startTime
        let bytesSent = self.requestBody?.length ?? 0
        
        // Data for analytics logging
        var responseMetadata: [String: AnyObject] = [:]
        
        responseMetadata["$category"] = "network"
        responseMetadata["$path"] = url
        responseMetadata["$trackingId"] = self.trackingId
        responseMetadata["$outboundTimestamp"] = startTime
        responseMetadata["$inboundTimestamp"] = endTime
        responseMetadata["$roundTripTime"] = roundTripTime
        responseMetadata["$responseCode"] = response.statusCode
        responseMetadata["$bytesSent"] = bytesSent
        
        if (response.responseText != nil && !response.responseText!.isEmpty) {
            responseMetadata["$bytesReceived"] = response.responseText?.lengthOfBytesUsingEncoding(NSUTF8StringEncoding)
        }
        Analytics.logger.analytics(responseMetadata)
    }
    
    
