-
Notifications
You must be signed in to change notification settings - Fork 324
Use Telemetry v1.75 VSCode API #4457
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
Conversation
…nd keeps all of the business logic in wrapper `Analytics`
I think some properties on the internal google analytics class need to be moved back there because the send method needs them like flutter sdk version, is using dap or lsp |
@aitor-gomila
Do you mean move them to the |
@aitor-gomila I had a quick look through the analytics and here's a list of things I'd like to remove. I can do this on
|
Sorry for my terrible explanation. The
The problem is So Is that correct? Any feedback? Just one more thing: I think one of the calls to |
Agreed, these cause unnecessary complexity, but I didn't want to change intended behaviour. logError I think needs to be kept but we can |
This information is just added to custom dimensions though, so it should be possible to just include it in the data passed to Right now (before your changes), there's an
Sorry, my comment was ambiguous here :) I meant the |
Ok, giving it a thought, it makes sense to separate the concerns of Analytics and the Sender. |
Ok @DanTup, updated some of the code.
Since
|
src/extension/analytics.ts
Outdated
const data = { | ||
aip: 1, | ||
an: "Dart Code", |
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.
I think we should be adding all of this info inside the Analytics
class. Otherwise the user won't be able to see the data being sent (since VS Code is presumably only showing what's passed in to this method).
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.
Yes, the change is in my local branch. Pushing ASAP. Thanks for letting me know.
Things to fix:
Don't tell me how to do these, I want to learn problem solving myself. But PR is almost 99% done. Needs some testing before merging, though |
Sure! Let me know when you want me to take a look and make comments. Thanks for your work on this so far! :-) |
I've got a question. Send uses a handleError function. But since it's a promise, why not In this line I'm getting a TypeError, but you are not:
data is |
I think you're right, we could change: this.handleError(e);
resolve(); to: reject(e); and then wrap a It's been a long time since I wrote this so I'm not sure if there was a reason it was done this way, but you're welcome to change it as long as we ensure we're handling the error here (and not relying on the caller to catch it).
In the original code, We should probably avoid using explicit |
Why not use `.catch(logger.info)` instead of `try/catch`? Performance-wise.Will see what I can do, but the sent data could be anything. Maybe `Record<string, any>` would be better
Try/catch blocks should be avoided at all costs, specially in Promises since throw calls get converted to reject anyway. https://stackoverflow.com/a/41540641 (but I'm not very good at coding so correct me if wrong!)
Just one more thing: do you use ESLint/Prettier?
|
I think either will work. I generally prefer using
ES Lint should be set up. You can run |
except try/catch is synchronous code which defeats the purpose of Promises. Await too. If you don't use this frequently it's okay. But try to avoid it. But do whatever. Not trying to sound nitpicky :) Now I need to re-introduce that large object |
Everything seems to be ready. Make sure to test it well because I have not tried any of these changes If you need me to do any changes let me know ;) |
This isn't accurate :) Using I'll try out the changes and add feedback shortly - thanks again! |
Oh, okay! I didn't know, thank you too :)
|
:,) We should have a more visual way for thw user to see them, though! VSCode's fault most likely tho. Its nice to see this was born out of a confusion. |
That would be nice, but I think it's a bit out of scope for the extension - it would be better if something like that was handled by VS Code (since it should apply to all extensions and not be something specific to Dart). Maybe it's something they'll consider if everyone adopts this new unified API :-) |
Migrates all telemetry code to the new
TelemetrySender
/TelemetryLogger
API.