Problem to save a new variable on the bucket when i have to use the payload parser to save the variables coming on payload

Problem to save a new variable on the bucket when i have to use the payload parser to save the variables coming on payload

Hi!

I'm receiving a payload from my device, is just like this:
{"DATA":
      {
      "pulses": 11182
      }
}

I have a code on the payload parser to receive this information and send to the bucket. 
function toTagoFormat(object_item, group, prefix = '') {
  const result = [];
  for (const key in object_item) {

    if (ignore_vars.includes(key)) continue;

    if (typeof object_item[key] == 'object') {
      result.push({
        variable: object_item[key].variable || `${prefix}${key}`,
        value: object_item[key].value,
        group: object_item[key].group || group,
        unit: object_item[key].unit,
      });
    } else {
      result.push({
        variable: `${prefix}${key}`,
        value: object_item[key]
      });
    }
  }

  return result;
}

// Check if what is being stored is the ttn_payload.
// Payload is an environment variable. Is where what is being inserted to your device comes in.
if (!payload[0].DATA.variable) {
  // Get a unique group for the incoming data.
  const group = payload[0].DATA.group || String(new Date().getTime());
 
  payload = toTagoFormat(payload[0].DATA, group);
 
}


After this, it runs an analysis, this analysis is filtered and returned a value. And this value that i have, i must to save in the bucket. So i'm doing this comand:

  const registerMonthFlow = {"DATA":{
    "monthFlow:": monthFlow,
    "priceCustomersPaying": totalCustimersPaying
  }}

  const jsonData = JSON.stringify(registerMonthFlow);

if i log the constant 'jsonData', it returns (is formated exacly like i have to receive the payload into the payload parser):
{"DATA":{"monthFlow:":0,"priceCustomersPaying":0}}

But, everytime it returns an error:
Error when inserting: Function Parse Error: TypeError: Cannot read properties of undefined (reading 'variable')

But if i go to my device area, on emulator tab, i copy and paste the payload {"DATA":{"monthFlow:":0,"priceCustomersPaying":0}}, the two variables on payload is been saved.

I took this way, cause if i save on tagoformat {variable: variableName, value: 0}, the Tago Support team, told me it will not work cause when the function 'sendData' is called, the payload i'm trying to save, pass througth the Payload parser again.

I gess the format i'm saving this variables on analysis is wrong, but i don't have another way to do it, cause i have to use a payload parser to receive a variable on payload, and after that create an action to get the other results that i need, and create another variables to send to dashboards.