Skip to content

Conversation

tsdk02
Copy link
Contributor

@tsdk02 tsdk02 commented Mar 6, 2025

Type of Change

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

Description

Added support for filters and dimensions for authentication analytics.
Filters added:

  • AuthenticationConnector
  • MessageVersion

Dimensions added:

  • AuthenticationStatus,
  • TransactionStatus,
  • ErrorMessage,
  • AuthenticationConnector,
  • MessageVersion,

New metrics added:

  • AuthenticationErrorMessage
  • AuthenticationFunnel

Additional Changes

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

Motivation and Context

Get better insights into authentication data.

How did you test it?

Hit the curls:

AuthenticationErrorMessage:

curl --location 'http://localhost:8080/analytics/v1/metrics/auth_events' \
--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 '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/128.0.0.0 Safari/537.36' \
--header 'api-key: hyperswitch' \
--header 'authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiYWFiNWIxNDEtNjQwOC00YTUyLTk2MjMtNTVhNTgxMTU1M2U4IiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzQwNDE0OTA5Iiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTc0MTI3NDY4NSwib3JnX2lkIjoib3JnX1QwSEtYNHYyRGFRT2lHUDVwRk52IiwicHJvZmlsZV9pZCI6InByb19xOWc2ZW1xcGM3YjQxTG83VVhweCIsInRlbmFudF9pZCI6InB1YmxpYyJ9.LIExs1jjG6N5AFu5_S3oiuy77fWF0IbJmNGbK8HHLXI' \
--header 'sec-ch-ua: "Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "macOS"' \
--data '[
    {
        "timeRange": {
            "startTime": "2025-02-01T18:30:00Z",
            "endTime": "2025-02-28T09:22:00Z"
        },
        "source": "BATCH",
        "timeSeries": {
            "granularity": "G_ONEDAY"
        },
        "groupByNames": [
            "error_message"
        ],    
        "metrics": [
            "authentication_error_message"
        ],
        "delta": true
    }
]'

Sample Output:

{
    "queryData": [
        {
            "authentication_count": null,
            "authentication_attempt_count": null,
            "authentication_success_count": null,
            "challenge_flow_count": null,
            "challenge_attempt_count": null,
            "challenge_success_count": null,
            "frictionless_flow_count": null,
            "frictionless_success_count": null,
            "error_message_count": 1,
            "authentication_funnel": null,
            "authentication_status": null,
            "trans_status": null,
            "error_message": "Failed to authenticate",
            "authentication_connector": null,
            "message_version": null,
            "time_range": {
                "start_time": "2025-02-10T00:00:00.000Z",
                "end_time": "2025-02-10T23:00:00.000Z"
            },
            "time_bucket": "2025-02-10 00:00:00"
        },
        {
            "authentication_count": null,
            "authentication_attempt_count": null,
            "authentication_success_count": null,
            "challenge_flow_count": null,
            "challenge_attempt_count": null,
            "challenge_success_count": null,
            "frictionless_flow_count": null,
            "frictionless_success_count": null,
            "error_message_count": 1,
            "authentication_funnel": null,
            "authentication_status": null,
            "trans_status": null,
            "error_message": "Something went wrong",
            "authentication_connector": null,
            "message_version": null,
            "time_range": {
                "start_time": "2025-02-20T00:00:00.000Z",
                "end_time": "2025-02-20T23:00:00.000Z"
            },
            "time_bucket": "2025-02-20 00:00:00"
        }
    ],
    "metaData": [
        {
            "total_error_message_count": 2
        }
    ]
}

Authentication Funnel:

curl --location 'http://localhost:8080/analytics/v1/metrics/auth_events' \
--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 '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/128.0.0.0 Safari/537.36' \
--header 'api-key: hyperswitch' \
--header 'authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiYWFiNWIxNDEtNjQwOC00YTUyLTk2MjMtNTVhNTgxMTU1M2U4IiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzQwNDE0OTA5Iiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTc0MTI3NDY4NSwib3JnX2lkIjoib3JnX1QwSEtYNHYyRGFRT2lHUDVwRk52IiwicHJvZmlsZV9pZCI6InByb19xOWc2ZW1xcGM3YjQxTG83VVhweCIsInRlbmFudF9pZCI6InB1YmxpYyJ9.LIExs1jjG6N5AFu5_S3oiuy77fWF0IbJmNGbK8HHLXI' \
--header 'sec-ch-ua: "Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "macOS"' \
--data '[
    {
        "timeRange": {
            "startTime": "2025-02-01T18:30:00Z",
            "endTime": "2025-02-28T09:22:00Z"
        },
        "source": "BATCH",
        "timeSeries": {
            "granularity": "G_ONEDAY"
        },   
        "filters": {
            "authentication_status": [
                "success", "failed"
            ]
        },
        "metrics": [
            "authentication_funnel"
        ],
        "delta": true
    }
]'

