Skip to content

Commit 78d3442

Browse files
bsneedBrandon Sneed
andauthored
Fixes + Misses corrections (#17)
* Removed segmentexample scheme * Connected up flush/reset such that all plugins can use it. * Fixed version number messup. * Added remote notification and reset support to Adjust plugin. Co-authored-by: Brandon Sneed <[email protected]>
1 parent ba409d3 commit 78d3442

File tree

7 files changed

+29
-93
lines changed

7 files changed

+29
-93
lines changed

Examples/destination_plugins/AdjustDestination.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ internal struct AdjustSettings: Codable {
5050
}
5151

5252
@objc
53-
public class AdjustDestination: NSObject, DestinationPlugin {
53+
public class AdjustDestination: NSObject, DestinationPlugin, RemoteNotifications {
5454
public let timeline: Timeline = Timeline()
5555
public let type: PluginType = .destination
5656
public let name: String
@@ -145,6 +145,16 @@ public class AdjustDestination: NSObject, DestinationPlugin {
145145

146146
return event
147147
}
148+
149+
public func reset() {
150+
guard started == true else { return }
151+
Adjust.resetSessionPartnerParameters()
152+
}
153+
154+
public func registeredForRemoteNotifications(deviceToken: Data) {
155+
guard started == true else { return }
156+
Adjust.setDeviceToken(deviceToken)
157+
}
148158
}
149159

150160
// MARK: - Adjust Delegate conformance

Segment.xcodeproj/xcshareddata/xcschemes/SegmentExample.xcscheme

Lines changed: 0 additions & 78 deletions
This file was deleted.

Sources/Segment/Analytics.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,20 @@ extension Analytics {
8585
}
8686

8787
public func flush() {
88-
flushCurrentQueue()
88+
apply { plugin in
89+
if let p = plugin as? EventPlugin {
90+
p.flush()
91+
}
92+
}
8993
}
9094

9195
public func reset() {
9296
store.dispatch(action: UserInfo.ResetAction())
97+
apply { plugin in
98+
if let p = plugin as? EventPlugin {
99+
p.reset()
100+
}
101+
}
93102
}
94103

95104
public func settings() -> Settings? {

Sources/Segment/Plugins.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public protocol EventPlugin: Plugin {
4141
func group(event: GroupEvent) -> GroupEvent?
4242
func alias(event: AliasEvent) -> AliasEvent?
4343
func screen(event: ScreenEvent) -> ScreenEvent?
44+
func reset()
45+
func flush()
4446
}
4547

4648
public protocol DestinationPlugin: EventPlugin {

Sources/Segment/Plugins/SegmentDestination.swift

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public class SegmentDestination: DestinationPlugin {
9797
}
9898
}
9999

100-
internal func flush() {
100+
public func flush() {
101101
guard let storage = self.storage else { return }
102102
guard let analytics = self.analytics else { return }
103103
guard let httpClient = self.httpClient else { return }
@@ -149,13 +149,3 @@ public class SegmentDestination: DestinationPlugin {
149149
}
150150
}
151151
}
152-
153-
extension Analytics {
154-
internal func flushCurrentQueue() {
155-
apply { (plugin) in
156-
if let destinationPlugin = plugin as? SegmentDestination {
157-
destinationPlugin.flush()
158-
}
159-
}
160-
}
161-
}

Sources/Segment/Timeline.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ extension EventPlugin {
189189
public func alias(event: AliasEvent) -> AliasEvent? {
190190
return event
191191
}
192+
193+
public func flush() { }
194+
public func reset() { }
192195
}
193196

194197
// MARK: - Destination Timeline

Sources/Segment/Version.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//
22
// Version.swift
3-
// Segment-Tests
3+
// Segment
44
//
55
// Created by Brandon Sneed on 12/3/20.
66
//
77

88
// Referred to by Analytics.swift
99

1010
// BREAKING.FEATURE.FIX
11-
internal let __segment_version = "5.0.0"
11+
internal let __segment_version = "1.0.1"

0 commit comments

Comments
 (0)