Preheat your oven to 375°F (190°C).
Roll out the puff pastry on a lightly floured surface to fit a 9-inch tart pan. Press the pastry into the pan and trim any excess dough hanging over the edges. Prick the base with a fork and refrigerate while preparing the filling.
In a skillet over medium heat, heat the olive oil. Add the sliced onions and sprinkle with sugar and salt. Cook for about 20 minutes, stirring occasionally, until the onions are deeply caramelized and soft.
Add thyme to the skillet and stir for an additional minute. Remove from heat and let cool slightly.
In a mixing bowl, whisk together the heavy cream, eggs, and a pinch of black pepper. Add the caramelized onions and half of the grated Gruyère cheese to the bowl. Mix until combined.
Pour the onion mixture into the prepared tart shell. Top with the remaining Gruyère cheese.
Bake in the preheated oven for 25-30 minutes, or until the tart is golden brown and set in the center.
Once baked, remove from the oven and let cool for 5-10 minutes before slicing and serving.