managed-components / managed-components/mixpanel

Support for Mixpanel's "Simplified API" ID Merging

Open
#9 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Looking at the current source code, it seems like only "Original API" mode is supported for Mixpanel ID management.

Simplified ID Merge docs: https://docs.mixpanel.com/docs/tracking-methods/id-management/migrating-to-simplified-id-merge-system

Essentially, it just uses the `$device_id` and `$used_id` properties in track events to identify users (no separate identify calls needed).

If a Mixplanel project is created using a "Simplified API" id merge mode (which can't be changed), and we pass $device_id, and $user_id, I think it's being replaced in the following line:

https://github.com/managed-components/mixpanel/blob/3e0e5cfb6860bf94cb992f4c9379425159ab924f/src/index.ts#L159-L162

Because `...getRequestBodyProperties(event, token)` returns a `$device_id` property that has been [set to a random UUID managed by this MC tool](https://github.com/managed-components/mixpanel/blob/3e0e5cfb6860bf94cb992f4c9379425159ab924f/src/index.ts#L105) (in its [own cookie](https://github.com/managed-components/mixpanel/blob/3e0e5cfb6860bf94cb992f4c9379425159ab924f/src/index.ts#L59-L67)), any `$device_id` we pass in the `customFields` is being overridden.

---

What do you think about switching the places so that any `customField` could replace the built-in ones, like this?

```ts
properties: {
...getRequestBodyProperties(event, token),
...customFields,
},
```

This way the `$device_id` and `$user_id` fields added to the tool settings (example: in Clodflare Zaraz dasboard) will have priority, and that way we can support "Simplified API" mode easily too?

Generally, I think `customFields` overriding any built-in properties the tool sets is a good and more intuitive idea.

Please let me know if I missed something. If this change is the only thing needed I can create a PR from a fork for it.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review src/index.ts around lines 159-162, along with the built-in $device_id handling at lines 105 and 59-67, and compare it with Mixpanel's Simplified API documentation. Confirm how customFields are merged and whether they can take precedence over built-in properties. Done means Simplified API projects can use supplied $device_id and $user_id values without being replaced.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
analytics
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.