feat(posthog): SDK needs to be initialized early to capture application lifecycle events in iOS #552
+27
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If the Posthog SDK is not initialized as soon as the app starts, there's an issue in iOS that lifecycle events such as Application Installed and Application Updated are not triggered.
With this change what I did is try to get the
apiKey
andhost
fromcapacitor.config.ts
file and if the values are there then initialize the sdk when the plugin loads. If you do this then you don't need to call thesetup
function from your app's code.In
capacitor.config.ts
inside yourplugins
object add:Disclaimer: this is my first time working with Capacitor plugins so maybe I'm missing something.
Pull request checklist
Please check if your PR fulfills the following requirements:
npm run changeset
).