
Self-insertion is a literary phenomenon in which a fictional character, that represents the true author of a work of fiction, appears as a version of themselves as a character within that fiction, openly or hiddenly.
In art, it's similar to a self-portrait, where the artist includes himself in a painting of a narrative subject. This has been a common artifice since at least the Renaissance.