Enhance usage API by exposing Analytics data#18
Draft
piyushryn wants to merge 1 commit into
Draft
Conversation
…eakdowns for analytics based on requests and bandwidth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposing these points
topBreakdownsByRequestandtopBreakdownsByBandwidthas the two top-level sort buckets, visible duplication but a cleaner approach (we can also start accepting a sorting key to return bandwidth and requests separatly rather than a monolith response with both kinds of sorting )Old response of the api
{ "bandwidthBytes": 18273487, "mediaLibraryStorageBytes": 697650923, "videoProcessingUnitsCount": 232, "extensionUnitsCount": 0, "originalCacheStorageBytes": 0 }Proposed new New Response Types
Proposed new New Response Example
{ "meta": { "from": "2026-06-01", "to": "2026-06-26" }, "bandwidthBytes": 18273487, "mediaLibraryStorageBytes": 697650923, "videoProcessingUnitsCount": 232, "extensionUnitsCount": 0, "originalCacheStorageBytes": 0, "requestCount": 160, "videoProcessingUnitsUsage": { "SD": 232, "HD": 0, "4K": 0, "8K": 0, "16K": 0 }, "extensionUnitsUsage": { "total": 0, "aws-auto-tagging": 0, "google-auto-tagging": 0, "ai-auto-description": 0, "ikremovebg": 0, "remove-bg": 0, "upscale": 0, "retouch": 0, "genvar": 0, "genfill": 0, "genimg": 0, "dropshadow": 0, "change-bg": 0, "edit": 0, "ai-tasks": 0, "ai-video-transcription": 0, "creative-banner": 0 }, "topBreakdownsByRequest": { "statusCodes": [ { "value": "200", "requests": 148, "bandwidthBytes": 13924675 }, { "value": "404", "requests": 7, "bandwidthBytes": 4250 }, { "value": "206", "requests": 4, "bandwidthBytes": 4344030 } ], "formats": [ { "value": "image/webp", "requests": 119, "bandwidthBytes": 5261379 }, { "value": "image/jpeg", "requests": 20, "bandwidthBytes": 4570132 }, { "value": "video/webm", "requests": 8, "bandwidthBytes": 6727289 } ], "cache": [ { "value": "Miss", "requests": 96, "bandwidthBytes": 12276318 }, { "value": "Hit", "requests": 56, "bandwidthBytes": 5992387 }, { "value": "Error", "requests": 8, "bandwidthBytes": 4782 } ], "geography": [ { "value": "India", "countryCode": "IN", "requests": 136, "bandwidthBytes": 11218939 }, { "value": "Singapore", "countryCode": "SG", "requests": 22, "bandwidthBytes": 5669799 } ], "devices": [ { "value": "Desktop", "requests": 139, "bandwidthBytes": 16644941 }, { "value": "Smartphone", "requests": 17, "bandwidthBytes": 237432 } ], "transformations": [ { "value": "n-ik_ml_thumbnail", "requests": 80, "bandwidthBytes": 868433 } ], "images": [ { "value": "https://ik.imagekit.io/your_id/photo.jpeg", "requests": 80, "bandwidthBytes": 868433 } ], "videos": [ { "value": "https://ik.imagekit.io/your_id/clip.mp4", "requests": 8, "bandwidthBytes": 6727289 } ], "others": [ { "value": "https://ik.imagekit.io/your_id/design.psd", "requests": 2, "bandwidthBytes": 1389412 } ], "referral": [], "videoTransformations": [], "resultType": [ { "value": "Miss", "requests": 96, "bandwidthBytes": 12276318 }, { "value": "Hit", "requests": 56, "bandwidthBytes": 5992387 }, { "value": "Error", "requests": 8, "bandwidthBytes": 4782 } ], "userAgents": [ { "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36", "requests": 103, "bandwidthBytes": 10238534 }, { "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36", "requests": 22, "bandwidthBytes": 5669799 } ] }, "topBreakdownsByBandwidth": { "statusCodes": [ { "value": "200", "requests": 148, "bandwidthBytes": 13924675 }, { "value": "206", "requests": 4, "bandwidthBytes": 4344030 }, { "value": "404", "requests": 7, "bandwidthBytes": 4250 } ], "formats": [ { "value": "video/webm", "requests": 8, "bandwidthBytes": 6727289 }, { "value": "image/webp", "requests": 119, "bandwidthBytes": 5261379 }, { "value": "image/jpeg", "requests": 20, "bandwidthBytes": 4570132 } ], "cache": [ { "value": "Miss", "requests": 96, "bandwidthBytes": 12276318 }, { "value": "Hit", "requests": 56, "bandwidthBytes": 5992387 }, { "value": "Error", "requests": 8, "bandwidthBytes": 4782 } ], "geography": [ { "value": "India", "countryCode": "IN", "requests": 136, "bandwidthBytes": 11218939 }, { "value": "Singapore", "countryCode": "SG", "requests": 22, "bandwidthBytes": 5669799 } ], "devices": [ { "value": "Desktop", "requests": 139, "bandwidthBytes": 16644941 }, { "value": "Smartphone", "requests": 17, "bandwidthBytes": 237432 } ], "transformations": [ { "value": "n-ik_ml_thumbnail", "requests": 80, "bandwidthBytes": 868433 } ], "images": [ { "value": "https://ik.imagekit.io/your_id/photo.jpeg", "requests": 80, "bandwidthBytes": 868433 } ], "videos": [ { "value": "https://ik.imagekit.io/your_id/clip.mp4", "requests": 8, "bandwidthBytes": 6727289 } ], "others": [ { "value": "https://ik.imagekit.io/your_id/design.psd", "requests": 2, "bandwidthBytes": 1389412 } ], "referral": [], "videoTransformations": [], "resultType": [ { "value": "Miss", "requests": 96, "bandwidthBytes": 12276318 }, { "value": "Hit", "requests": 56, "bandwidthBytes": 5992387 }, { "value": "Error", "requests": 8, "bandwidthBytes": 4782 } ], "userAgents": [ { "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36", "requests": 103, "bandwidthBytes": 10238534 }, { "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36", "requests": 22, "bandwidthBytes": 5669799 } ] } }