Repository: expo/expo
File: apps/expo-go/ios/Client/SwiftUI/Services/FeedbackService.swift (Swift)

Code before:
// Copyright 2015-present 650 Industries. All rights reserved.

import Foundation
import UIKit

struct FeedbackService {
  func submitFeedback(message: String, email: String?) async throws {
    guard let url = URL(string: "\(APIClient.shared.apiOrigin)/--/api/v2/feedback/expo-go-send") else {
      throw APIError.invalidURL
    }

    var request = URLRequest(url: url)
    request.httpMethod = "POST"
    request.setValue("application/json", forHTTPHeaderField: "Content-Type")
    request.setValue("application/json", forHTTPHeaderField: "Accept")

    let payload = FeedbackPayload(
      feedback: message,
      email: email,
      metadata: FeedbackMetadata(
        os: "\(await UIDevice.current.systemName ) \(await UIDevice.current.systemVersion)",
        model: await UIDevice.current.model,
        expoGoVersion: Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
      )
    )

    let encoder = JSONEncoder()
    request.httpBody = try encoder.encode(payload)

    do {
      let (data, response) = try await URLSession.shared.data(for: request)
      guard let httpResponse = response as? HTTPURLResponse else {
        throw APIError.invalidResponse
      }

      guard (200..<300).contains(httpResponse.statusCode) else {
        let message = parseAPIErrorMessage(from: data) ?? "Something went wrong."
        throw APIError.httpError(statusCode: httpResponse.statusCode, message: message)
      }
    } catch let error as APIError {
      throw error
    } catch {
      throw APIError.networkError(error)
    }
  }


Review comment (suggestion):
```suggestion
        os: "\(await UIDevice.current.systemName) \(await UIDevice.current.systemVersion)",
```

Code after:
// Copyright 2015-present 650 Industries. All rights reserved.

import Foundation
import UIKit

struct FeedbackService {
  func submitFeedback(message: String, email: String?) async throws {
    guard let url = URL(string: "\(APIClient.shared.apiOrigin)/--/api/v2/feedback/expo-go-send") else {
      throw APIError.invalidURL
    }

    var request = URLRequest(url: url)
    request.httpMethod = "POST"
    request.setValue("application/json", forHTTPHeaderField: "Content-Type")
    request.setValue("application/json", forHTTPHeaderField: "Accept")

    let payload = FeedbackPayload(
      feedback: message,
      email: email,
      metadata: FeedbackMetadata(
        os: "\(await UIDevice.current.systemName) \(await UIDevice.current.systemVersion)",
        model: await UIDevice.current.model,
        expoGoVersion: Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
      )
    )

    let encoder = JSONEncoder()
    request.httpBody = try encoder.encode(payload)

    do {
      let (data, response) = try await URLSession.shared.data(for: request)
      guard let httpResponse = response as? HTTPURLResponse else {
        throw APIError.invalidResponse
      }

      guard (200..<300).contains(httpResponse.statusCode) else {
        let message = parseAPIErrorMessage(from: data) ?? "Something went wrong."
        throw APIError.httpError(statusCode: httpResponse.statusCode, message: message)
      }
    } catch let error as APIError {
      throw error
    } catch {
      throw APIError.networkError(error)
    }
  }