Skip to content

Commit

Permalink
fix: check enrichment closure type before calling it (#1012)
Browse files Browse the repository at this point in the history
Co-authored-by: Wenxi Zeng <[email protected]>
  • Loading branch information
wenxi-zeng and Wenxi Zeng authored Oct 11, 2024
1 parent 2b3a176 commit 3b82c37
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class Timeline {
if (key !== PluginType.destination) {
if (result === undefined) {
return;
} else if (key === PluginType.enrichment && pluginResult?.enrichment) {
} else if (key === PluginType.enrichment && pluginResult?.enrichment && typeof pluginResult.enrichment === 'function') {
result = pluginResult.enrichment(pluginResult);
} else {
result = pluginResult;
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ export type Config = {
};

export type ClientMethods = {
screen: (name: string, properties?: JsonMap) => Promise<void>;
track: (event: string, properties?: JsonMap) => Promise<void>;
identify: (userId?: string, userTraits?: UserTraits) => Promise<void>;
screen: (name: string, properties?: JsonMap, enrichment?: EnrichmentClosure) => Promise<void>;
track: (event: string, properties?: JsonMap, enrichment?: EnrichmentClosure) => Promise<void>;
identify: (userId?: string, userTraits?: UserTraits, enrichment?: EnrichmentClosure) => Promise<void>;
flush: () => Promise<void>;
group: (groupId: string, groupTraits?: GroupTraits) => Promise<void>;
alias: (newUserId: string) => Promise<void>;
group: (groupId: string, groupTraits?: GroupTraits, enrichment?: EnrichmentClosure) => Promise<void>;
alias: (newUserId: string, enrichment?: EnrichmentClosure) => Promise<void>;
reset: (resetAnonymousId?: boolean) => Promise<void>;
};

Expand Down

0 comments on commit 3b82c37

Please sign in to comment.