From 36239fd0bfe2218cf4cac4c2cc83231f955b9ddd Mon Sep 17 00:00:00 2001 From: RyosukeCla Date: Fri, 20 Oct 2023 15:13:06 +0900 Subject: [PATCH] rename TriggerEvent to NativebrikEvent --- ios/Nativebrik/Classes/repository.swift | 2 +- ios/Nativebrik/Classes/sdk.swift | 4 ++-- ios/Nativebrik/Classes/trigger.swift | 20 ++++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ios/Nativebrik/Classes/repository.swift b/ios/Nativebrik/Classes/repository.swift index f70f652..dee8dc0 100644 --- a/ios/Nativebrik/Classes/repository.swift +++ b/ios/Nativebrik/Classes/repository.swift @@ -209,7 +209,7 @@ class ExperimentConfigsRepository { self.cache = cacheStrategy } - func trigger(event: TriggerEvent, callback: @escaping (_ entry: Entry) -> Void) async { + func trigger(event: NativebrikEvent, callback: @escaping (_ entry: Entry) -> Void) async { let url = self.config.cdnUrl + "/projects/" + self.config.projectId + "/experiments/trigger/" + event.name await self._fetch(key: event.name, url: url, callback: callback) } diff --git a/ios/Nativebrik/Classes/sdk.swift b/ios/Nativebrik/Classes/sdk.swift index 434b78d..a7f4280 100644 --- a/ios/Nativebrik/Classes/sdk.swift +++ b/ios/Nativebrik/Classes/sdk.swift @@ -120,7 +120,7 @@ public struct ComponentEvent { public let payload: [EventProperty]? } -public struct TriggerEvent { +public struct NativebrikEvent { public let name: String public init(_ name: String) { self.name = name @@ -166,7 +166,7 @@ public class NativebrikClient: ObservableObject { return OverlayViewControllerRepresentable(overlayVC: self.overlayVC).frame(width: 0, height: 0) } - public func dispatch(event: TriggerEvent) { + public func dispatch(event: NativebrikEvent) { self.overlayVC.triggerViewController.dispatch(event: event) } } diff --git a/ios/Nativebrik/Classes/trigger.swift b/ios/Nativebrik/Classes/trigger.swift index 0c27835..f2cdc02 100644 --- a/ios/Nativebrik/Classes/trigger.swift +++ b/ios/Nativebrik/Classes/trigger.swift @@ -40,13 +40,13 @@ class TriggerViewController: UIViewController { self.didLoaded = true // dispatch an event when the user is only booted - self.dispatch(event: TriggerEvent(TriggerEventNameDefs.USER_BOOT_APP.rawValue)) + self.dispatch(event: NativebrikEvent(TriggerEventNameDefs.USER_BOOT_APP.rawValue)) // dispatch user enter the app firtly let count = UserDefaults.standard.object(forKey: UserDefaultsKeys.SDK_INITIALIZED_COUNT.rawValue) as? Int ?? 0 UserDefaults.standard.set(count + 1, forKey: UserDefaultsKeys.SDK_INITIALIZED_COUNT.rawValue) if count == 0 { - self.dispatch(event: TriggerEvent(TriggerEventNameDefs.USER_ENTER_TO_APP_FIRSTLY.rawValue)) + self.dispatch(event: NativebrikEvent(TriggerEventNameDefs.USER_ENTER_TO_APP_FIRSTLY.rawValue)) } // dispatch retention event @@ -57,7 +57,7 @@ class TriggerViewController: UIViewController { } @objc func willEnterForeground() { - self.dispatch(event: TriggerEvent(TriggerEventNameDefs.USER_ENTER_TO_FOREGROUND.rawValue)) + self.dispatch(event: NativebrikEvent(TriggerEventNameDefs.USER_ENTER_TO_FOREGROUND.rawValue)) self.callWhenUserComeBack() } @@ -65,23 +65,23 @@ class TriggerViewController: UIViewController { self.user.comeBack() // dispatch the event when every time the user is activated - self.dispatch(event: TriggerEvent(TriggerEventNameDefs.USER_ENTER_TO_APP.rawValue)) + self.dispatch(event: NativebrikEvent(TriggerEventNameDefs.USER_ENTER_TO_APP.rawValue)) let retention = self.user.retention if retention == 1 { - self.dispatch(event: TriggerEvent(TriggerEventNameDefs.RETENTION_1.rawValue)) + self.dispatch(event: NativebrikEvent(TriggerEventNameDefs.RETENTION_1.rawValue)) } else if 1 < retention && retention <= 3 { - self.dispatch(event: TriggerEvent(TriggerEventNameDefs.RETENTION_2_3.rawValue)) + self.dispatch(event: NativebrikEvent(TriggerEventNameDefs.RETENTION_2_3.rawValue)) } else if 3 < retention && retention <= 7 { - self.dispatch(event: TriggerEvent(TriggerEventNameDefs.RETENTION_4_7.rawValue)) + self.dispatch(event: NativebrikEvent(TriggerEventNameDefs.RETENTION_4_7.rawValue)) } else if 7 < retention && retention <= 14 { - self.dispatch(event: TriggerEvent(TriggerEventNameDefs.RETENTION_8_14.rawValue)) + self.dispatch(event: NativebrikEvent(TriggerEventNameDefs.RETENTION_8_14.rawValue)) } else if 14 < retention { - self.dispatch(event: TriggerEvent(TriggerEventNameDefs.RETENTION_15.rawValue)) + self.dispatch(event: NativebrikEvent(TriggerEventNameDefs.RETENTION_15.rawValue)) } } - func dispatch(event: TriggerEvent) { + func dispatch(event: NativebrikEvent) { DispatchQueue.global().async { Task { if event.name.isEmpty {