diff --git a/src/__tests__/identify.test.ts b/src/__tests__/identify.test.ts index b164255b4..fe18888ca 100644 --- a/src/__tests__/identify.test.ts +++ b/src/__tests__/identify.test.ts @@ -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 () => { @@ -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) }) }) diff --git a/src/posthog-core.ts b/src/posthog-core.ts index fa43907db..ce30edf80 100644 --- a/src/posthog-core.ts +++ b/src/posthog-core.ts @@ -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