Skip to content

Commit

Permalink
profile-builder: allow to override profile_id
Browse files Browse the repository at this point in the history
  • Loading branch information
absorbb committed Feb 10, 2025
1 parent 0179928 commit 8f83ac8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ export async function ProfileUDFTestRun({
}
const result = await wrapper?.userFunction(eventsProvider, userProvider, funcCtx);
const profile = {
profile_id: user.id,
profile_id: result?.profile_id || user.id,
traits: { ...user.traits, ...result?.traits },
version: version,
updated_at: new Date(),
Expand Down
2 changes: 1 addition & 1 deletion services/profiles/src/lib/functions-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export async function runChain(
try {
result = await f.exec(eventsProvider, userProvider, f.context);
return {
profile_id: profileId,
profile_id: result?.profile_id || profileId,
traits: { ...(await userProvider()).traits, ...result?.traits },
version: profileBuilder.version,
updated_at: new Date(),
Expand Down
1 change: 1 addition & 0 deletions types/protocols/profile.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { FunctionContext } from "./functions";
import { AnalyticsServerEvent } from "./analytics";

export type ProfileResult = {
profile_id?: string;
traits: Record<string, any>;
};

Expand Down

0 comments on commit 8f83ac8

Please sign in to comment.