As a general rule, the passé composé is used for completed actions in the past E.g. "Hier, j'ai vu un chien dans la rue," whilst the imparfait is used when talking about continuous actions in the past, or when describing something in the past. E.g. "Généralement, je passais mes vacances avec mes parents." or "il faisait gris."
It is easy to distinguish between the two when they are both used in the same sentence: the imparfait is used to describe a continuous or ongoing action, and the passé composé is used to describe a specific event which interrupts it. E.g. "ils sont entrés (specific event) pendant que nous dormions (ongoing action)."