juspay / hyperswitch

An open source payments switch written in Rust to make payments fast, reliable and affordable
https://hyperswitch.io/
Apache License 2.0
12.63k stars 1.36k forks source link

feat(analytics): add `sessionized_metrics` for disputes analytics #6573

Open maverox opened 1 week ago

maverox commented 1 week ago

Type of Change

Description

Motivation and Context

How did you test it?

curl --location 'http://localhost:8080/analytics/v1/org/metrics/disputes' \
--header 'Accept: */*' \
--header 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
--header 'Connection: keep-alive' \
--header 'Content-Type: application/json' \
--header 'Origin: http://localhost:9000' \
--header 'QueryType: SingleStat' \
--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/130.0.0.0 Safari/537.36' \
--header 'api-key: dev_r3kVZ4URj3fMiHhJJuhHOVqteaXwKyEMGCaFo6PiCS6S9vZsb0ErV4kCVqogM60H' \
--header 'authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiMDZlOGRmZWYtMzI0Zi00Yjc0LTg2MTItYzdkZjNhOGZmZTcyIiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzI3NDM0NTkzIiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTczMTY1MTcyMCwib3JnX2lkIjoib3JnXzl3Y0kxQ2hTOGVEdnRRQmRXak9IIiwicHJvZmlsZV9pZCI6InByb19FNW5lek43YjZUbVB1WlUzbEU1VSJ9.gtctUL339INfdj6CVmZLW2NDMNcseMTCPX0uxSsOD1c' \
--header 'sec-ch-ua: "Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "macOS"' \
--data '[
    {
        "timeRange": {
            "startTime": "2024-11-06T18:30:00Z",
            "endTime": "2024-11-14T10:51:00Z"
        },
        "mode": "ORDER",
        "source": "BATCH",
        "metrics": [
            "dispute_status_metric",
            "total_amount_disputed",
            "total_dispute_lost_amount",
            "sessionized_dispute_status_metric",
            "sessionized_total_amount_disputed",
            "sessionized_total_dispute_lost_amount"
        ],
        "delta": true
    }
]'
Screenshot 2024-11-14 at 6 14 32 PM

Result: Earlier it used to throw 5xx for sessionized metrics but here it's giving us 200 for both metrics.

Checklist

semanticdiff-com[bot] commented 1 week ago

Review changes with  SemanticDiff

Changed Files
| File | Status | | :--- | :--- | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/core.rs)  [crates/analytics/src/disputes/core\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/core.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/core.rs)  50% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/clickhouse.rs)  [crates/analytics/src/clickhouse\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/clickhouse.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/clickhouse.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/accumulators.rs)  [crates/analytics/src/disputes/accumulators\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/accumulators.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/accumulators.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/metrics.rs)  [crates/analytics/src/disputes/metrics\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/metrics.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/metrics.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/metrics/sessionized_metrics/dispute_status_metric.rs)  [crates/analytics/src/disputes/metrics/sessionized\_metrics/dispute\_status\_metric\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/metrics/sessionized_metrics/dispute_status_metric.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/metrics/sessionized_metrics/dispute_status_metric.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/metrics/sessionized_metrics/mod.rs)  [crates/analytics/src/disputes/metrics/sessionized\_metrics/mod\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/metrics/sessionized_metrics/mod.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/metrics/sessionized_metrics/mod.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/metrics/sessionized_metrics/total_amount_disputed.rs)  [crates/analytics/src/disputes/metrics/sessionized\_metrics/total\_amount\_disputed\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/metrics/sessionized_metrics/total_amount_disputed.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/metrics/sessionized_metrics/total_amount_disputed.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/metrics/sessionized_metrics/total_dispute_lost_amount.rs)  [crates/analytics/src/disputes/metrics/sessionized\_metrics/total\_dispute\_lost\_amount\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/metrics/sessionized_metrics/total_dispute_lost_amount.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/disputes/metrics/sessionized_metrics/total_dispute_lost_amount.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/sqlx.rs)  [crates/analytics/src/sqlx\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/sqlx.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/sqlx.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/types.rs)  [crates/analytics/src/types\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/types.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/analytics/src/types.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/api_models/src/analytics.rs)  [crates/api\_models/src/analytics\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/api_models/src/analytics.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/api_models/src/analytics.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/api_models/src/analytics/disputes.rs)  [crates/api\_models/src/analytics/disputes\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/api_models/src/analytics/disputes.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/api_models/src/analytics/disputes.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/api_models/src/events.rs)  [crates/api\_models/src/events\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/api_models/src/events.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6573/changes#crates/api_models/src/events.rs)  0% smaller |