Skip to content
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
2 changes: 1 addition & 1 deletion Sources/Segment/Plugins.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ internal protocol PlatformPlugin: Plugin { }
public typealias EnrichmentClosure = (_ event: RawEvent?) -> RawEvent?
public class ClosureEnrichment: Plugin {
public var type: PluginType = .enrichment
public var analytics: Analytics? = nil
public weak var analytics: Analytics? = nil

internal let closure: EnrichmentClosure

Expand Down
5 changes: 5 additions & 0 deletions Tests/Segment-Tests/MemoryLeak_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ final class MemoryLeak_Tests: XCTestCase {
let macLifecycle = analytics.find(pluginType: macOSLifecycleEvents.self)!
let macMonitor = analytics.find(pluginType: macOSLifecycleMonitor.self)!
#endif

// test that enrichment closure isn't leaked. was previously a retain loop.
analytics.add { event in
return event
}

analytics.remove(plugin: startupQueue)
analytics.remove(plugin: segmentDest)
Expand Down