-
-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Ref https://twitter.com/left_pad/status/907357756713205761
Didn't give enough context into what "analytics" means so I'l write that here.
As Sebastian wrote, doing analytics similar to how other projects do/did it with things like homebrew, etc might not really work for a few reasons: pushback from the community, having to decide opt-in/opt-out, CI/development builds, per file/per build. So this idea would be opt-in (unless it's useful enough to be opt-out), run per build, and only run when the user turns on this option (or just plugin).
Maybe analytics is the wrong word to use since it reminds us of different things, so I'l say another word for it is just local stats for the syntax that you use.
Maybe it's weird, but I think it would be useful to setup some plugin/infra to be able to have stats of different kinds of patterns/syntax used in a codebase? Basic stuff could just simply be the number of functions in a file/codebase, over time, etc. But that could be changed to look for IIFEs, or other kinds of patterns (like an AST grep).
I'd like to see this kind of thing mostly for new syntax (new proposals) and see the kinds of usage the community has for syntax and how often things are used.
Example
An example to explain it better: we'll take optional chaining. Some possible questions I just randomly came up with (some may be specific to that proposal):
- Is it used at all in a codebase?
- How often is it used?
- What's the longest chain it's used in: for example just
a?.b
(1) ora?.b?.c?.d
(3) - Are people skipping the operator?
a?.b.c?.d
- Are people using the CallExpression or NewExpression forms?
a?.()
new a?.()
? - Where is it being used (what surrounding syntax)?
I think some of these will help with feedback to TC39 on the kinds of use cases the community is using it for (maybe including the call/new expressions isn't that important, or could be added later), etc.
I think this would be useful for someone to explore (not sure what it looks like yet, this is just the general idea of doing an AST grep/analysis with new syntax), and also nice for us if someone wanted to share the data/results. We could also run a minifier plugin to rename variable?.name?.here
to a?.b?.c
Potential Learnings
- Better idea of how people are using the syntax (for learning/TC39)
- Possibility for real-life examples in our docs: ref Enhanced Examples website#1263
- Test cases
- Nice baseline/start for more codebase analysis tooling in general?
cc @addyosmani, @bmeurer