The Crimean campaigns of 1687 and 1689  were two military campaigns of the Tsardom of Russia against the Crimean Khanate. They were a part of the Russo-Turkish War  and Russo-Crimean Wars. These were the first Russian forces to come close to Crimea since 1569. They failed due to poor planning and the practical problem of moving such a large force across the steppe but nonetheless played a key role in halting the Ottoman expansion in Europe. The campaigns came as a surprise for the Ottoman leadership, spoiled its plans to invade Poland and Hungary and forced it to move significant forces from Europe to the east, which greatly helped the League in its struggle against the Ottomans. Having signed the Eternal Peace Treaty with Poland in 1686, Russia became a member of the anti-Turkish coalition , which was pushing the Turks south after their failure at Vienna in 1683 . Russia's role in 1687 was to send a force south to Perekop to bottle up the Crimeans inside their peninsula.

What event happened first,  the Eternal Peace Treaty with Poland or Russia became a member of the anti-Turkish coalition?
Eternal Peace Treaty with Poland