Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix aliasing #40

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Fix aliasing #40

wants to merge 4 commits into from

Conversation

MarconLP
Copy link
Member

No description provided.

@MarconLP MarconLP marked this pull request as draft May 29, 2024 17:46
@@ -148,14 +146,12 @@ export const onEvent: Plugin<CustomerIoPluginInput>['onEvent'] = async (event, m
}

async function syncCustomerMetadata(event: ProcessedPluginEvent, storage: StorageExtension): Promise<Customer> {
const customerStatusKey = `customer-status/${event.distinct_id}`
const customerStatusKey = `customer-status/${event.person.uuid}`
Copy link
Contributor

Choose a reason for hiding this comment

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

would that not break existing users?
If we want to do this we can, we might just want to roll this out as a separate v2 app

Copy link
Member Author

@MarconLP MarconLP Jun 4, 2024

Choose a reason for hiding this comment

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

True. If there's demand we could also write a one-off script that will fetch the person UUID for every distinct_id inside of customer.io and merge it into that.

index.ts Outdated Show resolved Hide resolved
index.ts Outdated
// Create or update customer
// See https://www.customer.io/docs/api/#operation/identify
await callCustomerIoApi('PUT', host, `/api/v1/customers/${id}`, authorizationHeader, customerPayload)

if (['$identify', '$merge_dangerously'].includes(event.event) && !event.$merge_blocked) {
const secondaryId = event?.properties?.$anon_distinct_id ?? event?.properties?.alias
const mergeUserPayload = { primary : { id: event.distinct_id }, secondary: { id: secondaryId }}
Copy link
Contributor

Choose a reason for hiding this comment

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

how does this work with the person.uuid usage change above?

Copy link
Member Author

@MarconLP MarconLP Jun 4, 2024

Choose a reason for hiding this comment

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

Yeah this only works on the first identify, since the person UUID inside of PostHog isn't changing, but not for additional identify or merge_dangerously events. We'll need to convert this distinct_id into the PostHog UUID. Should I just call http://localhost:8000/api/projects/1/persons?distinct_id=9fe3478a-3e19-4c7b-8c93-f0bc32b45341 inside of the plugin? That will require me to have some kind of access as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants