i created an observer before add to cart like this:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="controller_action_predispatch_checkout_cart_add">
<observer name="test_custom_controller_action_predispatch_checkout_cart_add" instance="Test\Custom\Observer\BeforeAddCart" />
</event>
</config>
in this observer i want to check if the cart is empty and do some function, before add product to the cart