Skip to content

Track Telesign SMS delivery failure event

Eugie Limpin requested to merge el-track-failed-sms-delivery-event into master

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

1. Add index on Users::PhoneNumberValidation telesign_reference_xid column

Screenshot_2023-10-20_at_10.23.52_AM

2. Users::PhoneNumberValidation.by_reference_id scope

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
EXPLAIN: https://console.postgres.ai/shared/d3f90ce8-ac1e-4e33-b543-aac54887cc9d

Screenshot_2023-10-20_at_10.25.18_AM

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

  1. Setup Snowplow Micro
  2. Setup Telesign
    $ rails c
    > ApplicationSetting.first.update(telesign_customer_xid: 'test_cust_id', telesign_api_key: 'test_api_key')
  3. Create a test Users::PhoneNumberValidation record
    $ rails c
    > FactoryBot.create(:phone_number_validation, telesign_reference_xid: '2557312299CC1304904080F4BE17BFB4')
  4. 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" }'
  5. Validate that the event is tracked in Snowplow Micro (http://localhost:9090/micro/good) Screenshot_2023-10-19_at_11.12.43_AM

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Eugie Limpin

Merge request reports