Open ddiachkov opened 6 months ago
Hey @ddiachkov, thank you for your great feedback!
I agree that we should allow passing a configuration to the native initialiser, as it can be useful in many different use cases.
We will evaluate this feature soon to work on a solid solution.
At first glance, I believe that we should allow you to retrieve the configuration from our SDK module itself, so that you can use it on the JS side if you have to. On the other hand, I would also consider refactoring the current implementation to avoid having to maintain two configurations, as it would be counterintuitive and possibly unsafe.
We will look into this and keep you updated on this thread.
Thank you again for your contribution!
+1 it will be really helpful to have this support added
Feature description
Hello! We have an app with a lot of native code that initializes before the JS side and runs in the background. The native code needs the ability to send logs to DD, and so the SDK must be initialized on application start.
Recently dd-sdk-reactnative added the new
DdSdkNativeInitialization.initFromNative
API to load configuration from JSON file. Unfortunately, it is a bit limiting since JSON configurations need to be stored in the repo, and it doesn't support environment variables or build environments.Proposed solution
It would be nice to be able to init dd-sdk-reactnative with just
DdSdkConfiguration
instance. That would fix the limitations since we can generate it in the runtime using BuildConfig for tokens.Here is the patch I ended up with:
Alternatively, making
internal
constructor public also works.Other relevant information
For more context, this is how my whole setup works:
DdSdkConfiguration
with settings based on runtime / build environment.DdSdkNativeInitialization.initFromNative
withDdSdkConfiguration
.DdSdkConfiguration
to the JS side (it generatesdatadog-configuration.json
fromDdSdkConfiguration
).DatadogProvider
like this: