Skip to content

Introduced support for importing historical events through the /import endpoint, along with gzip compression for both event and historical event data.#44

Merged
jaredmixpanel merged 11 commits intomixpanel:masterfrom
santigracia:master
Oct 15, 2025

Conversation

@santigracia
Copy link
Contributor

@santigracia santigracia commented Oct 11, 2025

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

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
@santigracia santigracia changed the title Adding support for Importing Historical events via /import Introduced support for importing historical events through the /import endpoint, along with gzip compression for both event and historical event data. Oct 13, 2025
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}
@jaredmixpanel jaredmixpanel requested a review from Copilot October 14, 2025 16:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 importEvent method to MessageBuilder for creating historical event messages with auto-generated timestamps and insert IDs
  • Implements /import endpoint support in MixpanelAPI with 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);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a known/recommended solution for generating $insert_ids?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

santigracia and others added 5 commits October 14, 2025 15:45
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
using random uuidv4 if insert_id not provided
@santigracia santigracia requested a review from Copilot October 14, 2025 21:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Copy link
Contributor

@jaredmixpanel jaredmixpanel left a comment

Choose a reason for hiding this comment

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

LGTM

@jaredmixpanel jaredmixpanel merged commit c50e1aa into mixpanel:master Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments