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

feat(analytics): remove additional filters from PaymentIntentFilters #6407

Merged

Conversation

tsdk02
Copy link
Contributor

@tsdk02 tsdk02 commented Oct 23, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

Hotfix PR for: #6403

  • Additional filters are added to PaymentIntentFilters as new analytics APIs are expected to be calculated from Sessionizer Payment Intents table.

  • Existing metrics on current dashboard are breaking due to these new filters as the fields are not present in the Payment Intents table.

Removed the following additional filters from PaymentIntentFilters

  • connector
  • authentication_type
  • payment_method
  • payment_method_type
  • card_network
  • merchant_id
  • card_last_4
  • card_issuer
  • error_reason

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

Closes: https://github.com/juspay/hyperswitch/issues/6404
Dashboard is raising error (status_code - 500) when payment intent based analytics APIs ae being hit, due to filter fields not present in the payment intents table.

How did you test it?

Added filters of connector, payment_method, etc on the dashboard and the payments v2 APIs should not return 500 error.

  • Hit the curl:
curl --location 'http://localhost:8080/analytics/v2/org/metrics/payments' \
--header 'Accept: */*' \
--header 'Accept-Language: en-US,en;q=0.9' \
--header 'Connection: keep-alive' \
--header 'Content-Type: application/json' \
--header 'Origin: http://localhost:9000' \
--header 'QueryType: SingleStatTimeseries' \
--header 'Referer: http://localhost:9000/' \
--header 'Sec-Fetch-Dest: empty' \
--header 'Sec-Fetch-Mode: cors' \
--header 'Sec-Fetch-Site: same-site' \
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36' \
--header 'api-key: snd_ug3Xjm7pNJ6u3SeC5jQCApLIPr6NdDppvEKht091zd62EJJ0pWF6KziALr0yQEuF' \
--header 'authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiNTQ5ZTNkMmItMTY5Yi00NzUzLWJmNTQtZDcxMTM2YjRiN2JkIiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzI2MDQ2MzI4Iiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTcyOTc0ODc1Mywib3JnX2lkIjoib3JnX1ZwU0hPanNZZkR2YWJWWUpnQ0FKIiwicHJvZmlsZV9pZCI6InByb192NXNGb0hlODBPZWlVbElvbm9jTSJ9.-NHlfMrAjUDwjMpCo9PAn86koRkkPMBygNfCTh2jiTw' \
--header 'sec-ch-ua: "Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "macOS"' \
--data '[
    {
        "timeRange": {
            "startTime": "2024-10-14T18:30:00Z",
            "endTime": "2024-10-22T15:24:00Z"
        },
        "groupByNames": [
            "currency"
        ],
        "filters": {
            "connector": [
                "stripe_test"
            ]
        },
        "timeSeries": {
            "granularity": "G_ONEDAY"
        },
        "mode": "ORDER",
        "source": "BATCH",
        "metrics": [
            "successful_smart_retries",
            "total_smart_retries",
            "smart_retried_amount"
        ]
    }
]'
  • Response:
{
    "queryData": [
        {
            "successful_smart_retries": 1,
            "total_smart_retries": 1,
            "smart_retried_amount": 6540,
            "smart_retried_amount_without_smart_retries": 0,
            "payment_intent_count": null,
            "successful_payments": null,
            "successful_payments_without_smart_retries": null,
            "total_payments": null,
            "payments_success_rate": null,
            "payments_success_rate_without_smart_retries": null,
            "payment_processed_amount": 0,
            "payment_processed_count": null,
            "payment_processed_amount_without_smart_retries": 0,
            "payment_processed_count_without_smart_retries": null,
            "payments_success_rate_distribution_without_smart_retries": null,
            "payments_failure_rate_distribution_without_smart_retries": null,
            "status": null,
            "currency": "USD",
            "profile_id": null,
            "time_range": {
                "start_time": "2024-10-18T00:00:00.000Z",
                "end_time": "2024-10-18T23:00:00.000Z"
            },
            "time_bucket": "2024-10-18 00:00:00"
        }
    ],
    "metaData": [
        {
            "total_success_rate": null,
            "total_success_rate_without_smart_retries": null,
            "total_smart_retried_amount": 6540,
            "total_smart_retried_amount_without_smart_retries": 0,
            "total_payment_processed_amount": 0,
            "total_payment_processed_amount_without_smart_retries": 0,
            "total_payment_processed_count": 0,
            "total_payment_processed_count_without_smart_retries": 0
        }
    ]
}

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@tsdk02 tsdk02 self-assigned this Oct 23, 2024
@tsdk02 tsdk02 requested a review from a team as a code owner October 23, 2024 07:54
Copy link

semanticdiff-com bot commented Oct 23, 2024

Review changes with SemanticDiff.

Analyzed 19 of 19 files.

Overall, the semantic diff is 1% smaller than the GitHub diff.

Filename Status
✔️ crates/api_models/src/analytics/payment_intents.rs 4.92% smaller
✔️ crates/analytics/src/sqlx.rs Analyzed
✔️ crates/analytics/src/utils.rs Analyzed
✔️ crates/analytics/src/payment_intents/core.rs Analyzed
✔️ crates/analytics/src/payment_intents/filters.rs 0.15% smaller
✔️ crates/analytics/src/payment_intents/metrics.rs Analyzed
✔️ crates/analytics/src/payment_intents/types.rs Analyzed
✔️ crates/analytics/src/payment_intents/metrics/payment_intent_count.rs Analyzed
✔️ crates/analytics/src/payment_intents/metrics/payments_success_rate.rs Analyzed
✔️ crates/analytics/src/payment_intents/metrics/smart_retried_amount.rs Analyzed
✔️ crates/analytics/src/payment_intents/metrics/successful_smart_retries.rs Analyzed
✔️ crates/analytics/src/payment_intents/metrics/total_smart_retries.rs Analyzed
✔️ crates/analytics/src/payment_intents/metrics/sessionized_metrics/payment_intent_count.rs Analyzed
✔️ crates/analytics/src/payment_intents/metrics/sessionized_metrics/payment_processed_amount.rs Analyzed
✔️ crates/analytics/src/payment_intents/metrics/sessionized_metrics/payments_distribution.rs Analyzed
✔️ crates/analytics/src/payment_intents/metrics/sessionized_metrics/payments_success_rate.rs Analyzed
✔️ crates/analytics/src/payment_intents/metrics/sessionized_metrics/smart_retried_amount.rs Analyzed
✔️ crates/analytics/src/payment_intents/metrics/sessionized_metrics/successful_smart_retries.rs Analyzed
✔️ crates/analytics/src/payment_intents/metrics/sessionized_metrics/total_smart_retries.rs Analyzed

@likhinbopanna likhinbopanna merged commit 838788b into hotfix-2024.10.18.0 Oct 23, 2024
45 of 48 checks passed
@likhinbopanna likhinbopanna deleted the remove-filters-payment-intents-hotfix branch October 23, 2024 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(analytics): remove additional filters from PaymentIntentFilters hotfix
4 participants