Dimension door wouldn't really make a very good choice, since it requires a relative directional specifier, which presumably must be specified at the time of casting, being, at the time the contingency is set up. Since dimension door's destination is specified, as I mentioned, in direction and distance relative to you at the time of triggering, this means that it is highly likely anything you specify in advance will warp you into a wall and stick you into the Astral plane. While it does include provisions for getting out of the astral plane, it doesn't guarantee you won't land in something nasty. The alternative targetting method, visualizing an area, isn't any better, because you have no idea where you will be when it goes off, and it is quite likely the visualized area you had in mind at time of casting won't be in range.
Otiluke's Resilient Sphere, on the other hand, is definitely THE 4th level spell of choice. Useful both as a defensive, and offensive tool, it provides near invulnerability to just about anything, magical or otherwise, as it states that nothing can pass through the sphere, inside or out. Nothing, as in, any weapons, any attacks, any magic, nothing. While it's possible to bring down the sphere itself by dispelling or disintegrate, this doesn't affect you, and you are free to reshield, or do something else.
In the meantime, you're in your own little bubble. You're free to do anything you want, including vanishing by any means which doesn't involve passing through the sphere, such as dimension door, healing and buffing in safety, or just slumming it.
You can also use it to protect a partymember, which can be done both offensively and defensively: Defensively, for the same reason YOU might want an emergency shield, and simultaneously offensively, as since the shield is impenetrable, you're free to use the targetted invididual as a contigency-triggered decoy, and the moment the shield goes up, lay the smackdown on the area, which has surely attracted the attention of the monsters, since the bait obviously goes first.
You can also cast it to immobilize and remove enemies, but since this spell allows a saving throw to negate, this use is not recommended, as enemies never fail saves.