-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
654b3e0
commit 36de1da
Showing
4 changed files
with
48 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,10 @@ test('person properties set in identify() with new distinct_id are sent to decid | |
|
||
resetRequests(token) | ||
|
||
// wait for decide callback | ||
// eslint-disable-next-line compat/compat | ||
await new Promise((res) => setTimeout(res, 500)) | ||
|
||
// Person properties set here should also be sent to the decide endpoint. | ||
posthog.identify('test-id', { | ||
email: '[email protected]', | ||
|
@@ -63,6 +67,10 @@ test('person properties set in identify() with the same distinct_id are sent to | |
|
||
resetRequests(token) | ||
|
||
// wait for decide callback | ||
// eslint-disable-next-line compat/compat | ||
await new Promise((res) => setTimeout(res, 500)) | ||
|
||
// First we identify with a new distinct_id but with no properties set | ||
posthog.identify('test-id') | ||
|
||
|
@@ -98,3 +106,36 @@ test('person properties set in identify() with the same distinct_id are sent to | |
]) | ||
}) | ||
}) | ||
|
||
test('identify() doesnt trigger new request automatically if first request takes too long', async () => { | ||
// TODO: Make this experience nicer, and queue requests, rather than leave | ||
// it upto the user to call reloadFeatureFlags() manually. | ||
|
||
const token = v4() | ||
const posthog = await createPosthogInstance(token, { advanced_disable_decide: false }) | ||
|
||
const anonymousId = posthog.get_distinct_id() | ||
|
||
await waitFor(() => { | ||
expect(getRequests(token)['/decide/']).toEqual([ | ||
// This is the initial call to the decide endpoint on PostHog init. | ||
{ | ||
distinct_id: anonymousId, | ||
groups: {}, | ||
token, | ||
}, | ||
]) | ||
}) | ||
|
||
resetRequests(token) | ||
|
||
// don't wait for decide callback | ||
|
||
posthog.identify('test-id', { | ||
email: '[email protected]', | ||
}) | ||
|
||
await waitFor(() => { | ||
expect(getRequests(token)['/decide/']).toEqual([]) | ||
}) | ||
}) |
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