The core source crediting Leah as the first person ever to thank God is Berakhot 7b:5-6, which states that from the day the world was created no one had thanked God until Leah did so upon naming her fourth son Yehuda, as the pasuk says 'this time I will give thanks to God' (Bereishit 29:31-35).
Rashi, quoting the midrash, explains why this thanks came specifically with the fourth son: Leah knew by tradition that the four wives of Yaakov would share twelve sons equally, three each, so upon having more than her calculated share she recognized an extra measure of good requiring praise (Rashi on Bereishit 29:35; see also Bereshit Rabbah 71:4, which illustrates this with the parable of the kohen who values a handful given from one's own portion over a large measure given from an obligatory tithe).
The Ibn Ezra reads the pasuk similarly, explaining that Leah thanked God precisely because, now having four sons, she recognized that she should not covet more, and thus she gave thanks for having received enough rather than seeking additional increase (Ibn Ezra on Bereishit 29:35).
As for the closing words 'ותעמד מלדת,' the Targum Yonatan reads this not as a punishment but as a continuation of the same verse of praise, tying Yehuda's birth to the future kingship of David who would likewise give thanks before God, with her ceasing to bear following directly as part of that larger plan rather than as a rebuke (Targum Jonathan on Bereishit 29:35).
The Or HaChaim situates Leah's attitude throughout these conceptions as one of consistently judging her own situation favorably rather than complaining about being unloved, suggesting that her declaration of thanks was the natural culmination of her disposition rather than a sudden correction of fault (Or HaChaim on Bereishit 29:32), while the Kli Yakar's discussion of the earlier sons' names traces how Leah's statements evolved from hope that Yaakov would now love her, to naming reflecting her sense of being hated, providing the backdrop against which her shift to pure thanks at the fourth birth stands out (Kli Yakar on Bereishit 29:33-34).
The Sforno adds that the name Yehuda itself was constructed to contain the letters of God's great Name together with the root of hoda'ah, and that it was also a name already known among earlier generations, chosen because it fit the occasion of her thanks (Sforno on Bereishit 29:35).
Rav Kook explains the deeper significance of why Leah's act was the very first act of hoda'ah in history: a brachah can be said over any good that comes from a cause, even without conscious bestowal, but hoda'ah specifically responds to good that came through free will, where the giver could have withheld it, and Leah's thanks therefore expressed the idea that Hashem's kindnesses flow from free will and are deserving of acknowledgment, the root later of the korban todah which remains valid for all time (Ein Aya, Berakhot 1:78).
The Sfas Emes al HaShas addresses whether Leah's statement was meant as prophecy or simple speech, noting a dispute as to whether the Imahot are to be counted among the formal nevi'im, but concluding that Rashi's own comments on the chumash imply that the Imahot did possess ruach hakodesh, which lends Leah's words a prophetic dimension beyond simple gratitude (Sfas Emes al HaShas, Berakhot 7b).
The Ramban's broader discussion of Leah's situation, describing how she had deceived Yaakov on the wedding night yet was shown compassion by God precisely because her hated status stemmed from devotion to marrying into the righteous family, supplies important background for understanding the emotional arc that culminates in her thanksgiving (Ramban on Bereishit 29:31).
Beyond Leah's own hoda'ah, the broader Jewish obligation to give thanks for good that occurs is recorded elsewhere: Midrash HaGadol traces the requirement to thank God for miracles to sources in Torah, Neviim, and Ketuvim Midrash HaGadol, and the Gemara and Rambam specify the four categories of people obligated in Birkat HaGomel for deliverance from danger — sea travelers, desert travelers, the sick who recover, and prisoners who are freed (Berakhot 54b:12; Mishneh Torah, Blessings 10:8).