Track Telesign SMS delivery failure event
What does this MR do and why?
Implements https://gitlab.com/gitlab-org/modelops/anti-abuse/team-tasks/-/issues/468.
Context: we use Telesign to send phone number verification code to users through SMS.
This MR adds Snowplow tracking for Telesign SMS delivery failure events so we can track the delivery error rate. Country code and status are added as extra data so we can analyze error rate by country and failure reason.
Database changes
Users::PhoneNumberValidation
telesign_reference_xid
column
1. Add index on
Users::PhoneNumberValidation.by_reference_id
scope
2. Raw SQL:
SELECT
"user_phone_number_validations"."user_id",
"user_phone_number_validations"."validated_at",
"user_phone_number_validations"."created_at",
"user_phone_number_validations"."updated_at",
"user_phone_number_validations"."international_dial_code",
"user_phone_number_validations"."risk_score",
"user_phone_number_validations"."country",
"user_phone_number_validations"."phone_number",
"user_phone_number_validations"."telesign_reference_xid"
FROM
"user_phone_number_validations"
WHERE
"user_phone_number_validations"."telesign_reference_xid" = '262D2B00EB44080491901EFD3A82446B'
LIMIT 1
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
- Setup Snowplow Micro
- Setup Telesign
$ rails c > ApplicationSetting.first.update(telesign_customer_xid: 'test_cust_id', telesign_api_key: 'test_api_key')
- Create a test
Users::PhoneNumberValidation
record$ rails c > FactoryBot.create(:phone_number_validation, telesign_reference_xid: '2557312299CC1304904080F4BE17BFB4')
- Send a test callback request
$ curl -X POST http://localhost:3000/-/phone_verification/telesign_callback -H 'Authorization: TSA test_cust_id:edBpPk9ZCt3N+Z0+2EaW6MZPn9DnbRo3smDbVhH9A1E=' -H 'Content-Type: application/json' -d '{ "status": { "updated_on": "2016-07-08T20:52:46.417428Z", "code": "207", "description": "Error delivering SMS to handset (reason unknown)" }, "errors": {}, "reference_id": "2557312299CC1304904080F4BE17BFB4" }'
- Validate that the event is tracked in Snowplow Micro (http://localhost:9090/micro/good)
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Eugie Limpin