Heat the butter and olive oil in a large skillet over medium heat until the butter melts.
Add the sliced onions and a pinch of salt. Cook, stirring often, for 25 to 30 minutes until the onions turn deep golden and soft.
Stir in the thyme leaves and black pepper. Remove the skillet from the heat and let the onion mixture cool for 5 minutes.
Heat the oven to 400°F and line a baking sheet with parchment paper.
Roll out the puff pastry sheet on a lightly floured surface and cut it into 12 small rounds or squares.
Place the pastry pieces on the baking sheet. Spoon a small amount of the caramelized onions onto each piece, leaving a border around the edges.
Top each tartlet with a sprinkle of Gruyère cheese. Brush the exposed pastry edges with the beaten egg.
Bake for 15 to 18 minutes until the pastry is golden and the cheese has melted and bubbled.