Skip to content
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

address event plugin disparity and track issue #87

Merged
merged 6 commits into from
May 19, 2022

Conversation

wenxi-zeng
Copy link
Contributor

  • address event plugin execute disparity between swift and kotlin
  • fix issue that event being lost if tracked right after sdk initialization

@codecov-commenter
Copy link

codecov-commenter commented May 19, 2022

Codecov Report

Merging #87 (30ca972) into main (1510073) will increase coverage by 32.19%.
The diff coverage is 93.33%.

@@              Coverage Diff              @@
##               main      #87       +/-   ##
=============================================
+ Coverage     45.49%   77.69%   +32.19%     
- Complexity       14      440      +426     
=============================================
  Files             8       64       +56     
  Lines           855     5487     +4632     
  Branches         85      692      +607     
=============================================
+ Hits            389     4263     +3874     
- Misses          436      679      +243     
- Partials         30      545      +515     
Impacted Files Coverage Δ
.../segment/analytics/kotlin/android/utils/Plugins.kt 0.00% <0.00%> (ø)
...om/segment/analytics/kotlin/core/AnalyticsTests.kt 71.60% <ø> (ø)
...ava/com/segment/analytics/kotlin/core/Analytics.kt 76.43% <100.00%> (ø)
...segment/analytics/kotlin/core/platform/Mediator.kt 100.00% <100.00%> (ø)
...m/segment/analytics/kotlin/core/platform/Plugin.kt 93.93% <100.00%> (ø)
...ytics/kotlin/core/platform/plugins/StartupQueue.kt 90.00% <100.00%> (ø)
...com/segment/analytics/kotlin/core/utils/Plugins.kt 44.82% <100.00%> (ø)
...ics/kotlin/core/compat/ConfigurationBuilderTest.kt 98.55% <0.00%> (ø)
...analytics/kotlin/core/utilities/Base64UtilsTest.kt 100.00% <0.00%> (ø)
...n/core/utilities/EventManipulationFunctionsTest.kt 100.00% <0.00%> (ø)
... and 53 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1510073...30ca972. Read the comment docs.

result = plugin.alias(result as AliasEvent)
}
}
plugin.execute(result!!)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this needs to be result = plugin.execute(result)

secondly, we should not be using !! since the result from one of the plugins could be null and this would then throw an NPE. lets wrap the call in a null check or use ?.let and capture the state of result before using it as non-null

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hrm. result = plugin.execute(result) is a compile time error. we don't need a null check because we checked it on line 27

Copy link
Contributor

@prayansh prayansh May 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually scratch that first comment, didnt realize this was for DestinationPlugin, but second one still holds

}
else -> {
result = plugin.execute(result as BaseEvent)
result = plugin.execute(result!!)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@@ -70,6 +70,14 @@ interface EventPlugin : Plugin {
return payload
}

override fun execute(event: BaseEvent): BaseEvent? = when (event) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be marked final?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. we shouldn't, because we extends execute in edge function. amplitude also overrides this method.

Copy link
Contributor

@prayansh prayansh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments for changes.

Also are we sure this change wont break any existing plugin implementations? I didnt see any new tests to verify the behavior consistency

@wenxi-zeng
Copy link
Contributor Author

I'd say we're pretty safe here. the difference lays on whether the child plugin overrides execute method and if the execute method calls super.execute. if not calling super.execute, then yes it might break things. so I checked all the existing event plugins. amplitude is the only one that does not call super.execute, but it has a when statement in its implementation which basically does the same thing.

Copy link
Contributor

@prayansh prayansh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@wenxi-zeng wenxi-zeng merged commit b91c131 into main May 19, 2022
@wenxi-zeng wenxi-zeng deleted the wenxi/address-disparity-and-track-issue branch May 19, 2022 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants