From bdd6b7b118d7a1d5228de0e1bf99d1dcfeece89d Mon Sep 17 00:00:00 2001 From: Ben White Date: Tue, 10 Dec 2024 16:17:39 +0100 Subject: [PATCH 1/6] Reduce type (#1590) --- .../extensions/surveys/action-matcher.test.ts | 6 +++--- src/__tests__/utils/survey-event-receiver.test.ts | 10 +++++----- src/extensions/surveys/action-matcher.ts | 10 +++++----- src/posthog-surveys-types.ts | 10 ++-------- 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/__tests__/extensions/surveys/action-matcher.test.ts b/src/__tests__/extensions/surveys/action-matcher.test.ts index c7ef574f2..021088470 100644 --- a/src/__tests__/extensions/surveys/action-matcher.test.ts +++ b/src/__tests__/extensions/surveys/action-matcher.test.ts @@ -1,6 +1,6 @@ /// -import { ActionType, ActionStepStringMatching } from '../../../posthog-surveys-types' +import { SurveyActionType, ActionStepStringMatching } from '../../../posthog-surveys-types' import { PostHogPersistence } from '../../../posthog-persistence' import { PostHog } from '../../../posthog-core' import { CaptureResult, PostHogConfig } from '../../../types' @@ -45,7 +45,7 @@ describe('action-matcher', () => { eventName: string, currentUrl?: string, urlMatch?: ActionStepStringMatching - ): ActionType => { + ): SurveyActionType => { return { id: id, name: `${eventName || 'user defined '} action`, @@ -68,7 +68,7 @@ describe('action-matcher', () => { } it('can match action on event name', () => { - const pageViewAction = createAction(3, '$mypageview') as unknown as ActionType + const pageViewAction = createAction(3, '$mypageview') as unknown as SurveyActionType const actionMatcher = new ActionMatcher(instance) actionMatcher.register([pageViewAction]) let pageViewActionMatched = false diff --git a/src/__tests__/utils/survey-event-receiver.test.ts b/src/__tests__/utils/survey-event-receiver.test.ts index d36ff33e4..4ee51ed51 100644 --- a/src/__tests__/utils/survey-event-receiver.test.ts +++ b/src/__tests__/utils/survey-event-receiver.test.ts @@ -4,7 +4,7 @@ import { SurveyType, SurveyQuestionType, Survey, - ActionType, + SurveyActionType, ActionStepStringMatching, } from '../../posthog-surveys-types' import { PostHogPersistence } from '../../posthog-persistence' @@ -209,7 +209,7 @@ describe('survey-event-receiver', () => { eventName: string, currentUrl?: string, urlMatch?: ActionStepStringMatching - ): ActionType => { + ): SurveyActionType => { return { id: id, name: `${eventName || 'user defined '} action`, @@ -238,7 +238,7 @@ describe('survey-event-receiver', () => { type: SurveyType.Popover, questions: [{ type: SurveyQuestionType.Open, question: 'what is a bokoblin?' }], conditions: { - actions: [createAction(2, '$autocapture') as unknown as ActionType], + actions: [createAction(2, '$autocapture') as unknown as SurveyActionType], }, } as unknown as Survey @@ -249,7 +249,7 @@ describe('survey-event-receiver', () => { type: SurveyType.Popover, questions: [{ type: SurveyQuestionType.Open, question: 'what is a bokoblin?' }], conditions: { - actions: [createAction(3, '$pageview') as unknown as ActionType], + actions: [createAction(3, '$pageview') as unknown as SurveyActionType], }, } as unknown as Survey @@ -262,7 +262,7 @@ describe('survey-event-receiver', () => { questions: [{ type: SurveyQuestionType.Open, question: 'what is a bokoblin?' }], conditions: { actions: { - values: [createAction(3, '$mypageview') as unknown as ActionType], + values: [createAction(3, '$mypageview') as unknown as SurveyActionType], }, }, } as unknown as Survey diff --git a/src/extensions/surveys/action-matcher.ts b/src/extensions/surveys/action-matcher.ts index a6d4ceb0a..82bb125a0 100644 --- a/src/extensions/surveys/action-matcher.ts +++ b/src/extensions/surveys/action-matcher.ts @@ -1,5 +1,5 @@ import { PostHog } from '../../posthog-core' -import { ActionStepStringMatching, ActionStepType, ActionType, SurveyElement } from '../../posthog-surveys-types' +import { ActionStepStringMatching, ActionStepType, SurveyActionType, SurveyElement } from '../../posthog-surveys-types' import { SimpleEventEmitter } from '../../utils/simple-event-emitter' import { CaptureResult } from '../../types' import { isUndefined } from '../../utils/type-utils' @@ -7,7 +7,7 @@ import { window } from '../../utils/globals' import { isUrlMatchingRegex } from '../../utils/request-utils' export class ActionMatcher { - private readonly actionRegistry?: Set + private readonly actionRegistry?: Set private readonly instance?: PostHog private readonly actionEvents: Set private _debugEventEmitter = new SimpleEventEmitter() @@ -15,7 +15,7 @@ export class ActionMatcher { constructor(instance?: PostHog) { this.instance = instance this.actionEvents = new Set() - this.actionRegistry = new Set() + this.actionRegistry = new Set() } init() { @@ -27,7 +27,7 @@ export class ActionMatcher { } } - register(actions: ActionType[]): void { + register(actions: SurveyActionType[]): void { if (isUndefined(this.instance?._addCaptureHook)) { return } @@ -74,7 +74,7 @@ export class ActionMatcher { this.onAction('actionCaptured', (data) => callback(data)) } - private checkAction(event?: CaptureResult, action?: ActionType): boolean { + private checkAction(event?: CaptureResult, action?: SurveyActionType): boolean { if (action?.steps == null) { return false } diff --git a/src/posthog-surveys-types.ts b/src/posthog-surveys-types.ts index 8313093b1..09aea91ce 100644 --- a/src/posthog-surveys-types.ts +++ b/src/posthog-surveys-types.ts @@ -172,7 +172,7 @@ export interface Survey { }[] } | null actions: { - values: ActionType[] + values: SurveyActionType[] } | null } | null start_date: string | null @@ -181,16 +181,10 @@ export interface Survey { current_iteration_start_date: string | null } -export interface ActionType { - count?: number - created_at: string - deleted?: boolean +export interface SurveyActionType { id: number name: string | null steps?: ActionStepType[] - tags?: string[] - is_action?: true - action_id?: number // alias of id to make it compatible with event definitions uuid } /** Sync with plugin-server/src/types.ts */ From 4b28ae7b731fa742b7737de8837138ba0ef2fb01 Mon Sep 17 00:00:00 2001 From: benjackwhite Date: Tue, 10 Dec 2024 15:18:25 +0000 Subject: [PATCH 2/6] chore: Bump version to 1.195.0 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a237c96da..9ef8c6c98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.195.0 - 2024-12-10 + +- Reduce type (#1590) + ## 1.194.6 - 2024-12-09 - feat: Load site functions via RemoteConfig (#1580) diff --git a/package.json b/package.json index 394db41d7..b26c47a4e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "posthog-js", - "version": "1.194.6", + "version": "1.195.0", "description": "Posthog-js allows you to automatically capture usage and send events to PostHog.", "repository": "https://github.com/PostHog/posthog-js", "author": "hey@posthog.com", From c84defcf1b040fc8c908ebc61bc2c8684dde0299 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Thu, 12 Dec 2024 10:49:31 +0100 Subject: [PATCH 3/6] feat: include attribution with all web vitals (#1594) --- src/entrypoints/web-vitals.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/entrypoints/web-vitals.ts b/src/entrypoints/web-vitals.ts index d1732a378..0d8e8e4df 100644 --- a/src/entrypoints/web-vitals.ts +++ b/src/entrypoints/web-vitals.ts @@ -1,5 +1,4 @@ -import { onLCP, onCLS, onFCP } from 'web-vitals' -import { onINP } from 'web-vitals/attribution' +import { onINP, onLCP, onCLS, onFCP } from 'web-vitals/attribution' import { assignableWindow } from '../utils/globals' const postHogWebVitalsCallbacks = { From 3ee3180f2970ef4c16490e3a928bd667a269f186 Mon Sep 17 00:00:00 2001 From: pauldambra Date: Thu, 12 Dec 2024 09:50:15 +0000 Subject: [PATCH 4/6] chore: Bump version to 1.196.0 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ef8c6c98..41273274d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.196.0 - 2024-12-12 + +- feat: include attribution with all web vitals (#1594) + ## 1.195.0 - 2024-12-10 - Reduce type (#1590) diff --git a/package.json b/package.json index b26c47a4e..4bcc3147c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "posthog-js", - "version": "1.195.0", + "version": "1.196.0", "description": "Posthog-js allows you to automatically capture usage and send events to PostHog.", "repository": "https://github.com/PostHog/posthog-js", "author": "hey@posthog.com", From a934d031531986842a27d42584eba5fce2c3e3ee Mon Sep 17 00:00:00 2001 From: Robbie Date: Thu, 12 Dec 2024 09:56:46 +0000 Subject: [PATCH 5/6] feat: Don't create person profile when setting properties for flags (#1586) --- src/posthog-core.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/posthog-core.ts b/src/posthog-core.ts index a310f84e5..c2bced9f5 100644 --- a/src/posthog-core.ts +++ b/src/posthog-core.ts @@ -1491,9 +1491,6 @@ export class PostHog { * to update user properties. */ setPersonPropertiesForFlags(properties: Properties, reloadFeatureFlags = true): void { - if (!this._requirePersonProcessing('posthog.setPersonPropertiesForFlags')) { - return - } this.featureFlags.setPersonPropertiesForFlags(properties, reloadFeatureFlags) } From 0ea603b06ecc8ec2a6eb014631dfe91389f81567 Mon Sep 17 00:00:00 2001 From: robbie-c Date: Thu, 12 Dec 2024 09:57:28 +0000 Subject: [PATCH 6/6] chore: Bump version to 1.196.1 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41273274d..4d9ac4d94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.196.1 - 2024-12-12 + +- feat: Don't create person profile when setting properties for flags (#1586) + ## 1.196.0 - 2024-12-12 - feat: include attribution with all web vitals (#1594) diff --git a/package.json b/package.json index 4bcc3147c..3d1097e53 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "posthog-js", - "version": "1.196.0", + "version": "1.196.1", "description": "Posthog-js allows you to automatically capture usage and send events to PostHog.", "repository": "https://github.com/PostHog/posthog-js", "author": "hey@posthog.com",