Issue:
feat(analytics): refactor and introduce analytics APIs to accommodate OrgLevel, MerchantLevel and ProfileLevel authentication

## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [ ] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->
Cherry picked the commit for #5729

### Additional Changes

- [ ] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

<!--
Provide links to the files with corresponding changes.

Following are the paths where you can find config files:
1. `config`
2. `crates/router/src/configs`
3. `loadtest/config`
-->


## Motivation and Context
<!--
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.

If you don't have an issue, we'd recommend starting with one first so the PR
can focus on the implementation (unless it is an obvious bug or documentation fix
that will have little conversation).
-->


## How did you test it?
<!--
Did you write an integration/unit/API test to verify the code changes?
Or did you test this change manually (provide relevant screenshots)?
-->


## Checklist
<!-- Put an `x` in the boxes that apply -->

- [ ] 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


Resolution:
<think>
PR Context:
- Title: revert: feat(analytics): refactor and introduce analytics APIs to accommodate OrgLevel, MerchantLevel and ProfileLevel authentication
- Merged: 2024-09-05T11:19:25Z
- Files changed: 30 files
- Commits: 1 commits

Implementation approach:
Reverts juspay/hyperswitch#5784
</think>

To implement this, you'll need to modify:


**Detailed Implementation:**


**Commit 1:** revert: feat(analytics): refactor and introduce analytics APIs to accommodate OrgLevel, MerchantLeve
Files to modify:


**crates/analytics/src/api_event/core.rs**
  Modify existing code

**crates/analytics/src/api_event/filters.rs**
  Modify existing code

**crates/analytics/src/api_event/metrics.rs**
  Modify existing code

**crates/analytics/src/api_event/metrics/api_count.rs**
  Modify existing code

**crates/analytics/src/api_event/metrics/latency.rs**
  Modify existing code

**crates/analytics/src/api_event/metrics/status_code_count.rs**
  Modify existing code

**crates/analytics/src/clickhouse.rs**
  Modify existing code

**crates/analytics/src/disputes/core.rs**
  Modify existing code

**crates/analytics/src/disputes/filters.rs**
  Modify existing code

**crates/analytics/src/disputes/metrics.rs**
  Modify existing code

**crates/analytics/src/disputes/metrics/dispute_status_metric.rs**
  Modify existing code

**crates/analytics/src/disputes/metrics/total_amount_disputed.rs**
  Modify existing code

**crates/analytics/src/disputes/metrics/total_dispute_lost_amount.rs**
  Modify existing code

**crates/analytics/src/enums.rs**
  Modify existing code

**crates/analytics/src/errors.rs**
  Modify existing code

**crates/analytics/src/lib.rs**
  Remove:
    - mod: pub::active_payments
    - mod: pub::api_event
    - mod: pub::auth_events
    - mod: pub::connector_events
    - mod: pub::enums
    - mod: pub::health_check
    - mod: pub::opensearch
    - mod: pub::outgoing_webhook_event
  Add:
    - mod: pub::active_payments
    - mod: pub::api_event
    - mod: pub::auth_events
    - mod: pub::connector_events
    - mod: pub::health_check
    - mod: pub::opensearch
    - mod: pub::outgoing_webhook_event

**crates/analytics/src/outgoing_webhook_event/events.rs**
  Modify existing code

**crates/analytics/src/payment_intents/core.rs**
  Modify existing code

**crates/analytics/src/payment_intents/filters.rs**
  Modify existing code

**crates/analytics/src/payment_intents/metrics.rs**
  Modify existing code

**crates/analytics/src/payment_intents/metrics/payment_intent_count.rs**
  Modify existing code

**crates/analytics/src/payment_intents/metrics/smart_retried_amount.rs**
  Modify existing code

**crates/analytics/src/payment_intents/metrics/successful_smart_retries.rs**
  Modify existing code

**crates/analytics/src/payment_intents/metrics/total_smart_retries.rs**
  Modify existing code

**crates/analytics/src/payment_intents/types.rs**
  Modify existing code

