Heat oven to 200C/180C fan/gas 6. Heat 2 tbsp of the oil in a large non-stick frying pan and cook the onions over a low heat for 20-25 mins or until well softened and lightly browned. Add the vinegar and cranberry sauce, and simmer for 5-10 mins more, stirring until almost all the liquid has disappeared. Leave to cool.
Meanwhile, put the sweet potatoes in a bowl and toss with the remaining oil, 1/2 tsp salt, 1/2 tsp pepper and the chilli flakes. Arrange on a baking tray and cook for 20 mins, turning halfway, until softened and lightly browned. Leave to cool.
Reduce oven to 180C/160C fan/gas 4. Line two large baking trays with baking parchment and unroll the pastry sheets on top – trimming the edges neatly at this point will encourage a good rise. Leaving a 2cm gap around the edge, spread the onions over the pastry, then top with the sweet potatoes and goat’s cheese. Brush the beaten egg around the border of the pastry and bake in the oven for 35-40 mins or until the pastry is golden and crisp, swapping the shelves after 20 mins.
Scatter over the thyme, then cut each tart into quarters (or smaller pieces if serving more). Serve with a large leafy salad.