Skip to content

Fixes + Misses corrections #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Examples/destination_plugins/AdjustDestination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal struct AdjustSettings: Codable {
}

@objc
public class AdjustDestination: NSObject, DestinationPlugin {
public class AdjustDestination: NSObject, DestinationPlugin, RemoteNotifications {
public let timeline: Timeline = Timeline()
public let type: PluginType = .destination
public let name: String
Expand Down Expand Up @@ -145,6 +145,16 @@ public class AdjustDestination: NSObject, DestinationPlugin {

return event
}

public func reset() {
guard started == true else { return }
Adjust.resetSessionPartnerParameters()
}

public func registeredForRemoteNotifications(deviceToken: Data) {
guard started == true else { return }
Adjust.setDeviceToken(deviceToken)
}
}

// MARK: - Adjust Delegate conformance
Expand Down
78 changes: 0 additions & 78 deletions Segment.xcodeproj/xcshareddata/xcschemes/SegmentExample.xcscheme

This file was deleted.

11 changes: 10 additions & 1 deletion Sources/Segment/Analytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,20 @@ extension Analytics {
}

public func flush() {
flushCurrentQueue()
apply { plugin in
if let p = plugin as? EventPlugin {
p.flush()
}
}
}

public func reset() {
store.dispatch(action: UserInfo.ResetAction())
apply { plugin in
if let p = plugin as? EventPlugin {
p.reset()
}
}
}

public func settings() -> Settings? {
Expand Down
2 changes: 2 additions & 0 deletions Sources/Segment/Plugins.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public protocol EventPlugin: Plugin {
func group(event: GroupEvent) -> GroupEvent?
func alias(event: AliasEvent) -> AliasEvent?
func screen(event: ScreenEvent) -> ScreenEvent?
func reset()
func flush()
}

public protocol DestinationPlugin: EventPlugin {
Expand Down
12 changes: 1 addition & 11 deletions Sources/Segment/Plugins/SegmentDestination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public class SegmentDestination: DestinationPlugin {
}
}

internal func flush() {
public func flush() {
guard let storage = self.storage else { return }
guard let analytics = self.analytics else { return }
guard let httpClient = self.httpClient else { return }
Expand Down Expand Up @@ -149,13 +149,3 @@ public class SegmentDestination: DestinationPlugin {
}
}
}

extension Analytics {
internal func flushCurrentQueue() {
apply { (plugin) in
if let destinationPlugin = plugin as? SegmentDestination {
destinationPlugin.flush()
}
}
}
}
3 changes: 3 additions & 0 deletions Sources/Segment/Timeline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ extension EventPlugin {
public func alias(event: AliasEvent) -> AliasEvent? {
return event
}

public func flush() { }
public func reset() { }
}

// MARK: - Destination Timeline
Expand Down
4 changes: 2 additions & 2 deletions Sources/Segment/Version.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//
// Version.swift
// Segment-Tests
// Segment
//
// Created by Brandon Sneed on 12/3/20.
//

// Referred to by Analytics.swift

// BREAKING.FEATURE.FIX
internal let __segment_version = "5.0.0"
internal let __segment_version = "1.0.1"