How to check if a track is already added to a WebRTC peer connection before adding it?

I’m working on a WebRTC application where I dynamically add audio tracks to a peerConnection after obtaining microphone permissions. I want to avoid adding duplicate tracks to prevent unnecessary signaling and offers. However, I’ve noticed that the track.id changes each time I call getUserMedia, making it difficult to check if a track has already been added.

Here’s the code I’m using to add tracks

const localStream = await navigator.mediaDevices.getUserMedia({
   video: false,
   audio: true,
})
localStream.getAudioTracks().forEach((track) => {
   mapPeerConnection.forEach((peerConnection, userId) => {
     peerConnection.addTrack(track, localStream)
     sendOffer(userId)
   })
})