Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: nit pick log message #997

Merged
merged 3 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/__tests__/identify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('identify', () => {
// assert
expect(posthog.persistence!.properties()['$user_id']).toEqual(distinctId)
expect(jest.mocked(logger).error).toBeCalledTimes(0)
expect(jest.mocked(logger).warn).toBeCalledTimes(0)
})

it('should convert a numeric distinct_id to a string', async () => {
Expand All @@ -34,6 +35,7 @@ describe('identify', () => {

// assert
expect(posthog.persistence!.properties()['$user_id']).toEqual(distinctIdString)
expect(jest.mocked(logger).error).toBeCalledTimes(1)
expect(jest.mocked(logger).error).toBeCalledTimes(0)
expect(jest.mocked(logger).warn).toBeCalledTimes(1)
})
})
4 changes: 3 additions & 1 deletion src/posthog-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1302,8 +1302,10 @@ export class PostHog {
return logger.uninitializedWarning('posthog.identify')
}
if (_isNumber(new_distinct_id)) {
logger.error('The first argument to posthog.identify was a number, but it should be a string.')
new_distinct_id = (new_distinct_id as number).toString()
logger.warn(
'The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.'
)
}

//if the new_distinct_id has not been set ignore the identify event
Expand Down
Loading