Preact-cli: Analytics in our cli commands

Created on 2 Mar 2018  路  6Comments  路  Source: preactjs/preact-cli

It might be a good idea to put node-google-analytics in our commands.

It'll give us good insights on the cli usage and other things, what kind of config ppl are using, pain points, insights into templates etc.

discussion stale

Most helpful comment

This should be an opt-in only features as I'm there's a large group of people using this tool internally and would rather keep their usage private.

All 6 comments

as long as we use something that doesn't have 100 sub dependencies

This should be an opt-in only features as I'm there's a large group of people using this tool internally and would rather keep their usage private.

+1 to both points~!

If we were to go this route, something like this:

const http = require('http');
const UA = 'UA-XXX...';

function track(command, result, label) {
  // argv from somewhere else
  if (argv.private || OFFLINE) {
    return; // aka, --private or no outbound
  }
  let k, opts = { aip:1, ec:command, ea:result, el:label };
  let url = `https://www.google-analytics.com/collect?v=1&tid=${UA}&t=event`;
  for (k in opts) {
    !!opts[k] && (url += `&${k}=${encodeURIComponent(opts[k)}`);
  }
  return http.get(url);
}

This is essentially what ganalytics is doing

Back when we created Yeoman, we published https://github.com/yeoman/insight as a way to gather opt-in anonymous usage stats from your CLI users. Plumbs back to Google Analytics and works well with existing events dashboards pretty okay:

image

Just another option as you're evaluating :)

Adding this for commands would be a lot helpful. Will probably give this a try today and see how it goes.

Thanks Addy 馃槃

Definitely interested in this. I can set us up a shared GA account.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hesselbom picture hesselbom  路  3Comments

hardcoar picture hardcoar  路  3Comments

ajay28kumar picture ajay28kumar  路  3Comments

c0debreaker picture c0debreaker  路  4Comments

andybons picture andybons  路  3Comments