It doesn't appear that any one mission prompts the attack other than exploring the derelict Reaper to acquire the IFF. Because EDI needs time to safely integrate the IFF into the Normandy's systems the player character is allowed to continue on as usual until a side mission is completed in the meantime (such as Legion's loyalty mission which you acquire soon after recruiting him).
After that EDI should inform you that the IFF is integrated and any further use of the Starmap will prompt the Collector attack.
After obtaining the IFF in the derelict Reaper, 1 mission anywhere in the galaxy and finishing it and use the galaxy map will trigger the collector attack.
It's kinda tricky to say, because after I got the IFF I did Tali and Legion's loyalty missions, which were the last ones, before the attack. So it may or may not depend on the type of mission.
There is nothing tricky or random about it, you can do precisely two missions after the Reaper IFF before the Collector attack on the Normandy, if you activate Legion and do not talk to it immediately after. Activate it, go do another mission, go back and talk to Legion, do its loyalty mission, boom, Collectors attack. TiberiusYakushev 14:50, October 19, 2011 (UTC)
Actually I think the collector attack doesn't happen while you have a loyalty mission available. I've gotten the iff and left the com room and had not had a chance to go talk to legion and it triggered the attack but when I went back to the save after the mission I bypassed the galaxy map and went to legion and after accusing him talk to him again and got his loyalty mission then went and did it then triggered the attack.
- This exploit is specific for Legion's loyalty mission, AFAIK. It's pretty much required if you want to bring him to Tali's loyalty mission and then do his own. Otherwise, you only have time for one. Land Raider
- The rules are simple. If you have completed all available loyalty missions, the attack happens after one mission. Otherwise, it happens after two. This allows you to finish all loyalties, including Legion's, before the attack. See Stop_the_Collectors#Await_IFF_Installation. Mitranim