static callFBAEventsAPI()

in loginconnect_directintegrator/services/graph-api.js [308:341]


  static callFBAEventsAPI(senderPsid, eventName) {
    // Construct the message body
    let requestBody = {
      event: "CUSTOM_APP_EVENTS",
      custom_events: JSON.stringify([
        {
          _eventName: "postback_payload",
          _value: eventName,
          _origin: "original_coast_clothing"
        }
      ]),
      advertiser_tracking_enabled: 1,
      application_tracking_enabled: 1,
      extinfo: JSON.stringify(["mb1"]),
      page_id: config.pageId,
      page_scoped_user_id: senderPsid
    };

    // Send the HTTP request to the Activities API
    request(
      {
        uri: `${config.mPlatfom}/${config.appId}/activities`,
        method: "POST",
        form: requestBody
      },
      error => {
        if (!error) {
          console.log(`FBA event '${eventName}'`);
        } else {
          console.error(`Unable to send FBA event '${eventName}':` + error);
        }
      }
    );
  }