IMO gamification is
1. Overused and
2. Relies on rewards to incentivize behavior.
Using rewards kills/diminishes intrinsic motivation - see Alfie Kohn’s book Punished by Rewards.
Giving a gold star for good behavior will piss off the child who acts good but is not noticed and doesn’t get the star and make them act good only when the teacher is watching.
Leaderboards pit users against each other and give a momentary ego boost.
Measuring behavior to build trust and allow more responsibility is another matter - discourse does that successfully.
People ended up manipulating the system to score more without adding much value to code but even then they were a little miserable. The manager tried to justify the system but the system was taken down after a year or so.
The reward process becomes the game, measurements get manipulated, the original purpose goes under the bus.
People are not birds or rats, we learn to manipulate the hand feeding us but in the process lose motivation for the original behavior and our relationship with the hand gets reduced to a transactional one.
Really counterproductive and destructive long term.
"Gamification" was more buzzword than real and where it was covering the lack of anything actually interesting then no, it's not going to work long term and probably not short term.
Where is was useful was in getting people to pay attention to barriers to entry their product imposed and reduce them. Beyond that it was a fad for anti-social, unproductive manipulation of users emotions in place of delivering value.
If you want to know what works, start by reading 'Hooked' and 'Actionable Gamification'.