Skip to content

Commit 43c1a6c

Browse files
authored
fix manually enabling logic + add tests (#68)
1 parent 9944986 commit 43c1a6c

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

core/src/main/java/com/segment/analytics/kotlin/core/Settings.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ data class Settings(
4343

4444
internal fun Analytics.update(settings: Settings, type: Plugin.UpdateType) {
4545
timeline.applyClosure { plugin ->
46-
if (plugin is DestinationPlugin) {
47-
plugin.enabled = settings.hasIntegrationSettings(plugin)
48-
}
4946
// tell all top level plugins to update.
5047
// For destination plugins they auto-handle propagation to sub-plugins
5148
plugin.update(settings, type)

core/src/main/java/com/segment/analytics/kotlin/core/platform/Plugin.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ abstract class DestinationPlugin : EventPlugin {
9393
timeline.remove(plugin)
9494
}
9595

96+
/**
97+
* Update `enabled` state of destination and apply settings update to destination timeline
98+
* We recommend calling `super.update(..., ...) in case this function is overridden
99+
*/
96100
override fun update(settings: Settings, type: Plugin.UpdateType) {
101+
enabled = settings.hasIntegrationSettings(this)
97102
// Apply settings update to its own plugins
98103
timeline.applyClosure {
99104
it.update(settings, type)

core/src/main/java/com/segment/analytics/kotlin/core/platform/plugins/SegmentDestination.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class SegmentDestination : DestinationPlugin() {
101101
}
102102

103103
override fun update(settings: Settings, type: Plugin.UpdateType) {
104+
super.update(settings, type)
104105
if (settings.hasIntegrationSettings(this)) {
105106
settings.destinationSettings<SegmentSettings>(key)?.let {
106107
pipeline.apiHost = it.apiHost

0 commit comments

Comments
 (0)