Database hook works in preview but not in production...but it used to work (hashId)

Dear community,

There is a form on my website that utilizes the hashId package to generate a unique ID and is inserted into the database on the backend when a user submits for the form.
For the past month, there has not been any issues but suddenly over the weekend, the hook stopped recording data as it should.
Oddly, when we test it in preview mode, the hook appears to be in working order.

Thank you in advance for your advice.

Below is a snippit of the hook’s code:


import HashIds from ‘hashids’;
const hashIds = new HashIds(‘Company-API Salt’, 9, ‘abcdefghijkmnpqrstuvwxyz23456789’);

let incr = 0;

export function prodRegistration_beforeInsert(item, context) {
incr += 1;
if (incr > 9) {
incr = 1;
}
const d = new Date();
const t = parseInt(${d.getDate()}${d.getHours()}${d.getMinutes()}${d.getSeconds()}${d.getMilliseconds()}${incr}, 10);
const lotId = hashIds.encode(t);
console.log( **in** prodRegistration_beforeInsert generated id: ${lotId});
item.lotId = lotId;
console.log( **in** prodRegistration_beforeInsert item.lotId: ${item.lotId});
return item;
}

#hooks #hook #beforeInsert #hashId