I've always used "What did just happen?" because I believe we are asking about the object of the verb "happen" so I use an auxiliary and the infinitive. However, I've heard native speakers say "What just happened?", is this correct too?
What did just happen?
– is not a correct neutral way of forming this question. ‘What’ here is not the object of ‘happen’, but the subject: It happened => What happened? ‘Happen’ is an intransitive verb and cannot take an object (“†It happened an earthquake” is grammatically incorrect).
You can, however, say “What did just happen?” as an emphatic question:
— Woah, what just happened?
— Yeah, what did just happen?
This is a different use of ‘do’, of course, where the main verb is emphasised. It differs from the purely automatic ‘do’ that appears in subject-auxiliary inversion. Similarly, you could also say, “Who did do that?” as an emphatic variant of “Who did that?”.