Client library
Undercurrent’s event ingest is wire-compatible with Mixpanel. You track events by adding the official Mixpanel client library for your platform and pointing it at Undercurrent’s ingest endpoint. This can be done effectively by your AI coding harness.
Delegating setup to an AI harness
Paste this prompt into your coding harness in your app repo. It installs the library, configures it, and instruments your key user interactions.
Set up mobile analytics in this app for use with Undercurrent Analytics, which is wire-compatible with Mixpanel. Use the official Mixpanel client library and point it at Undercurrent's ingest endpoint, https://ingest.undercurrentanalytics.dev. Follow this step-by-step process: 1. Add the Mixpanel client library for this app's platform as a dependency. Reference: https://docs.mixpanel.com/docs/quickstart/install-mixpanel#code 2. Decide how you will introduce the Mixpanel analytics client. If the app already uses another analytics service, including Mixpanel, add Undercurrent Analytics ingest _alongside_ it in all cases. Do not remove any existing analytics clients or change their setup. You may need to perform a refactoring to create a single, reusable analytics service to track events through, so that they reach both any existing analytics services, and the Undercurrent Analytics-configured Mixpanel client. Strongly avoid calling the third party Mixpanel library directly throughout the app - use a wrapping analytics service instead. When designing the wrapping analytics service, avoid using a singleton - prefer to create an object that is injected to the components where it's needed. That said, conform to the existing design - if there isn't a clean way to inject an instance of the analytics service to the UI components that need it, then you may fall back to using a singleton. 3. Ensure the new Mixpanel client to be used for Undercurrent Analytics is initialized with these settings: - Server URL: https://ingest.undercurrentanalytics.dev - Project token: Take this from the Undercurrent Analytics credentials JSON file in this repo. 4. Identify each user with a stable, anonymous distinct ID. If there is other analytics code which requires a distinct ID, reuse what those other services are using. Otherwise, if some form of device ID is available, that's an ideal value to use. The distinct ID needs to be provided to the new Mixpanel client as per the Mixpanel documentation. 5. Now that the infrastructure is in place, instrument the key user interactions in this app with clearly named events and useful properties (for example: screen name, the action taken, and any relevant context). 6. Build the app to verify that everything compiles. 7. If there are tests, run them. Be judicious in your choice of tests to run. At least one high-level UI test that launches the app as it would run in production, and a fast running set of unit tests (perhaps all of them, if there are relatively few). 8. Once you're finished, summarise: - How the Mixpanel dependency was added - Where the new Mixpanel client is initialised - The list of events you added, where they fire, and most importantly, why you added them
What it does
- Adds the Mixpanel client library for your platform (iOS, Android, React Native, or Flutter) as a dependency. See Install Mixpanel → Code.
- Wraps the library in a reusable analytics service rather than calling it directly throughout the app. If another analytics service already exists, Undercurrent is added alongside it, not in place of it.
- Initialises the client with the server URL of https://ingest.undercurrentanalytics.dev and project token taken from your credentials file.
- Identifies each user with a stable, anonymous distinct ID (reuses an existing one, or a device ID where available).
- Instruments key interactions with clearly named events and useful properties.
When you’re done
Your app should:
- Depend on the Mixpanel client library for your platform.
- Initialise Mixpanel with your project token and
serverURLset tohttps://ingest.undercurrentanalytics.dev. - Identify each user with a stable distinct ID.
- Send events for the interactions you care about.
Events typically appear in your data within a few minutes. You can test it in Grafana’s Explore view by running a query like SELECT * FROM $__table WHERE $__timeFilter(time). Once events are flowing in, move on to dashboard creation.