Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analytics plugins #26

Merged
merged 5 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation
import Swinject

public protocol AnalyticsService {
public protocol AnalyticsService: Sendable {
func identify(id: String, username: String?, email: String?)
func logEvent(_ event: String, parameters: [String: Any]?)
func logScreenEvent(_ event: String, parameters: [String: Any]?)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// DeepLinkManagerProtocol.swift
// OEXFoundation
//
// Created by Anton Yarmolenka on 26/11/2024.
//

import Foundation

@MainActor
public protocol DeepLinkManagerProtocol: Sendable {
func processLinkFrom(userInfo: [AnyHashable: Any])
func processDeepLink(with params: [AnyHashable: Any]?)
}
1 change: 1 addition & 0 deletions Sources/OEXFoundation/Extensions/Notification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ public extension Notification.Name {
public extension Notification {
enum UserInfoKey: String {
case isForced
case status
}
}
32 changes: 32 additions & 0 deletions Sources/OEXFoundation/Network/Alamofire+Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,35 @@ public extension Error {
}
}
}

public extension Error {
var errorCode: Int {
guard let afError = self.asAFError else {
return (self as NSError).code
}

if let validationError = afError.validationError {
return validationError.statusCode
}

if let code = afError.responseCode {
return code
}

return (self as NSError).code
}

var errorMessage: String {
guard let afError = self.asAFError else {
return (self as NSError).localizedDescription
}

if let validationError = afError.validationError,
let data = validationError.data,
let error = data["error"] as? String {
return error
}

return afError.localizedDescription
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// PushNotificationService.swift
// OpenEdX
//
// Created by Anton Yarmolenka on 22/11/2024.
//

import Foundation

public protocol PushNotificationsProvider: Sendable {
func didRegisterWithDeviceToken(deviceToken: Data)
}

public extension PushNotificationsProvider {
func didFailToRegisterForRemoteNotificationsWithError(error: Error) {}
func synchronizeToken() {}
func refreshToken() {}
}

@MainActor
public protocol PushNotificationsListener: Sendable {
func shouldListenNotification(userinfo: [AnyHashable: Any]) -> Bool
func didReceiveRemoteNotification(userInfo: [AnyHashable: Any])
}