Skip to content

Commit

Permalink
fix: segment compatibility (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shahroz16 committed May 7, 2024
1 parent 2398277 commit a9ef2bd
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 44 deletions.
7 changes: 4 additions & 3 deletions AnalyticsSwiftCIO.podspec
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation
import Segment

@objc(SEGTestDestination)
@objc(CIOTestDestination)
public class ObjCTestDestination: NSObject, ObjCPlugin, ObjCPluginShim {
public func instance() -> EventPlugin { return TestDestination() }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand All @@ -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 */

Expand Down Expand Up @@ -48,7 +48,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
46E383572658307800BA2502 /* Segment in Frameworks */,
30678B7F2BE982DC000C3E2D /* CioAnalytics in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -138,7 +138,7 @@
);
name = SegmentUIKitExample;
packageProductDependencies = (
46E383562658307800BA2502 /* Segment */,
30678B7E2BE982DC000C3E2D /* CioAnalytics */,
);
productName = SegmentUIKitExample;
productReference = 46022781261F860100A9E913 /* SegmentUIKitExample.app */;
Expand Down Expand Up @@ -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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

import UIKit
import Segment
import CioAnalytics

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
Expand Down
2 changes: 1 addition & 1 deletion Examples/other_plugins/CellularCarrier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#if os(iOS) && !targetEnvironment(macCatalyst)

import Foundation
import Segment
import CioAnalytics
import CoreTelephony

/**
Expand Down
2 changes: 1 addition & 1 deletion Examples/other_plugins/ConsentTracking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// SOFTWARE.

import Foundation
import Segment
import CioAnalytics
import UIKit

/**
Expand Down
2 changes: 1 addition & 1 deletion Examples/other_plugins/IDFACollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

import Foundation
import UIKit
import Segment
import CioAnalytics
import AdSupport
import AppTrackingTransparency

Expand Down
2 changes: 1 addition & 1 deletion Examples/other_plugins/NotificationTracking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#if !os(Linux) && !os(macOS)

import Foundation
import Segment
import CioAnalytics

class NotificationTracking: Plugin {
var type: PluginType = .utility
Expand Down
2 changes: 1 addition & 1 deletion Examples/other_plugins/UIKitScreenTracking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// SOFTWARE.

import Foundation
import Segment
import CioAnalytics
import UIKit

/**
Expand Down
2 changes: 1 addition & 1 deletion Examples/tasks/CustomScreenTracking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

import Foundation
import UIKit
import Segment
import CioAnalytics

class QueryAlertController: UIAlertController {
// we already conform to UIKitScreenTrackable so override
Expand Down
2 changes: 1 addition & 1 deletion Examples/tasks/MultiInstance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// SOFTWARE.

import Foundation
import Segment
import CioAnalytics

/**
An example of implementing multiple Analytics instances in a single application.
Expand Down
14 changes: 7 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import PackageDescription

let package = Package(
name: "Segment",
name: "CioAnalytics",
platforms: [
.macOS("10.15"),
.iOS("13.0"),
Expand All @@ -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.
Expand All @@ -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"]),
]
)
2 changes: 1 addition & 1 deletion Sources/Segment/ObjC/ObjCAnalytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Segment/ObjC/ObjCConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import Foundation
import JSONSafeEncoding

@objc(SEGConfiguration)
@objc(CIOConfiguration)
public class ObjCConfiguration: NSObject {
internal var configuration: Configuration

Expand Down
14 changes: 7 additions & 7 deletions Sources/Segment/ObjC/ObjCEvents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal protocol ObjCEvent {
var _event: EventType { get set }
}

@objc(SEGDestinationMetadata)
@objc(CIODestinationMetadata)
public class ObjCDestinationMetadata: NSObject {
internal var _metadata: DestinationMetadata

Expand Down Expand Up @@ -43,7 +43,7 @@ public class ObjCDestinationMetadata: NSObject {
}
}

@objc(SEGRawEvent)
@objc(CIORawEvent)
public protocol ObjCRawEvent: NSObjectProtocol {
var type: String? { get }
var messageId: String? { get }
Expand Down Expand Up @@ -80,7 +80,7 @@ internal func objcEventFromEvent<T: RawEvent>(_ event: T?) -> ObjCRawEvent? {
}
}

@objc(SEGTrackEvent)
@objc(CIOTrackEvent)
public class ObjCTrackEvent: NSObject, ObjCEvent, ObjCRawEvent {
internal var _event: TrackEvent

Expand Down Expand Up @@ -139,7 +139,7 @@ public class ObjCTrackEvent: NSObject, ObjCEvent, ObjCRawEvent {
}
}

@objc(SEGIdentifyEvent)
@objc(CIOIdentifyEvent)
public class ObjCIdentifyEvent: NSObject, ObjCEvent, ObjCRawEvent {
internal var _event: IdentifyEvent

Expand Down Expand Up @@ -192,7 +192,7 @@ public class ObjCIdentifyEvent: NSObject, ObjCEvent, ObjCRawEvent {
}
}

@objc(SEGScreenEvent)
@objc(CIOScreenEvent)
public class ObjCScreenEvent: NSObject, ObjCEvent, ObjCRawEvent {
internal var _event: ScreenEvent

Expand Down Expand Up @@ -257,7 +257,7 @@ public class ObjCScreenEvent: NSObject, ObjCEvent, ObjCRawEvent {
}
}

@objc(SEGGroupEvent)
@objc(CIOGroupEvent)
public class ObjCGroupEvent: NSObject, ObjCEvent, ObjCRawEvent {
internal var _event: GroupEvent

Expand Down Expand Up @@ -316,7 +316,7 @@ public class ObjCGroupEvent: NSObject, ObjCEvent, ObjCRawEvent {
}
}

@objc(SEGAliasEvent)
@objc(CIOAliasEvent)
public class ObjCAliasEvent: NSObject, ObjCEvent, ObjCRawEvent {
internal var _event: AliasEvent

Expand Down
8 changes: 4 additions & 4 deletions Sources/Segment/ObjC/ObjCPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import Foundation

@objc(SEGPlugin)
@objc(CIOPlugin)
public protocol ObjCPlugin {}

public protocol ObjCPluginShim {
Expand All @@ -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
Expand All @@ -48,7 +48,7 @@ public class ObjCEventPlugin: NSObject, EventPlugin, ObjCPlugin {
}
}

@objc(SEGBlockPlugin)
@objc(CIOBlockPlugin)
public class ObjCBlockPlugin: ObjCEventPlugin {
let block: (ObjCRawEvent?) -> ObjCRawEvent?

Expand Down
4 changes: 2 additions & 2 deletions Sources/Segment/Plugins/SegmentDestination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Sources/Segment/Utilities/Storage/Storage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion Tests/Segment-Tests/Support/TestUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
}
Expand Down

0 comments on commit a9ef2bd

Please sign in to comment.