mailchimp / Firebase

IO-4458: product partnerships team
Apache License 2.0
20 stars 18 forks source link

mergeFieldsHandler does not sync values #71

Closed manuelperez96 closed 1 year ago

manuelperez96 commented 1 year ago

Hi,

I'm trying to configure the Mailchimp extension for firebase, but I can't do that it sync 2 or more values. With one value, it works well.

This is the configuration that I have in Firebase Merge Fields Config section: { "mergeFields": { "name": "FNAME", "sur-name": "LNAME" }, "subscriberEmail": "email" }

I have the corresponding fields in both, firebase and mailchimp, but it does not sync data. But if I remove sur-name field, it does sync the name.

In console log I see this message, but I don't know if it relevant:

Error [ParserError]: Unexpected token type: Number, value: NaN
    at Parser.parse (/workspace/node_modules/jmespath/jmespath.js:513:27)
    at Object.search (/workspace/node_modules/jmespath/jmespath.js:1664:25)
    at /workspace/index.js:241:46
    at Array.reduce (<anonymous>)
    at /workspace/index.js:238:81
    at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:78:23)
    at /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/function_wrappers.js:141:25
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

If you need more info, please, tell me.

barticus commented 1 year ago

Hi @manuelperez96 , this is a quirk of JMESpath. Can you try enclosing your sur-name field in quotes, e.g.

{ "mergeFields": { "name": "FNAME", "\"sur-name\"": "LNAME" }, "subscriberEmail": "email" }

Let me know how that goes!

manuelperez96 commented 1 year ago

Hi @manuelperez96 , this is a quirk of JMESpath. Can you try enclosing your sur-name field in quotes, e.g.

{ "mergeFields": { "name": "FNAME", "\"sur-name\"": "LNAME" }, "subscriberEmail": "email" }

Let me know how that goes!

Hi, thank you for respond me.

You have post "\"sur-name\"", but it could be "\"sur-name"\"?

I've a new error message now:

Error [ParserError]: Unexpected token type: Number, value: NaN
    at Parser.parse (/workspace/node_modules/jmespath/jmespath.js:513:27)
    at Object.search (/workspace/node_modules/jmespath/jmespath.js:1664:25)
    at /workspace/index.js:241:46
    at Array.reduce (<anonymous>)
    at /workspace/index.js:238:81
    at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:78:23)
    at /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/function_wrappers.js:141:25
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

I don't understand what is de problem. I think I've the correct syntax... I tried to change from "sur-name" to surname and it stll doesn't update the data.

barticus commented 1 year ago

Hi @manuelperez96 , No, it should be "\"sur-name\"". We are trying to put the string "sur-name" inside quotes, so those inner ones need escaping, not the outer ones. That looks like the same error you posted earlier.

Changing the field name to surname should work, please post the error you receive there.

manuelperez96 commented 1 year ago

Man, you saved my life!!!

Yeah, it looks like to work with "\"sur-name\"". I'm going to do more tests to be sure, but at least with sur-name it's worked!!!

Thank you so much!!!

manuelperez96 commented 1 year ago

Hi, again. Excuse me for reopen the issue again.

Your solution works for me, but I've another problem now.

I've the following configuration:

{
    "mergeFields": {
        "name": {
            "mailchimpFieldName": "FNAME",
            "when": "always"
        },
        "\"sur-name\"": {
            "mailchimpFieldName": "LNAME",
            "when": "always"
        },
        "address.address": {
            "mailchimpFieldName": "ADDRESS",
            "when": "always"
        },
        "\"mobile-phone\"": {
            "mailchimpFieldName": "PHONE",
            "when": "always"
        }
    },
    "subscriberEmail": "email"
}

The field address is not sending to mailchimp. My field address in firebase is a map with the following format:

address{
    "address":"address name",
    "geohash":"geohash position",
    "latituded":"23423",
    "logintuded":"sdfwe"
}

I supposed that to get the address name, I should do something like "address.address" to get the inner value of the map, but it doesn't seem to work.

Any idea about how to do it works?

Thank you so much.

barticus commented 1 year ago

Hi @manuelperez96 , Yes, address.address should get that inner field. Can you confirm in Mailchimp that you have the ADDRESS merge field set to visible? Alternatively, you can try with the other merge field name listed under "Put this tag in your content:" for Address (e.g. in the below, I can use ADDRESS or MERGE3).

image
barticus commented 1 year ago

Ah, actually, this is more likely related to the type of address (see here).

address: a JSON object with the required keys addr1, city, state, and zip, and the optional keys addr2 and country. Values for these fields must be strings.

If you only need a single line of text, I would add a new merge field (e.g. customAddress) and then point to that merge field ID (as listed under "Put this tag in your content:"). This plugin does not currently support compiling nested fields, which would be needed to send a full address type.