@usesophi/sophi-event-react-native 0.0.0-stage → 0.0.1-alpha01
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +4 -0
- package/README.md +116 -2
- package/SophiEventSDK-ReactNative.podspec +23 -0
- package/android/build.gradle +39 -0
- package/android/consumer-rules.pro +1 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/com/sophi/eventreactnative/SophiEventsModule.kt +199 -0
- package/android/src/main/java/com/sophi/eventreactnative/SophiEventsPackage.kt +11 -0
- package/index.ts +4 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/Info.plist +44 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64/SophiEventSDK.framework/Headers/SophiEventSDK-Swift.h +382 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64/SophiEventSDK.framework/Info.plist +0 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64/SophiEventSDK.framework/Modules/SophiEventSDK.swiftmodule/arm64-apple-ios.abi.json +21707 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64/SophiEventSDK.framework/Modules/SophiEventSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +413 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64/SophiEventSDK.framework/Modules/SophiEventSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64/SophiEventSDK.framework/Modules/SophiEventSDK.swiftmodule/arm64-apple-ios.swiftinterface +413 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64/SophiEventSDK.framework/Modules/module.modulemap +3 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64/SophiEventSDK.framework/PrivacyInfo.xcprivacy +153 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64/SophiEventSDK.framework/SophiEventSDK +0 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64_x86_64-simulator/SophiEventSDK.framework/Headers/SophiEventSDK-Swift.h +760 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64_x86_64-simulator/SophiEventSDK.framework/Info.plist +0 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64_x86_64-simulator/SophiEventSDK.framework/Modules/SophiEventSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +21707 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64_x86_64-simulator/SophiEventSDK.framework/Modules/SophiEventSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +413 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64_x86_64-simulator/SophiEventSDK.framework/Modules/SophiEventSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64_x86_64-simulator/SophiEventSDK.framework/Modules/SophiEventSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +413 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64_x86_64-simulator/SophiEventSDK.framework/Modules/SophiEventSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +21707 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64_x86_64-simulator/SophiEventSDK.framework/Modules/SophiEventSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +413 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64_x86_64-simulator/SophiEventSDK.framework/Modules/SophiEventSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64_x86_64-simulator/SophiEventSDK.framework/Modules/SophiEventSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +413 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64_x86_64-simulator/SophiEventSDK.framework/Modules/module.modulemap +3 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64_x86_64-simulator/SophiEventSDK.framework/PrivacyInfo.xcprivacy +153 -0
- package/ios/Frameworks/SophiEventSDK.xcframework/ios-arm64_x86_64-simulator/SophiEventSDK.framework/SophiEventSDK +0 -0
- package/ios/Frameworks/SophiIdentity.xcframework/Info.plist +44 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64/SophiIdentity.framework/Headers/SophiIdentity-Swift.h +382 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64/SophiIdentity.framework/Info.plist +0 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64/SophiIdentity.framework/Modules/SophiIdentity.swiftmodule/arm64-apple-ios.abi.json +6314 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64/SophiIdentity.framework/Modules/SophiIdentity.swiftmodule/arm64-apple-ios.private.swiftinterface +170 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64/SophiIdentity.framework/Modules/SophiIdentity.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64/SophiIdentity.framework/Modules/SophiIdentity.swiftmodule/arm64-apple-ios.swiftinterface +170 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64/SophiIdentity.framework/Modules/module.modulemap +3 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64/SophiIdentity.framework/PrivacyInfo.xcprivacy +50 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64/SophiIdentity.framework/SophiIdentity +0 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64_x86_64-simulator/SophiIdentity.framework/Headers/SophiIdentity-Swift.h +760 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64_x86_64-simulator/SophiIdentity.framework/Info.plist +0 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64_x86_64-simulator/SophiIdentity.framework/Modules/SophiIdentity.swiftmodule/arm64-apple-ios-simulator.abi.json +6314 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64_x86_64-simulator/SophiIdentity.framework/Modules/SophiIdentity.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +170 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64_x86_64-simulator/SophiIdentity.framework/Modules/SophiIdentity.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64_x86_64-simulator/SophiIdentity.framework/Modules/SophiIdentity.swiftmodule/arm64-apple-ios-simulator.swiftinterface +170 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64_x86_64-simulator/SophiIdentity.framework/Modules/SophiIdentity.swiftmodule/x86_64-apple-ios-simulator.abi.json +6314 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64_x86_64-simulator/SophiIdentity.framework/Modules/SophiIdentity.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +170 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64_x86_64-simulator/SophiIdentity.framework/Modules/SophiIdentity.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64_x86_64-simulator/SophiIdentity.framework/Modules/SophiIdentity.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +170 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64_x86_64-simulator/SophiIdentity.framework/Modules/module.modulemap +3 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64_x86_64-simulator/SophiIdentity.framework/PrivacyInfo.xcprivacy +50 -0
- package/ios/Frameworks/SophiIdentity.xcframework/ios-arm64_x86_64-simulator/SophiIdentity.framework/SophiIdentity +0 -0
- package/ios/SophiEventsModule.m +54 -0
- package/ios/SophiEventsModuleImpl.swift +178 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +10 -0
- package/lib/src/SophiEvents.d.ts +3 -0
- package/lib/src/SophiEvents.js +11 -0
- package/lib/src/client.d.ts +60 -0
- package/lib/src/client.js +151 -0
- package/lib/src/types.d.ts +204 -0
- package/lib/src/types.js +3 -0
- package/lib/src/wire.d.ts +10 -0
- package/lib/src/wire.js +191 -0
- package/native-versions.json +16 -0
- package/package.json +62 -4
- package/react-native.config.js +10 -0
- package/src/SophiEvents.ts +13 -0
- package/src/client.ts +191 -0
- package/src/types.ts +216 -0
- package/src/wire.ts +189 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// swift-interface-format-version: 1.0
|
|
2
|
+
// swift-compiler-version: Apple Swift version 6.3.3 effective-5.10 (swiftlang-6.3.3.1.3 clang-2100.1.1.101)
|
|
3
|
+
// swift-module-flags: -target x86_64-apple-ios15.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -O -enable-experimental-feature DebugDescriptionMacro -enable-bare-slash-regex -module-name SophiIdentity -module-alias Module___SophiIdentity=SophiIdentity -module-alias Module____StringProcessing=_StringProcessing -module-alias Module____SwiftConcurrencyShims=_SwiftConcurrencyShims -module-alias Module____Concurrency=_Concurrency -module-alias Module___CoreFoundation=CoreFoundation -module-alias Module___CryptoKit=CryptoKit
|
|
4
|
+
// swift-module-flags-ignorable: -no-verify-emitted-module-interface -formal-cxx-interoperability-mode=off -interface-compiler-version 6.3.3
|
|
5
|
+
import Module___CoreFoundation
|
|
6
|
+
import Module___CryptoKit
|
|
7
|
+
import Foundation
|
|
8
|
+
import Swift
|
|
9
|
+
import Module____Concurrency
|
|
10
|
+
import Module____StringProcessing
|
|
11
|
+
import Module____SwiftConcurrencyShims
|
|
12
|
+
public enum SophiIdentityError : Swift.Error, Swift.Equatable, Swift.Sendable {
|
|
13
|
+
case invalidConfiguration, disabled, staleGeneration, invalidResponse
|
|
14
|
+
case http(Swift.Int)
|
|
15
|
+
case storageUnavailable, mergePending
|
|
16
|
+
public static func == (a: Module___SophiIdentity.SophiIdentityError, b: Module___SophiIdentity.SophiIdentityError) -> Swift.Bool
|
|
17
|
+
}
|
|
18
|
+
public struct SophiIdentityConfiguration : Swift.Sendable {
|
|
19
|
+
public let apiKey: Swift.String
|
|
20
|
+
public let baseURL: Foundation.URL
|
|
21
|
+
public let namespace: Swift.String
|
|
22
|
+
public init(apiKey: Swift.String, baseURL: Foundation.URL) throws
|
|
23
|
+
}
|
|
24
|
+
public struct SophiShopperIdentity : Swift.Codable, Swift.Equatable, Swift.Sendable {
|
|
25
|
+
public var ownerID: Foundation.UUID
|
|
26
|
+
public var clientID: Swift.String?
|
|
27
|
+
public var externalUserID: Swift.String?
|
|
28
|
+
public var pendingMergeSourceID: Swift.String?
|
|
29
|
+
public var aliasOwnerIDs: [Foundation.UUID]?
|
|
30
|
+
public init(ownerID: Foundation.UUID = UUID(), clientID: Swift.String? = nil, externalUserID: Swift.String? = nil, pendingMergeSourceID: Swift.String? = nil, aliasOwnerIDs: [Foundation.UUID]? = nil)
|
|
31
|
+
public var ownerIDs: [Foundation.UUID] {
|
|
32
|
+
get
|
|
33
|
+
}
|
|
34
|
+
public static func == (a: Module___SophiIdentity.SophiShopperIdentity, b: Module___SophiIdentity.SophiShopperIdentity) -> Swift.Bool
|
|
35
|
+
public func encode(to encoder: any Swift.Encoder) throws
|
|
36
|
+
public init(from decoder: any Swift.Decoder) throws
|
|
37
|
+
}
|
|
38
|
+
public struct SophiHeldIdentity : Swift.Codable, Swift.Equatable, Swift.Sendable {
|
|
39
|
+
public var identity: Module___SophiIdentity.SophiShopperIdentity
|
|
40
|
+
public var heldAt: Foundation.TimeInterval
|
|
41
|
+
public init(identity: Module___SophiIdentity.SophiShopperIdentity, heldAt: Foundation.TimeInterval)
|
|
42
|
+
public static func == (a: Module___SophiIdentity.SophiHeldIdentity, b: Module___SophiIdentity.SophiHeldIdentity) -> Swift.Bool
|
|
43
|
+
public func encode(to encoder: any Swift.Encoder) throws
|
|
44
|
+
public init(from decoder: any Swift.Decoder) throws
|
|
45
|
+
}
|
|
46
|
+
public struct SophiStoredIdentity : Swift.Codable, Swift.Equatable, Swift.Sendable {
|
|
47
|
+
public var identity: Module___SophiIdentity.SophiShopperIdentity
|
|
48
|
+
public var held: Module___SophiIdentity.SophiHeldIdentity?
|
|
49
|
+
public var chatStorage: Swift.Bool
|
|
50
|
+
public var analyticsStorage: Swift.Bool
|
|
51
|
+
public var savedAt: Foundation.TimeInterval?
|
|
52
|
+
public init(identity: Module___SophiIdentity.SophiShopperIdentity, held: Module___SophiIdentity.SophiHeldIdentity? = nil, chatStorage: Swift.Bool = false, analyticsStorage: Swift.Bool = false, savedAt: Foundation.TimeInterval? = nil)
|
|
53
|
+
public init(from decoder: any Swift.Decoder) throws
|
|
54
|
+
public func encode(to encoder: any Swift.Encoder) throws
|
|
55
|
+
public static func == (a: Module___SophiIdentity.SophiStoredIdentity, b: Module___SophiIdentity.SophiStoredIdentity) -> Swift.Bool
|
|
56
|
+
}
|
|
57
|
+
public struct SophiIdentitySession : Swift.Sendable, Swift.Equatable {
|
|
58
|
+
public let clientID: Swift.String
|
|
59
|
+
public let accessToken: Swift.String
|
|
60
|
+
public let authSessionID: Swift.String?
|
|
61
|
+
public let expiresAt: Foundation.Date
|
|
62
|
+
public let companyCode: Swift.String
|
|
63
|
+
public let layoutID: Swift.String
|
|
64
|
+
public let userName: Swift.String?
|
|
65
|
+
public let identity: Module___SophiIdentity.SophiShopperIdentity
|
|
66
|
+
public let generation: Foundation.UUID
|
|
67
|
+
public static func == (a: Module___SophiIdentity.SophiIdentitySession, b: Module___SophiIdentity.SophiIdentitySession) -> Swift.Bool
|
|
68
|
+
}
|
|
69
|
+
public struct SophiIdentitySnapshot : Swift.Sendable, Swift.Equatable {
|
|
70
|
+
public let identity: Module___SophiIdentity.SophiShopperIdentity
|
|
71
|
+
public let generation: Foundation.UUID
|
|
72
|
+
public let analyticsGeneration: Foundation.UUID
|
|
73
|
+
public let analyticsAllowed: Swift.Bool
|
|
74
|
+
public let analyticsConfigured: Swift.Bool
|
|
75
|
+
public let ownerIDs: [Foundation.UUID]
|
|
76
|
+
public let heldOwnerIDs: [Foundation.UUID]
|
|
77
|
+
public var heldOwnerID: Foundation.UUID? {
|
|
78
|
+
get
|
|
79
|
+
}
|
|
80
|
+
public let storedIdentityLoaded: Swift.Bool
|
|
81
|
+
public let dormantOwnerIDs: [Foundation.UUID]?
|
|
82
|
+
public let storedIdentityIdle: Swift.Bool
|
|
83
|
+
public static func == (a: Module___SophiIdentity.SophiIdentitySnapshot, b: Module___SophiIdentity.SophiIdentitySnapshot) -> Swift.Bool
|
|
84
|
+
}
|
|
85
|
+
public enum SophiIdentityChange : Swift.Sendable {
|
|
86
|
+
case identity(previous: Module___SophiIdentity.SophiShopperIdentity, current: Module___SophiIdentity.SophiShopperIdentity)
|
|
87
|
+
case consent(Swift.Bool?)
|
|
88
|
+
case held(owner: Foundation.UUID, restored: Swift.Bool)
|
|
89
|
+
case storageFailed
|
|
90
|
+
}
|
|
91
|
+
public enum SophiIdentityUsage : Swift.String, Swift.Sendable {
|
|
92
|
+
case analytics, chat
|
|
93
|
+
public init?(rawValue: Swift.String)
|
|
94
|
+
public typealias RawValue = Swift.String
|
|
95
|
+
public var rawValue: Swift.String {
|
|
96
|
+
get
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
public enum SophiStorageQuarantine {
|
|
100
|
+
public static let retention: Swift.Double
|
|
101
|
+
@discardableResult
|
|
102
|
+
public static func move(_ url: Foundation.URL, now: Foundation.Date) -> Swift.Bool
|
|
103
|
+
public static func sweep(_ url: Foundation.URL, before: Foundation.Date)
|
|
104
|
+
}
|
|
105
|
+
public protocol SophiIdentityPersistence : Swift.Sendable {
|
|
106
|
+
func load() throws -> Module___SophiIdentity.SophiStoredIdentity?
|
|
107
|
+
func save(_ record: Module___SophiIdentity.SophiStoredIdentity) throws
|
|
108
|
+
func clear() throws
|
|
109
|
+
func clearAnalyticsState(keepRecord: Swift.Bool) throws
|
|
110
|
+
func takeQuarantined() -> Swift.Bool
|
|
111
|
+
}
|
|
112
|
+
extension Module___SophiIdentity.SophiIdentityPersistence {
|
|
113
|
+
public func clearAnalyticsState(keepRecord: Swift.Bool) throws
|
|
114
|
+
public func takeQuarantined() -> Swift.Bool
|
|
115
|
+
}
|
|
116
|
+
final public class SophiFileIdentityPersistence : Module___SophiIdentity.SophiIdentityPersistence, @unchecked Swift.Sendable {
|
|
117
|
+
public init(namespace: Swift.String, directory: Foundation.URL? = nil, now: @escaping @Sendable () -> Foundation.Date = { Date() }) throws
|
|
118
|
+
final public func load() throws -> Module___SophiIdentity.SophiStoredIdentity?
|
|
119
|
+
final public func save(_ record: Module___SophiIdentity.SophiStoredIdentity) throws
|
|
120
|
+
final public func clear() throws
|
|
121
|
+
final public func clearAnalyticsState(keepRecord: Swift.Bool) throws
|
|
122
|
+
final public func takeQuarantined() -> Swift.Bool
|
|
123
|
+
@objc deinit
|
|
124
|
+
}
|
|
125
|
+
final public class SophiIdentityRegistry : @unchecked Swift.Sendable {
|
|
126
|
+
public static let shared: Module___SophiIdentity.SophiIdentityRegistry
|
|
127
|
+
public init(factory: @escaping @Sendable (Module___SophiIdentity.SophiIdentityConfiguration) throws -> Module___SophiIdentity.SophiIdentityRuntime)
|
|
128
|
+
convenience public init()
|
|
129
|
+
public static let duplicateModuleMessage: Swift.String
|
|
130
|
+
public static var linkedTwice: Swift.Bool {
|
|
131
|
+
get
|
|
132
|
+
}
|
|
133
|
+
final public func runtime(configuration: Module___SophiIdentity.SophiIdentityConfiguration) throws -> Module___SophiIdentity.SophiIdentityRuntime
|
|
134
|
+
@objc deinit
|
|
135
|
+
}
|
|
136
|
+
final public class SophiIdentityRuntime : @unchecked Swift.Sendable {
|
|
137
|
+
final public let configuration: Module___SophiIdentity.SophiIdentityConfiguration
|
|
138
|
+
public init(configuration: Module___SophiIdentity.SophiIdentityConfiguration, persistence: any Module___SophiIdentity.SophiIdentityPersistence, now: @escaping @Sendable () -> Foundation.Date = { Date() }, transport: @escaping @Sendable (Foundation.URLRequest) async throws -> (Foundation.Data, Foundation.HTTPURLResponse) = {
|
|
139
|
+
request in
|
|
140
|
+
try await SophiIdentityHTTP.data(for: request)
|
|
141
|
+
}) throws
|
|
142
|
+
final public var snapshot: Module___SophiIdentity.SophiIdentitySnapshot {
|
|
143
|
+
get
|
|
144
|
+
}
|
|
145
|
+
final public var cachedSession: Module___SophiIdentity.SophiIdentitySession? {
|
|
146
|
+
get
|
|
147
|
+
}
|
|
148
|
+
final public func takeStorageQuarantined() -> Swift.Bool
|
|
149
|
+
final public func configure(usage: Module___SophiIdentity.SophiIdentityUsage, persistent enabled: Swift.Bool?, externalUserID: Swift.String? = nil, metadata: Foundation.Data? = nil) throws
|
|
150
|
+
final public func discardIdleStoredIdentity()
|
|
151
|
+
final public func setAnalyticsConsent(_ granted: Swift.Bool?) throws
|
|
152
|
+
final public func setStoragePermission(_ enabled: Swift.Bool, usage: Module___SophiIdentity.SophiIdentityUsage) throws
|
|
153
|
+
final public func updateIdentity(_ externalUserID: Swift.String?, usage: Module___SophiIdentity.SophiIdentityUsage = .analytics) throws
|
|
154
|
+
final public func logout() throws
|
|
155
|
+
final public func addObserver(_ observer: @escaping @Sendable (Module___SophiIdentity.SophiIdentityChange) -> Swift.Void) -> Foundation.UUID
|
|
156
|
+
final public func removeObserver(_ id: Foundation.UUID)
|
|
157
|
+
final public func withAnalyticsOwner<T>(_ expected: Module___SophiIdentity.SophiIdentitySnapshot, body: () throws -> T) throws -> T
|
|
158
|
+
@discardableResult
|
|
159
|
+
final public func adoptMemorySession(clientID: Swift.String, accessToken: Swift.String, expiresAt: Foundation.Date, externalUserID: Swift.String?, companyCode: Swift.String, layoutID: Swift.String, userName: Swift.String?) throws -> Swift.Bool
|
|
160
|
+
final public func checkGeneration(_ expected: Foundation.UUID) throws
|
|
161
|
+
final public func invalidateToken(_ failedToken: Swift.String)
|
|
162
|
+
final public func currentSession(usage: Module___SophiIdentity.SophiIdentityUsage) async throws -> Module___SophiIdentity.SophiIdentitySession
|
|
163
|
+
@objc deinit
|
|
164
|
+
}
|
|
165
|
+
public enum SophiIdentityHTTP {
|
|
166
|
+
public static func data(for request: Foundation.URLRequest, using session: Foundation.URLSession? = nil) async throws -> (Foundation.Data, Foundation.HTTPURLResponse)
|
|
167
|
+
}
|
|
168
|
+
extension Module___SophiIdentity.SophiIdentityUsage : Swift.Equatable {}
|
|
169
|
+
extension Module___SophiIdentity.SophiIdentityUsage : Swift.Hashable {}
|
|
170
|
+
extension Module___SophiIdentity.SophiIdentityUsage : Swift.RawRepresentable {}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// swift-interface-format-version: 1.0
|
|
2
|
+
// swift-compiler-version: Apple Swift version 6.3.3 effective-5.10 (swiftlang-6.3.3.1.3 clang-2100.1.1.101)
|
|
3
|
+
// swift-module-flags: -target x86_64-apple-ios15.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -O -enable-experimental-feature DebugDescriptionMacro -enable-bare-slash-regex -module-name SophiIdentity -module-alias Module___SophiIdentity=SophiIdentity -module-alias Module____StringProcessing=_StringProcessing -module-alias Module____SwiftConcurrencyShims=_SwiftConcurrencyShims -module-alias Module____Concurrency=_Concurrency -module-alias Module___CoreFoundation=CoreFoundation -module-alias Module___CryptoKit=CryptoKit
|
|
4
|
+
// swift-module-flags-ignorable: -no-verify-emitted-module-interface -formal-cxx-interoperability-mode=off -interface-compiler-version 6.3.3
|
|
5
|
+
import Module___CoreFoundation
|
|
6
|
+
import Module___CryptoKit
|
|
7
|
+
import Foundation
|
|
8
|
+
import Swift
|
|
9
|
+
import Module____Concurrency
|
|
10
|
+
import Module____StringProcessing
|
|
11
|
+
import Module____SwiftConcurrencyShims
|
|
12
|
+
public enum SophiIdentityError : Swift.Error, Swift.Equatable, Swift.Sendable {
|
|
13
|
+
case invalidConfiguration, disabled, staleGeneration, invalidResponse
|
|
14
|
+
case http(Swift.Int)
|
|
15
|
+
case storageUnavailable, mergePending
|
|
16
|
+
public static func == (a: Module___SophiIdentity.SophiIdentityError, b: Module___SophiIdentity.SophiIdentityError) -> Swift.Bool
|
|
17
|
+
}
|
|
18
|
+
public struct SophiIdentityConfiguration : Swift.Sendable {
|
|
19
|
+
public let apiKey: Swift.String
|
|
20
|
+
public let baseURL: Foundation.URL
|
|
21
|
+
public let namespace: Swift.String
|
|
22
|
+
public init(apiKey: Swift.String, baseURL: Foundation.URL) throws
|
|
23
|
+
}
|
|
24
|
+
public struct SophiShopperIdentity : Swift.Codable, Swift.Equatable, Swift.Sendable {
|
|
25
|
+
public var ownerID: Foundation.UUID
|
|
26
|
+
public var clientID: Swift.String?
|
|
27
|
+
public var externalUserID: Swift.String?
|
|
28
|
+
public var pendingMergeSourceID: Swift.String?
|
|
29
|
+
public var aliasOwnerIDs: [Foundation.UUID]?
|
|
30
|
+
public init(ownerID: Foundation.UUID = UUID(), clientID: Swift.String? = nil, externalUserID: Swift.String? = nil, pendingMergeSourceID: Swift.String? = nil, aliasOwnerIDs: [Foundation.UUID]? = nil)
|
|
31
|
+
public var ownerIDs: [Foundation.UUID] {
|
|
32
|
+
get
|
|
33
|
+
}
|
|
34
|
+
public static func == (a: Module___SophiIdentity.SophiShopperIdentity, b: Module___SophiIdentity.SophiShopperIdentity) -> Swift.Bool
|
|
35
|
+
public func encode(to encoder: any Swift.Encoder) throws
|
|
36
|
+
public init(from decoder: any Swift.Decoder) throws
|
|
37
|
+
}
|
|
38
|
+
public struct SophiHeldIdentity : Swift.Codable, Swift.Equatable, Swift.Sendable {
|
|
39
|
+
public var identity: Module___SophiIdentity.SophiShopperIdentity
|
|
40
|
+
public var heldAt: Foundation.TimeInterval
|
|
41
|
+
public init(identity: Module___SophiIdentity.SophiShopperIdentity, heldAt: Foundation.TimeInterval)
|
|
42
|
+
public static func == (a: Module___SophiIdentity.SophiHeldIdentity, b: Module___SophiIdentity.SophiHeldIdentity) -> Swift.Bool
|
|
43
|
+
public func encode(to encoder: any Swift.Encoder) throws
|
|
44
|
+
public init(from decoder: any Swift.Decoder) throws
|
|
45
|
+
}
|
|
46
|
+
public struct SophiStoredIdentity : Swift.Codable, Swift.Equatable, Swift.Sendable {
|
|
47
|
+
public var identity: Module___SophiIdentity.SophiShopperIdentity
|
|
48
|
+
public var held: Module___SophiIdentity.SophiHeldIdentity?
|
|
49
|
+
public var chatStorage: Swift.Bool
|
|
50
|
+
public var analyticsStorage: Swift.Bool
|
|
51
|
+
public var savedAt: Foundation.TimeInterval?
|
|
52
|
+
public init(identity: Module___SophiIdentity.SophiShopperIdentity, held: Module___SophiIdentity.SophiHeldIdentity? = nil, chatStorage: Swift.Bool = false, analyticsStorage: Swift.Bool = false, savedAt: Foundation.TimeInterval? = nil)
|
|
53
|
+
public init(from decoder: any Swift.Decoder) throws
|
|
54
|
+
public func encode(to encoder: any Swift.Encoder) throws
|
|
55
|
+
public static func == (a: Module___SophiIdentity.SophiStoredIdentity, b: Module___SophiIdentity.SophiStoredIdentity) -> Swift.Bool
|
|
56
|
+
}
|
|
57
|
+
public struct SophiIdentitySession : Swift.Sendable, Swift.Equatable {
|
|
58
|
+
public let clientID: Swift.String
|
|
59
|
+
public let accessToken: Swift.String
|
|
60
|
+
public let authSessionID: Swift.String?
|
|
61
|
+
public let expiresAt: Foundation.Date
|
|
62
|
+
public let companyCode: Swift.String
|
|
63
|
+
public let layoutID: Swift.String
|
|
64
|
+
public let userName: Swift.String?
|
|
65
|
+
public let identity: Module___SophiIdentity.SophiShopperIdentity
|
|
66
|
+
public let generation: Foundation.UUID
|
|
67
|
+
public static func == (a: Module___SophiIdentity.SophiIdentitySession, b: Module___SophiIdentity.SophiIdentitySession) -> Swift.Bool
|
|
68
|
+
}
|
|
69
|
+
public struct SophiIdentitySnapshot : Swift.Sendable, Swift.Equatable {
|
|
70
|
+
public let identity: Module___SophiIdentity.SophiShopperIdentity
|
|
71
|
+
public let generation: Foundation.UUID
|
|
72
|
+
public let analyticsGeneration: Foundation.UUID
|
|
73
|
+
public let analyticsAllowed: Swift.Bool
|
|
74
|
+
public let analyticsConfigured: Swift.Bool
|
|
75
|
+
public let ownerIDs: [Foundation.UUID]
|
|
76
|
+
public let heldOwnerIDs: [Foundation.UUID]
|
|
77
|
+
public var heldOwnerID: Foundation.UUID? {
|
|
78
|
+
get
|
|
79
|
+
}
|
|
80
|
+
public let storedIdentityLoaded: Swift.Bool
|
|
81
|
+
public let dormantOwnerIDs: [Foundation.UUID]?
|
|
82
|
+
public let storedIdentityIdle: Swift.Bool
|
|
83
|
+
public static func == (a: Module___SophiIdentity.SophiIdentitySnapshot, b: Module___SophiIdentity.SophiIdentitySnapshot) -> Swift.Bool
|
|
84
|
+
}
|
|
85
|
+
public enum SophiIdentityChange : Swift.Sendable {
|
|
86
|
+
case identity(previous: Module___SophiIdentity.SophiShopperIdentity, current: Module___SophiIdentity.SophiShopperIdentity)
|
|
87
|
+
case consent(Swift.Bool?)
|
|
88
|
+
case held(owner: Foundation.UUID, restored: Swift.Bool)
|
|
89
|
+
case storageFailed
|
|
90
|
+
}
|
|
91
|
+
public enum SophiIdentityUsage : Swift.String, Swift.Sendable {
|
|
92
|
+
case analytics, chat
|
|
93
|
+
public init?(rawValue: Swift.String)
|
|
94
|
+
public typealias RawValue = Swift.String
|
|
95
|
+
public var rawValue: Swift.String {
|
|
96
|
+
get
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
public enum SophiStorageQuarantine {
|
|
100
|
+
public static let retention: Swift.Double
|
|
101
|
+
@discardableResult
|
|
102
|
+
public static func move(_ url: Foundation.URL, now: Foundation.Date) -> Swift.Bool
|
|
103
|
+
public static func sweep(_ url: Foundation.URL, before: Foundation.Date)
|
|
104
|
+
}
|
|
105
|
+
public protocol SophiIdentityPersistence : Swift.Sendable {
|
|
106
|
+
func load() throws -> Module___SophiIdentity.SophiStoredIdentity?
|
|
107
|
+
func save(_ record: Module___SophiIdentity.SophiStoredIdentity) throws
|
|
108
|
+
func clear() throws
|
|
109
|
+
func clearAnalyticsState(keepRecord: Swift.Bool) throws
|
|
110
|
+
func takeQuarantined() -> Swift.Bool
|
|
111
|
+
}
|
|
112
|
+
extension Module___SophiIdentity.SophiIdentityPersistence {
|
|
113
|
+
public func clearAnalyticsState(keepRecord: Swift.Bool) throws
|
|
114
|
+
public func takeQuarantined() -> Swift.Bool
|
|
115
|
+
}
|
|
116
|
+
final public class SophiFileIdentityPersistence : Module___SophiIdentity.SophiIdentityPersistence, @unchecked Swift.Sendable {
|
|
117
|
+
public init(namespace: Swift.String, directory: Foundation.URL? = nil, now: @escaping @Sendable () -> Foundation.Date = { Date() }) throws
|
|
118
|
+
final public func load() throws -> Module___SophiIdentity.SophiStoredIdentity?
|
|
119
|
+
final public func save(_ record: Module___SophiIdentity.SophiStoredIdentity) throws
|
|
120
|
+
final public func clear() throws
|
|
121
|
+
final public func clearAnalyticsState(keepRecord: Swift.Bool) throws
|
|
122
|
+
final public func takeQuarantined() -> Swift.Bool
|
|
123
|
+
@objc deinit
|
|
124
|
+
}
|
|
125
|
+
final public class SophiIdentityRegistry : @unchecked Swift.Sendable {
|
|
126
|
+
public static let shared: Module___SophiIdentity.SophiIdentityRegistry
|
|
127
|
+
public init(factory: @escaping @Sendable (Module___SophiIdentity.SophiIdentityConfiguration) throws -> Module___SophiIdentity.SophiIdentityRuntime)
|
|
128
|
+
convenience public init()
|
|
129
|
+
public static let duplicateModuleMessage: Swift.String
|
|
130
|
+
public static var linkedTwice: Swift.Bool {
|
|
131
|
+
get
|
|
132
|
+
}
|
|
133
|
+
final public func runtime(configuration: Module___SophiIdentity.SophiIdentityConfiguration) throws -> Module___SophiIdentity.SophiIdentityRuntime
|
|
134
|
+
@objc deinit
|
|
135
|
+
}
|
|
136
|
+
final public class SophiIdentityRuntime : @unchecked Swift.Sendable {
|
|
137
|
+
final public let configuration: Module___SophiIdentity.SophiIdentityConfiguration
|
|
138
|
+
public init(configuration: Module___SophiIdentity.SophiIdentityConfiguration, persistence: any Module___SophiIdentity.SophiIdentityPersistence, now: @escaping @Sendable () -> Foundation.Date = { Date() }, transport: @escaping @Sendable (Foundation.URLRequest) async throws -> (Foundation.Data, Foundation.HTTPURLResponse) = {
|
|
139
|
+
request in
|
|
140
|
+
try await SophiIdentityHTTP.data(for: request)
|
|
141
|
+
}) throws
|
|
142
|
+
final public var snapshot: Module___SophiIdentity.SophiIdentitySnapshot {
|
|
143
|
+
get
|
|
144
|
+
}
|
|
145
|
+
final public var cachedSession: Module___SophiIdentity.SophiIdentitySession? {
|
|
146
|
+
get
|
|
147
|
+
}
|
|
148
|
+
final public func takeStorageQuarantined() -> Swift.Bool
|
|
149
|
+
final public func configure(usage: Module___SophiIdentity.SophiIdentityUsage, persistent enabled: Swift.Bool?, externalUserID: Swift.String? = nil, metadata: Foundation.Data? = nil) throws
|
|
150
|
+
final public func discardIdleStoredIdentity()
|
|
151
|
+
final public func setAnalyticsConsent(_ granted: Swift.Bool?) throws
|
|
152
|
+
final public func setStoragePermission(_ enabled: Swift.Bool, usage: Module___SophiIdentity.SophiIdentityUsage) throws
|
|
153
|
+
final public func updateIdentity(_ externalUserID: Swift.String?, usage: Module___SophiIdentity.SophiIdentityUsage = .analytics) throws
|
|
154
|
+
final public func logout() throws
|
|
155
|
+
final public func addObserver(_ observer: @escaping @Sendable (Module___SophiIdentity.SophiIdentityChange) -> Swift.Void) -> Foundation.UUID
|
|
156
|
+
final public func removeObserver(_ id: Foundation.UUID)
|
|
157
|
+
final public func withAnalyticsOwner<T>(_ expected: Module___SophiIdentity.SophiIdentitySnapshot, body: () throws -> T) throws -> T
|
|
158
|
+
@discardableResult
|
|
159
|
+
final public func adoptMemorySession(clientID: Swift.String, accessToken: Swift.String, expiresAt: Foundation.Date, externalUserID: Swift.String?, companyCode: Swift.String, layoutID: Swift.String, userName: Swift.String?) throws -> Swift.Bool
|
|
160
|
+
final public func checkGeneration(_ expected: Foundation.UUID) throws
|
|
161
|
+
final public func invalidateToken(_ failedToken: Swift.String)
|
|
162
|
+
final public func currentSession(usage: Module___SophiIdentity.SophiIdentityUsage) async throws -> Module___SophiIdentity.SophiIdentitySession
|
|
163
|
+
@objc deinit
|
|
164
|
+
}
|
|
165
|
+
public enum SophiIdentityHTTP {
|
|
166
|
+
public static func data(for request: Foundation.URLRequest, using session: Foundation.URLSession? = nil) async throws -> (Foundation.Data, Foundation.HTTPURLResponse)
|
|
167
|
+
}
|
|
168
|
+
extension Module___SophiIdentity.SophiIdentityUsage : Swift.Equatable {}
|
|
169
|
+
extension Module___SophiIdentity.SophiIdentityUsage : Swift.Hashable {}
|
|
170
|
+
extension Module___SophiIdentity.SophiIdentityUsage : Swift.RawRepresentable {}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>NSPrivacyTracking</key>
|
|
6
|
+
<false/>
|
|
7
|
+
<key>NSPrivacyAccessedAPITypes</key>
|
|
8
|
+
<array>
|
|
9
|
+
<dict>
|
|
10
|
+
<key>NSPrivacyAccessedAPIType</key>
|
|
11
|
+
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
|
|
12
|
+
<key>NSPrivacyAccessedAPITypeReasons</key>
|
|
13
|
+
<array>
|
|
14
|
+
<string>CA92.1</string>
|
|
15
|
+
</array>
|
|
16
|
+
</dict>
|
|
17
|
+
</array>
|
|
18
|
+
<key>NSPrivacyCollectedDataTypes</key>
|
|
19
|
+
<array>
|
|
20
|
+
<dict>
|
|
21
|
+
<key>NSPrivacyCollectedDataType</key>
|
|
22
|
+
<string>NSPrivacyCollectedDataTypeUserID</string>
|
|
23
|
+
<key>NSPrivacyCollectedDataTypeLinked</key>
|
|
24
|
+
<true/>
|
|
25
|
+
<key>NSPrivacyCollectedDataTypeTracking</key>
|
|
26
|
+
<false/>
|
|
27
|
+
<key>NSPrivacyCollectedDataTypePurposes</key>
|
|
28
|
+
<array>
|
|
29
|
+
<string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
|
|
30
|
+
<string>NSPrivacyCollectedDataTypePurposeProductPersonalization</string>
|
|
31
|
+
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
|
|
32
|
+
</array>
|
|
33
|
+
</dict>
|
|
34
|
+
<dict>
|
|
35
|
+
<key>NSPrivacyCollectedDataType</key>
|
|
36
|
+
<string>NSPrivacyCollectedDataTypeName</string>
|
|
37
|
+
<key>NSPrivacyCollectedDataTypeLinked</key>
|
|
38
|
+
<true/>
|
|
39
|
+
<key>NSPrivacyCollectedDataTypeTracking</key>
|
|
40
|
+
<false/>
|
|
41
|
+
<key>NSPrivacyCollectedDataTypePurposes</key>
|
|
42
|
+
<array>
|
|
43
|
+
<string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
|
|
44
|
+
<string>NSPrivacyCollectedDataTypePurposeProductPersonalization</string>
|
|
45
|
+
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
|
|
46
|
+
</array>
|
|
47
|
+
</dict>
|
|
48
|
+
</array>
|
|
49
|
+
</dict>
|
|
50
|
+
</plist>
|
|
Binary file
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#import <React/RCTEventEmitter.h>
|
|
2
|
+
#import <React/RCTBridgeModule.h>
|
|
3
|
+
#import "SophiEventSDK_ReactNative-Swift.h"
|
|
4
|
+
|
|
5
|
+
@interface SophiEventsModule : RCTEventEmitter <RCTBridgeModule, SophiEventsModuleEmitter>
|
|
6
|
+
@end
|
|
7
|
+
|
|
8
|
+
@implementation SophiEventsModule {
|
|
9
|
+
SophiEventsModuleImpl *_impl;
|
|
10
|
+
BOOL _listening;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
RCT_EXPORT_MODULE()
|
|
14
|
+
|
|
15
|
+
+ (BOOL)requiresMainQueueSetup { return NO; }
|
|
16
|
+
|
|
17
|
+
- (instancetype)init {
|
|
18
|
+
if ((self = [super init])) {
|
|
19
|
+
_impl = [SophiEventsModuleImpl new];
|
|
20
|
+
_impl.eventEmitter = self;
|
|
21
|
+
}
|
|
22
|
+
return self;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
- (NSArray<NSString *> *)supportedEvents { return @[@"SophiEventDiagnostic"]; }
|
|
26
|
+
- (void)startObserving { _listening = YES; }
|
|
27
|
+
- (void)stopObserving { _listening = NO; }
|
|
28
|
+
- (void)emitDiagnostic:(NSDictionary *)body {
|
|
29
|
+
if (_listening) [self sendEventWithName:@"SophiEventDiagnostic" body:body];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
RCT_EXPORT_METHOD(configure:(NSDictionary *)options resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
33
|
+
[_impl configure:options resolve:resolve reject:reject];
|
|
34
|
+
}
|
|
35
|
+
RCT_EXPORT_METHOD(setAnalyticsEnabled:(BOOL)enabled resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
36
|
+
[_impl setAnalyticsEnabled:enabled resolve:resolve reject:reject];
|
|
37
|
+
}
|
|
38
|
+
RCT_EXPORT_METHOD(updateUser:(NSString *)externalUserId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
39
|
+
[_impl updateUser:externalUserId resolve:resolve reject:reject];
|
|
40
|
+
}
|
|
41
|
+
RCT_EXPORT_METHOD(logout:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
42
|
+
[_impl logout:resolve reject:reject];
|
|
43
|
+
}
|
|
44
|
+
RCT_EXPORT_METHOD(track:(NSString *)eventJson resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
45
|
+
[_impl track:eventJson resolve:resolve reject:reject];
|
|
46
|
+
}
|
|
47
|
+
RCT_EXPORT_METHOD(flush:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
48
|
+
[_impl flush:resolve reject:reject];
|
|
49
|
+
}
|
|
50
|
+
RCT_EXPORT_METHOD(pendingCount:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
51
|
+
[_impl pendingCount:resolve reject:reject];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@end
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import SophiEventSDK
|
|
3
|
+
|
|
4
|
+
/// Receives diagnostics for the JavaScript event emitter (implemented by SophiEventsModule.m).
|
|
5
|
+
@objc public protocol SophiEventsModuleEmitter: AnyObject {
|
|
6
|
+
func emitDiagnostic(_ body: [String: Any])
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/// Forwards JavaScript calls to `SophiEventSDK.shared`. Events arrive as the wire JSON produced
|
|
10
|
+
/// by the JavaScript layer and are decoded into the SDK's own `SophiEvent` type, so validation and
|
|
11
|
+
/// delivery stay inside the native SDK.
|
|
12
|
+
@objc(SophiEventsModuleImpl) public final class SophiEventsModuleImpl: NSObject {
|
|
13
|
+
@objc public weak var eventEmitter: SophiEventsModuleEmitter?
|
|
14
|
+
|
|
15
|
+
public typealias Resolve = (Any?) -> Void
|
|
16
|
+
public typealias Reject = (String?, String?, Error?) -> Void
|
|
17
|
+
|
|
18
|
+
@objc public func configure(
|
|
19
|
+
_ options: NSDictionary, resolve: @escaping Resolve, reject: @escaping Reject
|
|
20
|
+
) {
|
|
21
|
+
let apiKey = options["apiKey"] as? String ?? ""
|
|
22
|
+
let consent = options["analyticsEnabled"] as? Bool
|
|
23
|
+
let user = options["externalUserId"] as? String
|
|
24
|
+
let limitsInput = options["queueLimits"] as? [String: Any] ?? [:]
|
|
25
|
+
let defaults = SophiQueueLimits()
|
|
26
|
+
let limits = SophiQueueLimits(
|
|
27
|
+
maxAge: (limitsInput["maxAgeMs"] as? NSNumber).map { $0.doubleValue / 1000 } ?? defaults.maxAge,
|
|
28
|
+
maxEvents: (limitsInput["maxEvents"] as? NSNumber)?.intValue ?? defaults.maxEvents,
|
|
29
|
+
maxBytes: (limitsInput["maxBytes"] as? NSNumber)?.intValue ?? defaults.maxBytes,
|
|
30
|
+
maxEventBytes: (limitsInput["maxEventBytes"] as? NSNumber)?.intValue ?? defaults.maxEventBytes)
|
|
31
|
+
let configuration: SophiEventConfiguration
|
|
32
|
+
if let origin = options["baseUrl"] as? String {
|
|
33
|
+
guard let url = URL(string: origin) else {
|
|
34
|
+
return Self.fail(SophiEventError.invalidConfiguration, reject)
|
|
35
|
+
}
|
|
36
|
+
configuration = SophiEventConfiguration(
|
|
37
|
+
apiKey: apiKey, baseURL: url, analyticsEnabled: consent, queueLimits: limits,
|
|
38
|
+
externalUserID: user)
|
|
39
|
+
} else {
|
|
40
|
+
configuration = SophiEventConfiguration(
|
|
41
|
+
apiKey: apiKey, analyticsEnabled: consent, queueLimits: limits, externalUserID: user)
|
|
42
|
+
}
|
|
43
|
+
let diagnostic: @Sendable (SophiEventDiagnostic) -> Void = { [weak self] value in
|
|
44
|
+
let body: [String: Any] = [
|
|
45
|
+
"code": value.code,
|
|
46
|
+
"eventId": value.eventID.map { $0.uuidString.lowercased() as Any } ?? NSNull(),
|
|
47
|
+
"count": value.count,
|
|
48
|
+
]
|
|
49
|
+
DispatchQueue.main.async { self?.eventEmitter?.emitDiagnostic(body) }
|
|
50
|
+
}
|
|
51
|
+
Task {
|
|
52
|
+
do {
|
|
53
|
+
try await SophiEventSDK.shared.configure(configuration, onDiagnostic: diagnostic)
|
|
54
|
+
resolve(nil)
|
|
55
|
+
} catch { Self.fail(error, reject) }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@objc public func setAnalyticsEnabled(
|
|
60
|
+
_ enabled: Bool, resolve: @escaping Resolve, reject: @escaping Reject
|
|
61
|
+
) {
|
|
62
|
+
run(resolve, reject) {
|
|
63
|
+
try await SophiEventSDK.shared.setAnalyticsEnabled(enabled)
|
|
64
|
+
return nil
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@objc public func updateUser(
|
|
69
|
+
_ externalUserID: String?, resolve: @escaping Resolve, reject: @escaping Reject
|
|
70
|
+
) {
|
|
71
|
+
run(resolve, reject) {
|
|
72
|
+
try await SophiEventSDK.shared.updateUser(externalUserID)
|
|
73
|
+
return nil
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@objc public func logout(_ resolve: @escaping Resolve, reject: @escaping Reject) {
|
|
78
|
+
run(resolve, reject) {
|
|
79
|
+
try await SophiEventSDK.shared.logout()
|
|
80
|
+
return nil
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@objc public func track(
|
|
85
|
+
_ eventJSON: String, resolve: @escaping Resolve, reject: @escaping Reject
|
|
86
|
+
) {
|
|
87
|
+
let event: SophiEvent
|
|
88
|
+
do {
|
|
89
|
+
event = try JSONDecoder().decode(SophiEvent.self, from: Data(eventJSON.utf8))
|
|
90
|
+
} catch { return Self.fail(error, reject) }
|
|
91
|
+
run(resolve, reject) {
|
|
92
|
+
let receipt = try await SophiEventSDK.shared.track(event)
|
|
93
|
+
return [
|
|
94
|
+
"id": receipt.id.map { $0.uuidString.lowercased() as Any } ?? NSNull(),
|
|
95
|
+
"status": receipt.status.rawValue,
|
|
96
|
+
] as [String: Any]
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@objc public func flush(_ resolve: @escaping Resolve, reject: @escaping Reject) {
|
|
101
|
+
run(resolve, reject) {
|
|
102
|
+
let result = try await SophiEventSDK.shared.flush()
|
|
103
|
+
return [
|
|
104
|
+
"delivered": result.delivered, "retried": result.retried, "discarded": result.discarded,
|
|
105
|
+
"pending": result.pending, "pausedReason": result.pausedReason.map { $0 as Any } ?? NSNull(),
|
|
106
|
+
] as [String: Any]
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@objc public func pendingCount(_ resolve: @escaping Resolve, reject: @escaping Reject) {
|
|
111
|
+
run(resolve, reject) { try await SophiEventSDK.shared.pendingCount() }
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private func run(
|
|
115
|
+
_ resolve: @escaping Resolve, _ reject: @escaping Reject,
|
|
116
|
+
_ operation: @escaping () async throws -> Any?
|
|
117
|
+
) {
|
|
118
|
+
Task {
|
|
119
|
+
do { resolve(try await operation()) } catch { Self.fail(error, reject) }
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// MARK: - Errors: the same codes as the Android bridge
|
|
124
|
+
|
|
125
|
+
static func fail(_ error: Error, _ reject: Reject) {
|
|
126
|
+
let (code, message, info) = describe(error)
|
|
127
|
+
reject(code, message, NSError(domain: "SophiEvents", code: 0, userInfo: info))
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
static func describe(_ error: Error) -> (String, String, [String: Any]) {
|
|
131
|
+
if let invalid = error as? EventValidationError {
|
|
132
|
+
return ("validation", "Invalid event fields: " + invalid.fields.joined(separator: ", "),
|
|
133
|
+
["fields": invalid.fields])
|
|
134
|
+
}
|
|
135
|
+
if let decoding = error as? DecodingError {
|
|
136
|
+
let field = path(of: decoding)
|
|
137
|
+
return ("validation", "Invalid event fields: \(field)", ["fields": [field]])
|
|
138
|
+
}
|
|
139
|
+
guard let sdk = error as? SophiEventError else {
|
|
140
|
+
return ("internal_error", "The native event SDK failed", [:])
|
|
141
|
+
}
|
|
142
|
+
switch sdk {
|
|
143
|
+
case .notConfigured: return ("not_configured", "Configure the event SDK first", [:])
|
|
144
|
+
case .invalidConfiguration: return ("invalid_configuration", "The event configuration is invalid", [:])
|
|
145
|
+
case .queueFull: return ("queue_full", "The event queue is full", [:])
|
|
146
|
+
case .eventTooLarge: return ("event_too_large", "The event is too large", [:])
|
|
147
|
+
case .storageUnavailable: return ("storage_unavailable", "Event storage is unavailable", [:])
|
|
148
|
+
case .identityChanged: return ("identity_changed", "The shopper, consent or configuration changed", [:])
|
|
149
|
+
case .backendUnsupported: return ("backend_unsupported", "The backend does not support mobile events", [:])
|
|
150
|
+
case .http(let status): return ("http", "The request failed with status \(status)", ["status": status])
|
|
151
|
+
case .invalidReceipt: return ("invalid_receipt", "The server answer was not usable", [:])
|
|
152
|
+
case .network: return ("network", "The server could not be reached", [:])
|
|
153
|
+
case .analyticsDisabled: return ("disabled", "Analytics is not granted", [:])
|
|
154
|
+
case .mergePending: return ("merge_pending", "The sign-in merge is not confirmed yet", [:])
|
|
155
|
+
case .duplicateIdentityModule:
|
|
156
|
+
return ("duplicate_identity_module", sdk.localizedDescription, [:])
|
|
157
|
+
@unknown default: return ("internal_error", "The native event SDK failed", [:])
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/// The wire path of a decoding failure, e.g. `basket.line_items[0].quantity`.
|
|
162
|
+
private static func path(of error: DecodingError) -> String {
|
|
163
|
+
var keys: [CodingKey]
|
|
164
|
+
switch error {
|
|
165
|
+
case .keyNotFound(let key, let context): keys = context.codingPath + [key]
|
|
166
|
+
case .typeMismatch(_, let context), .valueNotFound(_, let context), .dataCorrupted(let context):
|
|
167
|
+
keys = context.codingPath
|
|
168
|
+
@unknown default: keys = []
|
|
169
|
+
}
|
|
170
|
+
var text = ""
|
|
171
|
+
for key in keys {
|
|
172
|
+
if let index = key.intValue { text += "[\(index)]" } else {
|
|
173
|
+
text += (text.isEmpty ? "" : ".") + key.stringValue
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return text.isEmpty ? "event" : text
|
|
177
|
+
}
|
|
178
|
+
}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SophiEventError = exports.SophiEvents = void 0;
|
|
7
|
+
var SophiEvents_1 = require("./src/SophiEvents");
|
|
8
|
+
Object.defineProperty(exports, "SophiEvents", { enumerable: true, get: function () { return __importDefault(SophiEvents_1).default; } });
|
|
9
|
+
var client_1 = require("./src/client");
|
|
10
|
+
Object.defineProperty(exports, "SophiEventError", { enumerable: true, get: function () { return client_1.SophiEventError; } });
|