There are several upgrading strategies people use. Choose one or hybrid one or more to suit your needs. It is always good to keep in mind upgrading for war since won wars give loot.

Upgrading based on War defense: Upgrade all defenses that target both air and ground first. DPS is a factor so archer towers and teslas give the most DPS, then wizard towers. Once those are done, point damage and splash damage can thwart different attack strategies so upgrade cannons if attacked by giants and mortars if attacked by hogs. Depending on what you get attacked by, always upgrade your traps (air or ground) as your upgrading your first defenses.

Upgrading based on cost: Upgrading the most expensive defense that you can afford is always the case but after a while you may want to start saving for the most expensive defenses first and work your way down.

Upgrading based on time: Alternating upgrades so your builders are free in succession, rather than having all builders becoming free at once is advisable.

Upgrading based on resources: Some people upgrade collectors first in order to maximize resource output. It is usually better to upgrade some defenses first to protect saved resources but you can do a juggle act between collectors and defenses.