Server getting data from TTN (lots of "connections) with same counter)

@cslorabox, I dont know if I got you!
changing the script a little!!

const moment = require("moment-timezone");

const gps = (json) => {
  return json.payload_fields.latitude ? "with GPS" : "without GPS";
};

const time = (json) => {
  let time = json.metadata.gateways[0].time
    ? json.metadata.gateways[0].time	// gateway time
    : json.metadata.time;				// server time
  return moment	
    .utc(time)
    .tz("America/Fortaleza")
    .format("YYYY-MM-DD HH:mm:ss.SSS");
};

// and changing the mentioned line

 console.log(
    `inserted [${doc.dev_id}] with counter [${doc.counter}.${
      doc.confirmed ? "confirmed" : "unconfirmed"
    }] ${gps(jsonMsg)}, with time: ${time(jsonMsg)}`
 );

I got different timestamps on each message! I think They are not the same!
those messages are the output of the method call! isn’t it? If not, how to log the right messages?
You are right confirmation is device specific! I am gonna change it right now!
I forgot to mention I setup the device to send messages each 180 secs (20 samples/hour)
the jsonMsg came from the client.on(“message”…) event! and is the same as msg (after I parse it as json).
I really dont know What I am missing here!
output:

inserted [tracker01] with counter [1693.confirmed] with GPS, with time: 2020-10-20 18:06:24.554
inserted [tracker01] with counter [1693.confirmed] with GPS, with time: 2020-10-20 18:06:29.565
inserted [tracker01] with counter [1693.confirmed] with GPS, with time: 2020-10-20 18:06:34.739
inserted [tracker01] with counter [1693.confirmed] with GPS, with time: 2020-10-20 18:06:40.751
inserted [tracker01] with counter [1693.confirmed] with GPS, with time: 2020-10-20 18:06:45.090
inserted [tracker01] with counter [1693.confirmed] with GPS, with time: 2020-10-20 18:06:51.103
inserted [tracker01] with counter [1694.confirmed] with GPS, with time: 2020-10-20 18:10:44.433
inserted [tracker01] with counter [1694.confirmed] with GPS, with time: 2020-10-20 18:10:48.440
inserted [tracker01] with counter [1694.confirmed] with GPS, with time: 2020-10-20 18:10:54.190
inserted [tracker01] with counter [1694.confirmed] with GPS, with time: 2020-10-20 18:11:01.203
inserted [tracker01] with counter [1694.confirmed] with GPS, with time: 2020-10-20 18:11:08.448