Check what event called the trigger on PostgreSQL?
Trigger functions can check the value of the TG_OP variable to determine the event which caused the trigger to fire.  There are a number of other special variables as well listed in the documentation.