Skip to content
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

Add phone number as identifier #2186

Merged
merged 9 commits into from
Aug 12, 2024
Merged

Add phone number as identifier #2186

merged 9 commits into from
Aug 12, 2024

Conversation

harsh-joshi99
Copy link
Contributor

@harsh-joshi99 harsh-joshi99 commented Jul 17, 2024

Add phone number as identifier in add profile to list, remove profile from list and remove profile actions.

JIRA -> STRATCONN-3866

Testing

Tested successfully in local and staging env.
Testing doc -> https://docs.google.com/document/d/1tlUdTiNfkiXF86yvW2faTpV8UGjI4sVzOqQ_2mzak0g/edit?usp=sharing

Add to list
Screenshot 2024-07-25 at 10 04 25 AM

Screenshot 2024-07-24 at 4 55 37 PM

Remove Profile
Screenshot 2024-07-25 at 11 21 38 AM

Screenshot 2024-07-25 at 11 20 42 AM Screenshot 2024-07-25 at 11 21 11 AM

Include any additional information about the testing you have completed to
ensure your changes behave as expected. For a speedy review, please check
any of the tasks you completed below during your testing.

  • Added unit tests for new functionality
  • Tested end-to-end using the local server
  • [Segmenters] Tested in the staging environment

Copy link
Contributor

@varadarajan-tw varadarajan-tw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Left a few questions. Nothing major.

@@ -5,6 +5,10 @@ export interface Payload {
* The user's email to send to Klavio.
*/
email?: string
/**
* Individual's phone number in E.164 format. If SMS is not enabled and if you use Phone Number as identifier, then you have to provide one of Email or External ID.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would Klaviyo throw an error if the phone number is not E.164 format?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should do a validation on our end? Would Klaviyo reject the entire batch if one event fails E.164 check?

@@ -163,17 +166,26 @@ export async function getProfiles(
const response = await request(`${API_URL}/profiles/?filter=any(${filterId})`, {
method: 'GET'
})
const data: GetProfileResponse = await response.json()
profileIds.push(...data.data.map((profile: Profile) => profile.id))
const res: GetProfileResponse = await response.json()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi - you could actually use response.data directly to get parsed JSON object. No need to run await response.json() again. This is an inbuilt feature of our RequestClient.

image

Copy link
Contributor

@varadarajan-tw varadarajan-tw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks very good. Test doc also looks very good.

Comment on lines 301 to 304
if (profile.phone_number && !validatePhoneNumber(profile.phone_number)) {
return false
}
return profile.email || profile.phone_number || profile.external_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a nit: you could probably do something like this and move the undefined check to validatePhoneNumber

Suggested change
if (profile.phone_number && !validatePhoneNumber(profile.phone_number)) {
return false
}
return profile.email || profile.phone_number || profile.external_id
return profile.email || validatePhoneNumber(profile.phone_number) || profile.external_id

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will keep the profiles which have invalid phone number but also has either email or external_id, we want to filter those out as well since Klaviyo will throw error for those too.

@joe-ayoub-segment joe-ayoub-segment merged commit bf3713d into main Aug 12, 2024
11 checks passed
@joe-ayoub-segment joe-ayoub-segment deleted the STRATCONN-3866 branch August 12, 2024 13:48
@joe-ayoub-segment
Copy link
Contributor

hi @harsh-joshi99 this PR has been deployed.

sayan-das-in pushed a commit that referenced this pull request Aug 15, 2024
* Add phone number as identifier in add profile to list and remove profile from list

* add phone number for remove profile action

* Update snapshot

* Update tests

* Fix test descriptions

* Add E.164 validation in all actions, update test cases, update snapshots

* Revert non engage actions changes to original state (splitting large PR)

* Add removeProfile actions changes

* Update snapshots
harsh-joshi99 added a commit that referenced this pull request Aug 16, 2024
* Add phone number as identifier in add profile to list and remove profile from list

* add phone number for remove profile action

* Update snapshot

* Update tests

* Fix test descriptions

* Add E.164 validation in all actions, update test cases, update snapshots

* Revert non engage actions changes to original state (splitting large PR)

* Add removeProfile actions changes

* Update snapshots
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants