Skip to content

Add WhatsApp Business Account ID to Conversions API User Data #306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion src/objects/serverside/user-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default class UserData {
_app_user_id: string;
_ctwa_clid: string;
_page_id: string;
_whatsapp_business_account_id: string;

/**
* @param {String} email An email address, in lowercase.
Expand Down Expand Up @@ -74,11 +75,12 @@ export default class UserData {
* @param {String} app_user_id
* @param {String} ctwa_clid ID of a conversation that was started on WhatsApp
* @param {String} page_id ID of the page that the ad is associated with
* @param {String} whatsapp_business_account_id WABA ID for a conversation that was started on WhatsApp.
*/
constructor(email: string, phone: string, gender: string, first_name: string, last_name: string, date_of_birth: string,
city: string, state: string, zip: string, country: string, external_id: string, client_ip_address: string, client_user_agent: string,
fbp: string, fbc: string, subscription_id: string, fb_login_id: string, lead_id: string, dobd: string, dobm: string, doby: string,
madid: string, anon_id: string, app_user_id: string, ctwa_clid: string, page_id: string) {
madid: string, anon_id: string, app_user_id: string, ctwa_clid: string, page_id: string, whatsapp_business_account_id: string) {
if (email != null) {
this._emails = new Array(email);
}
Expand Down Expand Up @@ -127,6 +129,7 @@ export default class UserData {
this._app_user_id = app_user_id;
this._ctwa_clid = ctwa_clid;
this._page_id = page_id;
this._whatsapp_business_account_id = whatsapp_business_account_id;
}

static get Gender(): Object {
Expand Down Expand Up @@ -1197,6 +1200,28 @@ export default class UserData {
return this;
}

/**
*
*/
get whatsapp_business_account_id () {
return this._whatsapp_business_account_id;
}

/**
*
*/
set whatsapp_business_account_id (whatsapp_business_account_id: string) {
this._whatsapp_business_account_id = whatsapp_business_account_id;
}

/**
*
*/
setWhatsappBusinessAccountId (whatsapp_business_account_id: string): UserData {
this._whatsapp_business_account_id = whatsapp_business_account_id;
return this;
}

/**
* Returns the normalized payload for the user_data parameter.
* @returns {Object} normalized user data payload.
Expand Down Expand Up @@ -1320,6 +1345,10 @@ export default class UserData {
userData['page_id'] = this.page_id;
}

if (this.whatsapp_business_account_id) {
userData['whatsapp_business_account_id'] = this.whatsapp_business_account_id;
}

return userData;
}

Expand Down