-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
feat(create-gatsby): add telemetry tracking #28107
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing how straightforward this is, but the value from it will be huge 🙂
@ascorbic lodash.merge is the only one we use afaik, for deep-merging objects (so Object.assign won't work (unless there is a config option)) |
@jamo A thought: is it possible for us to have a lighter-weight approach, where we just enqueue the events at this stage, and then actually dispatch them when gatsby itself has been installed? I'm trying to think of ways that we could avoid needing to depend on the whole telemetry package. |
We could replace lodash.merge with deepmerge if that's all we need. That's less than 1kB |
I don't think it would make sense to implement a custom library for this purpose, rather invest the time to optimize the bundle size. Maybe we could |
I was originally against lodash but I was told that I need to use it and the size isn't a concern as gatsby already ships with it :( |
Yeah, it's fine in gatsby, but the considerations in create-gatsby are very different. For context: the whole compiled package is around 60kB at the moment. This PR would quadruple that. I'm not sure how realistic it is to shrink it enough (nor if that's a valuable use of time, either). If we could extract just the queuing part, we could avoid needing all the network stuff. |
I wouldn't feel too comfortable maintaining two packages doing the same work, the risk of losing or misformatting data becomes significant. I should have time next week to look at the telemetry-package bundle size. But sounds like you have already a plan on how to drop lodash so why won't we start with that? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
Thanks!
const analyticsApi = | ||
process.env.GATSBY_TELEMETRY_API || `https://analytics.gatsbyjs.com/events` | ||
|
||
let machineId = store.get(`telemetry.machineId`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might need to move this to be after the function
let machineId = store.get(`telemetry.machineId`) | |
let machineId = getMachineId() |
method: `POST`, | ||
headers: { | ||
"content-type": `application/json`, | ||
"user-agent": `Gatsby Telemetry`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit nit nit, we could maybe add the package version here. just in case we see one acting up
valueStringArray?: Array<string> | ||
} | ||
|
||
export const trackCli = (eventType: string, args?: ITrackCliArgs): void => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sweet! Didn't realise it was so simple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Nice work. I would like to get the machine info in at some point, but it's not a blocker
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
Description
Add telemetry to
create-gatsby