From d9b1074abf1c61ee9aae6b1605a92f65e3379ad7 Mon Sep 17 00:00:00 2001 From: Brandon Sneed Date: Fri, 10 Mar 2023 10:11:03 -0800 Subject: [PATCH 1/6] Tighten up Codable compile time conformance --- Sources/Segment/Events.swift | 8 ++++---- Sources/Segment/ObjC/ObjCAnalytics.swift | 8 ++++---- Sources/Segment/Utilities/Utils.swift | 4 ++++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Sources/Segment/Events.swift b/Sources/Segment/Events.swift index ecff0e85..520ceb8a 100644 --- a/Sources/Segment/Events.swift +++ b/Sources/Segment/Events.swift @@ -142,7 +142,7 @@ extension Analytics { /// generate the UUID and Apple's policies on IDs, see /// https://segment.io/libraries/ios#ids /// - properties: A dictionary of traits you know about the user. Things like: email, name, plan, etc. - public func track(name: String, properties: [String: Any]? = nil) { + public func track(name: String, properties: [String: Codable]? = nil) { var props: JSON? = nil if let properties = properties { do { @@ -165,7 +165,7 @@ extension Analytics { /// https://segment.io/libraries/ios#ids /// - traits: A dictionary of traits you know about the user. Things like: email, name, plan, etc. /// In the case when user logs out, make sure to call ``reset()`` to clear user's identity info. - public func identify(userId: String, traits: [String: Any]? = nil) { + public func identify(userId: String, traits: [String: Codable]? = nil) { do { if let traits = traits { let traits = try JSON(traits as Any) @@ -187,7 +187,7 @@ extension Analytics { /// - screenTitle: The title of the screen being tracked. /// - category: A category to the type of screen if it applies. /// - properties: Any extra metadata associated with the screen. e.g. method of access, size, etc. - public func screen(title: String, category: String? = nil, properties: [String: Any]? = nil) { + public func screen(title: String, category: String? = nil, properties: [String: Codable]? = nil) { var event = ScreenEvent(title: title, category: category, properties: nil) if let properties = properties { do { @@ -204,7 +204,7 @@ extension Analytics { /// - Parameters: /// - groupId: A unique identifier for the group identification in your system. /// - traits: Traits of the group you may be interested in such as email, phone or name. - public func group(groupId: String, traits: [String: Any]?) { + public func group(groupId: String, traits: [String: Codable]?) { var event = GroupEvent(groupId: groupId) if let traits = traits { do { diff --git a/Sources/Segment/ObjC/ObjCAnalytics.swift b/Sources/Segment/ObjC/ObjCAnalytics.swift index ce1750cc..70ffdca5 100644 --- a/Sources/Segment/ObjC/ObjCAnalytics.swift +++ b/Sources/Segment/ObjC/ObjCAnalytics.swift @@ -41,7 +41,7 @@ extension ObjCAnalytics { @objc(track:properties:) public func track(name: String, properties: [String: Any]?) { - analytics.track(name: name, properties: properties) + analytics.track(name: name, properties: properties as? [String: Codable]) } /// Associate a user with their unique ID and record traits about them. @@ -67,7 +67,7 @@ extension ObjCAnalytics { if let userId = userId { // at first glance this looks like recursion. It's actually calling // into the swift version of this call where userId is NOT optional. - analytics.identify(userId: userId, traits: traits) + analytics.identify(userId: userId, traits: codable(traits)) } else if let traits = try? JSON(traits as Any) { analytics.store.dispatch(action: UserInfo.SetTraitsAction(traits: traits)) let userInfo: UserInfo? = analytics.store.currentState() @@ -100,7 +100,7 @@ extension ObjCAnalytics { /// - properties: Any extra metadata associated with the screen. e.g. method of access, size, etc. @objc(screen:category:properties:) public func screen(title: String, category: String?, properties: [String: Any]?) { - analytics.screen(title: title, category: category, properties: properties) + analytics.screen(title: title, category: category, properties: codable(properties)) } /// Associate a user with a group such as a company, organization, project, etc. @@ -117,7 +117,7 @@ extension ObjCAnalytics { /// - traits: Traits of the group you may be interested in such as email, phone or name. @objc(group:traits:) public func group(groupId: String, traits: [String: Any]?) { - analytics.group(groupId: groupId, traits: traits) + analytics.group(groupId: groupId, traits: codable(traits)) } @objc(alias:) diff --git a/Sources/Segment/Utilities/Utils.swift b/Sources/Segment/Utilities/Utils.swift index c4c254fa..7cd3bbab 100644 --- a/Sources/Segment/Utilities/Utils.swift +++ b/Sources/Segment/Utilities/Utils.swift @@ -57,3 +57,7 @@ extension Optional: Flattenable { } } } + +internal func codable(_ dict: [String: Any]?) -> [String: Codable]? { + return dict as? [String: Codable] +} From 7596a05ddccc04e72894e3fb31d68df94da3827a Mon Sep 17 00:00:00 2001 From: Brandon Sneed Date: Fri, 10 Mar 2023 10:35:19 -0800 Subject: [PATCH 2/6] Fixed ios/tvos typecheck issue --- .../Segment/Plugins/Platforms/iOS/iOSLifecycleEvents.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/Segment/Plugins/Platforms/iOS/iOSLifecycleEvents.swift b/Sources/Segment/Plugins/Platforms/iOS/iOSLifecycleEvents.swift index e2a5a3c8..d1181d89 100644 --- a/Sources/Segment/Plugins/Platforms/iOS/iOSLifecycleEvents.swift +++ b/Sources/Segment/Plugins/Platforms/iOS/iOSLifecycleEvents.swift @@ -54,12 +54,15 @@ class iOSLifecycleEvents: PlatformPlugin, iOSLifecycle { ]) } + let sourceApp: String? = launchOptions?[UIApplication.LaunchOptionsKey.sourceApplication] as? String ?? "" + let url: String? = launchOptions?[UIApplication.LaunchOptionsKey.url] as? String ?? "" + analytics?.track(name: "Application Opened", properties: [ "from_background": false, "version": currentVersion ?? "", "build": currentBuild ?? "", - "referring_application": launchOptions?[UIApplication.LaunchOptionsKey.sourceApplication] ?? "", - "url": launchOptions?[UIApplication.LaunchOptionsKey.url] ?? "" + "referring_application": sourceApp, + "url": url ]) UserDefaults.standard.setValue(currentVersion, forKey: Self.versionKey) From 744d76d8b9d87868261783cac2276a99ca6ff79c Mon Sep 17 00:00:00 2001 From: Brandon Sneed Date: Fri, 10 Mar 2023 10:40:37 -0800 Subject: [PATCH 3/6] Removed console logger --- Examples/other_plugins/ConsoleLogger.swift | 68 ---------------------- 1 file changed, 68 deletions(-) delete mode 100644 Examples/other_plugins/ConsoleLogger.swift diff --git a/Examples/other_plugins/ConsoleLogger.swift b/Examples/other_plugins/ConsoleLogger.swift deleted file mode 100644 index de4699fe..00000000 --- a/Examples/other_plugins/ConsoleLogger.swift +++ /dev/null @@ -1,68 +0,0 @@ -// -// ConsoleLogger.swift -// SegmentUIKitExample -// -// Created by Brandon Sneed on 4/9/21. -// - -// NOTE: You can see this plugin in use in the SwiftUIKitExample application. -// -// This plugin is NOT SUPPORTED by Segment. It is here merely as an example, -// and for your convenience should you find it useful. - -// MIT License -// -// Copyright (c) 2021 Segment -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -import Foundation -import Segment - -/** - A generic console logging plugin. The type `.after` signifies that this plugin will - run at the end of the event timeline, at which point it will print event data to the Xcode console window. - */ -class ConsoleLogger: Plugin { - let type = PluginType.after - let name: String - weak var analytics: Analytics? = nil - - var identifier: String? = nil - - required init(name: String) { - self.name = name - } - - // we want to log every event, so lets override `execute`. - func execute(event: T?) -> T? { - if let json = event?.prettyPrint() { - analytics?.log(message: "event received on instance: \(name)") - analytics?.log(message: "\(json)\n") - } - return event - } - - // we also want to know when settings are retrieved or changed. - func update(settings: Settings) { - let json = settings.prettyPrint() - analytics?.log(message: "settings updated on instance: \(name)\nPayload: \(json)") - } - -} From 7e2e4411202d130f2c0db5507eff3cc62138f715 Mon Sep 17 00:00:00 2001 From: Brandon Sneed Date: Fri, 10 Mar 2023 10:45:53 -0800 Subject: [PATCH 4/6] Example project fixes --- .../apps/BasicExample/BasicExample.xcodeproj/project.pbxproj | 4 ---- .../DestinationsExample.xcodeproj/project.pbxproj | 4 ---- .../SegmentUIKitExample.xcodeproj/project.pbxproj | 4 ---- 3 files changed, 12 deletions(-) diff --git a/Examples/apps/BasicExample/BasicExample.xcodeproj/project.pbxproj b/Examples/apps/BasicExample/BasicExample.xcodeproj/project.pbxproj index 95687aa1..b0d77e27 100644 --- a/Examples/apps/BasicExample/BasicExample.xcodeproj/project.pbxproj +++ b/Examples/apps/BasicExample/BasicExample.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 465879BD268A511600180335 /* ConsoleLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 465879BC268A511600180335 /* ConsoleLogger.swift */; }; 469F7AF9265C25890038E773 /* EventData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 469F7AF8265C25890038E773 /* EventData.swift */; }; 46E38365265837EA00BA2502 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46E38364265837EA00BA2502 /* AppDelegate.swift */; }; 46E38367265837EA00BA2502 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46E38366265837EA00BA2502 /* SceneDelegate.swift */; }; @@ -20,7 +19,6 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 465879BC268A511600180335 /* ConsoleLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ConsoleLogger.swift; path = ../../../other_plugins/ConsoleLogger.swift; sourceTree = ""; }; 4663C72A267A8D6B00ADDD1A /* BasicExample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = BasicExample.entitlements; sourceTree = ""; }; 469F7AF8265C25890038E773 /* EventData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventData.swift; sourceTree = ""; }; 46E38361265837EA00BA2502 /* BasicExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BasicExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -68,7 +66,6 @@ children = ( 4663C72A267A8D6B00ADDD1A /* BasicExample.entitlements */, 46E38364265837EA00BA2502 /* AppDelegate.swift */, - 465879BC268A511600180335 /* ConsoleLogger.swift */, 46E38366265837EA00BA2502 /* SceneDelegate.swift */, 469F7AF8265C25890038E773 /* EventData.swift */, 46E38368265837EA00BA2502 /* ViewController.swift */, @@ -167,7 +164,6 @@ 46E38369265837EA00BA2502 /* ViewController.swift in Sources */, 46E38365265837EA00BA2502 /* AppDelegate.swift in Sources */, 469F7AF9265C25890038E773 /* EventData.swift in Sources */, - 465879BD268A511600180335 /* ConsoleLogger.swift in Sources */, 46E38367265837EA00BA2502 /* SceneDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Examples/apps/DestinationsExample/DestinationsExample.xcodeproj/project.pbxproj b/Examples/apps/DestinationsExample/DestinationsExample.xcodeproj/project.pbxproj index 72d7c023..c4f19227 100644 --- a/Examples/apps/DestinationsExample/DestinationsExample.xcodeproj/project.pbxproj +++ b/Examples/apps/DestinationsExample/DestinationsExample.xcodeproj/project.pbxproj @@ -11,7 +11,6 @@ 46871695270E16080028B595 /* UIKitScreenTracking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4687168F270E16080028B595 /* UIKitScreenTracking.swift */; }; 46871696270E16080028B595 /* ConsentTracking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46871690270E16080028B595 /* ConsentTracking.swift */; }; 46871697270E16080028B595 /* IDFACollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46871691270E16080028B595 /* IDFACollection.swift */; }; - 46871698270E16080028B595 /* ConsoleLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46871692270E16080028B595 /* ConsoleLogger.swift */; }; 468DE06527D28C6500F2D94B /* SegmentAmplitude in Frameworks */ = {isa = PBXBuildFile; productRef = 468DE06427D28C6500F2D94B /* SegmentAmplitude */; }; 468DE06827D28C7E00F2D94B /* SegmentAppsFlyer in Frameworks */ = {isa = PBXBuildFile; productRef = 468DE06727D28C7E00F2D94B /* SegmentAppsFlyer */; }; 468DE06B27D28CB200F2D94B /* SegmentFacebook in Frameworks */ = {isa = PBXBuildFile; productRef = 468DE06A27D28CB200F2D94B /* SegmentFacebook */; }; @@ -34,7 +33,6 @@ 4687168F270E16080028B595 /* UIKitScreenTracking.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIKitScreenTracking.swift; sourceTree = ""; }; 46871690270E16080028B595 /* ConsentTracking.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConsentTracking.swift; sourceTree = ""; }; 46871691270E16080028B595 /* IDFACollection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IDFACollection.swift; sourceTree = ""; }; - 46871692270E16080028B595 /* ConsoleLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConsoleLogger.swift; sourceTree = ""; }; 469EC8CF266066130068F9E3 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; 469EC8E1266828AF0068F9E3 /* DestinationsExample-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "DestinationsExample-Bridging-Header.h"; sourceTree = ""; }; 469F7B04266011690038E773 /* DestinationsExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DestinationsExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -75,7 +73,6 @@ 4687168F270E16080028B595 /* UIKitScreenTracking.swift */, 46871690270E16080028B595 /* ConsentTracking.swift */, 46871691270E16080028B595 /* IDFACollection.swift */, - 46871692270E16080028B595 /* ConsoleLogger.swift */, ); name = other_plugins; path = ../../../other_plugins; @@ -220,7 +217,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 46871698270E16080028B595 /* ConsoleLogger.swift in Sources */, 469F7B0C266011690038E773 /* ViewController.swift in Sources */, 469F7B08266011690038E773 /* AppDelegate.swift in Sources */, 46871694270E16080028B595 /* NotificationTracking.swift in Sources */, diff --git a/Examples/apps/SegmentUIKitExample/SegmentUIKitExample.xcodeproj/project.pbxproj b/Examples/apps/SegmentUIKitExample/SegmentUIKitExample.xcodeproj/project.pbxproj index c297dc48..84ebe5fd 100644 --- a/Examples/apps/SegmentUIKitExample/SegmentUIKitExample.xcodeproj/project.pbxproj +++ b/Examples/apps/SegmentUIKitExample/SegmentUIKitExample.xcodeproj/project.pbxproj @@ -17,7 +17,6 @@ 46E3834C26582D9E00BA2502 /* UIKitScreenTracking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46E3834826582D9E00BA2502 /* UIKitScreenTracking.swift */; }; 46E3834D26582D9E00BA2502 /* ConsentTracking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46E3834926582D9E00BA2502 /* ConsentTracking.swift */; }; 46E3834E26582D9E00BA2502 /* IDFACollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46E3834A26582D9E00BA2502 /* IDFACollection.swift */; }; - 46E3834F26582D9E00BA2502 /* ConsoleLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46E3834B26582D9E00BA2502 /* ConsoleLogger.swift */; }; 46E3835326582DA400BA2502 /* CustomScreenTracking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46E3835126582DA400BA2502 /* CustomScreenTracking.swift */; }; 46E3835426582DA400BA2502 /* MultiInstance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46E3835226582DA400BA2502 /* MultiInstance.swift */; }; 46E383572658307800BA2502 /* Segment in Frameworks */ = {isa = PBXBuildFile; productRef = 46E383562658307800BA2502 /* Segment */; }; @@ -39,7 +38,6 @@ 46E3834826582D9E00BA2502 /* UIKitScreenTracking.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIKitScreenTracking.swift; sourceTree = ""; }; 46E3834926582D9E00BA2502 /* ConsentTracking.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConsentTracking.swift; sourceTree = ""; }; 46E3834A26582D9E00BA2502 /* IDFACollection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IDFACollection.swift; sourceTree = ""; }; - 46E3834B26582D9E00BA2502 /* ConsoleLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConsoleLogger.swift; sourceTree = ""; }; 46E3835126582DA400BA2502 /* CustomScreenTracking.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomScreenTracking.swift; sourceTree = ""; }; 46E3835226582DA400BA2502 /* MultiInstance.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MultiInstance.swift; sourceTree = ""; }; 46E73DA226F531320021042C /* NotificationTracking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationTracking.swift; sourceTree = ""; }; @@ -100,7 +98,6 @@ 46E73DA226F531320021042C /* NotificationTracking.swift */, 46E3834926582D9E00BA2502 /* ConsentTracking.swift */, 46E3834A26582D9E00BA2502 /* IDFACollection.swift */, - 46E3834B26582D9E00BA2502 /* ConsoleLogger.swift */, ); name = other_plugins; path = ../../other_plugins; @@ -200,7 +197,6 @@ buildActionMask = 2147483647; files = ( 46E3835326582DA400BA2502 /* CustomScreenTracking.swift in Sources */, - 46E3834F26582D9E00BA2502 /* ConsoleLogger.swift in Sources */, 46022789261F860100A9E913 /* Tab1ViewController.swift in Sources */, 46022785261F860100A9E913 /* AppDelegate.swift in Sources */, 46E3834C26582D9E00BA2502 /* UIKitScreenTracking.swift in Sources */, From ff949c5047a10b65778695c4991e175cf29bf8cb Mon Sep 17 00:00:00 2001 From: Brandon Sneed Date: Fri, 10 Mar 2023 10:52:13 -0800 Subject: [PATCH 5/6] more project fixes --- Examples/apps/BasicExample/BasicExample/AppDelegate.swift | 1 - .../SegmentSwiftUIExample/ContentView.swift | 1 - .../SegmentUIKitExample/AppDelegate.swift | 2 -- Examples/other_plugins/NotificationTracking.swift | 6 +++--- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Examples/apps/BasicExample/BasicExample/AppDelegate.swift b/Examples/apps/BasicExample/BasicExample/AppDelegate.swift index 86599f93..ce56765d 100644 --- a/Examples/apps/BasicExample/BasicExample/AppDelegate.swift +++ b/Examples/apps/BasicExample/BasicExample/AppDelegate.swift @@ -21,7 +21,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { .flushInterval(10) analytics = Analytics(configuration: configuration) - analytics?.add(plugin: ConsoleLogger(name: "consoleLogger")) return true } diff --git a/Examples/apps/SegmentSwiftUIExample/SegmentSwiftUIExample/ContentView.swift b/Examples/apps/SegmentSwiftUIExample/SegmentSwiftUIExample/ContentView.swift index 771b9e0f..5944496b 100644 --- a/Examples/apps/SegmentSwiftUIExample/SegmentSwiftUIExample/ContentView.swift +++ b/Examples/apps/SegmentSwiftUIExample/SegmentSwiftUIExample/ContentView.swift @@ -26,7 +26,6 @@ struct ContentView: View { HStack { Button(action: { Analytics.main.group(groupId: "12345-Group") - Analytics.main.log(message: "Started group") }, label: { Text("Group") }).padding(6) diff --git a/Examples/apps/SegmentUIKitExample/SegmentUIKitExample/AppDelegate.swift b/Examples/apps/SegmentUIKitExample/SegmentUIKitExample/AppDelegate.swift index 8786a92a..31ad90a8 100644 --- a/Examples/apps/SegmentUIKitExample/SegmentUIKitExample/AppDelegate.swift +++ b/Examples/apps/SegmentUIKitExample/SegmentUIKitExample/AppDelegate.swift @@ -13,7 +13,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // add console logging plugins to our multiple instances - Analytics.main.add(plugin: ConsoleLogger(name: "main")) Analytics.main.add(plugin: ConsentTracking()) Analytics.main.add(plugin: IDFACollection()) Analytics.main.add(plugin: UIKitScreenTracking()) @@ -23,7 +22,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { Analytics.main.add(plugin: CellularCarrier()) #endif - Analytics.support.add(plugin: ConsoleLogger(name: "support")) Analytics.support.add(plugin: ConsentTracking()) Analytics.support.track(name: "test event") diff --git a/Examples/other_plugins/NotificationTracking.swift b/Examples/other_plugins/NotificationTracking.swift index 471158ac..3385b4ed 100644 --- a/Examples/other_plugins/NotificationTracking.swift +++ b/Examples/other_plugins/NotificationTracking.swift @@ -42,7 +42,7 @@ class NotificationTracking: Plugin { var type: PluginType = .utility weak var analytics: Analytics? - func trackNotification(_ properties: [String: Any], fromLaunch launch: Bool) { + func trackNotification(_ properties: [String: Codable], fromLaunch launch: Bool) { if launch { analytics?.track(name: "Push Notification Tapped", properties: properties) } else { @@ -55,7 +55,7 @@ class NotificationTracking: Plugin { // determination if a push notification caused the app to open. extension NotificationTracking: RemoteNotifications { func receivedRemoteNotification(userInfo: [AnyHashable: Any]) { - if let notification = userInfo as? [String: Any] { + if let notification = userInfo as? [String: Codable] { trackNotification(notification, fromLaunch: false) } } @@ -88,7 +88,7 @@ import UIKit extension NotificationTracking: iOSLifecycle { func application(_ application: UIApplication?, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) { - if let notification = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any] { + if let notification = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Codable] { trackNotification(notification, fromLaunch: true) } } From a54311a559b206e36f3c7a255e000474e9ce5506 Mon Sep 17 00:00:00 2001 From: Brandon Sneed Date: Fri, 10 Mar 2023 11:03:41 -0800 Subject: [PATCH 6/6] Remove dest example build --- .github/workflows/swift.yml | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 9d2c2120..ec64922a 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -117,20 +117,4 @@ jobs: run: | cd Examples/apps/SegmentUIKitExample xcodebuild -workspace "SegmentUIKitExample.xcworkspace" -scheme "SegmentUIKitExample" -destination 'platform=macOS,variant=Mac Catalyst' - - - build_and_test_dest_examples: - needs: cancel_previous - runs-on: macos-11 - steps: - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: latest-stable - - uses: actions/checkout@v2 - - uses: webfactory/ssh-agent@v0.5.3 - with: - ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }} - - name: build for ios simulator - run: | - cd Examples/apps/DestinationsExample - xcodebuild -workspace "DestinationsExample.xcworkspace" -scheme "DestinationsExample" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11,OS=14.0' + \ No newline at end of file