[FEATURE] Improve storage of `.asyncapi-analytics` config file
peter-rr opened this issue ยท 7 comments
Why do we need this improvement?
Main ideas taken from @asyncapi/developer_experience_wg slack discussion:
cc @smoya @fmvilas
-
We are handling the same analytics config file for integration tests and source code, which might lead to potential conflicts.
-
Also we are storing that analytics config file at home directory, which is not a recommended practice.
How will this change help?
-
We can avoid potential conflicts by not mixing testing data with real user data.
-
Not polluting the user's home directory.
Screenshots
No response
How could it be implemented/designed?
-
Handling different config files for testing and source code.
-
The analytics config file should have a configurable path, and also be interchangeable between the different apps (like CLI, Studio), so we can know when the user is jumping from one app to another.
๐ง Breaking changes
No
๐ Have you checked for similar open issues?
- I checked and didn't find a similar issue
๐ข Have you read the Contributing Guidelines?
- I have read the Contributing Guidelines
Are you willing to work on this issue?
No, someone else can work on it.
/gfi dx
Hey @Amzani, your message doesn't follow the requirements, you can try /help
.
@fmvilas @smoya I'm trying to find out a good solution for what we talked about here, but I'm kind of stuck right now ๐ค
Regarding the usage of a configurable path for the analytics config file, should we interact with the user to get the file path desired and then use the value passed as a parameter? Could you provide any suggestion or example about this topic? Thanks, folks ๐
@fmvilas @smoya I'm trying to find out a good solution for what we talked about here, but I'm kind of stuck right now ๐ค
Regarding the usage of a configurable path for the analytics config file, should we interact with the user to get the file path desired and then use the value passed as a parameter? Could you provide any suggestion or example about this topic? Thanks, folks ๐
Let the path for the config file to be defined by an environment variable, with a default value in case is missing (the home directory is the default value).
Despite the env var name (up to you), line https://github.com/asyncapi/cli/blob/master/src/base.ts#L101 could be changed to:
const analyticsConfigFile = process.env.ASYNCAPI_METRICS_CONFIG_PATH || join(homedir(), '.asyncapi-analytics');
Then, users could change the path by just setting such an env var. i.e.ASYNCAPI_METRICS_CONFIG_PATH=/tmp/hello/.asyncapi-analytics
Regarding tests, you can do the same: set up that env var to a known and controlled config file path instead of using the one located in ~home.
However, as I recommended in the Slack thread you shared, the best way to work with tests is to create an interface for the storage of the config, and swap it in tests (from in file, to in memory).