It is not a crime and legal in Canada to record a conversation as long as at least one party consents to the recording. It is legal to record a conversation between you and another person or persons but not legal to surreptitiously record a conversation between two other people without their knowledge. As such, the law in Canada draws a distinction between recording a conversation you are involved in and one that your are eavesdropping on.
The Criminal Code of Canada, imposes a general prohibition on recording private communications, but then provides an exception where one of the parties to the private communication consents to the interception of that communication. The maximum sentence for surreptitiously intercepting or recording a conversation is 5 years in jail
If the police want to record conversations that none of the officers (undercover or otherwise) will be involved in they can apply beforehand for a warrant permitting them to listen in on the conversation that is expected to reveal evidence of a crime.