**crates/analytics/src/payments/core.rs**
  Modify existing code

**crates/analytics/src/payments/distribution.rs**
  Modify existing code

**crates/analytics/src/payments/distribution/payment_error_message.rs**
  Modify existing code

**crates/analytics/src/payments/filters.rs**
  Remove:
    - struct: private::PaymentFilterRow
    - trait: pub::PaymentFilterAnalytics
  Add:
    - struct: private::FilterRow
    - trait: pub::PaymentFilterAnalytics

**crates/analytics/src/payments/metrics.rs**
  Modify existing code

**crates/analytics/src/payments/metrics/avg_ticket_size.rs**
  Modify existing code

**crates/analytics/src/payments/metrics/connector_success_rate.rs**
  Modify existing code

**crates/analytics/src/payments/metrics/payment_count.rs**
  Modify existing code

**crates/analytics/src/payments/metrics/payment_processed_amount.rs**
  Modify existing code

**crates/analytics/src/payments/metrics/payment_success_count.rs**
  Modify existing code

**crates/analytics/src/payments/metrics/retries_count.rs**
  Modify existing code

**crates/analytics/src/payments/metrics/success_rate.rs**
  Modify existing code

**crates/analytics/src/payments/types.rs**
  Modify existing code

**crates/analytics/src/query.rs**
  Remove:
    - function: private::to_sql
    - function: private::to_sql
    - function: private::to_sql
    - function: private::set_filter_clause
    - impl: impl ToSql<T> for &MerchantId
    - impl: impl ToSql<T> for MerchantId
    - impl: impl ToSql<T> for &OrganizationId
    - impl: impl ToSql<T> for ProfileId
    - impl: impl QueryFilter<T> for AuthInfo
  Add:
    - impl: impl ToSql<T> for &common_utils::id_type::MerchantId

**crates/analytics/src/refunds/core.rs**
  Modify existing code

**crates/analytics/src/refunds/filters.rs**
  Modify existing code

**crates/analytics/src/refunds/metrics.rs**
  Modify existing code

**crates/analytics/src/refunds/metrics/refund_count.rs**
  Modify existing code

**crates/analytics/src/refunds/metrics/refund_processed_amount.rs**
  Modify existing code

**crates/analytics/src/refunds/metrics/refund_success_count.rs**
  Modify existing code

**crates/analytics/src/refunds/metrics/refund_success_rate.rs**
  Modify existing code

**crates/analytics/src/refunds/types.rs**
  Modify existing code

**crates/analytics/src/sqlx.rs**
  Remove:
    - impl: impl FromRow<'a, PgRow> for super::payments::filters::PaymentFilterRow

**crates/api_models/src/analytics.rs**
  Modify existing code

**crates/api_models/src/analytics/payment_intents.rs**
  Modify existing code

**crates/api_models/src/analytics/payments.rs**
  Modify existing code

**crates/api_models/src/analytics/refunds.rs**
  Modify existing code

**crates/common_utils/src/types.rs**
  Remove:
    - mod: pub::authentication

**crates/common_utils/src/types/authentication.rs**
  Remove:
    - enum: pub::AuthInfo

**crates/hyperswitch_domain_models/src/merchant_account.rs**
  Remove:
    - function: pub::get_org_id

**crates/router/src/analytics.rs**
  Remove:
    - function: pub::get_org_payment_metrics
    - function: pub::get_merchant_payment_intent_metrics
    - function: pub::get_org_payment_intent_metrics
    - function: pub::get_merchant_refund_metrics
    - function: pub::get_org_refund_metrics
    - function: pub::get_profile_refund_filters
    - function: pub::get_profile_outgoing_webhook_events
    - function: pub::generate_org_dispute_report
    - function: pub::generate_profile_dispute_report
    - function: pub::get_merchant_api_event_filters

**crates/router/src/core/verification/utils.rs**
  Remove:
    - function: pub::check_if_profile_id_is_present_in_payment_intent

**crates/router/src/types/domain/user.rs**
  Modify existing code