Genius level SAP scientist Freetz has put together this handy guide to the order of operations of different phases and trigger types. Now that's dedication!

Pets with the same trigger type activate their abilities in order from highest attack to lowest attack, with ties being broken randomly. - Grounded

Phase 1: Before battle:
  1. Before battle abilities (just perks)
  2. Any other potentially activated ability in normal order
Phase 2: Start of battle:
  1. Start of battle pets with churros
  2. Start of battle toys
  3. Start of battle pets
  4. Any other potentially activated ability in normal order
Phase 3: Before attack:
  1. Before attack
  2. Before friend attacks
  3. Any other potentially activated ability in normal order
Phase 4: After attack:
  1. After attack
  2. Friend attacks/Friend ahead attacks/Friendly attacked
  3. Any other potentially activated ability in normal order
The normal ability order:
  1. Level up
  2. Friend level up, Friendly level up
  3. Hurt
  4. Friend/Enemy hurt
  5. Gains mana
  6. Summoned
  7. Friend/Enemy summoned
  8. Faint
  9. Friend ahead faints
  10. After faint (These are faint abilities that only activate after fainted pets disappeared, so summons and some other weird ones)
  11. Friend/Enemy faints, Friendly toy broke (These abilities also need to wait until fainted pets disappear, except for Kitsune)
  12. Knock out
  13. Transformed
  14. Friend gained experience
  15. Friendly ate food, Eats food
  16. Abilities with counters (Eats two food, Four friends hurt, Five friendly attacks, Two friends faint. Two friends faint also has to wait for fainted pets to disappear)
  17. Friend lost perk
  18. Gain perk/ailment
  19. Friendly/Enemy gained perk/ailment
  20. Pet flung
  21. Mana snipe
  22. Fainted pets disappear
  23. Friend jumped (This could also be earlier, but there's no way to test, since the only way to jump is 24th and only the golden retriever summon is after)
  24. Empty front space
  25. Golden retriever summons