Skip to content

fix: ensure data is sent to analytics on preuninstall #4989

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

Merged
merged 3 commits into from
Aug 29, 2019

Conversation

rosen-vladimirov
Copy link
Contributor

@rosen-vladimirov rosen-vladimirov commented Aug 28, 2019

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 that npm starts removing the CLI package and its node_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 and npm un -g nativescript or npm 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

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.
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 that `npm` starts removing the CLI package and its `node_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.
In case the environment variable `NS_CLI_PREUNINSTALL_ANALYTICS_LOG_FILE` is set and `npm un -g nativescript` or `npm 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.
@rosen-vladimirov rosen-vladimirov force-pushed the vladimirov/update-feedback-analytics branch from 4c92f8e to bab894d Compare August 28, 2019 16:41
@rosen-vladimirov
Copy link
Contributor Author

test cli-smoke

@rosen-vladimirov rosen-vladimirov merged commit f2bffae into master Aug 29, 2019
@rosen-vladimirov rosen-vladimirov deleted the vladimirov/update-feedback-analytics branch August 29, 2019 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants