Skip to content

Add Analytics and MCP APIs#286

Open
kiran-4444 wants to merge 4 commits intomainfrom
feat/add-analytics-apis
Open

Add Analytics and MCP APIs#286
kiran-4444 wants to merge 4 commits intomainfrom
feat/add-analytics-apis

Conversation

@kiran-4444
Copy link
Copy Markdown

@kiran-4444 kiran-4444 commented Apr 14, 2026

Title
Add analytics and MCP APIs

Related Issues
Related to ENG-1185

@kiran-4444 kiran-4444 changed the title Add Analytics APIs Add Analytics and MCP APIs Apr 14, 2026
Comment thread src/version.ts Outdated
@@ -1 +1 @@
export const VERSION = '3.0.1';
export const VERSION = '3.0.2';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert this, version change can be raised separately once all cahnges are merged, and we do npm version patch to do it not this way

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Comment thread src/utils.ts
.join('&');

return queryParams ? `?${queryParams}` : '';
const search = new URLSearchParams();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this change required?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the query params aren't being encoded with the existing implementation and all the analytics APIs are failing due to invalid query params parsing. I've taken the python SDK implementation as reference and implemented it here as well.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not change the implementation here, please update the new api endpoint methods to pass the query params in the same way as existing invocations

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous toQueryParams isn't encoding timestamps correctly. We need to send time_of_generation_min or time_of_generation_max for almost all of the analytics APIs as query params. For example, 2026-04-05T15:13:57+05:30 won't be serialized and the + part will be sent as it is and is interpreted as a space, which fails with the following error:

URL: https://api.portkeydev.com/v1/analytics/summary/cache?time_of_generation_min=2026-04-05T15:13:57+05:30&time_of_generation_max=2026-04-07T18:56:59+05:30
 {
  "success": false,
  "data": {
    "message": "Validation failed: undefined: Invalid value, undefined: Invalid value",
    "errorCode": "AB01",
    "request_id": "f52f7c4c-67fd-4f44-bb0e-dac4902489ed",
    "error_details": [
      {
        "value": "2026-04-05T15:13:57 05:30",
        "msg": "Invalid value",
        "param": "time_of_generation_min",
        "location": "query"
      },
      {
        "value": "2026-04-07T18:56:59 05:30",
        "msg": "Invalid value",
        "param": "time_of_generation_max",
        "location": "query"
      }
    ]
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants