-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature/sht 5366 dynamically initialize posthog #1
Feature/sht 5366 dynamically initialize posthog #1
Conversation
private fun configure(call: MethodCall, result: Result) { | ||
try { | ||
val apiKey: String = call.argument("apiKey") ?: return result.error("Invalid API Key", "API Key is null or empty", null) | ||
val host: String = call.argument("host") ?: return result.error("Invalid Host", "Host is null or empty", null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mastersam07 How about using the default host if the host is not passed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Earlier in the file, there is an initPlugin
method where we try to initialise the plugin using the values set in the android manifest. When the apiKey is not in the manifest, the initialisation is cancelled.
This leaves the developer to manually call configure
and pass in the apiKey and host as required parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just read your message again @shuttlers-ifiok . Will modify accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shuttlers-ifiok this has been treated in #3
channel.setMethodCallHandler(this) | ||
} | ||
|
||
private fun initPlugin(applicationContext: Context) { | ||
private fun initPlugin(context: Context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shuttlers-ifiok here.
On start, the plugin tries to initialize using the values in the manifest. Where apiKey is empty, initialization process is aborted.
Leaving the developer to manually call configure.
💡 Motivation and Context
Posthog initialization can only be done natively from android manifest and info.plist. However, there are cases where user want to configure dynamically from the dart side.
A good example is loading the posthog api key and host from some 3rd party(say api or firebase remote config) and then setting up posthog.
The current setup does not allow
This PR aims at solving the above described issue.
💚 How did you test it?
With the example code, on an emulator.
📝 Checklist