Sample Output:

{
    "queryData": [
        {
            "authentication_count": null,
            "authentication_attempt_count": null,
            "authentication_success_count": null,
            "challenge_flow_count": null,
            "challenge_attempt_count": null,
            "challenge_success_count": null,
            "frictionless_flow_count": null,
            "frictionless_success_count": null,
            "error_message_count": null,
            "authentication_funnel": 3,
            "authentication_status": null,
            "trans_status": null,
            "error_message": null,
            "authentication_connector": null,
            "message_version": null,
            "time_range": {
                "start_time": "2025-02-11T00:00:00.000Z",
                "end_time": "2025-02-11T23:00:00.000Z"
            },
            "time_bucket": "2025-02-11 00:00:00"
        },
        {
            "authentication_count": null,
            "authentication_attempt_count": null,
            "authentication_success_count": null,
            "challenge_flow_count": null,
            "challenge_attempt_count": null,
            "challenge_success_count": null,
            "frictionless_flow_count": null,
            "frictionless_success_count": null,
            "error_message_count": null,
            "authentication_funnel": 64,
            "authentication_status": null,
            "trans_status": null,
            "error_message": null,
            "authentication_connector": null,
            "message_version": null,
            "time_range": {
                "start_time": "2025-02-10T00:00:00.000Z",
                "end_time": "2025-02-10T23:00:00.000Z"
            },
            "time_bucket": "2025-02-10 00:00:00"
        },
        {
            "authentication_count": null,
            "authentication_attempt_count": null,
            "authentication_success_count": null,
            "challenge_flow_count": null,
            "challenge_attempt_count": null,
            "challenge_success_count": null,
            "frictionless_flow_count": null,
            "frictionless_success_count": null,
            "error_message_count": null,
            "authentication_funnel": 11,
            "authentication_status": null,
            "trans_status": null,
            "error_message": null,
            "authentication_connector": null,
            "message_version": null,
            "time_range": {
                "start_time": "2025-02-20T00:00:00.000Z",
                "end_time": "2025-02-20T23:00:00.000Z"
            },
            "time_bucket": "2025-02-20 00:00:00"
        }
    ],
    "metaData": [
        {
            "total_error_message_count": 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 added C-feature Category: Feature request or enhancement A-Analytics labels Mar 6, 2025
@tsdk02 tsdk02 self-assigned this Mar 6, 2025
@tsdk02 tsdk02 requested review from a team as code owners March 6, 2025 14:57
Copy link

semanticdiff-com bot commented Mar 6, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/analytics/src/lib.rs  59% smaller
  crates/analytics/src/auth_events/metrics.rs  52% smaller
  crates/analytics/src/query.rs  35% smaller
  crates/analytics/src/auth_events/metrics/authentication_attempt_count.rs  20% smaller
  crates/analytics/src/auth_events/metrics/authentication_count.rs  20% smaller
  crates/analytics/src/auth_events/metrics/authentication_success_count.rs  20% smaller
  crates/analytics/src/auth_events/metrics/challenge_attempt_count.rs  20% smaller
  crates/analytics/src/auth_events/metrics/challenge_flow_count.rs  20% smaller
  crates/analytics/src/auth_events/metrics/challenge_success_count.rs  20% smaller
  crates/analytics/src/auth_events/metrics/frictionless_flow_count.rs  20% smaller
  crates/analytics/src/auth_events/metrics/frictionless_success_count.rs  20% smaller
  crates/analytics/src/auth_events/core.rs  18% smaller
  crates/analytics/src/core.rs  12% smaller
  crates/api_models/src/analytics/auth_events.rs  12% smaller
  crates/router/src/analytics.rs  8% smaller
  crates/analytics/src/auth_events.rs  1% smaller
  crates/analytics/src/utils.rs  1% smaller
  crates/api_models/src/analytics.rs  1% smaller
  crates/analytics/src/auth_events/accumulator.rs  0% smaller
  crates/analytics/src/auth_events/filters.rs  0% smaller
  crates/analytics/src/auth_events/metrics/authentication_error_message.rs  0% smaller
  crates/analytics/src/auth_events/metrics/authentication_funnel.rs  0% smaller
  crates/analytics/src/auth_events/types.rs  0% smaller
  crates/analytics/src/clickhouse.rs  0% smaller
  crates/analytics/src/sqlx.rs  0% smaller
  crates/api_models/src/events.rs  0% smaller
  crates/common_enums/src/enums.rs  0% smaller

ShankarSinghC
ShankarSinghC previously approved these changes Mar 6, 2025
@tsdk02 tsdk02 requested a review from maverox March 6, 2025 15:02
@tsdk02 tsdk02 requested a review from ShankarSinghC March 6, 2025 15:51
@likhinbopanna likhinbopanna enabled auto-merge March 6, 2025 15:58
@likhinbopanna likhinbopanna added this pull request to the merge queue Mar 6, 2025
Merged via the queue into main with commit 7473182 Mar 6, 2025
14 of 20 checks passed
@likhinbopanna likhinbopanna deleted the authentication-analytics-latest branch March 6, 2025 16:53
tsdk02 added a commit that referenced this pull request Mar 6, 2025
pixincreate added a commit that referenced this pull request Mar 7, 2025
* 'main' of github.com:juspay/hyperswitch:
  feat(hipay): Add Template PR (#7360)
  chore(version): 2025.03.07.0
  chore(postman): update Postman collection files
  feat(analytics): add new filters, dimensions and metrics for authentication analytics (#7451)
  feat(router): add capability to force challenge for 3DS Payments through Netcetera and send few optional fields (#7429)
  feat(analytics): refactor and rewrite authentication related analytics (#7433)
  refactor(core): Added payment id in authentication router data (#7441)
  feat(connector): Added ThreeDs server integration template pr (#7424)
  fix(xendit): Fix wasm changes (#7419)
  chore(postman): postman tests fixes (#7159)
  ci(cypress): move customer acceptance in configs to a const within commons (#7435)
  feat(core): add additional revenue recovery call flow (#7402)
  chore(version): 2025.03.06.0
  feat(payment_link): expose payment link configs for SDK UI rules and payment button (#7427)
pixincreate added a commit that referenced this pull request Mar 7, 2025
…juspay/hyperswitch into connector/gpay-mandates-authorizedotnet

* 'connector/gpay-mandates-authorizedotnet' of github.com:juspay/hyperswitch: (25 commits)
  ci(cypress): address lints and refactor redirection handler (#7437)
  chore: make v1 merchant account forward compatible (#7426)
  fix(dashboard): Added auth key to juspay threeds server (#7457)
  feat(hipay): Add Template PR (#7360)
  chore(version): 2025.03.07.0
  chore(postman): update Postman collection files
  feat(analytics): add new filters, dimensions and metrics for authentication analytics (#7451)
  feat(router): add capability to force challenge for 3DS Payments through Netcetera and send few optional fields (#7429)
  feat(analytics): refactor and rewrite authentication related analytics (#7433)
  refactor(core): Added payment id in authentication router data (#7441)
  feat(connector): Added ThreeDs server integration template pr (#7424)
  fix(xendit): Fix wasm changes (#7419)
  chore(postman): postman tests fixes (#7159)
  ci(cypress): move customer acceptance in configs to a const within commons (#7435)
  feat(core): add additional revenue recovery call flow (#7402)
  chore(version): 2025.03.06.0
  feat(payment_link): expose payment link configs for SDK UI rules and payment button (#7427)
  feat(connector): [EFT] Add EFT as a payment method (#7304)
  chore(version): 2025.03.05.1
  feat(connector): [Moneris] Implement mandate for Moneris (#7322)
  ...
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(analytics): add new filters, dimensions and metrics for authentication analytics
4 participants