react-native-hubspot-wrapper 0.5.0 → 0.5.1
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/ios/HubspotWrapperImpl.swift +16 -18
- package/package.json +1 -1
|
@@ -81,10 +81,8 @@ public class HubspotWrapperImpl: NSObject {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
/// Clear the SDK's in-memory identity/property state and synchronously wait for
|
|
85
|
-
///
|
|
86
|
-
/// workers, etc.) to be removed from the shared `WKWebsiteDataStore` before invoking
|
|
87
|
-
/// `completion`.
|
|
84
|
+
/// Clear the SDK's in-memory identity/property state and synchronously wait for HubSpot's
|
|
85
|
+
/// visitor-identity cookies to be removed before invoking `completion`.
|
|
88
86
|
///
|
|
89
87
|
/// Why we do our own clearing instead of relying on the SDK:
|
|
90
88
|
///
|
|
@@ -95,29 +93,29 @@ public class HubspotWrapperImpl: NSObject {
|
|
|
95
93
|
/// races the still-in-flight cookie deletion, so the next chat session re-uses
|
|
96
94
|
/// the previous visitor identity.
|
|
97
95
|
///
|
|
98
|
-
///
|
|
99
|
-
///
|
|
100
|
-
///
|
|
101
|
-
/// `sessionStorage` / `IndexedDB`. Cookie-only clearing leaves the draft visible
|
|
102
|
-
/// on the next open, which is exactly the bug we kept seeing.
|
|
103
|
-
///
|
|
104
|
-
/// We therefore remove all shared WebKit website data during logout. This is intentionally
|
|
105
|
-
/// broader than HubSpot-only cleanup: fetching individual `WKWebsiteDataRecord`s crashed
|
|
106
|
-
/// in production inside WebKit's `_fetchDataRecords...allDataStores` path.
|
|
96
|
+
/// Broader WebKit website-data cleanup is intentionally avoided here. Both
|
|
97
|
+
/// `dataRecords(ofTypes:)` and `removeData(ofTypes:modifiedSince:)` have crashed in
|
|
98
|
+
/// production inside WebKit's `allDataStores()` path on iOS 18 simulators.
|
|
107
99
|
public func clearUserData(_ completion: @escaping () -> Void) {
|
|
108
100
|
Task { @MainActor in
|
|
109
101
|
HubspotManager.shared.clearUserData()
|
|
110
|
-
await Self.
|
|
102
|
+
await Self.deleteHubspotIdentityCookies()
|
|
111
103
|
completion()
|
|
112
104
|
}
|
|
113
105
|
}
|
|
114
106
|
|
|
115
|
-
private static func
|
|
116
|
-
let
|
|
117
|
-
let
|
|
118
|
-
|
|
107
|
+
private static func deleteHubspotIdentityCookies() async {
|
|
108
|
+
let cookieStore = WKWebsiteDataStore.default().httpCookieStore
|
|
109
|
+
let matchingCookies = await cookieStore.allCookies().filter {
|
|
110
|
+
hubspotIdentityCookieNames.contains($0.name)
|
|
111
|
+
}
|
|
112
|
+
for cookie in matchingCookies {
|
|
113
|
+
await cookieStore.deleteCookie(cookie)
|
|
114
|
+
}
|
|
119
115
|
}
|
|
120
116
|
|
|
117
|
+
private static let hubspotIdentityCookieNames = Set(["hubspotutk", "messagesUtk"])
|
|
118
|
+
|
|
121
119
|
private static func topViewController(
|
|
122
120
|
base: UIViewController? = UIApplication.shared.connectedScenes
|
|
123
121
|
.compactMap { $0 as? UIWindowScene }
|