pid를 심어놓은 광고를 타고 들어온 경우 항상 AppLaunch 이벤트를 실행하는 코드

This commit is contained in:
Yu Sung
2025-03-26 22:12:18 +09:00
parent 236cf4db1e
commit 82dc43b40f
4 changed files with 94 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
//
// AdTrackingApi.swift
// SodaLive
//
// Created by klaus on 3/26/25.
//
import Foundation
import Moya
enum AdTrackingApi {
case appLaunch(pid: String)
}
extension AdTrackingApi: TargetType {
var baseURL: URL {
return URL(string: BASE_URL)!
}
var path: String {
switch self {
case .appLaunch:
return "/ad-tracking/app-launch"
}
}
var method: Moya.Method {
switch self {
case .appLaunch:
return .post
}
}
var task: Moya.Task {
switch self {
case .appLaunch(let pid):
return .requestJSONEncodable(AdTrackingAppLaunchRequest(pid: pid))
}
}
var headers: [String : String]? {
return nil
}
}

View File

@@ -0,0 +1,10 @@
//
// AdTrackingAppLaunchRequest.swift
// SodaLive
//
// Created by klaus on 3/26/25.
//
struct AdTrackingAppLaunchRequest: Encodable {
let pid: String
}

View File

@@ -0,0 +1,19 @@
//
// AdTrackingRepository.swift
// SodaLive
//
// Created by klaus on 3/26/25.
//
import Foundation
import CombineMoya
import Combine
import Moya
final class AdTrackingRepository {
private let api = MoyaProvider<AdTrackingApi>()
func adTrackingAppLaunch(pid: String) -> AnyPublisher<Response, MoyaError> {
return api.requestPublisher(.appLaunch(pid: pid))
}
}