Our application is expected to have very high volumes of transactions. In order to reduce the amount of http calls to our Piwik server, the architecture passes Piwik page view and event data to a Node.js frontend to Amazon Simple Queue Service. A process batches up the transactions from the queue to make a single call to Piwik with a set of data.
Amazon’s SQS does not guarantee the order of reading responses from the queue so we had to specify the Piwik ‘cdt’ parameter in the call to make sure that the correct time was associated with each item.
After a lot of attempts, we finally figured out that the ‘cdt’ parameter is a simple UNIX timestamp!
//calculating UTC datetime it looks like server need unix timestamp:P
process.env.TZ = ‘America/New_York’;
event.data.cdt = parseInt(Date.now()/1000);