From 97950d2655224e8087e3e1593110a3fe1bf69bb9 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Tue, 6 Feb 2024 09:14:18 +0000 Subject: [PATCH 1/3] chore: nit pick log message --- functional_tests/identify.test.ts | 5 +++-- src/posthog-core.ts | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/functional_tests/identify.test.ts b/functional_tests/identify.test.ts index d9f95d587..0d864201f 100644 --- a/functional_tests/identify.test.ts +++ b/functional_tests/identify.test.ts @@ -1,10 +1,11 @@ -import 'regenerator-runtime/runtime' import { waitFor } from '@testing-library/dom' import { v4 } from 'uuid' import { getRequests } from './mock-server' import { createPosthogInstance } from './posthog-instance' import { logger } from '../src/utils/logger' + jest.mock('../src/utils/logger') + test('identify sends a identify event', async () => { const token = v4() const posthog = await createPosthogInstance(token) @@ -29,7 +30,7 @@ test('identify sends a identify event', async () => { }) test('identify sends an engage request if identify called twice with the same distinct id and with $set/$set_once', async () => { - // The intention here is to reduce the number of unncecessary $identify + // The intention here is to reduce the number of unnecessary $identify // requests to process. const token = v4() const posthog = await createPosthogInstance(token) 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 From 00e5663a5e5a3eb6033697eab98d047d9b283834 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Tue, 6 Feb 2024 09:25:43 +0000 Subject: [PATCH 2/3] update test --- src/__tests__/identify.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) }) }) From 7e91ff69fe13b4ea8a441d3f1d5350b50f3ac760 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Tue, 6 Feb 2024 09:38:27 +0000 Subject: [PATCH 3/3] no need to change tests that don't run --- functional_tests/identify.test.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/functional_tests/identify.test.ts b/functional_tests/identify.test.ts index 0d864201f..d9f95d587 100644 --- a/functional_tests/identify.test.ts +++ b/functional_tests/identify.test.ts @@ -1,11 +1,10 @@ +import 'regenerator-runtime/runtime' import { waitFor } from '@testing-library/dom' import { v4 } from 'uuid' import { getRequests } from './mock-server' import { createPosthogInstance } from './posthog-instance' import { logger } from '../src/utils/logger' - jest.mock('../src/utils/logger') - test('identify sends a identify event', async () => { const token = v4() const posthog = await createPosthogInstance(token) @@ -30,7 +29,7 @@ test('identify sends a identify event', async () => { }) test('identify sends an engage request if identify called twice with the same distinct id and with $set/$set_once', async () => { - // The intention here is to reduce the number of unnecessary $identify + // The intention here is to reduce the number of unncecessary $identify // requests to process. const token = v4() const posthog = await createPosthogInstance(token)