Skip to content

Commit

Permalink
fix manually enabling logic + add tests (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
prayansh authored Jan 12, 2022
1 parent 9944986 commit 43c1a6c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ data class Settings(

internal fun Analytics.update(settings: Settings, type: Plugin.UpdateType) {
timeline.applyClosure { plugin ->
if (plugin is DestinationPlugin) {
plugin.enabled = settings.hasIntegrationSettings(plugin)
}
// tell all top level plugins to update.
// For destination plugins they auto-handle propagation to sub-plugins
plugin.update(settings, type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ abstract class DestinationPlugin : EventPlugin {
timeline.remove(plugin)
}

/**
* Update `enabled` state of destination and apply settings update to destination timeline
* We recommend calling `super.update(..., ...) in case this function is overridden
*/
override fun update(settings: Settings, type: Plugin.UpdateType) {
enabled = settings.hasIntegrationSettings(this)
// Apply settings update to its own plugins
timeline.applyClosure {
it.update(settings, type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class SegmentDestination : DestinationPlugin() {
}

override fun update(settings: Settings, type: Plugin.UpdateType) {
super.update(settings, type)
if (settings.hasIntegrationSettings(this)) {
settings.destinationSettings<SegmentSettings>(key)?.let {
pipeline.apiHost = it.apiHost
Expand Down

0 comments on commit 43c1a6c

Please sign in to comment.