Skip to content

feat(analytics): add support for multiple emails as input to forward reports#6776

Merged
Gnanasundari24 merged 1 commit intomainfrom
add-multiple-customer-emails-reports
Dec 10, 2024
Merged

feat(analytics): add support for multiple emails as input to forward reports#6776
Gnanasundari24 merged 1 commit intomainfrom
add-multiple-customer-emails-reports

Conversation

@tsdk02
Copy link
Contributor

@tsdk02 tsdk02 commented Dec 9, 2024

Type of Change

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

Description

Currently, while generating reports on the dashboard, the current setup only supports forwarding reports to the email of the account signed in.
This PR adds support to have custom emails in the input text box on the dashboard while generating and forwarding the report, to make the reporting module slightly flexible and convenient.

  • Adding the field for taking multiple emails as input in the report request body.
  • Currently having it as an Option, for backwards compatibility.

Additional Changes

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

Motivation and Context

To make the reporting module slightly flexible and convenient, to send the report to emails entered by the users.

How did you test it?

Hit the curl:

curl --location 'http://localhost:8080/analytics/v1/org/report/payments' \
--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/131.0.0.0 Safari/537.36' \
--header 'api-key: dev_LZcIA7XeMpnK5satp4CDvjcnHCaeKTBcosyuBBJaknZu1odhFo96cwS0nSdfzuJF' \
--header 'authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiNTQ5ZTNkMmItMTY5Yi00NzUzLWJmNTQtZDcxMTM2YjRiN2JkIiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzI2MDQ2MzI4Iiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTczMzg5OTY3Nywib3JnX2lkIjoib3JnX1ZwU0hPanNZZkR2YWJWWUpnQ0FKIiwicHJvZmlsZV9pZCI6InByb192NXNGb0hlODBPZWlVbElvbm9jTSIsInRlbmFudF9pZCI6InB1YmxpYyJ9.poRn4McNVvd9Yrv2py9FO3HmG1ENu_SqYYc4hfF1Jm8' \
--header 'sec-ch-ua: "Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "macOS"' \
--data-raw '{
    "timeRange": {
        "startTime": "2024-10-31T18:30:00Z",
        "endTime": "2024-11-30T18:29:59Z"
    },
    "emails": [
        "test@gmail.com", "test2@juspay.in"
    ]
}'

Sample request payload:

payload: ReportRequest { time_range: TimeRange { start_time: 2024-10-31 18:30:00.0, end_time: Some(2024-11-30 18:29:59.0) }, emails: Some([****@gmail.com, *****@juspay.in]) }

Sample lambda request:

lambda_req: GenerateReportRequest { request: ReportRequest { time_range: TimeRange { start_time: 2024-10-31 18:30:00.0, end_time: Some(2024-11-30 18:29:59.0) }, emails: Some([****@gmail.com, *****@juspay.in]) }, merchant_id: None, auth: OrgLevel { org_id: OrganizationId("org_VpSHOjsYfDvabVYJgCAJ") }, email: *************@juspay.in }
  • emails is an Option (for backwards compatibility): So its not compulsary as of now to add this field.
curl --location 'http://localhost:8080/analytics/v1/org/report/payments' \
--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/131.0.0.0 Safari/537.36' \
--header 'api-key: dev_LZcIA7XeMpnK5satp4CDvjcnHCaeKTBcosyuBBJaknZu1odhFo96cwS0nSdfzuJF' \
--header 'authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiNTQ5ZTNkMmItMTY5Yi00NzUzLWJmNTQtZDcxMTM2YjRiN2JkIiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzI2MDQ2MzI4Iiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTczMzg5OTY3Nywib3JnX2lkIjoib3JnX1ZwU0hPanNZZkR2YWJWWUpnQ0FKIiwicHJvZmlsZV9pZCI6InByb192NXNGb0hlODBPZWlVbElvbm9jTSIsInRlbmFudF9pZCI6InB1YmxpYyJ9.poRn4McNVvd9Yrv2py9FO3HmG1ENu_SqYYc4hfF1Jm8' \
--header 'sec-ch-ua: "Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "macOS"' \
--data '{
    "timeRange": {
        "startTime": "2024-10-31T18:30:00Z",
        "endTime": "2024-11-30T18:29:59Z"
    }
}'

Sample request payload:

payload: ReportRequest { time_range: TimeRange { start_time: 2024-10-31 18:30:00.0, end_time: Some(2024-11-30 18:29:59.0) }, emails: None }

Sample lambda request:

lambda_req: GenerateReportRequest { request: ReportRequest { time_range: TimeRange { start_time: 2024-10-31 18:30:00.0, end_time: Some(2024-11-30 18:29:59.0) }, emails: None }, merchant_id: None, auth: OrgLevel { org_id: OrganizationId("org_VpSHOjsYfDvabVYJgCAJ") }, email: *************@juspay.in }

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 Dec 9, 2024
@tsdk02 tsdk02 self-assigned this Dec 9, 2024
@tsdk02 tsdk02 requested a review from a team as a code owner December 9, 2024 07:26
@semanticdiff-com
Copy link

semanticdiff-com bot commented Dec 9, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/api_models/src/analytics.rs  0% smaller

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Dec 10, 2024
Merged via the queue into main with commit 3df4233 Dec 10, 2024
@Gnanasundari24 Gnanasundari24 deleted the add-multiple-customer-emails-reports branch December 10, 2024 12:20
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 support for multiple emails as input to forward reports

4 participants