Set environment variables detailing the environment we're running in#5969
Conversation
Currently the extension only advertises itself as "Dart-Code" or "VSCode" to all tools, which can be misleading when the extension is run inside another editor (like Antigravity or Cursor). This change adds some additional values in new env vars that a tool might want to know about that will be available to all spawned processes without relying on protocol-specific values (such as the client info in LSP). All of these are informational and may contain arbitrary values. They are not intended to replace existing values (like `--client-id` for analysis server) that might control the opt-in/opt-out of analytics, though an additional env variable might be added for this in future (see `DASH__TOOL` in #5561). Fixes #5561
This comment was marked as off-topic.
This comment was marked as off-topic.
|
@cj-radcliff @kenzieschmoll @bwilkerson @pq This PR adds the env vars discussed previously (minus The vars are set for all processes we spawn (this includes Analysis server, Flutter, Pub, DevTools server), but not for the built-in terminal. Let me know if there's anything else we should confirm/check before landing these. If we're happy with them, we should also add the equivalent to the IJ plugins for all tool processes that are spawned (cc @helin24). |
|
That looks good to me. Thanks! |
|
Will DASH__IDE_NAME be passed to the DevTools query string and the flutter survey data as a follow up to this PR? |
For surveys - if that's what makes most sense and they both accept arbitrary strings (not just the specific values we pass today), sure. For DevTools, I'm wondering whether we should stop using* the querystring and instead have the server read these (and whatever * And by stop using, I mean continue to pass it, but update the server to use the new env variables when set, but fall back to the querystring otherwise. (Although I'll also note I don't recall whether DevTools stats are collected client-side or server-side, and whether they're via unified analytics). |
DevTools packages up the analytics event on the client and then sends it to unified analytics over DTD. So to read the environment variable from the DevTools server would be possible, but we would have to refactor how analytics dimensions are computed and add a new DevTools server API endpoint to retrieve the value. The IDE and IDE feature are computed from the query string: https://github.com/flutter/devtools/blob/master/packages/devtools_app/lib/src/shared/analytics/_analytics_web.dart#L905 This is then used when creating the event for unified analytics: https://github.com/flutter/devtools/blob/master/packages/devtools_app/lib/src/shared/analytics/_analytics_web.dart#L905 And then sent to analytics over DTD here: https://github.com/flutter/devtools/blob/master/packages/devtools_app/lib/src/shared/analytics/_analytics_web.dart#L886-L887 Can you elaborate more on why you think the query string is not a good option? I'm not clear on what the risk is that would justify modifying how our analytics work, when just updating the query string would require no changes on the DevTools side. |
I don't think it's a bad idea, I was just assuming you might want to capture the additional values discussed here (for example If all you want for DevTools is (and probably we should document this somewhere in the SDK once we've locked it down, since we want both/all IDEs to behave consistently, and there are multiple tools that may want to read the values) |
That makes sense. For now, I propose we just change the existing query parameter to read from |
Sure - I've filed #5970 about this and pinged you on it a few questions (so if it's not simple to just make the change now, we don't have to hold up landing this one). |
The value of using environment variables is that they are automatically passed on to child processes, which is important for several reasons. And given that we're going to use environment variables everywhere else, it would be nice if DevTools could be consistent.
This might be what you meant, but in the analysis server the plan is to read the environment variable if it exists, and to take the value from the command-line if it doesn't. That gives us reasonable semantics when there's a version skew. |
This comment was marked as resolved.
This comment was marked as resolved.
|
Assuming no other feedback (or objections), I will merge this in the next few days. (we can resolve the DevTools-related survey stuff via #5970, since it doesn't affect the values of these vars) |
Currently the extension only advertises itself as "Dart-Code" or "VSCode" to all tools, which can be misleading when the extension is run inside another editor (like Antigravity or Cursor).
This change adds some additional values in new env vars that a tool might want to know about that will be available to all spawned processes without relying on protocol-specific values (such as the client info in LSP).
All of these are informational and may contain arbitrary values. They are not intended to replace existing values (like
--client-idfor analysis server) that might control the opt-in/opt-out of analytics, though an additional env variable might be added for this in future (seeDASH__TOOLin #5561).Fixes #5561
(this table is copied from #5561 to here for convenience)
DASH__IDE_NAMEVS Code,Cursor,Antigravity,IntelliJ,Android StudioDASH__IDE_VERSION1.2.3,1.2.3-alpha.4DASH__IDE_NAMEDASH__PLUGIN_NAMEDart-Code,dart-intellij(?)DASH__PLUGIN_VERSION1.2.3,1.2.3-alpha.4DASH__PLUGIN_NAME--client-versionDASH__TOOL(not implemented by this PR)vscode-plugins,intellijPlugins--client-id,FLUTTER_HOST(?)DASH__IDE_ENVIRONMENTdesktop,wsl,ssh-remote,codespaces,dev-container-Remotesuffix in the tool name?