Preheat your oven to 400°F (200°C).
Roll out the puff pastry on a lightly floured surface.
Cut the pastry into circles and place them in tartlet pans.
Heat the olive oil in a large skillet over medium heat.
Add the sliced onions and a pinch of salt, cooking until caramelized.
Add the mushrooms and thyme to the skillet, cooking until softened.
Season the mixture with salt and pepper, then stir in the Gruyère cheese.
Spoon the mushroom and onion mixture into the pastry shells.
Brush the edges of the pastry with beaten egg.
Bake for 20-25 minutes or until the pastry is golden and puffed.
Allow to cool slightly before serving.