facebook / facebook-nodejs-business-sdk

Node.js SDK for Meta Marketing APIs
https://developers.facebook.com/docs/business-sdk
Other
489 stars 226 forks source link

Server Side Api Parameter Error: Unexpected key "advertiser_tracking_enabled" #258

Closed jcurlier closed 6 months ago

jcurlier commented 1 year ago

Which SDK version are you using?

17.0.2

What's the issue?

I am getting the following error Server Side Api Parameter Error: Unexpected key "advertiser_tracking_enabled" on param "$['data'][0]"." method: "POST" when sending an event with action source = 'app' and advertiser tracking enabled set.

Steps/Sample code to reproduce the issue

  if (actionSource === 'app') {
    // whether the user has opted into/out of advertiser tracking on apps.
    // @see https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager/authorizationstatus/
    // 3: the user authorizes access to app-related data for tracking the user or the device
    // The parameter 'advertiser_tracking_enabled' is required for the event with the action source 'app'
    serverEvent.setAdvertiserTrackingEnabled(advertiserTrackingEnabled);
  }

Observed Results:

I am getting the following error Server Side Api Parameter Error: Unexpected key "advertiser_tracking_enabled" on param "$['data'][0]"." method: "POST"

Expected Results:

The event should be sent without errors.

Investigation

For one instance, the following event is sent:

{
        "access_token": "EAiXJC4bAK",
        "test_event_code": null,
        "upload_tag": null,
        "upload_source": null,
        "partner_agent": null,
        "data": [
          {
            "advertiser_tracking_enabled": false,
            "event_id": "l8oOfFtjOxRuWBJOBLs2sKlINZ93.1691538913886",
            "event_name": "Subscribe",
            "action_source": "app",
            "data_processing_options": [],
            "custom_data": {
              "contents": [
                {
                  "id": "plan_FSFCkVrTS1sD3k",
                  "quantity": 1
                }
              ],
              "content_type": "product",
              "value": 59.99,
              "currency": "usd"
            },
            "user_data": {
              "subscription_id": "sub_1N",
              "ge": [
                "252f10c836"
              ],
              "external_id": [
                "l8oOfF"
              ],
              "country": [
                "79adb2a2"
              ],
              "fn": [
                "75117463"
              ],
              "em": [
                "7ab6eca8af8"
              ]
            },
            "event_time": 1691538913
          }
        ],
        "namespace_id": null,
        "upload_id": null,
        "id": "777428622613751"
      },

I believe (1) the advertiser_tracking_enabled flag should be set under app_data and (2) the value should be 0 or 1 according to the following documentation:

jcurlier commented 1 year ago

This is a follow up to the issue https://github.com/facebook/facebook-nodejs-business-sdk/issues/251 - both issues preventing setting advertiser_tracking_enabled

stcheng commented 1 year ago

Hi @jcurlier could you help file a bug here?

jcurlier commented 1 year ago

with the release 17.0.3, the error is now a FacebookRequestError

Error
    at FacebookRequestError.FacebookError [as constructor] (/home/app/node_modules/facebook-nodejs-business-sdk/dist/cjs.js:352:16)
    at new FacebookRequestError (/home/app/node_modules/facebook-nodejs-business-sdk/dist/cjs.js:374:129)
    at /home/app/node_modules/facebook-nodejs-business-sdk/dist/cjs.js:673:15
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

serverEvent:

_action_source: "app"
_advertiser_tracking_enabled: false
_custom_data: {
_content_type: "product"
_contents: [1]
_currency: "USD"
_value: 119.99
}
jcurlier commented 1 year ago

Created https://developers.facebook.com/support/bugs/1702578380246622/

logicappsource commented 8 months ago

Having the same issue here

saxo751 commented 7 months ago

Any update on this ? advertiser_tracking_enabled

saxo751 commented 6 months ago

IS this wrong implementation by me? . Node js I still receive error that the value is not provided


 const serverEvent_0 = new ServerEvent()
      .setEventName(FBEventName)
      .setEventSourceUrl(eventSourceUrl)
      .setEventTime(eventTime)
      .setUserData(userData)
      .setActionSource(actionSource);
    if (actionSource === 'app') {
      serverEvent_0.setAdvertiserTrackingEnabled(1); // or 1 0r 0
    }
stcheng commented 6 months ago

@saxo751 which version are you using? https://github.com/facebook/facebook-nodejs-business-sdk/pull/254/ this issue shall be resolved already.