A number of Halachic authorities maintained that one does not recite Birkat Ha’gomel after a flight if the trip was in violation of Halacha. For example, there is a prohibition against leaving Eretz Yisrael for purposes that do not involve a Misva. There were thus some authorities who ruled that if a resident of Eretz Yisrael goes on a recreational trip overseas, he does not recite Birkat Ha’gomel after his trip, since his trip entailed a Halachic violation. Likewise, these authorities ruled, if a person took a flight on Shabbat, Heaven forbid, and then decides to recite Birkat Ha’gomel in the synagogue, he should not be allowed to recite the Beracha, since his trip involved the desecration of Shabbat.
However, Rav Shemuel Pinhasi (contemporary), in his work Ve’chol Ha’haim (p. 35), writes that Halacha does not follow this view. Even if a person took a flight in violation of Halacha, he nevertheless recites Birkat Ha’gomel, since he did, after all, emerge safely from a dangerous situation, and must therefore express gratitude to Hashem through the recitation of Birkat Ha’gomel.
Summary: If a person leaves Israel for purely recreational purposes, or takes a flight on Shabbat, Heaven forbid, he recites Birkat Ha’gomel after his flight, even though his trip constituted a violation of Halacha.