Caramelize onions: Cook onion slices in butter, then sprinkle with salt. Reduce heat to a gentle sizzle.During the last 5 minutes of cooking, add brown sugar and red wine vinegar.
Preheat oven to 400F.Roll out pie dough onto a parchment paper-lined baking sheet. Arrange caramelized onions on pie crust, leaving a 2-3 inch edge of pie crust around the onions (reserve about a tablespoon of caramelized onions).
Fold up the edges of the pie crust around the tomatoes. Brush the crust with beaten egg if using. Bake for 25-35 minutes, until crust is golden brown. After removing from the oven, scatter reserved caramelized onions and fresh basil on top.Enjoy!