Skip to content

Commit 3b82c37

Browse files
authored
fix: check enrichment closure type before calling it (#1012)
Co-authored-by: Wenxi Zeng <wzeng@twilio.com>
1 parent 2b3a176 commit 3b82c37

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/core/src/timeline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class Timeline {
7575
if (key !== PluginType.destination) {
7676
if (result === undefined) {
7777
return;
78-
} else if (key === PluginType.enrichment && pluginResult?.enrichment) {
78+
} else if (key === PluginType.enrichment && pluginResult?.enrichment && typeof pluginResult.enrichment === 'function') {
7979
result = pluginResult.enrichment(pluginResult);
8080
} else {
8181
result = pluginResult;

packages/core/src/types.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ export type Config = {
153153
};
154154

155155
export type ClientMethods = {
156-
screen: (name: string, properties?: JsonMap) => Promise<void>;
157-
track: (event: string, properties?: JsonMap) => Promise<void>;
158-
identify: (userId?: string, userTraits?: UserTraits) => Promise<void>;
156+
screen: (name: string, properties?: JsonMap, enrichment?: EnrichmentClosure) => Promise<void>;
157+
track: (event: string, properties?: JsonMap, enrichment?: EnrichmentClosure) => Promise<void>;
158+
identify: (userId?: string, userTraits?: UserTraits, enrichment?: EnrichmentClosure) => Promise<void>;
159159
flush: () => Promise<void>;
160-
group: (groupId: string, groupTraits?: GroupTraits) => Promise<void>;
161-
alias: (newUserId: string) => Promise<void>;
160+
group: (groupId: string, groupTraits?: GroupTraits, enrichment?: EnrichmentClosure) => Promise<void>;
161+
alias: (newUserId: string, enrichment?: EnrichmentClosure) => Promise<void>;
162162
reset: (resetAnonymousId?: boolean) => Promise<void>;
163163
};
164164

0 commit comments

Comments
 (0)