Introduced support for importing historical events through the /import endpoint, along with gzip compression for both event and historical event data.#44
Introduced support for importing historical events through the /import endpoint, along with gzip compression for both event and historical event data.#44jaredmixpanel merged 11 commits intomixpanel:masterfrom santigracia:master
Conversation
Support for importing historical events using /import endpoint with project token authentication
fixing errorResponse
adding gzip compression for event tracking (both /track and /import endpoints). new constructor with parameter useGzipCompression update to tests, demo, and readme
Fix to handle API reponse from import when using strict=1
/import does not return "1" or "0" when using strict=1.
Instead it returns: {"code":200,"status":"OK","num_records_imported":N}
There was a problem hiding this comment.
Pull Request Overview
This PR introduces support for importing historical events through the /import endpoint with project token authentication, and adds optional gzip compression for both regular event tracking and historical event imports.
- Adds new
importEventmethod toMessageBuilderfor creating historical event messages with auto-generated timestamps and insert IDs - Implements
/importendpoint support inMixpanelAPIwith Basic Auth using project tokens and JSON content type - Introduces optional gzip compression for all network requests through constructor parameter
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
MixpanelAPITest.java |
Comprehensive test coverage for import functionality, gzip compression, and data integrity validation |
MixpanelAPI.java |
Core implementation of import endpoint support and gzip compression with proper error handling |
MessageBuilder.java |
New importEvent method with auto-generation of timestamps and insert IDs for deduplication |
Config.java |
Added batch size limit constant for import endpoint (2000 messages) |
ClientDelivery.java |
Extended message handling to support import message type and validation |
MixpanelAPIDemo.java |
Updated demo to showcase import functionality and gzip compression features |
README.md |
Documentation updates explaining gzip compression and historical event import capabilities |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| eventName.replaceAll("[^a-zA-Z0-9]", "-"), | ||
| time, | ||
| (long)(Math.random() * 1000000)); | ||
| propertiesObj.put("$insert_id", insertId); |
There was a problem hiding this comment.
Is this a known/recommended solution for generating $insert_ids?
There was a problem hiding this comment.
docs for import recommend a UUID or computing a hash of some set of properties.
For consistency with Python SDK import we can use UUIDv4.
Fixed here: 59fac6a
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
legacy spelling correction
using random uuidv4 if insert_id not provided
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Support for importing historical events using /import endpoint using project token authentication.
Optional gzip compression for both event and historical event data using constructor with useGzipCompression boolean parameter