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 and currency_conversion for refunds analytics #6419

Merged
merged 8 commits into from
Nov 14, 2024

Conversation

maverox
Copy link
Contributor

@maverox maverox commented Oct 23, 2024

Type of Change

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

Description

  • Add sessionized metrics module and implement backwards compatibility.
  • Implement currency conversion for refunds analytics

Minor unrelated changes

  • refactor inconsistent naming of fields in some places => commit
  • fix sankey incorrect formula => commit

Fixes #6417

Additional Changes

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

Motivation and Context

  • Refund metrics didn't had a sessionized_metrics module and implementation as were there in payments and payment_intents metrics
  • Refund metrics weren't implementing currency conversion.

How did you test it?

curl --location 'http://localhost:8080/analytics/v1/org/metrics/refunds' \
--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.eyJ1c2VyX2lkIjoiMDZlOGRmZWYtMzI0Zi00Yjc0LTg2MTItYzdkZjNhOGZmZTcyIiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzI3NDM0NTkzIiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTczMTA4ODY3NSwib3JnX2lkIjoib3JnXzl3Y0kxQ2hTOGVEdnRRQmRXak9IIiwicHJvZmlsZV9pZCI6InByb19FNW5lek43YjZUbVB1WlUzbEU1VSJ9.S0OBbdBmFjnRC-1hP-QTVA2fzQESHIvou_8dtmFDCgY' \
--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-10-15T18:30:00Z",
            "endTime": "2024-11-07T09:30:00Z"
        },
        "mode": "ORDER",
        "source": "BATCH",
        "metrics": [       
            "sessionized_refund_processed_amount"
        ],
        "delta": true
    }
]'
Screenshot 2024-11-07 at 2 56 08 PM

For sankey changes

curl --location 'http://localhost:8080/analytics/v1/profile/metrics/sankey' \
--header 'accept: */*' \
--header 'accept-language: en-US,en;q=0.9' \
--header 'api-key: dev_r3kVZ4URj3fMiHhJJuhHOVqteaXwKyEMGCaFo6PiCS6S9vZsb0ErV4kCVqogM60H' \
--header 'authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiMDZlOGRmZWYtMzI0Zi00Yjc0LTg2MTItYzdkZjNhOGZmZTcyIiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzI3NDM0NTkzIiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTczMTA4ODY3NSwib3JnX2lkIjoib3JnXzl3Y0kxQ2hTOGVEdnRRQmRXak9IIiwicHJvZmlsZV9pZCI6InByb19FNW5lek43YjZUbVB1WlUzbEU1VSJ9.S0OBbdBmFjnRC-1hP-QTVA2fzQESHIvou_8dtmFDCgY' \
--header 'content-type: application/json' \
--header 'origin: https://integ.hyperswitch.io' \
--header 'priority: u=1, i' \
--header 'referer: https://integ.hyperswitch.io/dashboard/new-analytics-payment' \
--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"' \
--header 'sec-fetch-dest: empty' \
--header 'sec-fetch-mode: cors' \
--header 'sec-fetch-site: same-origin' \
--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' \
--data '{"startTime":"2024-10-30T18:30:00Z","endTime":"2024-11-08T11:16:00Z"}'
Screenshot 2024-11-08 at 3 03 12 PM

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

- extend api_models/src/analytics/refunds.rs
- extend metrics to include these enum variants
@maverox maverox requested a review from a team as a code owner October 23, 2024 19:59
@maverox maverox self-assigned this Oct 23, 2024
@maverox maverox added C-feature Category: Feature request or enhancement C-refactor Category: Refactor A-Analytics Rust Pull requests that update Rust code labels Oct 23, 2024
tsdk02
tsdk02 previously approved these changes Oct 25, 2024
@maverox maverox requested a review from lsampras October 26, 2024 19:22
@maverox maverox changed the title feat(analytics): add sessionized_metrics for refunds analytics feat(analytics): add sessionized_metrics and currency_conversion for refunds analytics Nov 7, 2024
@maverox maverox removed the request for review from lsampras November 7, 2024 13:36
@likhinbopanna likhinbopanna added this pull request to the merge queue Nov 14, 2024
Merged via the queue into main with commit afd7f7d Nov 14, 2024
40 of 41 checks passed
@likhinbopanna likhinbopanna deleted the sessionized-refund-back-compat branch November 14, 2024 09:13
bsayak03 pushed a commit that referenced this pull request Nov 26, 2024
…for refunds analytics (#6419)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
bsayak03 pushed a commit that referenced this pull request Nov 26, 2024
…for refunds analytics (#6419)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
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 refunds (backwards compatibility) and currency_conversion
4 participants