Skip to content
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

Analytics error fallback, fix opt-out #495

Closed
wants to merge 0 commits into from

Conversation

RAMOhio
Copy link
Contributor

@RAMOhio RAMOhio commented Aug 22, 2019

Fixed the analytics opt-out functionality to check if the user has opted out before using Insight library for analytics. Checks if something in the Insight library failed (i.e. on initialization) and if so, trip the no-analytics flag.

Copy link
Member

@sinedied sinedied left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the finding and the PR, this one was really bugging me 👍
I have made a few comments regarding the form, but otherwise the idea for the workaround is perfect.

Also before commit, you should run npm run lint:fix to auto-fix code style issues, you can check that everything is good after with npm run lint so that the CI will be happy 😺

try{
this.insight = (!this.options.analytics || process.env.DISABLE_NGX_ANALYTICS) ? { optOut: true } : new Insight({trackingCode: 'UA-93069862-1', pkg});
}catch{
this.insight = { optOut: true };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to just noop the track function then, ie: this.insight = { track: () => {} };

@@ -68,7 +73,9 @@ class NgxGenerator extends Generator {
)})\n`
);
this.log(`${chalk.yellow("Make sure you don't have uncommitted changes before overwriting files!")}`);
this.insight.track('update', fromVersion, 'to', this.version);
if(!this.insight.optOut){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for all this (and following checks) using if insight.track is noop'ed 😉

'tools-hads': props => props.tools && props.tools.includes('hads'),
'tools-jest': props => props.tools && props.tools.includes('jest'),
'tools-karma': props => props.tools && !props.tools.includes('jest')
'tools-hads': props => props.tools && props.tools.includes('hads')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops, make sure you rebase your code on the current master or this will cause a regression

@sinedied
Copy link
Member

I think the lint part is missing in the contribution guide, I need to update it later my bad 🐳

@RAMOhio
Copy link
Contributor Author

RAMOhio commented Aug 23, 2019

I've learned that I know even less about git through the CLI than I thought... I think I've got everything figured out though, opening another pull request here in a sec with the comments fixed. Thanks for the info, learned some new things about JS today (I still suck at JS, but hey, learning is fun lol)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants