If possible. This type of information is usually called telemetry. How you implement it depends on your game, engine, programming language, etc. So it is impossible to tell you how to do it, beyond telling you to look for information on how to implement telemetry for the engine you are using.
Something very, very important is that telemetry is usually considered a serious security problem, because you are obtaining information about the equipment and how to use the game and the hardware at a given moment.
Many people don't like this, even depending on the country there are laws that you must comply with.
The minimum is to inform people that your game is going to capture information and send it to the developer. If you don't do that, having your game try to connect to the internet and send information without the consent of its owner can even be considered a scam (because it is not known what information you are collecting and what purpose you are going to give it), so it is not something minor and something you should keep in mind, especially if you are an unknown, independent developer.