fix: ensure data is sent to analytics on preuninstall #4989
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.
feat: enable to possibility to ensure analytics tracking is finished
Introudce finishTracking method in
analyticsService
which will ensure all pending information is send to Google Analytics. This is required for some rare cases in which we want to be sure all the information has been sent.fix: ensure data is sent to analytics on preuninstall
CLI's analytics process is a detached one, so during
preuninstall
command, CLI just sends information to the detached process what should be tracked and finishes CLI's execution. After thatnpm
starts removing the CLI package and itsnode_modules
.At this point the analytics process may still work and trying to send data, but as it relies on components in node_modules, which npm currently deletes, it fails to send information to Google Analytics.
To ensure correct data is send to Analytics, ensure tracking is finished before ending the preuninstall command.
feat: create analyticsLogFile during preuninstall
In case the environment variable
NS_CLI_PREUNINSTALL_ANALYTICS_LOG_FILE
is set andnpm un -g nativescript
ornpm i -g nativescript
is executed, CLI will use the value of the variable as path for the analyticsLogFile. This way it will be easy to check what information is tracked during install/uninstall of the CLI.PR Checklist
What is the current behavior?
During uninstall of CLI, some information may not be send to analytics.
What is the new behavior?
During uninstall of CLI, all information that must be tracked will be send to Google Analytics.
Related to #4974