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): add sessionized_metrics for disputes analytics #6573

Merged
merged 6 commits into from
Nov 26, 2024

Conversation

maverox
Copy link
Contributor

@maverox maverox commented Nov 14, 2024

Type of Change

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

Description

  • Add sessionized metrics module and implement backwards compatibility.
  • Add the sessionizer_dispute table support for Sessionized metrics.

Fixes #6572

Additional Changes

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

Motivation and Context

  • Dispute metrics didn't have a sessionized_metrics module and implementation as were there in payments and payment_intents metrics

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"
        ],
        "delta": true
    }
]'
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": [
            "sessionized_dispute_status_metric",
            "sessionized_total_amount_disputed",
            "sessionized_total_dispute_lost_amount"
        ],
        "delta": true
    }
]'
Screenshot 2024-11-14 at 6 14 32 PM 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

  • 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

@maverox maverox requested a review from a team as a code owner November 14, 2024 12:49
@maverox maverox self-assigned this Nov 14, 2024
@maverox maverox added C-feature Category: Feature request or enhancement C-refactor Category: Refactor Rust Pull requests that update Rust code A-Analytics labels Nov 14, 2024
@likhinbopanna likhinbopanna added this pull request to the merge queue Nov 26, 2024
Merged via the queue into main with commit 8fbb766 Nov 26, 2024
15 of 17 checks passed
@likhinbopanna likhinbopanna deleted the sessionized_dispute_back_compat branch November 26, 2024 13:58
pixincreate added a commit that referenced this pull request Nov 27, 2024
…ed-cypress

* 'main' of github.com:juspay/hyperswitch:
  chore(version): 2024.11.27.0
  fix(core): add payment_id as query param in merchant return url (#6665)
  feat(connector): [Netcetera] add sca exemption (#6611)
  feat(payments): propagate additional payment method data for google pay during MIT (#6644)
  feat: Added grpc based health check (#6441)
  feat(analytics): add `sessionized_metrics` for disputes analytics (#6573)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Analytics C-feature Category: Feature request or enhancement C-refactor Category: Refactor Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(analytics): add sessionized_metrics for disputes (backwards compatibility)
4 participants