From a9ef2bdcfd300be476f25fd79c4870d68daad0f9 Mon Sep 17 00:00:00 2001 From: Shahroz Khan Date: Tue, 7 May 2024 12:41:50 +0500 Subject: [PATCH] fix: segment compatibility (#2) --- AnalyticsSwiftCIO.podspec | 7 ++++--- .../ObjCExample/TestDestination.swift | 2 +- .../project.pbxproj | 16 ++++++++-------- .../SegmentUIKitExample/AppDelegate.swift | 2 +- Examples/other_plugins/CellularCarrier.swift | 2 +- Examples/other_plugins/ConsentTracking.swift | 2 +- Examples/other_plugins/IDFACollection.swift | 2 +- .../other_plugins/NotificationTracking.swift | 2 +- Examples/other_plugins/UIKitScreenTracking.swift | 2 +- Examples/tasks/CustomScreenTracking.swift | 2 +- Examples/tasks/MultiInstance.swift | 2 +- Package.swift | 14 +++++++------- Sources/Segment/ObjC/ObjCAnalytics.swift | 2 +- Sources/Segment/ObjC/ObjCConfiguration.swift | 2 +- Sources/Segment/ObjC/ObjCEvents.swift | 14 +++++++------- Sources/Segment/ObjC/ObjCPlugin.swift | 8 ++++---- Sources/Segment/Plugins/SegmentDestination.swift | 4 ++-- Sources/Segment/Utilities/Storage/Storage.swift | 2 +- Tests/Segment-Tests/Support/TestUtilities.swift | 2 +- 19 files changed, 45 insertions(+), 44 deletions(-) diff --git a/AnalyticsSwiftCIO.podspec b/AnalyticsSwiftCIO.podspec index 60d94cac..85ce39ff 100644 --- a/AnalyticsSwiftCIO.podspec +++ b/AnalyticsSwiftCIO.podspec @@ -1,20 +1,21 @@ Pod::Spec.new do |s| s.name = "AnalyticsSwiftCIO" - s.version = "1.5.11+cio.1" + s.version = "1.5.12+cio.1" s.license = { :type => 'MIT', :file => './LICENSE' } s.summary = "Customer.io Data Pipelines analytics client for Swift app (iOS/tvOS/watchOS/macOS/Linux)." s.homepage = "https://github.com/customerio/cdp-analytics-swift" s.authors = "Customer.io" # Make sure the tag is the same as what SPM customers are using. - s.source = { :git => 'https://github.com/customerio/cdp-analytics-swift.git', :tag => '1.5.11+cio.1' } + # update branch to version + s.source = { :git => 'https://github.com/customerio/cdp-analytics-swift.git', :tag => '1.5.12+cio.1' } s.ios.deployment_target = "13.0" s.requires_arc = true s.swift_version = '5.3' s.cocoapods_version = '>= 1.11.0' - s.module_name = "Segment" + s.module_name = "CioAnalytics" s.source_files = "Sources/**/*.swift" s.resource_bundles = { diff --git a/Examples/apps/ObjCExample/ObjCExample/TestDestination.swift b/Examples/apps/ObjCExample/ObjCExample/TestDestination.swift index 23846958..cf977b90 100644 --- a/Examples/apps/ObjCExample/ObjCExample/TestDestination.swift +++ b/Examples/apps/ObjCExample/ObjCExample/TestDestination.swift @@ -8,7 +8,7 @@ import Foundation import Segment -@objc(SEGTestDestination) +@objc(CIOTestDestination) public class ObjCTestDestination: NSObject, ObjCPlugin, ObjCPluginShim { public func instance() -> EventPlugin { return TestDestination() } } diff --git a/Examples/apps/SegmentUIKitExample/SegmentUIKitExample.xcodeproj/project.pbxproj b/Examples/apps/SegmentUIKitExample/SegmentUIKitExample.xcodeproj/project.pbxproj index 84ebe5fd..9251c620 100644 --- a/Examples/apps/SegmentUIKitExample/SegmentUIKitExample.xcodeproj/project.pbxproj +++ b/Examples/apps/SegmentUIKitExample/SegmentUIKitExample.xcodeproj/project.pbxproj @@ -3,10 +3,11 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ + 30678B7F2BE982DC000C3E2D /* CioAnalytics in Frameworks */ = {isa = PBXBuildFile; productRef = 30678B7E2BE982DC000C3E2D /* CioAnalytics */; }; 46022785261F860100A9E913 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46022784261F860100A9E913 /* AppDelegate.swift */; }; 46022787261F860100A9E913 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46022786261F860100A9E913 /* SceneDelegate.swift */; }; 46022789261F860100A9E913 /* Tab1ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46022788261F860100A9E913 /* Tab1ViewController.swift */; }; @@ -19,7 +20,6 @@ 46E3834E26582D9E00BA2502 /* IDFACollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46E3834A26582D9E00BA2502 /* IDFACollection.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 */; }; 46E73DA326F531320021042C /* NotificationTracking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46E73DA226F531320021042C /* NotificationTracking.swift */; }; /* End PBXBuildFile section */ @@ -48,7 +48,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 46E383572658307800BA2502 /* Segment in Frameworks */, + 30678B7F2BE982DC000C3E2D /* CioAnalytics in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -138,7 +138,7 @@ ); name = SegmentUIKitExample; packageProductDependencies = ( - 46E383562658307800BA2502 /* Segment */, + 30678B7E2BE982DC000C3E2D /* CioAnalytics */, ); productName = SegmentUIKitExample; productReference = 46022781261F860100A9E913 /* SegmentUIKitExample.app */; @@ -439,13 +439,13 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ - 460227A0261F887C00A9E913 /* Segment */ = { + 30678B7E2BE982DC000C3E2D /* CioAnalytics */ = { isa = XCSwiftPackageProductDependency; - package = 4602279B261F884600A9E913 /* XCRemoteSwiftPackageReference "analytics-swift" */; - productName = Segment; + productName = CioAnalytics; }; - 46E383562658307800BA2502 /* Segment */ = { + 460227A0261F887C00A9E913 /* Segment */ = { isa = XCSwiftPackageProductDependency; + package = 4602279B261F884600A9E913 /* XCRemoteSwiftPackageReference "analytics-swift" */; productName = Segment; }; /* End XCSwiftPackageProductDependency section */ diff --git a/Examples/apps/SegmentUIKitExample/SegmentUIKitExample/AppDelegate.swift b/Examples/apps/SegmentUIKitExample/SegmentUIKitExample/AppDelegate.swift index 31ad90a8..2d545261 100644 --- a/Examples/apps/SegmentUIKitExample/SegmentUIKitExample/AppDelegate.swift +++ b/Examples/apps/SegmentUIKitExample/SegmentUIKitExample/AppDelegate.swift @@ -6,7 +6,7 @@ // import UIKit -import Segment +import CioAnalytics @main class AppDelegate: UIResponder, UIApplicationDelegate { diff --git a/Examples/other_plugins/CellularCarrier.swift b/Examples/other_plugins/CellularCarrier.swift index 6dffc067..f13b8ac4 100644 --- a/Examples/other_plugins/CellularCarrier.swift +++ b/Examples/other_plugins/CellularCarrier.swift @@ -35,7 +35,7 @@ #if os(iOS) && !targetEnvironment(macCatalyst) import Foundation -import Segment +import CioAnalytics import CoreTelephony /** diff --git a/Examples/other_plugins/ConsentTracking.swift b/Examples/other_plugins/ConsentTracking.swift index 18a05c08..1084c23c 100644 --- a/Examples/other_plugins/ConsentTracking.swift +++ b/Examples/other_plugins/ConsentTracking.swift @@ -33,7 +33,7 @@ // SOFTWARE. import Foundation -import Segment +import CioAnalytics import UIKit /** diff --git a/Examples/other_plugins/IDFACollection.swift b/Examples/other_plugins/IDFACollection.swift index a2fe52e6..1a656bdf 100644 --- a/Examples/other_plugins/IDFACollection.swift +++ b/Examples/other_plugins/IDFACollection.swift @@ -34,7 +34,7 @@ import Foundation import UIKit -import Segment +import CioAnalytics import AdSupport import AppTrackingTransparency diff --git a/Examples/other_plugins/NotificationTracking.swift b/Examples/other_plugins/NotificationTracking.swift index 8346b1ec..13efb5db 100644 --- a/Examples/other_plugins/NotificationTracking.swift +++ b/Examples/other_plugins/NotificationTracking.swift @@ -36,7 +36,7 @@ #if !os(Linux) && !os(macOS) import Foundation -import Segment +import CioAnalytics class NotificationTracking: Plugin { var type: PluginType = .utility diff --git a/Examples/other_plugins/UIKitScreenTracking.swift b/Examples/other_plugins/UIKitScreenTracking.swift index 387b0223..548e2d3a 100644 --- a/Examples/other_plugins/UIKitScreenTracking.swift +++ b/Examples/other_plugins/UIKitScreenTracking.swift @@ -33,7 +33,7 @@ // SOFTWARE. import Foundation -import Segment +import CioAnalytics import UIKit /** diff --git a/Examples/tasks/CustomScreenTracking.swift b/Examples/tasks/CustomScreenTracking.swift index cd80d162..37fc787c 100644 --- a/Examples/tasks/CustomScreenTracking.swift +++ b/Examples/tasks/CustomScreenTracking.swift @@ -31,7 +31,7 @@ import Foundation import UIKit -import Segment +import CioAnalytics class QueryAlertController: UIAlertController { // we already conform to UIKitScreenTrackable so override diff --git a/Examples/tasks/MultiInstance.swift b/Examples/tasks/MultiInstance.swift index e762ccb7..7e6aed66 100644 --- a/Examples/tasks/MultiInstance.swift +++ b/Examples/tasks/MultiInstance.swift @@ -30,7 +30,7 @@ // SOFTWARE. import Foundation -import Segment +import CioAnalytics /** An example of implementing multiple Analytics instances in a single application. diff --git a/Package.swift b/Package.swift index 2c200be8..7c2ede23 100644 --- a/Package.swift +++ b/Package.swift @@ -4,7 +4,7 @@ import PackageDescription let package = Package( - name: "Segment", + name: "CioAnalytics", platforms: [ .macOS("10.15"), .iOS("13.0"), @@ -15,8 +15,8 @@ let package = Package( products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( - name: "Segment", - targets: ["Segment"]), + name: "CioAnalytics", + targets: ["CioAnalytics"]), ], dependencies: [ // Dependencies declare other packages that this package depends on. @@ -28,14 +28,14 @@ let package = Package( // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages this package depends on. .target( - name: "Segment", + name: "CioAnalytics", dependencies: [ .product(name: "Sovran", package: "sovran-swift"), .product(name: "JSONSafeEncoding", package: "jsonsafeencoding-swift") ], - resources: [.process("Resources")]), + resources: [.process("Segment/Resources")]), .testTarget( - name: "Segment-Tests", - dependencies: ["Segment"]), + name: "CioAnalytics-Tests", + dependencies: ["CioAnalytics"]), ] ) diff --git a/Sources/Segment/ObjC/ObjCAnalytics.swift b/Sources/Segment/ObjC/ObjCAnalytics.swift index d5883ec0..d2c80322 100644 --- a/Sources/Segment/ObjC/ObjCAnalytics.swift +++ b/Sources/Segment/ObjC/ObjCAnalytics.swift @@ -12,7 +12,7 @@ import JSONSafeEncoding // MARK: - ObjC Compatibility -@objc(SEGAnalytics) +@objc(CIOAnalytics) public class ObjCAnalytics: NSObject { /// The underlying Analytics object we're working with public let analytics: Analytics diff --git a/Sources/Segment/ObjC/ObjCConfiguration.swift b/Sources/Segment/ObjC/ObjCConfiguration.swift index 87117991..f80a0bea 100644 --- a/Sources/Segment/ObjC/ObjCConfiguration.swift +++ b/Sources/Segment/ObjC/ObjCConfiguration.swift @@ -10,7 +10,7 @@ import Foundation import JSONSafeEncoding -@objc(SEGConfiguration) +@objc(CIOConfiguration) public class ObjCConfiguration: NSObject { internal var configuration: Configuration diff --git a/Sources/Segment/ObjC/ObjCEvents.swift b/Sources/Segment/ObjC/ObjCEvents.swift index 019a7b6a..5d8081cd 100644 --- a/Sources/Segment/ObjC/ObjCEvents.swift +++ b/Sources/Segment/ObjC/ObjCEvents.swift @@ -14,7 +14,7 @@ internal protocol ObjCEvent { var _event: EventType { get set } } -@objc(SEGDestinationMetadata) +@objc(CIODestinationMetadata) public class ObjCDestinationMetadata: NSObject { internal var _metadata: DestinationMetadata @@ -43,7 +43,7 @@ public class ObjCDestinationMetadata: NSObject { } } -@objc(SEGRawEvent) +@objc(CIORawEvent) public protocol ObjCRawEvent: NSObjectProtocol { var type: String? { get } var messageId: String? { get } @@ -80,7 +80,7 @@ internal func objcEventFromEvent(_ event: T?) -> ObjCRawEvent? { } } -@objc(SEGTrackEvent) +@objc(CIOTrackEvent) public class ObjCTrackEvent: NSObject, ObjCEvent, ObjCRawEvent { internal var _event: TrackEvent @@ -139,7 +139,7 @@ public class ObjCTrackEvent: NSObject, ObjCEvent, ObjCRawEvent { } } -@objc(SEGIdentifyEvent) +@objc(CIOIdentifyEvent) public class ObjCIdentifyEvent: NSObject, ObjCEvent, ObjCRawEvent { internal var _event: IdentifyEvent @@ -192,7 +192,7 @@ public class ObjCIdentifyEvent: NSObject, ObjCEvent, ObjCRawEvent { } } -@objc(SEGScreenEvent) +@objc(CIOScreenEvent) public class ObjCScreenEvent: NSObject, ObjCEvent, ObjCRawEvent { internal var _event: ScreenEvent @@ -257,7 +257,7 @@ public class ObjCScreenEvent: NSObject, ObjCEvent, ObjCRawEvent { } } -@objc(SEGGroupEvent) +@objc(CIOGroupEvent) public class ObjCGroupEvent: NSObject, ObjCEvent, ObjCRawEvent { internal var _event: GroupEvent @@ -316,7 +316,7 @@ public class ObjCGroupEvent: NSObject, ObjCEvent, ObjCRawEvent { } } -@objc(SEGAliasEvent) +@objc(CIOAliasEvent) public class ObjCAliasEvent: NSObject, ObjCEvent, ObjCRawEvent { internal var _event: AliasEvent diff --git a/Sources/Segment/ObjC/ObjCPlugin.swift b/Sources/Segment/ObjC/ObjCPlugin.swift index 1396d670..5687b0bb 100644 --- a/Sources/Segment/ObjC/ObjCPlugin.swift +++ b/Sources/Segment/ObjC/ObjCPlugin.swift @@ -10,7 +10,7 @@ import Foundation -@objc(SEGPlugin) +@objc(CIOPlugin) public protocol ObjCPlugin {} public protocol ObjCPluginShim { @@ -20,14 +20,14 @@ public protocol ObjCPluginShim { // NOTE: Destination plugins need something similar to the following to work/ /* -@objc(SEGMixpanelDestination) +@objc(CIOMixpanelDestination) public class ObjCSegmentMixpanel: NSObject, ObjCPlugin, ObjCPluginShim { public func instance() -> EventPlugin { return MixpanelDestination() } } */ -@objc(SEGEventPlugin) +@objc(CIOEventPlugin) public class ObjCEventPlugin: NSObject, EventPlugin, ObjCPlugin { public var type: PluginType = .enrichment public weak var analytics: Analytics? = nil @@ -48,7 +48,7 @@ public class ObjCEventPlugin: NSObject, EventPlugin, ObjCPlugin { } } -@objc(SEGBlockPlugin) +@objc(CIOBlockPlugin) public class ObjCBlockPlugin: ObjCEventPlugin { let block: (ObjCRawEvent?) -> ObjCRawEvent? diff --git a/Sources/Segment/Plugins/SegmentDestination.swift b/Sources/Segment/Plugins/SegmentDestination.swift index 50c00f69..688f08dd 100644 --- a/Sources/Segment/Plugins/SegmentDestination.swift +++ b/Sources/Segment/Plugins/SegmentDestination.swift @@ -190,7 +190,7 @@ extension SegmentDestination { // we don't want to retry events in a given batch when a 400 // response for malformed JSON is returned - case .failure(Segment.HTTPClientErrors.statusCode(code: 400)): + case .failure(CioAnalytics.HTTPClientErrors.statusCode(code: 400)): storage.remove(data: [url]) cleanupUploads() default: @@ -261,7 +261,7 @@ extension SegmentDestination { // we don't want to retry events in a given batch when a 400 // response for malformed JSON is returned - case .failure(Segment.HTTPClientErrors.statusCode(code: 400)): + case .failure(CioAnalytics.HTTPClientErrors.statusCode(code: 400)): storage.remove(data: removable) cleanupUploads() default: diff --git a/Sources/Segment/Utilities/Storage/Storage.swift b/Sources/Segment/Utilities/Storage/Storage.swift index 12fd4d1d..a286d14d 100644 --- a/Sources/Segment/Utilities/Storage/Storage.swift +++ b/Sources/Segment/Utilities/Storage/Storage.swift @@ -24,7 +24,7 @@ internal class Storage: Subscriber { self.storageMode = storageMode self.userDefaults = UserDefaults(suiteName: "com.segment.storage.\(writeKey)")! - var storageURL = Segment.eventStorageDirectory(writeKey: writeKey) + var storageURL = CioAnalytics.eventStorageDirectory(writeKey: writeKey) let asyncAppend = (operatingMode == .asynchronous) switch storageMode { case .diskAtURL(let url): diff --git a/Tests/Segment-Tests/Support/TestUtilities.swift b/Tests/Segment-Tests/Support/TestUtilities.swift index 124daa64..b7bbab47 100644 --- a/Tests/Segment-Tests/Support/TestUtilities.swift +++ b/Tests/Segment-Tests/Support/TestUtilities.swift @@ -68,7 +68,7 @@ class ZiggyPlugin: EventPlugin { #if !os(Linux) -@objc(SEGMyDestination) +@objc(CIOMyDestination) public class ObjCMyDestination: NSObject, ObjCPlugin, ObjCPluginShim { public func instance() -> EventPlugin { return MyDestination() } }