-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: live plugin support and enrichment closure (#1010)
* feat: signals support and enrichment closure * test: fix test failures * test: add unit test for enrichment closure * fix: fix lint issues * feat: make enrichment closure a property of the event * fix: lint fix * refactor: revert changes of disabling hermes on sample app --------- Co-authored-by: Wenxi Zeng <[email protected]>
- Loading branch information
1 parent
a3a947c
commit c3a6f58
Showing
14 changed files
with
233 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,4 +112,49 @@ describe('process', () => { | |
expect.objectContaining(expectedEvent) | ||
); | ||
}); | ||
|
||
it('enrichment closure gets applied', async () => { | ||
const client = new SegmentClient(clientArgs); | ||
jest.spyOn(client.isReady, 'value', 'get').mockReturnValue(true); | ||
|
||
// @ts-ignore | ||
Check warning on line 120 in packages/core/src/__tests__/methods/process.test.ts GitHub Actions / build-and-test
|
||
const timeline = client.timeline; | ||
jest.spyOn(timeline, 'process'); | ||
|
||
await client.track('Some Event', { id: 1 }, (event) => { | ||
if (event.context == null) { | ||
event.context = {}; | ||
} | ||
event.context.__eventOrigin = { | ||
type: 'signals', | ||
}; | ||
event.anonymousId = 'foo'; | ||
|
||
return event; | ||
}); | ||
|
||
const expectedEvent = { | ||
event: 'Some Event', | ||
properties: { | ||
id: 1, | ||
}, | ||
type: EventType.TrackEvent, | ||
context: { | ||
__eventOrigin: { | ||
type: 'signals', | ||
}, | ||
...store.context.get(), | ||
}, | ||
userId: store.userInfo.get().userId, | ||
anonymousId: 'foo', | ||
} as SegmentEvent; | ||
|
||
// @ts-ignore | ||
Check warning on line 152 in packages/core/src/__tests__/methods/process.test.ts GitHub Actions / build-and-test
|
||
const pendingEvents = client.store.pendingEvents.get(); | ||
expect(pendingEvents.length).toBe(0); | ||
|
||
expect(timeline.process).toHaveBeenCalledWith( | ||
expect.objectContaining(expectedEvent) | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.