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

Missing Advertiser Tracking Enabled Flag even though it is set though setAdvertiserTrackingEnabled #251

Closed jcurlier closed 1 year ago

jcurlier commented 1 year ago

Steps/Sample code to reproduce the issue

Creating a ServerEvent and sending it with the API

Dump of the server event

{
  "_custom_data": {
     "_content_type": "product",
     "_currency": "USD",
     "_contents": [
        {
          "_id": "plan_FSFCkVrTS1sD3k",
          "_quantity": 1
        }
    ],
    "_value": 59.99
  },
  "_event_id": "1687437125049",
  "_event_name": "Subscribe",
  "_advertiser_tracking_enabled": true,
  "_event_time": 1687437125,
  "_action_source": "app",
  "_data_processing_options": [],
  "_user_data": {
    ....
   }
}

Sending

  const data = [serverEvent];
  const eventRequest = new EventRequest(PIXEL_ACCESS_TOKEN, PIXEL_ID).setEvents(data);
  const response = await eventRequest.execute();

Observed Results:

Did not send 'Subscribe' pixel event: FacebookRequestError: Missing Advertiser Tracking Enabled Flag: The parameter 'advertiser_tracking_enabled' is required for the event with the action source 'app' (each set to either 0 or 1). Apps should expose an opportunity for users to opt-out of ad tracking, resulting in the setting of the 'advertiser_tracking_enabled' parameter.

Expected Results:

jcurlier commented 1 year ago

Seems there is an issue with the getter:

    get advertiser_tracking_enabled() {
        return this._data_processing_options_country;
    }

Should be:

    get advertiser_tracking_enabled() {
        return this._advertiser_tracking_enabled;
    }

https://github.com/facebook/facebook-nodejs-business-sdk/blob/main/src/objects/serverside/server-event.js#L399

stcheng commented 1 year ago

closing this as the diff is merged