So one of the things that can interfere with ranged sneak attack is that standard
Darkvision is only 12m while your ranged weapon has an 18m range. If you are in a dark area and you exceed your
Darkvision range then you lose
Advantage and cannot sneak attack.
Thankfully, some jerk made a build that addresses this.
https://forums.larian.com/ubbthreads.php?ubb=showflat&Number=784086#Post784086