Firstly, it's not wrong to say that in Avengers: Infinity War Thanos and Black order may know how to bypass Heimdall's senses, provided that planetary-level Joutens can do it and even Dark elves INCLUDING their ships, so why not UNIVERSAL-level Thanos, his black order and his ship.
Secondly, Heimdall saw Thanos coming, and saw his resources like wielding a stone with space for more, and his black order.
Fearing for Thor and Hulk (fight with Thanos), Thanos may have killed Hulk on the spot, so he decides to transport Hulk to Earth knowing it will be for one last time knowing the consequences as he judged Hulk's life is more valuable.
So in both cases, Hulk's beating was inevitable, so did Heimdall sacrifice himself for Hulk?