Taking stats from previous campaign
When we create a new draft campaign, it seems to contain stats from the previous campaign.

It looks like a minor bug
Unfortunately, it seems to be doing that even after sending the campaign through... it's carrying on Opens from the previous send...

Whoa! Can you list out the exact steps? Did you create a fresh campaign or clone? Were both running at the same time? What finished first? etc ...
An alternative explanation is these are views from previews. I was about to open an issue about that as it seems that previews trigger the view pixel and as a campaign may go through many iterations could rack up quite a lot of views before sending out.

Yes, each time I click the preview button, the number increases! When I clone the campaign, the numbers don't seem to be carrying through but they did for the first campaign. Not sure how that might have happened.
The preview is meant to be an accurate render of exactly what's meant to be sent, including link and view tracking. To avoid counting stats, the preview will have to not render those URLs, which is problematic. Or there has to be a mechanism where those endpoints detect that the click/views are coming from a preview mode and not register them. But, that's also tricky.
@knadh right, maybe the most straight forward would be to disregard based on referrer or IP of the active admin session. Referrer should be easiest since the preview is hosted under the app domain.
based on referrer
Unreliable as the behaviour differs based on the client/browser.
IP of the active admin session
Not possible to guarantee accurate IP behind proxies, corporate networks, VPNs etc. Corporate networks will have the same IP for countless users. Admins and e-mail recipients within a company, thus, will have the same IP. The link/view endpoints are public and not connected to the admin session either.
The simplest thing would be to inject a ?preview=true, but than that's leaving a public backdoor. I'm not sure if this is a big enough issue that should be addressed right now.
The preview to me is to see if the email looks as intended (design-wise). If we can remove click and view tracking from the preview completely. This issue is sorted.
If people want to see whether view and click tracking are working, they can always send a test campaign. That's just my opinion mate!
If we can remove click and view tracking from the preview completely. This issue is sorted.
No straight forward way of doing this, is the issue :) Will explore what can be done.
Ah got you. Maybe snapshotting and presenting preview as an image is one idea.
Well in that case, as you said, this isn't a pressing issue, and who doesn't like seeing more opens/clicks even if they are your own ;)
Definitely not the most pressing issue. One alternative that I thought of would be maybe to set a short lived cookie when the preview is triggered that has the campaign UUID value and disables the tracking rendering (or counting). That would be hard to use by a 3rd party to mess with the trackers and be fairly compatible with the existing system.
How about passing an extra arguement to TemplateFuncs or CompileTemplate to stop rendering TrackLink, TrackView etc kind of keywords when it's called from any preview handler?
This is done: https://github.com/knadh/listmonk/commit/37824136c07a140af405ea071dbf5ea24d8d5bbf
There was a far simpler way to achieve this. Simply replace the campaign UUID with a dummy value in the preview!