The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/9.5/static/plpgsql-trigger.html
Description:
Before insert on update or insert trigger will fire twice when insert .. on
conflict do update does the update part. First with TG_OP='INSERT' and then
with TG_OP='UPDATE'.
It is not very obvious behaviour, and I think it deserves a notice in
documentation.
Here is an example:
https://gist.github.com/C-Pro/ff0000aaeee469e8f57f232de422bba0