pid를 심어놓은 광고를 타고 들어온 경우 항상 AppLaunch 이벤트를 실행하는 코드
This commit is contained in:
44
SodaLive/Sources/Tracking/AdTrackingApi.swift
Normal file
44
SodaLive/Sources/Tracking/AdTrackingApi.swift
Normal 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
|
||||
}
|
||||
}
|
10
SodaLive/Sources/Tracking/AdTrackingAppLaunchRequest.swift
Normal file
10
SodaLive/Sources/Tracking/AdTrackingAppLaunchRequest.swift
Normal file
@@ -0,0 +1,10 @@
|
||||
//
|
||||
// AdTrackingAppLaunchRequest.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 3/26/25.
|
||||
//
|
||||
|
||||
struct AdTrackingAppLaunchRequest: Encodable {
|
||||
let pid: String
|
||||
}
|
19
SodaLive/Sources/Tracking/AdTrackingRepository.swift
Normal file
19
SodaLive/Sources/Tracking/AdTrackingRepository.swift
Normal 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))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user