Skip to content

Commit

Permalink
Merge pull request #4 from segment-integrations/MichaelGHSeg/update_a…
Browse files Browse the repository at this point in the history
…djust_501

Updating Adjust SDK to 5.0.1
  • Loading branch information
MichaelGHSeg authored Dec 10, 2024
2 parents 4946476 + 001dae1 commit 87c5f38
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
8 changes: 4 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let package = Package(
name: "SegmentAdjust",
platforms: [
.iOS("13.0"),
.tvOS("11.0"),
.tvOS("12.0"),
.watchOS("7.1")
],
products: [
Expand All @@ -25,16 +25,16 @@ let package = Package(
from: "1.4.1"
),
.package(
name: "Adjust",
name: "AdjustSdk",
url: "https://github.com/adjust/ios_sdk.git",
from: "4.38.0")
from: "5.0.1")
],
targets: [
// 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: "SegmentAdjust",
dependencies: ["Segment", "Adjust"])
dependencies: ["Segment", "AdjustSdk"])

// TESTS ARE HANDLED VIA THE EXAMPLE APP.
]
Expand Down
26 changes: 10 additions & 16 deletions Sources/SegmentAdjust/AdjustDestination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import Foundation
import Segment
import Adjust
import AdjustSdk

@objc(SEGAdjustDestination)
open class ObjCSegmentAdjust: NSObject, ObjCPlugin, ObjCPluginShim {
Expand Down Expand Up @@ -61,37 +61,29 @@ open class AdjustDestination: NSObject, DestinationPlugin {
}

let adjustConfig = ADJConfig(appToken: settings.appToken, environment: environment)

if let bufferingEnabled = settings.setEventBufferingEnabled {
adjustConfig?.eventBufferingEnabled = bufferingEnabled
}


if let _ = settings.trackAttributionData {
adjustConfig?.delegate = self
}

if let useDelay = settings.setDelay, useDelay == true, let delayTime = settings.delayTime {
adjustConfig?.delayStart = delayTime
}

Adjust.appDidLaunch(adjustConfig)
Adjust.initSdk(adjustConfig)
}

public func identify(event: IdentifyEvent) -> IdentifyEvent? {
if let userId = event.userId, userId.count > 0 {
Adjust.addSessionPartnerParameter("user_id", value: userId)
Adjust.addGlobalPartnerParameter("user_id", forKey: userId)
}

if let anonId = event.anonymousId, anonId.count > 0 {
Adjust.addSessionPartnerParameter("anonymous_id", value: anonId)
Adjust.addGlobalPartnerParameter("anonymous_id", forKey: anonId)
}

return event
}

public func track(event: TrackEvent) -> TrackEvent? {
if let anonId = event.anonymousId, anonId.count > 0 {
Adjust.addSessionPartnerParameter("anonymous_id", value: anonId)
Adjust.addGlobalPartnerParameter("anonymous_id", forKey: anonId)
}

if let token = mappedCustomEventToken(eventName: event.event) {
Expand Down Expand Up @@ -123,12 +115,12 @@ open class AdjustDestination: NSObject, DestinationPlugin {
}

public func reset() {
Adjust.resetSessionPartnerParameters()
Adjust.removeGlobalPartnerParameters()
}
}
extension AdjustDestination: RemoteNotifications{
public func registeredForRemoteNotifications(deviceToken: Data) {
Adjust.setDeviceToken(deviceToken)
Adjust.setPushToken(deviceToken)
}
}
// Example of versioning for your plugin
Expand All @@ -141,8 +133,10 @@ extension AdjustDestination: VersionedPlugin {
private struct AdjustSettings: Codable {
let appToken: String
let setEnvironmentProduction: Bool?
@available(*, deprecated)
let setEventBufferingEnabled: Bool?
let trackAttributionData: Bool?
@available(*, deprecated)
let setDelay: Bool?
let customEvents: JSON?
let delayTime: Double?
Expand Down

0 comments on commit 87c5f38

Please sign in to comment.