posthog-js 1.294.0 → 1.296.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +56 -2
- package/dist/all-external-dependencies.js +1 -1
- package/dist/all-external-dependencies.js.map +1 -1
- package/dist/array.full.es5.js +1 -1
- package/dist/array.full.es5.js.map +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.full.no-external.js +1 -1
- package/dist/array.full.no-external.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/customizations.full.js +1 -1
- package/dist/lazy-recorder.js +1 -1
- package/dist/main.js +1 -1
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.full.no-external.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.no-external.js +1 -1
- package/dist/posthog-recorder.js +1 -1
- package/dist/src/extensions/surveys.d.ts +1 -1
- package/dist/surveys-preview.js +1 -1
- package/dist/surveys-preview.js.map +1 -1
- package/dist/surveys.js +1 -1
- package/dist/surveys.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/src/extensions/surveys.d.ts +1 -1
- package/lib/src/extensions/surveys.jsx +3 -3
- package/lib/src/extensions/surveys.jsx.map +1 -1
- package/package.json +1 -1
- package/react/dist/esm/index.js.map +1 -1
- package/react/dist/umd/index.js.map +1 -1
package/lib/package.json
CHANGED
|
@@ -90,7 +90,7 @@ type UseHideSurveyOnURLChangeProps = {
|
|
|
90
90
|
* 2. Subsequent URL changes are handled here to hide the survey as the user navigates
|
|
91
91
|
*/
|
|
92
92
|
export declare function useHideSurveyOnURLChange({ survey, removeSurveyFromFocus, setSurveyVisible, isPreviewMode, }: UseHideSurveyOnURLChangeProps): void;
|
|
93
|
-
export declare function usePopupVisibility(survey: Survey, posthog: PostHog | undefined, millisecondDelay: number, isPreviewMode: boolean, removeSurveyFromFocus: (survey: SurveyWithTypeAndAppearance) => void, surveyContainerRef?: React.RefObject<HTMLDivElement>): {
|
|
93
|
+
export declare function usePopupVisibility(survey: Survey, posthog: PostHog | undefined, millisecondDelay: number, isPreviewMode: boolean, removeSurveyFromFocus: (survey: SurveyWithTypeAndAppearance) => void, isPopup: boolean, surveyContainerRef?: React.RefObject<HTMLDivElement>): {
|
|
94
94
|
isPopupVisible: boolean;
|
|
95
95
|
isSurveySent: boolean;
|
|
96
96
|
setIsPopupVisible: import("preact/hooks").StateUpdater<boolean>;
|
|
@@ -749,12 +749,12 @@ function useHideSurveyOnURLChange(_a) {
|
|
|
749
749
|
};
|
|
750
750
|
}, [isPreviewMode, survey, removeSurveyFromFocus, setSurveyVisible]);
|
|
751
751
|
}
|
|
752
|
-
function usePopupVisibility(survey, posthog, millisecondDelay, isPreviewMode, removeSurveyFromFocus, surveyContainerRef) {
|
|
752
|
+
function usePopupVisibility(survey, posthog, millisecondDelay, isPreviewMode, removeSurveyFromFocus, isPopup, surveyContainerRef) {
|
|
753
753
|
var _a = __read((0, hooks_1.useState)(isPreviewMode || millisecondDelay === 0 || survey.type === posthog_surveys_types_1.SurveyType.ExternalSurvey), 2), isPopupVisible = _a[0], setIsPopupVisible = _a[1];
|
|
754
754
|
var _b = __read((0, hooks_1.useState)(false), 2), isSurveySent = _b[0], setIsSurveySent = _b[1];
|
|
755
755
|
var hidePopupWithViewTransition = function () {
|
|
756
756
|
var removeDOMAndHidePopup = function () {
|
|
757
|
-
if (
|
|
757
|
+
if (isPopup) {
|
|
758
758
|
removeSurveyFromFocus(survey);
|
|
759
759
|
}
|
|
760
760
|
setIsPopupVisible(false);
|
|
@@ -908,7 +908,7 @@ function SurveyPopup(_a) {
|
|
|
908
908
|
var surveyPopupDelayMilliseconds = ((_b = survey.appearance) === null || _b === void 0 ? void 0 : _b.surveyPopupDelaySeconds)
|
|
909
909
|
? survey.appearance.surveyPopupDelaySeconds * 1000
|
|
910
910
|
: 0;
|
|
911
|
-
var _p = usePopupVisibility(survey, posthog, surveyPopupDelayMilliseconds, isPreviewMode, removeSurveyFromFocus, surveyContainerRef), isPopupVisible = _p.isPopupVisible, isSurveySent = _p.isSurveySent, hidePopupWithViewTransition = _p.hidePopupWithViewTransition;
|
|
911
|
+
var _p = usePopupVisibility(survey, posthog, surveyPopupDelayMilliseconds, isPreviewMode, removeSurveyFromFocus, isPopup, surveyContainerRef), isPopupVisible = _p.isPopupVisible, isSurveySent = _p.isSurveySent, hidePopupWithViewTransition = _p.hidePopupWithViewTransition;
|
|
912
912
|
var shouldShowConfirmation = isSurveySent || previewPageIndex === survey.questions.length;
|
|
913
913
|
var surveyContextValue = (0, hooks_1.useMemo)(function () {
|
|
914
914
|
var getInProgressSurvey = (0, surveys_extension_utils_1.getInProgressSurveyState)(survey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surveys.jsx","sourceRoot":"","sources":["../../../src/extensions/surveys.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsGA,8CA6EC;AA4kBD,0CAmDC;AAmBD,4DAwDC;AAED,gDAmHC;AAsED,kCA4EC;AAED,8BAoHC;AAED,wCAuGC;AAn2CD,6CAAgC;AAChC,sCAA+E;AAE/E,kEAciC;AACjC,kCAA2C;AAC3C,4CAA2E;AAC3E,sDAM8B;AAC9B,sCAAmD;AACnD,oCAAkC;AAClC,gFAA8E;AAC9E,sEAA4D;AAC5D,oEAM2C;AAC3C,6EAoB0C;AAC1C,kEAIoC;AAEpC,gGAAgG;AAChG,IAAM,MAAM,GAAG,gBAAqC,CAAA;AACpD,IAAM,QAAQ,GAAG,kBAAqB,CAAA;AAEtC,IAAM,8BAA8B,GAAG,uBAAuB,CAAA;AAC9D,IAAM,yBAAyB,GAAG,6BAA6B,CAAA;AAE/D,SAAS,+BAA+B,CAAC,aAAqB,EAAE,KAAa;IACzE,IAAI,KAAK,KAAK,CAAC,EAAE,CA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EAAE,CAAC,EAAG,CAAA;QACpF,KAAK,0CAAkB,CAAC,IAAI;YACxB,OAAO,CAAC,4BAAY,CAAC,IAAI,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAG,CAAA;QAChF,KAAK,0CAAkB,CAAC,MAAM;YAC1B,OAAO,CAAC,8BAAc,CAAC,IAAI,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAG,CAAA;QAClF,KAAK,0CAAkB,CAAC,YAAY,CAAC;QACrC,KAAK,0CAAkB,CAAC,cAAc;YAClC,OAAO,CAAC,sCAAsB,CAAC,IAAI,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAG,CAAA;QAC1F;YACI,4BAAM,CAAC,KAAK,CAAC,qCAA+B,QAAgB,CAAC,IAAI,CAAE,CAAC,CAAA;YACpE,OAAO,IAAI,CAAA;IACnB,CAAC;AACL,CAAC,CAAA","sourcesContent":["import * as Preact from 'preact'\nimport { useContext, useEffect, useMemo, useRef, useState } from 'preact/hooks'\nimport { PostHog } from '../posthog-core'\nimport {\n Survey,\n SurveyCallback,\n SurveyEventName,\n SurveyEventProperties,\n SurveyPosition,\n SurveyQuestion,\n SurveyQuestionBranchingType,\n SurveyQuestionType,\n SurveySchedule,\n SurveyTabPosition,\n SurveyType,\n SurveyWidgetType,\n SurveyWithTypeAndAppearance,\n} from '../posthog-surveys-types'\nimport { addEventListener } from '../utils'\nimport { document as _document, window as _window } from '../utils/globals'\nimport {\n doesSurveyActivateByAction,\n doesSurveyActivateByEvent,\n IN_APP_SURVEY_TYPES,\n isSurveyRunning,\n SURVEY_LOGGER as logger,\n} from '../utils/survey-utils'\nimport { isNull, isUndefined } from '@posthog/core'\nimport { uuidv7 } from '../uuidv7'\nimport { ConfirmationMessage } from './surveys/components/ConfirmationMessage'\nimport { Cancel } from './surveys/components/QuestionHeader'\nimport {\n CommonQuestionProps,\n LinkQuestion,\n MultipleChoiceQuestion,\n OpenTextQuestion,\n RatingQuestion,\n} from './surveys/components/QuestionTypes'\nimport {\n canActivateRepeatedly,\n retrieveSurveyShadow,\n defaultSurveyAppearance,\n dismissedSurveyEvent,\n doesSurveyDeviceTypesMatch,\n doesSurveyMatchSelector,\n doesSurveyUrlMatch,\n getDisplayOrderQuestions,\n getInProgressSurveyState,\n getSurveyContainerClass,\n getSurveyResponseKey,\n getSurveySeen,\n hasWaitPeriodPassed,\n isSurveyInProgress,\n sendSurveyEvent,\n setInProgressSurveyState,\n SurveyContext,\n getSurveyStylesheet,\n addSurveyCSSVariablesToElement,\n} from './surveys/surveys-extension-utils'\nimport {\n extractPrefillParamsFromUrl,\n convertPrefillToResponses,\n allRequiredQuestionsFilled,\n} from '../utils/survey-url-prefill'\n\n// We cast the types here which is dangerous but protected by the top level generateSurveys call\nconst window = _window as Window & typeof globalThis\nconst document = _document as Document\n\nconst DISPATCH_FEEDBACK_WIDGET_EVENT = 'ph:show_survey_widget'\nconst WIDGET_LISTENER_ATTRIBUTE = 'PHWidgetSurveyClickListener'\n\nfunction getRatingBucketForResponseValue(responseValue: number, scale: number) {\n if (scale === 3) {\n if (responseValue < 1 || responseValue > 3) {\n throw new Error('The response must be in range 1-3')\n }\n\n return responseValue === 1 ? 'negative' : responseValue === 2 ? 'neutral' : 'positive'\n } else if (scale === 5) {\n if (responseValue < 1 || responseValue > 5) {\n throw new Error('The response must be in range 1-5')\n }\n\n return responseValue <= 2 ? 'negative' : responseValue === 3 ? 'neutral' : 'positive'\n } else if (scale === 7) {\n if (responseValue < 1 || responseValue > 7) {\n throw new Error('The response must be in range 1-7')\n }\n\n return responseValue <= 3 ? 'negative' : responseValue === 4 ? 'neutral' : 'positive'\n } else if (scale === 10) {\n if (responseValue < 0 || responseValue > 10) {\n throw new Error('The response must be in range 0-10')\n }\n\n return responseValue <= 6 ? 'detractors' : responseValue <= 8 ? 'passives' : 'promoters'\n }\n\n throw new Error('The scale must be one of: 3, 5, 7, 10')\n}\n\nexport function getNextSurveyStep(\n survey: Survey,\n currentQuestionIndex: number,\n response: string | string[] | number | null\n) {\n const question = survey.questions[currentQuestionIndex]\n const nextQuestionIndex = currentQuestionIndex + 1\n\n if (!question.branching?.type) {\n if (currentQuestionIndex === survey.questions.length - 1) {\n return SurveyQuestionBranchingType.End\n }\n\n return nextQuestionIndex\n }\n\n if (question.branching.type === SurveyQuestionBranchingType.End) {\n return SurveyQuestionBranchingType.End\n } else if (question.branching.type === SurveyQuestionBranchingType.SpecificQuestion) {\n if (Number.isInteger(question.branching.index)) {\n return question.branching.index\n }\n } else if (question.branching.type === SurveyQuestionBranchingType.ResponseBased) {\n // Single choice\n if (question.type === SurveyQuestionType.SingleChoice) {\n // :KLUDGE: for now, look up the choiceIndex based on the response\n // TODO: once QuestionTypes.MultipleChoiceQuestion is refactored, pass the selected choiceIndex into this method\n let selectedChoiceIndex = question.choices.indexOf(`${response}`)\n\n if (selectedChoiceIndex === -1 && question.hasOpenChoice) {\n // if the response is not found in the choices, it must be the open choice,\n // which is always the last choice\n selectedChoiceIndex = question.choices.length - 1\n }\n\n if (question.branching?.responseValues?.hasOwnProperty(selectedChoiceIndex)) {\n const nextStep = question.branching.responseValues[selectedChoiceIndex]\n\n // Specific question\n if (Number.isInteger(nextStep)) {\n return nextStep\n }\n\n if (nextStep === SurveyQuestionBranchingType.End) {\n return SurveyQuestionBranchingType.End\n }\n\n return nextQuestionIndex\n }\n } else if (question.type === SurveyQuestionType.Rating) {\n if (typeof response !== 'number' || !Number.isInteger(response)) {\n throw new Error('The response type must be an integer')\n }\n\n const ratingBucket = getRatingBucketForResponseValue(response, question.scale)\n\n if (question.branching?.responseValues?.hasOwnProperty(ratingBucket)) {\n const nextStep = question.branching.responseValues[ratingBucket]\n\n // Specific question\n if (Number.isInteger(nextStep)) {\n return nextStep\n }\n\n if (nextStep === SurveyQuestionBranchingType.End) {\n return SurveyQuestionBranchingType.End\n }\n\n return nextQuestionIndex\n }\n }\n\n return nextQuestionIndex\n }\n\n logger.warn('Falling back to next question index due to unexpected branching type')\n return nextQuestionIndex\n}\n\nconst SURVEY_NEXT_TO_TRIGGER_PARAMS = {\n ESTIMATED_MIN_HEIGHT: 250,\n HORIZONTAL_PADDING: 20,\n TRIGGER_SPACING: 12,\n} as const\n\nfunction getNextToTriggerPosition(target: HTMLElement, surveyWidth: number): React.CSSProperties | null {\n try {\n const buttonRect = target.getBoundingClientRect()\n const viewportHeight = window.innerHeight\n const viewportWidth = window.innerWidth\n const estimatedMinSurveyHeight = SURVEY_NEXT_TO_TRIGGER_PARAMS.ESTIMATED_MIN_HEIGHT\n const buttonCenterX = buttonRect.left + buttonRect.width / 2\n let left = buttonCenterX - surveyWidth / 2\n const horizontalPadding = SURVEY_NEXT_TO_TRIGGER_PARAMS.HORIZONTAL_PADDING\n if (left + surveyWidth > viewportWidth - horizontalPadding) {\n left = viewportWidth - surveyWidth - horizontalPadding\n }\n if (left < horizontalPadding) {\n left = horizontalPadding\n }\n const spacing = SURVEY_NEXT_TO_TRIGGER_PARAMS.TRIGGER_SPACING\n const spaceBelow = viewportHeight - buttonRect.bottom\n const spaceAbove = buttonRect.top\n const showAbove = spaceBelow < estimatedMinSurveyHeight && spaceAbove > spaceBelow\n\n return {\n position: 'fixed',\n top: showAbove ? 'auto' : `${buttonRect.bottom + spacing}px`,\n left: `${left}px`,\n right: 'auto',\n bottom: showAbove ? `${viewportHeight - buttonRect.top + spacing}px` : 'auto',\n zIndex: defaultSurveyAppearance.zIndex,\n } satisfies React.CSSProperties\n } catch (error) {\n logger.warn('Failed to calculate trigger position:', error)\n return null\n }\n}\n\n// Keep in sync with posthog/constants.py on main repo\nconst SURVEY_TARGETING_FLAG_PREFIX = 'survey-targeting-'\n\nexport class SurveyManager {\n private _posthog: PostHog\n private _surveyInFocus: string | null\n private _surveyTimeouts: Map<string, NodeJS.Timeout> = new Map()\n private _autoSubmitTimeout?: NodeJS.Timeout\n private _widgetSelectorListeners: Map<string, { element: Element; listener: EventListener; survey: Survey }> =\n new Map()\n private _prefillHandledSurveys: Set<string> = new Set()\n\n constructor(posthog: PostHog) {\n this._posthog = posthog\n // This is used to track the survey that is currently in focus. We only show one survey at a time.\n this._surveyInFocus = null\n }\n\n private _clearSurveyTimeout(surveyId: string) {\n const timeout = this._surveyTimeouts.get(surveyId)\n if (timeout) {\n clearTimeout(timeout)\n this._surveyTimeouts.delete(surveyId)\n }\n }\n\n public handlePopoverSurvey = (survey: Survey): void => {\n this._clearSurveyTimeout(survey.id)\n this._addSurveyToFocus(survey)\n const delaySeconds = survey.appearance?.surveyPopupDelaySeconds || 0\n const { shadow } = retrieveSurveyShadow(survey, this._posthog)\n if (delaySeconds <= 0) {\n return Preact.render(\n <SurveyPopup\n posthog={this._posthog}\n survey={survey}\n removeSurveyFromFocus={this._removeSurveyFromFocus}\n />,\n shadow\n )\n }\n const timeoutId = setTimeout(() => {\n if (!doesSurveyUrlMatch(survey)) {\n return this._removeSurveyFromFocus(survey)\n }\n // rendering with surveyPopupDelaySeconds = 0 because we're already handling the timeout here\n Preact.render(\n <SurveyPopup\n posthog={this._posthog}\n survey={{ ...survey, appearance: { ...survey.appearance, surveyPopupDelaySeconds: 0 } }}\n removeSurveyFromFocus={this._removeSurveyFromFocus}\n />,\n shadow\n )\n }, delaySeconds * 1000)\n this._surveyTimeouts.set(survey.id, timeoutId)\n }\n\n private _handleWidget = (survey: Survey): void => {\n // Ensure widget container exists if it doesn't\n const { shadow, isNewlyCreated } = retrieveSurveyShadow(survey, this._posthog)\n\n // If the widget is already rendered, do nothing. Otherwise the widget will be re-rendered every second\n if (!isNewlyCreated) {\n return\n }\n\n Preact.render(<FeedbackWidget posthog={this._posthog} survey={survey} key={survey.id} />, shadow)\n }\n\n private _removeWidgetSelectorListener = (survey: Pick<Survey, 'id' | 'type' | 'appearance'>): void => {\n this._removeSurveyFromDom(survey)\n const existing = this._widgetSelectorListeners.get(survey.id)\n if (existing) {\n existing.element.removeEventListener('click', existing.listener)\n existing.element.removeAttribute(WIDGET_LISTENER_ATTRIBUTE)\n this._widgetSelectorListeners.delete(survey.id)\n logger.info(`Removed click listener for survey ${survey.id}`)\n }\n }\n\n private _manageWidgetSelectorListener = (survey: Survey, selector: string): void => {\n const currentElement = document.querySelector(selector)\n const existingListenerData = this._widgetSelectorListeners.get(survey.id)\n\n if (!currentElement) {\n if (existingListenerData) {\n this._removeWidgetSelectorListener(survey)\n }\n return\n }\n\n this._handleWidget(survey)\n\n if (existingListenerData) {\n // Listener exists, check if element changed\n if (currentElement !== existingListenerData.element) {\n logger.info(`Selector element changed for survey ${survey.id}. Re-attaching listener.`)\n this._removeWidgetSelectorListener(survey)\n // Continue to attach listener to the new element below\n } else {\n // Element is the same, listener already attached, do nothing\n return\n }\n }\n\n // Element found, and no listener attached (or it was just removed from old element)\n if (!currentElement.hasAttribute(WIDGET_LISTENER_ATTRIBUTE)) {\n const listener = (event: Event) => {\n event.stopPropagation() // Prevent bubbling\n\n const positionStyles =\n survey.appearance?.position === SurveyPosition.NextToTrigger\n ? getNextToTriggerPosition(\n event.currentTarget as HTMLElement,\n parseInt(survey.appearance?.maxWidth || defaultSurveyAppearance.maxWidth)\n )\n : {}\n\n window.dispatchEvent(\n new CustomEvent(DISPATCH_FEEDBACK_WIDGET_EVENT, {\n detail: { surveyId: survey.id, position: positionStyles },\n })\n )\n }\n\n addEventListener(currentElement, 'click', listener)\n currentElement.setAttribute(WIDGET_LISTENER_ATTRIBUTE, 'true')\n this._widgetSelectorListeners.set(survey.id, { element: currentElement, listener, survey })\n logger.info(`Attached click listener for feedback button survey ${survey.id}`)\n }\n }\n\n /**\n * Sorts surveys by their appearance delay in ascending order. If a survey does not have an appearance delay,\n * it is considered to have a delay of 0.\n * @param surveys\n * @returns The surveys sorted by their appearance delay\n */\n private _sortSurveysByAppearanceDelay(surveys: Survey[]): Survey[] {\n return surveys.sort((a, b) => {\n const isSurveyInProgressA = isSurveyInProgress(a)\n const isSurveyInProgressB = isSurveyInProgress(b)\n if (isSurveyInProgressA && !isSurveyInProgressB) {\n return -1 // a comes before b (in progress surveys first)\n }\n if (!isSurveyInProgressA && isSurveyInProgressB) {\n return 1 // a comes after b (in progress surveys first)\n }\n const aIsAlways = a.schedule === SurveySchedule.Always\n const bIsAlways = b.schedule === SurveySchedule.Always\n\n if (aIsAlways && !bIsAlways) {\n return 1 // a comes after b\n }\n if (!aIsAlways && bIsAlways) {\n return -1 // a comes before b\n }\n // If both are Always or neither is Always, sort by delay\n return (a.appearance?.surveyPopupDelaySeconds || 0) - (b.appearance?.surveyPopupDelaySeconds || 0)\n })\n }\n\n public renderPopover = (survey: Survey): void => {\n const { shadow } = retrieveSurveyShadow(survey, this._posthog)\n Preact.render(\n <SurveyPopup posthog={this._posthog} survey={survey} removeSurveyFromFocus={this._removeSurveyFromFocus} />,\n shadow\n )\n }\n\n public renderSurvey = (survey: Survey, selector: Element): void => {\n if (this._posthog.config?.surveys?.prefillFromUrl) {\n this._handleUrlPrefill(survey)\n }\n\n Preact.render(\n <SurveyPopup\n posthog={this._posthog}\n survey={survey}\n removeSurveyFromFocus={this._removeSurveyFromFocus}\n isPopup={false}\n />,\n selector\n )\n }\n\n private _handleUrlPrefill(survey: Survey): void {\n // Only handle prefill once per survey session to avoid overwriting in-progress responses\n if (this._prefillHandledSurveys.has(survey.id)) {\n return\n }\n\n try {\n const { params, autoSubmit } = extractPrefillParamsFromUrl(window.location.search)\n\n if (Object.keys(params).length === 0) {\n return\n }\n\n logger.info('[Survey Prefill] Detected URL prefill parameters')\n\n const responses = convertPrefillToResponses(survey, params)\n\n if (Object.keys(responses).length === 0) {\n logger.warn('[Survey Prefill] No valid responses after conversion')\n return\n }\n\n const submissionId = uuidv7()\n\n setInProgressSurveyState(survey, {\n surveySubmissionId: submissionId,\n responses: responses,\n lastQuestionIndex: 0,\n })\n\n logger.info('[Survey Prefill] Stored prefilled responses in localStorage')\n\n const shouldAutoSubmit =\n autoSubmit &&\n this._posthog.config.surveys?.autoSubmitIfComplete &&\n allRequiredQuestionsFilled(survey, responses)\n\n if (shouldAutoSubmit) {\n this._scheduleAutoSubmit(survey, responses, submissionId)\n }\n\n // Mark this survey as having been prefilled\n this._prefillHandledSurveys.add(survey.id)\n } catch (error) {\n logger.error('[Survey Prefill] Error handling URL prefill:', error)\n }\n }\n\n private _scheduleAutoSubmit(survey: Survey, responses: Record<string, any>, submissionId: string): void {\n const delay = this._posthog.config.surveys?.autoSubmitDelay ?? 800\n\n logger.info('[Survey Prefill] Auto-submit scheduled')\n\n this._autoSubmitTimeout = setTimeout(() => {\n logger.info('[Survey Prefill] Auto-submitting survey')\n\n sendSurveyEvent({\n responses,\n survey,\n surveySubmissionId: submissionId,\n posthog: this._posthog,\n isSurveyCompleted: true,\n })\n }, delay)\n }\n\n private _isSurveyFeatureFlagEnabled(flagKey: string | null, flagVariant: string | undefined = undefined) {\n if (!flagKey) {\n return true\n }\n const isFeatureEnabled = !!this._posthog.featureFlags.isFeatureEnabled(flagKey, {\n send_event: !flagKey.startsWith(SURVEY_TARGETING_FLAG_PREFIX),\n })\n let flagVariantCheck = true\n if (flagVariant) {\n const flagVariantValue = this._posthog.featureFlags.getFeatureFlag(flagKey, { send_event: false })\n flagVariantCheck = flagVariantValue === flagVariant || flagVariant === 'any'\n }\n return isFeatureEnabled && flagVariantCheck\n }\n\n private _isSurveyConditionMatched(survey: Survey): boolean {\n if (!survey.conditions) {\n return true\n }\n return doesSurveyUrlMatch(survey) && doesSurveyDeviceTypesMatch(survey) && doesSurveyMatchSelector(survey)\n }\n\n private _internalFlagCheckSatisfied(survey: Survey): boolean {\n return (\n canActivateRepeatedly(survey) ||\n this._isSurveyFeatureFlagEnabled(survey.internal_targeting_flag_key) ||\n isSurveyInProgress(survey)\n )\n }\n\n public checkSurveyEligibility(survey: Survey): { eligible: boolean; reason?: string } {\n const eligibility = { eligible: true, reason: undefined as string | undefined }\n\n if (!isSurveyRunning(survey)) {\n eligibility.eligible = false\n eligibility.reason = `Survey is not running. It was completed on ${survey.end_date}`\n return eligibility\n }\n\n if (!IN_APP_SURVEY_TYPES.includes(survey.type)) {\n eligibility.eligible = false\n eligibility.reason = `Surveys of type ${survey.type} are never eligible to be shown in the app`\n return eligibility\n }\n\n const linkedFlagVariant = survey.conditions?.linkedFlagVariant\n if (!this._isSurveyFeatureFlagEnabled(survey.linked_flag_key, linkedFlagVariant)) {\n eligibility.eligible = false\n if (!linkedFlagVariant) {\n eligibility.reason = `Survey linked feature flag is not enabled`\n } else {\n eligibility.reason = `Survey linked feature flag is not enabled for variant ${linkedFlagVariant}`\n }\n return eligibility\n }\n\n if (!this._isSurveyFeatureFlagEnabled(survey.targeting_flag_key)) {\n eligibility.eligible = false\n eligibility.reason = `Survey targeting feature flag is not enabled`\n return eligibility\n }\n\n if (!this._internalFlagCheckSatisfied(survey)) {\n eligibility.eligible = false\n eligibility.reason =\n 'Survey internal targeting flag is not enabled and survey cannot activate repeatedly and survey is not in progress'\n return eligibility\n }\n\n if (!hasWaitPeriodPassed(survey.conditions?.seenSurveyWaitPeriodInDays)) {\n eligibility.eligible = false\n eligibility.reason = `Survey wait period has not passed`\n return eligibility\n }\n\n if (getSurveySeen(survey)) {\n eligibility.eligible = false\n eligibility.reason = `Survey has already been seen and it can't be activated again`\n return eligibility\n }\n\n return eligibility\n }\n\n /**\n * Surveys can be activated by events or actions. This method checks if the survey has events and actions,\n * and if so, it checks if the survey has been activated.\n * @param survey\n */\n private _hasActionOrEventTriggeredSurvey(survey: Survey): boolean {\n if (!doesSurveyActivateByEvent(survey) && !doesSurveyActivateByAction(survey)) {\n // If survey doesn't depend on events/actions, it's considered \"triggered\" by default\n return true\n }\n const surveysActivatedByEventsOrActions: string[] | undefined =\n this._posthog.surveys._surveyEventReceiver?.getSurveys()\n return !!surveysActivatedByEventsOrActions?.includes(survey.id)\n }\n\n private _checkFlags(survey: Survey): boolean {\n if (!survey.feature_flag_keys?.length) {\n return true\n }\n\n return survey.feature_flag_keys.every(({ key, value }) => {\n if (!key || !value) {\n return true\n }\n return this._isSurveyFeatureFlagEnabled(value)\n })\n }\n\n public getActiveMatchingSurveys = (callback: SurveyCallback, forceReload = false): void => {\n this._posthog?.surveys.getSurveys((surveys) => {\n const targetingMatchedSurveys = surveys.filter((survey) => {\n const eligibility = this.checkSurveyEligibility(survey)\n return (\n eligibility.eligible &&\n this._isSurveyConditionMatched(survey) &&\n this._hasActionOrEventTriggeredSurvey(survey) &&\n this._checkFlags(survey)\n )\n })\n\n callback(targetingMatchedSurveys)\n }, forceReload)\n }\n\n public callSurveysAndEvaluateDisplayLogic = (forceReload: boolean = false): void => {\n this.getActiveMatchingSurveys((surveys) => {\n const inAppSurveysWithDisplayLogic = surveys.filter(\n (survey) => survey.type === SurveyType.Popover || survey.type === SurveyType.Widget\n )\n\n // Create a queue of surveys sorted by their appearance delay. We will evaluate the display logic\n // for each survey in the queue in order, and only display one survey at a time.\n const inAppSurveysQueue = this._sortSurveysByAppearanceDelay(inAppSurveysWithDisplayLogic)\n\n // Keep track of surveys processed this cycle to remove listeners for inactive ones\n const activeSelectorSurveys = new Set<string>()\n\n inAppSurveysQueue.forEach((survey) => {\n // Widget Type Logic\n if (survey.type === SurveyType.Widget) {\n if (survey.appearance?.widgetType === SurveyWidgetType.Tab) {\n this._handleWidget(survey)\n return\n }\n\n // For selector widget types, we need to manage the listener attachment/detachment dynamically\n if (\n survey.appearance?.widgetType === SurveyWidgetType.Selector &&\n survey.appearance?.widgetSelector\n ) {\n activeSelectorSurveys.add(survey.id)\n this._manageWidgetSelectorListener(survey, survey.appearance?.widgetSelector)\n }\n }\n\n // Popover Type Logic (only one shown at a time)\n if (isNull(this._surveyInFocus) && survey.type === SurveyType.Popover) {\n this.handlePopoverSurvey(survey)\n }\n })\n\n // Clean up listeners for surveys that are no longer active or matched\n this._widgetSelectorListeners.forEach(({ survey }) => {\n if (!activeSelectorSurveys.has(survey.id)) {\n this._removeWidgetSelectorListener(survey)\n }\n })\n }, forceReload)\n }\n\n private _addSurveyToFocus = (survey: Pick<Survey, 'id'>): void => {\n if (!isNull(this._surveyInFocus)) {\n logger.error(`Survey ${this._surveyInFocus} already in focus. Cannot add survey ${survey.id}.`)\n }\n this._surveyInFocus = survey.id\n }\n\n private _removeSurveyFromDom(survey: Pick<Survey, 'id' | 'type' | 'appearance'>): void {\n try {\n const shadowContainer = document.querySelector(getSurveyContainerClass(survey, true))\n if (shadowContainer?.shadowRoot) {\n Preact.render(null, shadowContainer.shadowRoot)\n }\n shadowContainer?.remove()\n } catch (error) {\n logger.warn(`Failed to remove survey ${survey.id} from DOM:`, error)\n }\n }\n\n private _removeSurveyFromFocus = (survey: SurveyWithTypeAndAppearance): void => {\n if (this._surveyInFocus !== survey.id) {\n logger.error(`Survey ${survey.id} is not in focus. Cannot remove survey ${survey.id}.`)\n }\n this._clearSurveyTimeout(survey.id)\n this._clearAutoSubmitTimeout()\n this._surveyInFocus = null\n this._removeSurveyFromDom(survey)\n }\n\n private _clearAutoSubmitTimeout(): void {\n if (this._autoSubmitTimeout) {\n clearTimeout(this._autoSubmitTimeout)\n this._autoSubmitTimeout = undefined\n }\n }\n\n // Expose internal state and methods for testing\n public getTestAPI() {\n return {\n addSurveyToFocus: this._addSurveyToFocus,\n removeSurveyFromFocus: this._removeSurveyFromFocus,\n surveyInFocus: this._surveyInFocus,\n surveyTimeouts: this._surveyTimeouts,\n handleWidget: this._handleWidget,\n handlePopoverSurvey: this.handlePopoverSurvey,\n manageWidgetSelectorListener: this._manageWidgetSelectorListener,\n sortSurveysByAppearanceDelay: this._sortSurveysByAppearanceDelay,\n checkFlags: this._checkFlags.bind(this),\n isSurveyFeatureFlagEnabled: this._isSurveyFeatureFlagEnabled.bind(this),\n }\n }\n}\n\nconst DEFAULT_PREVIEW_POSITION_STYLES: React.CSSProperties = {\n position: 'relative',\n left: 'unset',\n right: 'unset',\n top: 'unset',\n bottom: 'unset',\n transform: 'unset',\n}\n\nexport const renderSurveysPreview = ({\n survey,\n parentElement,\n previewPageIndex,\n forceDisableHtml,\n onPreviewSubmit,\n positionStyles = DEFAULT_PREVIEW_POSITION_STYLES,\n}: {\n survey: Survey\n parentElement: HTMLElement\n previewPageIndex: number\n forceDisableHtml?: boolean\n onPreviewSubmit?: (res: string | string[] | number | null) => void\n posthog?: PostHog\n positionStyles?: React.CSSProperties\n}) => {\n const currentStyle = parentElement.querySelector('style[data-ph-survey-style]')\n if (currentStyle) {\n currentStyle.remove()\n }\n const stylesheet = getSurveyStylesheet()\n if (stylesheet) {\n parentElement.appendChild(stylesheet)\n addSurveyCSSVariablesToElement(parentElement, survey.type, survey.appearance)\n }\n Preact.render(\n <SurveyPopup\n survey={survey}\n forceDisableHtml={forceDisableHtml}\n style={positionStyles}\n onPreviewSubmit={onPreviewSubmit}\n previewPageIndex={previewPageIndex}\n removeSurveyFromFocus={() => {}}\n />,\n parentElement\n )\n}\n\nexport const renderFeedbackWidgetPreview = ({\n survey,\n root,\n forceDisableHtml,\n}: {\n survey: Survey\n root: HTMLElement\n forceDisableHtml?: boolean\n}) => {\n const stylesheet = getSurveyStylesheet()\n if (stylesheet) {\n root.appendChild(stylesheet)\n addSurveyCSSVariablesToElement(root, survey.type, survey.appearance)\n }\n\n Preact.render(<FeedbackWidget forceDisableHtml={forceDisableHtml} survey={survey} readOnly={true} />, root)\n}\n\n// This is the main exported function\nexport function generateSurveys(posthog: PostHog, isSurveysEnabled: boolean | undefined) {\n // NOTE: Important to ensure we never try and run surveys without a window environment\n if (!document || !window) {\n return\n }\n\n const surveyManager = new SurveyManager(posthog)\n if (posthog.config.disable_surveys_automatic_display) {\n logger.info('Surveys automatic display is disabled. Skipping call surveys and evaluate display logic.')\n return surveyManager\n }\n\n // NOTE: The `generateSurveys` function used to accept just a single parameter, without any `isSurveysEnabled` parameter.\n // To keep compatibility with old clients, we'll consider `undefined` the same as `true`\n if (isSurveysEnabled === false) {\n logger.info('There are no surveys to load or Surveys is disabled in the project settings.')\n return surveyManager\n }\n\n surveyManager.callSurveysAndEvaluateDisplayLogic(true)\n\n let intervalId: number | undefined\n\n const startInterval = () => {\n if (!isUndefined(intervalId)) {\n return\n }\n intervalId = setInterval(() => {\n surveyManager.callSurveysAndEvaluateDisplayLogic(false)\n }, 1000) as unknown as number\n }\n\n const stopInterval = () => {\n if (!isUndefined(intervalId)) {\n clearInterval(intervalId)\n intervalId = undefined\n }\n }\n\n startInterval()\n\n addEventListener(document, 'visibilitychange', () => {\n if (document.hidden) {\n stopInterval()\n } else {\n surveyManager.callSurveysAndEvaluateDisplayLogic(false)\n startInterval()\n }\n })\n\n return surveyManager\n}\n\ntype UseHideSurveyOnURLChangeProps = {\n survey: Pick<Survey, 'id' | 'conditions' | 'type' | 'appearance'>\n removeSurveyFromFocus?: (survey: SurveyWithTypeAndAppearance) => void\n setSurveyVisible: (visible: boolean) => void\n isPreviewMode?: boolean\n}\n\n/**\n * This hook handles URL-based survey visibility after the initial mount.\n * The initial URL check is handled by the `getActiveMatchingSurveys` method in the `PostHogSurveys` class,\n * which ensures the URL matches before displaying a survey for the first time.\n * That is the method that is called every second to see if there's a matching survey.\n *\n * This separation of concerns means:\n * 1. Initial URL matching is done by `getActiveMatchingSurveys` before displaying the survey\n * 2. Subsequent URL changes are handled here to hide the survey as the user navigates\n */\nexport function useHideSurveyOnURLChange({\n survey,\n removeSurveyFromFocus = () => {},\n setSurveyVisible,\n isPreviewMode = false,\n}: UseHideSurveyOnURLChangeProps) {\n useEffect(() => {\n if (isPreviewMode || !survey.conditions?.url) {\n return\n }\n\n const checkUrlMatch = () => {\n const isSurveyTypeWidget = survey.type === SurveyType.Widget\n const doesSurveyMatchUrlCondition = doesSurveyUrlMatch(survey)\n const isSurveyWidgetTypeTab = survey.appearance?.widgetType === SurveyWidgetType.Tab && isSurveyTypeWidget\n\n if (doesSurveyMatchUrlCondition) {\n if (isSurveyWidgetTypeTab) {\n logger.info(`Showing survey ${survey.id} because it is a feedback button tab and URL matches`)\n setSurveyVisible(true)\n }\n return\n }\n\n logger.info(`Hiding survey ${survey.id} because URL does not match`)\n setSurveyVisible(false)\n return removeSurveyFromFocus(survey)\n }\n\n // Listen for browser back/forward browser history changes\n addEventListener(window, 'popstate', checkUrlMatch)\n // Listen for hash changes, for SPA frameworks that use hash-based routing\n // The hashchange event is fired when the fragment identifier of the URL has changed (the part of the URL beginning with and following the # symbol).\n addEventListener(window, 'hashchange', checkUrlMatch)\n\n // Listen for SPA navigation\n const originalPushState = window.history.pushState\n const originalReplaceState = window.history.replaceState\n\n window.history.pushState = function (...args) {\n originalPushState.apply(this, args)\n checkUrlMatch()\n }\n\n window.history.replaceState = function (...args) {\n originalReplaceState.apply(this, args)\n checkUrlMatch()\n }\n\n return () => {\n window.removeEventListener('popstate', checkUrlMatch)\n window.removeEventListener('hashchange', checkUrlMatch)\n window.history.pushState = originalPushState\n window.history.replaceState = originalReplaceState\n }\n }, [isPreviewMode, survey, removeSurveyFromFocus, setSurveyVisible])\n}\n\nexport function usePopupVisibility(\n survey: Survey,\n posthog: PostHog | undefined,\n millisecondDelay: number,\n isPreviewMode: boolean,\n removeSurveyFromFocus: (survey: SurveyWithTypeAndAppearance) => void,\n surveyContainerRef?: React.RefObject<HTMLDivElement>\n) {\n const [isPopupVisible, setIsPopupVisible] = useState(\n isPreviewMode || millisecondDelay === 0 || survey.type === SurveyType.ExternalSurvey\n )\n const [isSurveySent, setIsSurveySent] = useState(false)\n\n const hidePopupWithViewTransition = () => {\n const removeDOMAndHidePopup = () => {\n if (survey.type === SurveyType.Popover) {\n removeSurveyFromFocus(survey)\n }\n setIsPopupVisible(false)\n }\n\n if (!document.startViewTransition) {\n removeDOMAndHidePopup()\n return\n }\n\n const transition = document.startViewTransition(() => {\n surveyContainerRef?.current?.remove()\n })\n\n transition.finished.then(() => {\n setTimeout(() => {\n removeDOMAndHidePopup()\n }, 100)\n })\n }\n\n const handleSurveyClosed = (event: CustomEvent) => {\n if (event.detail.surveyId !== survey.id) {\n return\n }\n hidePopupWithViewTransition()\n }\n\n useEffect(() => {\n if (!posthog) {\n logger.error('usePopupVisibility hook called without a PostHog instance.')\n return\n }\n if (isPreviewMode) {\n return\n }\n\n const handleSurveySent = (event: CustomEvent) => {\n if (event.detail.surveyId !== survey.id) {\n return\n }\n if (!survey.appearance?.displayThankYouMessage) {\n return hidePopupWithViewTransition()\n }\n setIsSurveySent(true)\n if (survey.appearance?.autoDisappear) {\n setTimeout(() => {\n hidePopupWithViewTransition()\n }, 5000)\n }\n }\n\n const showSurvey = () => {\n // check if the url is still matching, necessary for delayed surveys, as the URL may have changed\n if (!doesSurveyUrlMatch(survey)) {\n return\n }\n setIsPopupVisible(true)\n window.dispatchEvent(new Event('PHSurveyShown'))\n posthog.capture(SurveyEventName.SHOWN, {\n [SurveyEventProperties.SURVEY_NAME]: survey.name,\n [SurveyEventProperties.SURVEY_ID]: survey.id,\n [SurveyEventProperties.SURVEY_ITERATION]: survey.current_iteration,\n [SurveyEventProperties.SURVEY_ITERATION_START_DATE]: survey.current_iteration_start_date,\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n })\n localStorage.setItem('lastSeenSurveyDate', new Date().toISOString())\n }\n\n addEventListener(window, 'PHSurveyClosed', handleSurveyClosed as EventListener)\n addEventListener(window, 'PHSurveySent', handleSurveySent as EventListener)\n\n if (millisecondDelay > 0) {\n // This path is only used for direct usage of SurveyPopup,\n // not for surveys managed by SurveyManager\n const timeoutId = setTimeout(showSurvey, millisecondDelay)\n return () => {\n clearTimeout(timeoutId)\n window.removeEventListener('PHSurveyClosed', handleSurveyClosed as EventListener)\n window.removeEventListener('PHSurveySent', handleSurveySent as EventListener)\n }\n } else {\n // This is the path used for surveys managed by SurveyManager\n showSurvey()\n return () => {\n window.removeEventListener('PHSurveyClosed', handleSurveyClosed as EventListener)\n window.removeEventListener('PHSurveySent', handleSurveySent as EventListener)\n }\n }\n }, [])\n\n useHideSurveyOnURLChange({\n survey,\n removeSurveyFromFocus,\n setSurveyVisible: setIsPopupVisible,\n isPreviewMode,\n })\n\n return { isPopupVisible, isSurveySent, setIsPopupVisible, hidePopupWithViewTransition }\n}\n\ninterface SurveyPopupProps {\n survey: Survey\n forceDisableHtml?: boolean\n posthog?: PostHog\n style?: React.CSSProperties\n previewPageIndex?: number | undefined\n removeSurveyFromFocus?: (survey: SurveyWithTypeAndAppearance) => void\n isPopup?: boolean\n onPreviewSubmit?: (res: string | string[] | number | null) => void\n onPopupSurveyDismissed?: () => void\n onCloseConfirmationMessage?: () => void\n}\n\nfunction getPopoverPosition(\n type: SurveyType,\n position: SurveyPosition = SurveyPosition.Right,\n surveyWidgetType?: SurveyWidgetType\n) {\n if (type === SurveyType.ExternalSurvey) {\n return {}\n }\n\n switch (position) {\n case SurveyPosition.TopLeft:\n return { top: '0', left: '0', transform: 'translate(30px, 30px)' }\n case SurveyPosition.TopRight:\n return { top: '0', right: '0', transform: 'translate(-30px, 30px)' }\n case SurveyPosition.TopCenter:\n return { top: '0', left: '50%', transform: 'translate(-50%, 30px)' }\n case SurveyPosition.MiddleLeft:\n return { top: '50%', left: '0', transform: 'translate(30px, -50%)' }\n case SurveyPosition.MiddleRight:\n return { top: '50%', right: '0', transform: 'translate(-30px, -50%)' }\n case SurveyPosition.MiddleCenter:\n return { top: '50%', left: '50%', transform: 'translate(-50%, -50%)' }\n case SurveyPosition.Left:\n return { left: '30px' }\n case SurveyPosition.Center:\n return {\n left: '50%',\n transform: 'translateX(-50%)',\n }\n default:\n case SurveyPosition.Right:\n return { right: type === SurveyType.Widget && surveyWidgetType === SurveyWidgetType.Tab ? '60px' : '30px' }\n }\n}\n\nfunction getTabPositionStyles(position: SurveyTabPosition = SurveyTabPosition.Right): React.CSSProperties {\n switch (position) {\n case SurveyTabPosition.Top:\n return { top: '0', left: '50%', transform: 'translateX(-50%)' }\n case SurveyTabPosition.Left:\n return { top: '50%', left: '0', transform: 'rotate(90deg) translateY(-100%)', transformOrigin: 'left top' }\n case SurveyTabPosition.Bottom: // bottom center\n return { bottom: '0', left: '50%', transform: 'translateX(-50%)' }\n default:\n case SurveyTabPosition.Right:\n // not perfectly centered vertically, to avoid a \"breaking\" change\n return {\n top: '50%',\n right: '0',\n transform: 'rotate(-90deg) translateY(-100%)',\n transformOrigin: 'right top',\n }\n }\n}\n\nexport function SurveyPopup({\n survey,\n forceDisableHtml,\n posthog,\n style = {},\n previewPageIndex,\n removeSurveyFromFocus = () => {},\n isPopup = true,\n onPreviewSubmit = () => {},\n onPopupSurveyDismissed = () => {},\n onCloseConfirmationMessage = () => {},\n}: SurveyPopupProps) {\n const surveyContainerRef = useRef<HTMLDivElement>(null)\n const isPreviewMode = Number.isInteger(previewPageIndex)\n // NB: The client-side code passes the millisecondDelay in seconds, but setTimeout expects milliseconds, so we multiply by 1000\n const surveyPopupDelayMilliseconds = survey.appearance?.surveyPopupDelaySeconds\n ? survey.appearance.surveyPopupDelaySeconds * 1000\n : 0\n const { isPopupVisible, isSurveySent, hidePopupWithViewTransition } = usePopupVisibility(\n survey,\n posthog,\n surveyPopupDelayMilliseconds,\n isPreviewMode,\n removeSurveyFromFocus,\n surveyContainerRef\n )\n\n const shouldShowConfirmation = isSurveySent || previewPageIndex === survey.questions.length\n const surveyContextValue = useMemo(() => {\n const getInProgressSurvey = getInProgressSurveyState(survey)\n return {\n isPreviewMode,\n previewPageIndex: previewPageIndex,\n onPopupSurveyDismissed: () => {\n dismissedSurveyEvent(survey, posthog, isPreviewMode)\n onPopupSurveyDismissed()\n },\n isPopup: isPopup || false,\n surveySubmissionId: getInProgressSurvey?.surveySubmissionId || uuidv7(),\n onPreviewSubmit,\n posthog,\n }\n }, [isPreviewMode, previewPageIndex, isPopup, posthog, survey, onPopupSurveyDismissed, onPreviewSubmit])\n\n if (!isPopupVisible) {\n return null\n }\n\n return (\n <SurveyContext.Provider value={surveyContextValue}>\n <div\n className=\"ph-survey\"\n style={{\n ...getPopoverPosition(survey.type, survey.appearance?.position, survey.appearance?.widgetType),\n ...style,\n }}\n ref={surveyContainerRef}\n >\n {!shouldShowConfirmation ? (\n <Questions survey={survey} forceDisableHtml={!!forceDisableHtml} posthog={posthog} />\n ) : (\n <ConfirmationMessage\n header={survey.appearance?.thankYouMessageHeader || 'Thank you!'}\n description={survey.appearance?.thankYouMessageDescription || ''}\n forceDisableHtml={!!forceDisableHtml}\n contentType={survey.appearance?.thankYouMessageDescriptionContentType}\n appearance={survey.appearance || defaultSurveyAppearance}\n onClose={() => {\n hidePopupWithViewTransition()\n onCloseConfirmationMessage()\n }}\n />\n )}\n </div>\n </SurveyContext.Provider>\n )\n}\n\nexport function Questions({\n survey,\n forceDisableHtml,\n posthog,\n}: {\n survey: Survey\n forceDisableHtml: boolean\n posthog?: PostHog\n}) {\n // Initialize responses from localStorage or empty object\n const [questionsResponses, setQuestionsResponses] = useState(() => {\n const inProgressSurveyData = getInProgressSurveyState(survey)\n if (inProgressSurveyData?.responses) {\n logger.info('Survey is already in progress, filling in initial responses')\n }\n return inProgressSurveyData?.responses || {}\n })\n const { previewPageIndex, onPopupSurveyDismissed, isPopup, onPreviewSubmit, surveySubmissionId, isPreviewMode } =\n useContext(SurveyContext)\n const [currentQuestionIndex, setCurrentQuestionIndex] = useState(() => {\n const inProgressSurveyData = getInProgressSurveyState(survey)\n return previewPageIndex || inProgressSurveyData?.lastQuestionIndex || 0\n })\n const surveyQuestions = useMemo(() => getDisplayOrderQuestions(survey), [survey])\n\n // Sync preview state\n useEffect(() => {\n if (isPreviewMode && !isUndefined(previewPageIndex)) {\n setCurrentQuestionIndex(previewPageIndex)\n }\n }, [previewPageIndex, isPreviewMode])\n\n const onNextButtonClick = ({\n res,\n displayQuestionIndex,\n questionId,\n }: {\n res: string | string[] | number | null\n displayQuestionIndex: number\n questionId?: string\n }) => {\n if (!posthog) {\n logger.error('onNextButtonClick called without a PostHog instance.')\n return\n }\n\n if (!questionId) {\n logger.error('onNextButtonClick called without a questionId.')\n return\n }\n\n const responseKey = getSurveyResponseKey(questionId)\n\n const newResponses = { ...questionsResponses, [responseKey]: res }\n setQuestionsResponses(newResponses)\n\n const nextStep = getNextSurveyStep(survey, displayQuestionIndex, res)\n const isSurveyCompleted = nextStep === SurveyQuestionBranchingType.End\n\n if (!isSurveyCompleted) {\n setCurrentQuestionIndex(nextStep)\n setInProgressSurveyState(survey, {\n surveySubmissionId: surveySubmissionId,\n responses: newResponses,\n lastQuestionIndex: nextStep,\n })\n }\n\n // If partial responses are enabled, send the survey sent event with with the responses,\n // otherwise only send the event when the survey is completed\n if (survey.enable_partial_responses || isSurveyCompleted) {\n sendSurveyEvent({\n responses: newResponses,\n survey,\n surveySubmissionId,\n isSurveyCompleted,\n posthog,\n })\n }\n }\n\n const currentQuestion = surveyQuestions.at(currentQuestionIndex)\n\n if (!currentQuestion) {\n return null\n }\n\n return (\n <form className=\"survey-form\" name=\"surveyForm\">\n {isPopup && (\n <Cancel\n onClick={() => {\n onPopupSurveyDismissed()\n }}\n />\n )}\n <div className=\"survey-box\">\n {getQuestionComponent({\n question: currentQuestion,\n forceDisableHtml,\n displayQuestionIndex: currentQuestionIndex,\n appearance: survey.appearance || defaultSurveyAppearance,\n onSubmit: (res) =>\n onNextButtonClick({\n res,\n displayQuestionIndex: currentQuestionIndex,\n questionId: currentQuestion.id,\n }),\n onPreviewSubmit,\n initialValue: currentQuestion.id\n ? questionsResponses[getSurveyResponseKey(currentQuestion.id)]\n : undefined,\n })}\n </div>\n </form>\n )\n}\n\nexport function FeedbackWidget({\n survey,\n forceDisableHtml,\n posthog,\n readOnly,\n}: {\n survey: Survey\n forceDisableHtml?: boolean\n posthog?: PostHog\n readOnly?: boolean\n}): JSX.Element | null {\n const [isFeedbackButtonVisible, setIsFeedbackButtonVisible] = useState(true)\n const [showSurvey, setShowSurvey] = useState(false)\n const [styleOverrides, setStyleOverrides] = useState<React.CSSProperties>({})\n\n const toggleSurvey = () => {\n setShowSurvey(!showSurvey)\n }\n\n useEffect(() => {\n if (!posthog) {\n logger.error('FeedbackWidget called without a PostHog instance.')\n return\n }\n if (readOnly) {\n return\n }\n\n if (survey.appearance?.widgetType === 'tab') {\n setStyleOverrides({\n top: '50%',\n bottom: 'auto',\n })\n }\n const handleShowSurvey = (event: Event) => {\n const customEvent = event as CustomEvent\n // Check if the event is for this specific survey instance\n if (customEvent.detail?.surveyId === survey.id) {\n logger.info(`Received show event for feedback button survey ${survey.id}`)\n setStyleOverrides(customEvent.detail.position || {})\n toggleSurvey()\n }\n }\n\n addEventListener(window, DISPATCH_FEEDBACK_WIDGET_EVENT, handleShowSurvey)\n\n // Cleanup listener on component unmount\n return () => {\n window.removeEventListener(DISPATCH_FEEDBACK_WIDGET_EVENT, handleShowSurvey)\n }\n }, [\n posthog,\n readOnly,\n survey.id,\n survey.appearance?.widgetType,\n survey.appearance?.widgetSelector,\n survey.appearance?.borderColor,\n ])\n\n useHideSurveyOnURLChange({\n survey,\n setSurveyVisible: setIsFeedbackButtonVisible,\n })\n\n if (!isFeedbackButtonVisible) {\n return null\n }\n\n const resetShowSurvey = () => {\n // hide the feedback button after answering or closing the survey if it's not always show\n if (survey.schedule !== SurveySchedule.Always) {\n setIsFeedbackButtonVisible(false)\n }\n // important so our view transition has time to run\n setTimeout(() => {\n setShowSurvey(false)\n }, 200)\n }\n\n return (\n <Preact.Fragment>\n {survey.appearance?.widgetType === 'tab' && (\n <button\n className={`ph-survey-widget-tab ${survey.appearance?.tabPosition === SurveyTabPosition.Top ? 'widget-tab-top' : ''}`}\n onClick={toggleSurvey}\n disabled={readOnly}\n style={getTabPositionStyles(survey.appearance?.tabPosition)}\n >\n {survey.appearance?.widgetLabel || ''}\n </button>\n )}\n {showSurvey && (\n <SurveyPopup\n posthog={posthog}\n survey={survey}\n forceDisableHtml={forceDisableHtml}\n style={styleOverrides}\n onPopupSurveyDismissed={resetShowSurvey}\n onCloseConfirmationMessage={resetShowSurvey}\n />\n )}\n </Preact.Fragment>\n )\n}\n\ninterface GetQuestionComponentProps extends CommonQuestionProps {\n question: SurveyQuestion\n displayQuestionIndex: number\n}\n\nconst getQuestionComponent = ({\n question,\n forceDisableHtml,\n displayQuestionIndex,\n appearance,\n onSubmit,\n onPreviewSubmit,\n initialValue,\n}: GetQuestionComponentProps): JSX.Element | null => {\n const baseProps = {\n forceDisableHtml,\n appearance,\n onPreviewSubmit: (res: string | string[] | number | null) => {\n onPreviewSubmit(res)\n },\n onSubmit: (res: string | string[] | number | null) => {\n onSubmit(res)\n },\n initialValue,\n displayQuestionIndex,\n }\n\n switch (question.type) {\n case SurveyQuestionType.Open:\n return <OpenTextQuestion {...baseProps} question={question} key={question.id} />\n case SurveyQuestionType.Link:\n return <LinkQuestion {...baseProps} question={question} key={question.id} />\n case SurveyQuestionType.Rating:\n return <RatingQuestion {...baseProps} question={question} key={question.id} />\n case SurveyQuestionType.SingleChoice:\n case SurveyQuestionType.MultipleChoice:\n return <MultipleChoiceQuestion {...baseProps} question={question} key={question.id} />\n default:\n logger.error(`Unsupported question type: ${(question as any).type}`)\n return null\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"surveys.jsx","sourceRoot":"","sources":["../../../src/extensions/surveys.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsGA,8CA6EC;AA4kBD,0CAmDC;AAmBD,4DAwDC;AAED,gDAoHC;AAsED,kCA6EC;AAED,8BAoHC;AAED,wCAuGC;AAr2CD,6CAAgC;AAChC,sCAA+E;AAE/E,kEAciC;AACjC,kCAA2C;AAC3C,4CAA2E;AAC3E,sDAM8B;AAC9B,sCAAmD;AACnD,oCAAkC;AAClC,gFAA8E;AAC9E,sEAA4D;AAC5D,oEAM2C;AAC3C,6EAoB0C;AAC1C,kEAIoC;AAEpC,gGAAgG;AAChG,IAAM,MAAM,GAAG,gBAAqC,CAAA;AACpD,IAAM,QAAQ,GAAG,kBAAqB,CAAA;AAEtC,IAAM,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B,CAAC,IAAI;YACxB,OAAO,CAAC,gCAAgB,CAAC,IAAI,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAG,CAAA;QACpF,KAAK,0CAAkB,CAAC,IAAI;YACxB,OAAO,CAAC,4BAAY,CAAC,IAAI,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAG,CAAA;QAChF,KAAK,0CAAkB,CAAC,MAAM;YAC1B,OAAO,CAAC,8BAAc,CAAC,IAAI,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAG,CAAA;QAClF,KAAK,0CAAkB,CAAC,YAAY,CAAC;QACrC,KAAK,0CAAkB,CAAC,cAAc;YAClC,OAAO,CAAC,sCAAsB,CAAC,IAAI,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAG,CAAA;QAC1F;YACI,4BAAM,CAAC,KAAK,CAAC,qCAA+B,QAAgB,CAAC,IAAI,CAAE,CAAC,CAAA;YACpE,OAAO,IAAI,CAAA;IACnB,CAAC;AACL,CAAC,CAAA","sourcesContent":["import * as Preact from 'preact'\nimport { useContext, useEffect, useMemo, useRef, useState } from 'preact/hooks'\nimport { PostHog } from '../posthog-core'\nimport {\n Survey,\n SurveyCallback,\n SurveyEventName,\n SurveyEventProperties,\n SurveyPosition,\n SurveyQuestion,\n SurveyQuestionBranchingType,\n SurveyQuestionType,\n SurveySchedule,\n SurveyTabPosition,\n SurveyType,\n SurveyWidgetType,\n SurveyWithTypeAndAppearance,\n} from '../posthog-surveys-types'\nimport { addEventListener } from '../utils'\nimport { document as _document, window as _window } from '../utils/globals'\nimport {\n doesSurveyActivateByAction,\n doesSurveyActivateByEvent,\n IN_APP_SURVEY_TYPES,\n isSurveyRunning,\n SURVEY_LOGGER as logger,\n} from '../utils/survey-utils'\nimport { isNull, isUndefined } from '@posthog/core'\nimport { uuidv7 } from '../uuidv7'\nimport { ConfirmationMessage } from './surveys/components/ConfirmationMessage'\nimport { Cancel } from './surveys/components/QuestionHeader'\nimport {\n CommonQuestionProps,\n LinkQuestion,\n MultipleChoiceQuestion,\n OpenTextQuestion,\n RatingQuestion,\n} from './surveys/components/QuestionTypes'\nimport {\n canActivateRepeatedly,\n retrieveSurveyShadow,\n defaultSurveyAppearance,\n dismissedSurveyEvent,\n doesSurveyDeviceTypesMatch,\n doesSurveyMatchSelector,\n doesSurveyUrlMatch,\n getDisplayOrderQuestions,\n getInProgressSurveyState,\n getSurveyContainerClass,\n getSurveyResponseKey,\n getSurveySeen,\n hasWaitPeriodPassed,\n isSurveyInProgress,\n sendSurveyEvent,\n setInProgressSurveyState,\n SurveyContext,\n getSurveyStylesheet,\n addSurveyCSSVariablesToElement,\n} from './surveys/surveys-extension-utils'\nimport {\n extractPrefillParamsFromUrl,\n convertPrefillToResponses,\n allRequiredQuestionsFilled,\n} from '../utils/survey-url-prefill'\n\n// We cast the types here which is dangerous but protected by the top level generateSurveys call\nconst window = _window as Window & typeof globalThis\nconst document = _document as Document\n\nconst DISPATCH_FEEDBACK_WIDGET_EVENT = 'ph:show_survey_widget'\nconst WIDGET_LISTENER_ATTRIBUTE = 'PHWidgetSurveyClickListener'\n\nfunction getRatingBucketForResponseValue(responseValue: number, scale: number) {\n if (scale === 3) {\n if (responseValue < 1 || responseValue > 3) {\n throw new Error('The response must be in range 1-3')\n }\n\n return responseValue === 1 ? 'negative' : responseValue === 2 ? 'neutral' : 'positive'\n } else if (scale === 5) {\n if (responseValue < 1 || responseValue > 5) {\n throw new Error('The response must be in range 1-5')\n }\n\n return responseValue <= 2 ? 'negative' : responseValue === 3 ? 'neutral' : 'positive'\n } else if (scale === 7) {\n if (responseValue < 1 || responseValue > 7) {\n throw new Error('The response must be in range 1-7')\n }\n\n return responseValue <= 3 ? 'negative' : responseValue === 4 ? 'neutral' : 'positive'\n } else if (scale === 10) {\n if (responseValue < 0 || responseValue > 10) {\n throw new Error('The response must be in range 0-10')\n }\n\n return responseValue <= 6 ? 'detractors' : responseValue <= 8 ? 'passives' : 'promoters'\n }\n\n throw new Error('The scale must be one of: 3, 5, 7, 10')\n}\n\nexport function getNextSurveyStep(\n survey: Survey,\n currentQuestionIndex: number,\n response: string | string[] | number | null\n) {\n const question = survey.questions[currentQuestionIndex]\n const nextQuestionIndex = currentQuestionIndex + 1\n\n if (!question.branching?.type) {\n if (currentQuestionIndex === survey.questions.length - 1) {\n return SurveyQuestionBranchingType.End\n }\n\n return nextQuestionIndex\n }\n\n if (question.branching.type === SurveyQuestionBranchingType.End) {\n return SurveyQuestionBranchingType.End\n } else if (question.branching.type === SurveyQuestionBranchingType.SpecificQuestion) {\n if (Number.isInteger(question.branching.index)) {\n return question.branching.index\n }\n } else if (question.branching.type === SurveyQuestionBranchingType.ResponseBased) {\n // Single choice\n if (question.type === SurveyQuestionType.SingleChoice) {\n // :KLUDGE: for now, look up the choiceIndex based on the response\n // TODO: once QuestionTypes.MultipleChoiceQuestion is refactored, pass the selected choiceIndex into this method\n let selectedChoiceIndex = question.choices.indexOf(`${response}`)\n\n if (selectedChoiceIndex === -1 && question.hasOpenChoice) {\n // if the response is not found in the choices, it must be the open choice,\n // which is always the last choice\n selectedChoiceIndex = question.choices.length - 1\n }\n\n if (question.branching?.responseValues?.hasOwnProperty(selectedChoiceIndex)) {\n const nextStep = question.branching.responseValues[selectedChoiceIndex]\n\n // Specific question\n if (Number.isInteger(nextStep)) {\n return nextStep\n }\n\n if (nextStep === SurveyQuestionBranchingType.End) {\n return SurveyQuestionBranchingType.End\n }\n\n return nextQuestionIndex\n }\n } else if (question.type === SurveyQuestionType.Rating) {\n if (typeof response !== 'number' || !Number.isInteger(response)) {\n throw new Error('The response type must be an integer')\n }\n\n const ratingBucket = getRatingBucketForResponseValue(response, question.scale)\n\n if (question.branching?.responseValues?.hasOwnProperty(ratingBucket)) {\n const nextStep = question.branching.responseValues[ratingBucket]\n\n // Specific question\n if (Number.isInteger(nextStep)) {\n return nextStep\n }\n\n if (nextStep === SurveyQuestionBranchingType.End) {\n return SurveyQuestionBranchingType.End\n }\n\n return nextQuestionIndex\n }\n }\n\n return nextQuestionIndex\n }\n\n logger.warn('Falling back to next question index due to unexpected branching type')\n return nextQuestionIndex\n}\n\nconst SURVEY_NEXT_TO_TRIGGER_PARAMS = {\n ESTIMATED_MIN_HEIGHT: 250,\n HORIZONTAL_PADDING: 20,\n TRIGGER_SPACING: 12,\n} as const\n\nfunction getNextToTriggerPosition(target: HTMLElement, surveyWidth: number): React.CSSProperties | null {\n try {\n const buttonRect = target.getBoundingClientRect()\n const viewportHeight = window.innerHeight\n const viewportWidth = window.innerWidth\n const estimatedMinSurveyHeight = SURVEY_NEXT_TO_TRIGGER_PARAMS.ESTIMATED_MIN_HEIGHT\n const buttonCenterX = buttonRect.left + buttonRect.width / 2\n let left = buttonCenterX - surveyWidth / 2\n const horizontalPadding = SURVEY_NEXT_TO_TRIGGER_PARAMS.HORIZONTAL_PADDING\n if (left + surveyWidth > viewportWidth - horizontalPadding) {\n left = viewportWidth - surveyWidth - horizontalPadding\n }\n if (left < horizontalPadding) {\n left = horizontalPadding\n }\n const spacing = SURVEY_NEXT_TO_TRIGGER_PARAMS.TRIGGER_SPACING\n const spaceBelow = viewportHeight - buttonRect.bottom\n const spaceAbove = buttonRect.top\n const showAbove = spaceBelow < estimatedMinSurveyHeight && spaceAbove > spaceBelow\n\n return {\n position: 'fixed',\n top: showAbove ? 'auto' : `${buttonRect.bottom + spacing}px`,\n left: `${left}px`,\n right: 'auto',\n bottom: showAbove ? `${viewportHeight - buttonRect.top + spacing}px` : 'auto',\n zIndex: defaultSurveyAppearance.zIndex,\n } satisfies React.CSSProperties\n } catch (error) {\n logger.warn('Failed to calculate trigger position:', error)\n return null\n }\n}\n\n// Keep in sync with posthog/constants.py on main repo\nconst SURVEY_TARGETING_FLAG_PREFIX = 'survey-targeting-'\n\nexport class SurveyManager {\n private _posthog: PostHog\n private _surveyInFocus: string | null\n private _surveyTimeouts: Map<string, NodeJS.Timeout> = new Map()\n private _autoSubmitTimeout?: NodeJS.Timeout\n private _widgetSelectorListeners: Map<string, { element: Element; listener: EventListener; survey: Survey }> =\n new Map()\n private _prefillHandledSurveys: Set<string> = new Set()\n\n constructor(posthog: PostHog) {\n this._posthog = posthog\n // This is used to track the survey that is currently in focus. We only show one survey at a time.\n this._surveyInFocus = null\n }\n\n private _clearSurveyTimeout(surveyId: string) {\n const timeout = this._surveyTimeouts.get(surveyId)\n if (timeout) {\n clearTimeout(timeout)\n this._surveyTimeouts.delete(surveyId)\n }\n }\n\n public handlePopoverSurvey = (survey: Survey): void => {\n this._clearSurveyTimeout(survey.id)\n this._addSurveyToFocus(survey)\n const delaySeconds = survey.appearance?.surveyPopupDelaySeconds || 0\n const { shadow } = retrieveSurveyShadow(survey, this._posthog)\n if (delaySeconds <= 0) {\n return Preact.render(\n <SurveyPopup\n posthog={this._posthog}\n survey={survey}\n removeSurveyFromFocus={this._removeSurveyFromFocus}\n />,\n shadow\n )\n }\n const timeoutId = setTimeout(() => {\n if (!doesSurveyUrlMatch(survey)) {\n return this._removeSurveyFromFocus(survey)\n }\n // rendering with surveyPopupDelaySeconds = 0 because we're already handling the timeout here\n Preact.render(\n <SurveyPopup\n posthog={this._posthog}\n survey={{ ...survey, appearance: { ...survey.appearance, surveyPopupDelaySeconds: 0 } }}\n removeSurveyFromFocus={this._removeSurveyFromFocus}\n />,\n shadow\n )\n }, delaySeconds * 1000)\n this._surveyTimeouts.set(survey.id, timeoutId)\n }\n\n private _handleWidget = (survey: Survey): void => {\n // Ensure widget container exists if it doesn't\n const { shadow, isNewlyCreated } = retrieveSurveyShadow(survey, this._posthog)\n\n // If the widget is already rendered, do nothing. Otherwise the widget will be re-rendered every second\n if (!isNewlyCreated) {\n return\n }\n\n Preact.render(<FeedbackWidget posthog={this._posthog} survey={survey} key={survey.id} />, shadow)\n }\n\n private _removeWidgetSelectorListener = (survey: Pick<Survey, 'id' | 'type' | 'appearance'>): void => {\n this._removeSurveyFromDom(survey)\n const existing = this._widgetSelectorListeners.get(survey.id)\n if (existing) {\n existing.element.removeEventListener('click', existing.listener)\n existing.element.removeAttribute(WIDGET_LISTENER_ATTRIBUTE)\n this._widgetSelectorListeners.delete(survey.id)\n logger.info(`Removed click listener for survey ${survey.id}`)\n }\n }\n\n private _manageWidgetSelectorListener = (survey: Survey, selector: string): void => {\n const currentElement = document.querySelector(selector)\n const existingListenerData = this._widgetSelectorListeners.get(survey.id)\n\n if (!currentElement) {\n if (existingListenerData) {\n this._removeWidgetSelectorListener(survey)\n }\n return\n }\n\n this._handleWidget(survey)\n\n if (existingListenerData) {\n // Listener exists, check if element changed\n if (currentElement !== existingListenerData.element) {\n logger.info(`Selector element changed for survey ${survey.id}. Re-attaching listener.`)\n this._removeWidgetSelectorListener(survey)\n // Continue to attach listener to the new element below\n } else {\n // Element is the same, listener already attached, do nothing\n return\n }\n }\n\n // Element found, and no listener attached (or it was just removed from old element)\n if (!currentElement.hasAttribute(WIDGET_LISTENER_ATTRIBUTE)) {\n const listener = (event: Event) => {\n event.stopPropagation() // Prevent bubbling\n\n const positionStyles =\n survey.appearance?.position === SurveyPosition.NextToTrigger\n ? getNextToTriggerPosition(\n event.currentTarget as HTMLElement,\n parseInt(survey.appearance?.maxWidth || defaultSurveyAppearance.maxWidth)\n )\n : {}\n\n window.dispatchEvent(\n new CustomEvent(DISPATCH_FEEDBACK_WIDGET_EVENT, {\n detail: { surveyId: survey.id, position: positionStyles },\n })\n )\n }\n\n addEventListener(currentElement, 'click', listener)\n currentElement.setAttribute(WIDGET_LISTENER_ATTRIBUTE, 'true')\n this._widgetSelectorListeners.set(survey.id, { element: currentElement, listener, survey })\n logger.info(`Attached click listener for feedback button survey ${survey.id}`)\n }\n }\n\n /**\n * Sorts surveys by their appearance delay in ascending order. If a survey does not have an appearance delay,\n * it is considered to have a delay of 0.\n * @param surveys\n * @returns The surveys sorted by their appearance delay\n */\n private _sortSurveysByAppearanceDelay(surveys: Survey[]): Survey[] {\n return surveys.sort((a, b) => {\n const isSurveyInProgressA = isSurveyInProgress(a)\n const isSurveyInProgressB = isSurveyInProgress(b)\n if (isSurveyInProgressA && !isSurveyInProgressB) {\n return -1 // a comes before b (in progress surveys first)\n }\n if (!isSurveyInProgressA && isSurveyInProgressB) {\n return 1 // a comes after b (in progress surveys first)\n }\n const aIsAlways = a.schedule === SurveySchedule.Always\n const bIsAlways = b.schedule === SurveySchedule.Always\n\n if (aIsAlways && !bIsAlways) {\n return 1 // a comes after b\n }\n if (!aIsAlways && bIsAlways) {\n return -1 // a comes before b\n }\n // If both are Always or neither is Always, sort by delay\n return (a.appearance?.surveyPopupDelaySeconds || 0) - (b.appearance?.surveyPopupDelaySeconds || 0)\n })\n }\n\n public renderPopover = (survey: Survey): void => {\n const { shadow } = retrieveSurveyShadow(survey, this._posthog)\n Preact.render(\n <SurveyPopup posthog={this._posthog} survey={survey} removeSurveyFromFocus={this._removeSurveyFromFocus} />,\n shadow\n )\n }\n\n public renderSurvey = (survey: Survey, selector: Element): void => {\n if (this._posthog.config?.surveys?.prefillFromUrl) {\n this._handleUrlPrefill(survey)\n }\n\n Preact.render(\n <SurveyPopup\n posthog={this._posthog}\n survey={survey}\n removeSurveyFromFocus={this._removeSurveyFromFocus}\n isPopup={false}\n />,\n selector\n )\n }\n\n private _handleUrlPrefill(survey: Survey): void {\n // Only handle prefill once per survey session to avoid overwriting in-progress responses\n if (this._prefillHandledSurveys.has(survey.id)) {\n return\n }\n\n try {\n const { params, autoSubmit } = extractPrefillParamsFromUrl(window.location.search)\n\n if (Object.keys(params).length === 0) {\n return\n }\n\n logger.info('[Survey Prefill] Detected URL prefill parameters')\n\n const responses = convertPrefillToResponses(survey, params)\n\n if (Object.keys(responses).length === 0) {\n logger.warn('[Survey Prefill] No valid responses after conversion')\n return\n }\n\n const submissionId = uuidv7()\n\n setInProgressSurveyState(survey, {\n surveySubmissionId: submissionId,\n responses: responses,\n lastQuestionIndex: 0,\n })\n\n logger.info('[Survey Prefill] Stored prefilled responses in localStorage')\n\n const shouldAutoSubmit =\n autoSubmit &&\n this._posthog.config.surveys?.autoSubmitIfComplete &&\n allRequiredQuestionsFilled(survey, responses)\n\n if (shouldAutoSubmit) {\n this._scheduleAutoSubmit(survey, responses, submissionId)\n }\n\n // Mark this survey as having been prefilled\n this._prefillHandledSurveys.add(survey.id)\n } catch (error) {\n logger.error('[Survey Prefill] Error handling URL prefill:', error)\n }\n }\n\n private _scheduleAutoSubmit(survey: Survey, responses: Record<string, any>, submissionId: string): void {\n const delay = this._posthog.config.surveys?.autoSubmitDelay ?? 800\n\n logger.info('[Survey Prefill] Auto-submit scheduled')\n\n this._autoSubmitTimeout = setTimeout(() => {\n logger.info('[Survey Prefill] Auto-submitting survey')\n\n sendSurveyEvent({\n responses,\n survey,\n surveySubmissionId: submissionId,\n posthog: this._posthog,\n isSurveyCompleted: true,\n })\n }, delay)\n }\n\n private _isSurveyFeatureFlagEnabled(flagKey: string | null, flagVariant: string | undefined = undefined) {\n if (!flagKey) {\n return true\n }\n const isFeatureEnabled = !!this._posthog.featureFlags.isFeatureEnabled(flagKey, {\n send_event: !flagKey.startsWith(SURVEY_TARGETING_FLAG_PREFIX),\n })\n let flagVariantCheck = true\n if (flagVariant) {\n const flagVariantValue = this._posthog.featureFlags.getFeatureFlag(flagKey, { send_event: false })\n flagVariantCheck = flagVariantValue === flagVariant || flagVariant === 'any'\n }\n return isFeatureEnabled && flagVariantCheck\n }\n\n private _isSurveyConditionMatched(survey: Survey): boolean {\n if (!survey.conditions) {\n return true\n }\n return doesSurveyUrlMatch(survey) && doesSurveyDeviceTypesMatch(survey) && doesSurveyMatchSelector(survey)\n }\n\n private _internalFlagCheckSatisfied(survey: Survey): boolean {\n return (\n canActivateRepeatedly(survey) ||\n this._isSurveyFeatureFlagEnabled(survey.internal_targeting_flag_key) ||\n isSurveyInProgress(survey)\n )\n }\n\n public checkSurveyEligibility(survey: Survey): { eligible: boolean; reason?: string } {\n const eligibility = { eligible: true, reason: undefined as string | undefined }\n\n if (!isSurveyRunning(survey)) {\n eligibility.eligible = false\n eligibility.reason = `Survey is not running. It was completed on ${survey.end_date}`\n return eligibility\n }\n\n if (!IN_APP_SURVEY_TYPES.includes(survey.type)) {\n eligibility.eligible = false\n eligibility.reason = `Surveys of type ${survey.type} are never eligible to be shown in the app`\n return eligibility\n }\n\n const linkedFlagVariant = survey.conditions?.linkedFlagVariant\n if (!this._isSurveyFeatureFlagEnabled(survey.linked_flag_key, linkedFlagVariant)) {\n eligibility.eligible = false\n if (!linkedFlagVariant) {\n eligibility.reason = `Survey linked feature flag is not enabled`\n } else {\n eligibility.reason = `Survey linked feature flag is not enabled for variant ${linkedFlagVariant}`\n }\n return eligibility\n }\n\n if (!this._isSurveyFeatureFlagEnabled(survey.targeting_flag_key)) {\n eligibility.eligible = false\n eligibility.reason = `Survey targeting feature flag is not enabled`\n return eligibility\n }\n\n if (!this._internalFlagCheckSatisfied(survey)) {\n eligibility.eligible = false\n eligibility.reason =\n 'Survey internal targeting flag is not enabled and survey cannot activate repeatedly and survey is not in progress'\n return eligibility\n }\n\n if (!hasWaitPeriodPassed(survey.conditions?.seenSurveyWaitPeriodInDays)) {\n eligibility.eligible = false\n eligibility.reason = `Survey wait period has not passed`\n return eligibility\n }\n\n if (getSurveySeen(survey)) {\n eligibility.eligible = false\n eligibility.reason = `Survey has already been seen and it can't be activated again`\n return eligibility\n }\n\n return eligibility\n }\n\n /**\n * Surveys can be activated by events or actions. This method checks if the survey has events and actions,\n * and if so, it checks if the survey has been activated.\n * @param survey\n */\n private _hasActionOrEventTriggeredSurvey(survey: Survey): boolean {\n if (!doesSurveyActivateByEvent(survey) && !doesSurveyActivateByAction(survey)) {\n // If survey doesn't depend on events/actions, it's considered \"triggered\" by default\n return true\n }\n const surveysActivatedByEventsOrActions: string[] | undefined =\n this._posthog.surveys._surveyEventReceiver?.getSurveys()\n return !!surveysActivatedByEventsOrActions?.includes(survey.id)\n }\n\n private _checkFlags(survey: Survey): boolean {\n if (!survey.feature_flag_keys?.length) {\n return true\n }\n\n return survey.feature_flag_keys.every(({ key, value }) => {\n if (!key || !value) {\n return true\n }\n return this._isSurveyFeatureFlagEnabled(value)\n })\n }\n\n public getActiveMatchingSurveys = (callback: SurveyCallback, forceReload = false): void => {\n this._posthog?.surveys.getSurveys((surveys) => {\n const targetingMatchedSurveys = surveys.filter((survey) => {\n const eligibility = this.checkSurveyEligibility(survey)\n return (\n eligibility.eligible &&\n this._isSurveyConditionMatched(survey) &&\n this._hasActionOrEventTriggeredSurvey(survey) &&\n this._checkFlags(survey)\n )\n })\n\n callback(targetingMatchedSurveys)\n }, forceReload)\n }\n\n public callSurveysAndEvaluateDisplayLogic = (forceReload: boolean = false): void => {\n this.getActiveMatchingSurveys((surveys) => {\n const inAppSurveysWithDisplayLogic = surveys.filter(\n (survey) => survey.type === SurveyType.Popover || survey.type === SurveyType.Widget\n )\n\n // Create a queue of surveys sorted by their appearance delay. We will evaluate the display logic\n // for each survey in the queue in order, and only display one survey at a time.\n const inAppSurveysQueue = this._sortSurveysByAppearanceDelay(inAppSurveysWithDisplayLogic)\n\n // Keep track of surveys processed this cycle to remove listeners for inactive ones\n const activeSelectorSurveys = new Set<string>()\n\n inAppSurveysQueue.forEach((survey) => {\n // Widget Type Logic\n if (survey.type === SurveyType.Widget) {\n if (survey.appearance?.widgetType === SurveyWidgetType.Tab) {\n this._handleWidget(survey)\n return\n }\n\n // For selector widget types, we need to manage the listener attachment/detachment dynamically\n if (\n survey.appearance?.widgetType === SurveyWidgetType.Selector &&\n survey.appearance?.widgetSelector\n ) {\n activeSelectorSurveys.add(survey.id)\n this._manageWidgetSelectorListener(survey, survey.appearance?.widgetSelector)\n }\n }\n\n // Popover Type Logic (only one shown at a time)\n if (isNull(this._surveyInFocus) && survey.type === SurveyType.Popover) {\n this.handlePopoverSurvey(survey)\n }\n })\n\n // Clean up listeners for surveys that are no longer active or matched\n this._widgetSelectorListeners.forEach(({ survey }) => {\n if (!activeSelectorSurveys.has(survey.id)) {\n this._removeWidgetSelectorListener(survey)\n }\n })\n }, forceReload)\n }\n\n private _addSurveyToFocus = (survey: Pick<Survey, 'id'>): void => {\n if (!isNull(this._surveyInFocus)) {\n logger.error(`Survey ${this._surveyInFocus} already in focus. Cannot add survey ${survey.id}.`)\n }\n this._surveyInFocus = survey.id\n }\n\n private _removeSurveyFromDom(survey: Pick<Survey, 'id' | 'type' | 'appearance'>): void {\n try {\n const shadowContainer = document.querySelector(getSurveyContainerClass(survey, true))\n if (shadowContainer?.shadowRoot) {\n Preact.render(null, shadowContainer.shadowRoot)\n }\n shadowContainer?.remove()\n } catch (error) {\n logger.warn(`Failed to remove survey ${survey.id} from DOM:`, error)\n }\n }\n\n private _removeSurveyFromFocus = (survey: SurveyWithTypeAndAppearance): void => {\n if (this._surveyInFocus !== survey.id) {\n logger.error(`Survey ${survey.id} is not in focus. Cannot remove survey ${survey.id}.`)\n }\n this._clearSurveyTimeout(survey.id)\n this._clearAutoSubmitTimeout()\n this._surveyInFocus = null\n this._removeSurveyFromDom(survey)\n }\n\n private _clearAutoSubmitTimeout(): void {\n if (this._autoSubmitTimeout) {\n clearTimeout(this._autoSubmitTimeout)\n this._autoSubmitTimeout = undefined\n }\n }\n\n // Expose internal state and methods for testing\n public getTestAPI() {\n return {\n addSurveyToFocus: this._addSurveyToFocus,\n removeSurveyFromFocus: this._removeSurveyFromFocus,\n surveyInFocus: this._surveyInFocus,\n surveyTimeouts: this._surveyTimeouts,\n handleWidget: this._handleWidget,\n handlePopoverSurvey: this.handlePopoverSurvey,\n manageWidgetSelectorListener: this._manageWidgetSelectorListener,\n sortSurveysByAppearanceDelay: this._sortSurveysByAppearanceDelay,\n checkFlags: this._checkFlags.bind(this),\n isSurveyFeatureFlagEnabled: this._isSurveyFeatureFlagEnabled.bind(this),\n }\n }\n}\n\nconst DEFAULT_PREVIEW_POSITION_STYLES: React.CSSProperties = {\n position: 'relative',\n left: 'unset',\n right: 'unset',\n top: 'unset',\n bottom: 'unset',\n transform: 'unset',\n}\n\nexport const renderSurveysPreview = ({\n survey,\n parentElement,\n previewPageIndex,\n forceDisableHtml,\n onPreviewSubmit,\n positionStyles = DEFAULT_PREVIEW_POSITION_STYLES,\n}: {\n survey: Survey\n parentElement: HTMLElement\n previewPageIndex: number\n forceDisableHtml?: boolean\n onPreviewSubmit?: (res: string | string[] | number | null) => void\n posthog?: PostHog\n positionStyles?: React.CSSProperties\n}) => {\n const currentStyle = parentElement.querySelector('style[data-ph-survey-style]')\n if (currentStyle) {\n currentStyle.remove()\n }\n const stylesheet = getSurveyStylesheet()\n if (stylesheet) {\n parentElement.appendChild(stylesheet)\n addSurveyCSSVariablesToElement(parentElement, survey.type, survey.appearance)\n }\n Preact.render(\n <SurveyPopup\n survey={survey}\n forceDisableHtml={forceDisableHtml}\n style={positionStyles}\n onPreviewSubmit={onPreviewSubmit}\n previewPageIndex={previewPageIndex}\n removeSurveyFromFocus={() => {}}\n />,\n parentElement\n )\n}\n\nexport const renderFeedbackWidgetPreview = ({\n survey,\n root,\n forceDisableHtml,\n}: {\n survey: Survey\n root: HTMLElement\n forceDisableHtml?: boolean\n}) => {\n const stylesheet = getSurveyStylesheet()\n if (stylesheet) {\n root.appendChild(stylesheet)\n addSurveyCSSVariablesToElement(root, survey.type, survey.appearance)\n }\n\n Preact.render(<FeedbackWidget forceDisableHtml={forceDisableHtml} survey={survey} readOnly={true} />, root)\n}\n\n// This is the main exported function\nexport function generateSurveys(posthog: PostHog, isSurveysEnabled: boolean | undefined) {\n // NOTE: Important to ensure we never try and run surveys without a window environment\n if (!document || !window) {\n return\n }\n\n const surveyManager = new SurveyManager(posthog)\n if (posthog.config.disable_surveys_automatic_display) {\n logger.info('Surveys automatic display is disabled. Skipping call surveys and evaluate display logic.')\n return surveyManager\n }\n\n // NOTE: The `generateSurveys` function used to accept just a single parameter, without any `isSurveysEnabled` parameter.\n // To keep compatibility with old clients, we'll consider `undefined` the same as `true`\n if (isSurveysEnabled === false) {\n logger.info('There are no surveys to load or Surveys is disabled in the project settings.')\n return surveyManager\n }\n\n surveyManager.callSurveysAndEvaluateDisplayLogic(true)\n\n let intervalId: number | undefined\n\n const startInterval = () => {\n if (!isUndefined(intervalId)) {\n return\n }\n intervalId = setInterval(() => {\n surveyManager.callSurveysAndEvaluateDisplayLogic(false)\n }, 1000) as unknown as number\n }\n\n const stopInterval = () => {\n if (!isUndefined(intervalId)) {\n clearInterval(intervalId)\n intervalId = undefined\n }\n }\n\n startInterval()\n\n addEventListener(document, 'visibilitychange', () => {\n if (document.hidden) {\n stopInterval()\n } else {\n surveyManager.callSurveysAndEvaluateDisplayLogic(false)\n startInterval()\n }\n })\n\n return surveyManager\n}\n\ntype UseHideSurveyOnURLChangeProps = {\n survey: Pick<Survey, 'id' | 'conditions' | 'type' | 'appearance'>\n removeSurveyFromFocus?: (survey: SurveyWithTypeAndAppearance) => void\n setSurveyVisible: (visible: boolean) => void\n isPreviewMode?: boolean\n}\n\n/**\n * This hook handles URL-based survey visibility after the initial mount.\n * The initial URL check is handled by the `getActiveMatchingSurveys` method in the `PostHogSurveys` class,\n * which ensures the URL matches before displaying a survey for the first time.\n * That is the method that is called every second to see if there's a matching survey.\n *\n * This separation of concerns means:\n * 1. Initial URL matching is done by `getActiveMatchingSurveys` before displaying the survey\n * 2. Subsequent URL changes are handled here to hide the survey as the user navigates\n */\nexport function useHideSurveyOnURLChange({\n survey,\n removeSurveyFromFocus = () => {},\n setSurveyVisible,\n isPreviewMode = false,\n}: UseHideSurveyOnURLChangeProps) {\n useEffect(() => {\n if (isPreviewMode || !survey.conditions?.url) {\n return\n }\n\n const checkUrlMatch = () => {\n const isSurveyTypeWidget = survey.type === SurveyType.Widget\n const doesSurveyMatchUrlCondition = doesSurveyUrlMatch(survey)\n const isSurveyWidgetTypeTab = survey.appearance?.widgetType === SurveyWidgetType.Tab && isSurveyTypeWidget\n\n if (doesSurveyMatchUrlCondition) {\n if (isSurveyWidgetTypeTab) {\n logger.info(`Showing survey ${survey.id} because it is a feedback button tab and URL matches`)\n setSurveyVisible(true)\n }\n return\n }\n\n logger.info(`Hiding survey ${survey.id} because URL does not match`)\n setSurveyVisible(false)\n return removeSurveyFromFocus(survey)\n }\n\n // Listen for browser back/forward browser history changes\n addEventListener(window, 'popstate', checkUrlMatch)\n // Listen for hash changes, for SPA frameworks that use hash-based routing\n // The hashchange event is fired when the fragment identifier of the URL has changed (the part of the URL beginning with and following the # symbol).\n addEventListener(window, 'hashchange', checkUrlMatch)\n\n // Listen for SPA navigation\n const originalPushState = window.history.pushState\n const originalReplaceState = window.history.replaceState\n\n window.history.pushState = function (...args) {\n originalPushState.apply(this, args)\n checkUrlMatch()\n }\n\n window.history.replaceState = function (...args) {\n originalReplaceState.apply(this, args)\n checkUrlMatch()\n }\n\n return () => {\n window.removeEventListener('popstate', checkUrlMatch)\n window.removeEventListener('hashchange', checkUrlMatch)\n window.history.pushState = originalPushState\n window.history.replaceState = originalReplaceState\n }\n }, [isPreviewMode, survey, removeSurveyFromFocus, setSurveyVisible])\n}\n\nexport function usePopupVisibility(\n survey: Survey,\n posthog: PostHog | undefined,\n millisecondDelay: number,\n isPreviewMode: boolean,\n removeSurveyFromFocus: (survey: SurveyWithTypeAndAppearance) => void,\n isPopup: boolean,\n surveyContainerRef?: React.RefObject<HTMLDivElement>\n) {\n const [isPopupVisible, setIsPopupVisible] = useState(\n isPreviewMode || millisecondDelay === 0 || survey.type === SurveyType.ExternalSurvey\n )\n const [isSurveySent, setIsSurveySent] = useState(false)\n\n const hidePopupWithViewTransition = () => {\n const removeDOMAndHidePopup = () => {\n if (isPopup) {\n removeSurveyFromFocus(survey)\n }\n setIsPopupVisible(false)\n }\n\n if (!document.startViewTransition) {\n removeDOMAndHidePopup()\n return\n }\n\n const transition = document.startViewTransition(() => {\n surveyContainerRef?.current?.remove()\n })\n\n transition.finished.then(() => {\n setTimeout(() => {\n removeDOMAndHidePopup()\n }, 100)\n })\n }\n\n const handleSurveyClosed = (event: CustomEvent) => {\n if (event.detail.surveyId !== survey.id) {\n return\n }\n hidePopupWithViewTransition()\n }\n\n useEffect(() => {\n if (!posthog) {\n logger.error('usePopupVisibility hook called without a PostHog instance.')\n return\n }\n if (isPreviewMode) {\n return\n }\n\n const handleSurveySent = (event: CustomEvent) => {\n if (event.detail.surveyId !== survey.id) {\n return\n }\n if (!survey.appearance?.displayThankYouMessage) {\n return hidePopupWithViewTransition()\n }\n setIsSurveySent(true)\n if (survey.appearance?.autoDisappear) {\n setTimeout(() => {\n hidePopupWithViewTransition()\n }, 5000)\n }\n }\n\n const showSurvey = () => {\n // check if the url is still matching, necessary for delayed surveys, as the URL may have changed\n if (!doesSurveyUrlMatch(survey)) {\n return\n }\n setIsPopupVisible(true)\n window.dispatchEvent(new Event('PHSurveyShown'))\n posthog.capture(SurveyEventName.SHOWN, {\n [SurveyEventProperties.SURVEY_NAME]: survey.name,\n [SurveyEventProperties.SURVEY_ID]: survey.id,\n [SurveyEventProperties.SURVEY_ITERATION]: survey.current_iteration,\n [SurveyEventProperties.SURVEY_ITERATION_START_DATE]: survey.current_iteration_start_date,\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n })\n localStorage.setItem('lastSeenSurveyDate', new Date().toISOString())\n }\n\n addEventListener(window, 'PHSurveyClosed', handleSurveyClosed as EventListener)\n addEventListener(window, 'PHSurveySent', handleSurveySent as EventListener)\n\n if (millisecondDelay > 0) {\n // This path is only used for direct usage of SurveyPopup,\n // not for surveys managed by SurveyManager\n const timeoutId = setTimeout(showSurvey, millisecondDelay)\n return () => {\n clearTimeout(timeoutId)\n window.removeEventListener('PHSurveyClosed', handleSurveyClosed as EventListener)\n window.removeEventListener('PHSurveySent', handleSurveySent as EventListener)\n }\n } else {\n // This is the path used for surveys managed by SurveyManager\n showSurvey()\n return () => {\n window.removeEventListener('PHSurveyClosed', handleSurveyClosed as EventListener)\n window.removeEventListener('PHSurveySent', handleSurveySent as EventListener)\n }\n }\n }, [])\n\n useHideSurveyOnURLChange({\n survey,\n removeSurveyFromFocus,\n setSurveyVisible: setIsPopupVisible,\n isPreviewMode,\n })\n\n return { isPopupVisible, isSurveySent, setIsPopupVisible, hidePopupWithViewTransition }\n}\n\ninterface SurveyPopupProps {\n survey: Survey\n forceDisableHtml?: boolean\n posthog?: PostHog\n style?: React.CSSProperties\n previewPageIndex?: number | undefined\n removeSurveyFromFocus?: (survey: SurveyWithTypeAndAppearance) => void\n isPopup?: boolean\n onPreviewSubmit?: (res: string | string[] | number | null) => void\n onPopupSurveyDismissed?: () => void\n onCloseConfirmationMessage?: () => void\n}\n\nfunction getPopoverPosition(\n type: SurveyType,\n position: SurveyPosition = SurveyPosition.Right,\n surveyWidgetType?: SurveyWidgetType\n) {\n if (type === SurveyType.ExternalSurvey) {\n return {}\n }\n\n switch (position) {\n case SurveyPosition.TopLeft:\n return { top: '0', left: '0', transform: 'translate(30px, 30px)' }\n case SurveyPosition.TopRight:\n return { top: '0', right: '0', transform: 'translate(-30px, 30px)' }\n case SurveyPosition.TopCenter:\n return { top: '0', left: '50%', transform: 'translate(-50%, 30px)' }\n case SurveyPosition.MiddleLeft:\n return { top: '50%', left: '0', transform: 'translate(30px, -50%)' }\n case SurveyPosition.MiddleRight:\n return { top: '50%', right: '0', transform: 'translate(-30px, -50%)' }\n case SurveyPosition.MiddleCenter:\n return { top: '50%', left: '50%', transform: 'translate(-50%, -50%)' }\n case SurveyPosition.Left:\n return { left: '30px' }\n case SurveyPosition.Center:\n return {\n left: '50%',\n transform: 'translateX(-50%)',\n }\n default:\n case SurveyPosition.Right:\n return { right: type === SurveyType.Widget && surveyWidgetType === SurveyWidgetType.Tab ? '60px' : '30px' }\n }\n}\n\nfunction getTabPositionStyles(position: SurveyTabPosition = SurveyTabPosition.Right): React.CSSProperties {\n switch (position) {\n case SurveyTabPosition.Top:\n return { top: '0', left: '50%', transform: 'translateX(-50%)' }\n case SurveyTabPosition.Left:\n return { top: '50%', left: '0', transform: 'rotate(90deg) translateY(-100%)', transformOrigin: 'left top' }\n case SurveyTabPosition.Bottom: // bottom center\n return { bottom: '0', left: '50%', transform: 'translateX(-50%)' }\n default:\n case SurveyTabPosition.Right:\n // not perfectly centered vertically, to avoid a \"breaking\" change\n return {\n top: '50%',\n right: '0',\n transform: 'rotate(-90deg) translateY(-100%)',\n transformOrigin: 'right top',\n }\n }\n}\n\nexport function SurveyPopup({\n survey,\n forceDisableHtml,\n posthog,\n style = {},\n previewPageIndex,\n removeSurveyFromFocus = () => {},\n isPopup = true,\n onPreviewSubmit = () => {},\n onPopupSurveyDismissed = () => {},\n onCloseConfirmationMessage = () => {},\n}: SurveyPopupProps) {\n const surveyContainerRef = useRef<HTMLDivElement>(null)\n const isPreviewMode = Number.isInteger(previewPageIndex)\n // NB: The client-side code passes the millisecondDelay in seconds, but setTimeout expects milliseconds, so we multiply by 1000\n const surveyPopupDelayMilliseconds = survey.appearance?.surveyPopupDelaySeconds\n ? survey.appearance.surveyPopupDelaySeconds * 1000\n : 0\n const { isPopupVisible, isSurveySent, hidePopupWithViewTransition } = usePopupVisibility(\n survey,\n posthog,\n surveyPopupDelayMilliseconds,\n isPreviewMode,\n removeSurveyFromFocus,\n isPopup,\n surveyContainerRef\n )\n\n const shouldShowConfirmation = isSurveySent || previewPageIndex === survey.questions.length\n const surveyContextValue = useMemo(() => {\n const getInProgressSurvey = getInProgressSurveyState(survey)\n return {\n isPreviewMode,\n previewPageIndex: previewPageIndex,\n onPopupSurveyDismissed: () => {\n dismissedSurveyEvent(survey, posthog, isPreviewMode)\n onPopupSurveyDismissed()\n },\n isPopup: isPopup || false,\n surveySubmissionId: getInProgressSurvey?.surveySubmissionId || uuidv7(),\n onPreviewSubmit,\n posthog,\n }\n }, [isPreviewMode, previewPageIndex, isPopup, posthog, survey, onPopupSurveyDismissed, onPreviewSubmit])\n\n if (!isPopupVisible) {\n return null\n }\n\n return (\n <SurveyContext.Provider value={surveyContextValue}>\n <div\n className=\"ph-survey\"\n style={{\n ...getPopoverPosition(survey.type, survey.appearance?.position, survey.appearance?.widgetType),\n ...style,\n }}\n ref={surveyContainerRef}\n >\n {!shouldShowConfirmation ? (\n <Questions survey={survey} forceDisableHtml={!!forceDisableHtml} posthog={posthog} />\n ) : (\n <ConfirmationMessage\n header={survey.appearance?.thankYouMessageHeader || 'Thank you!'}\n description={survey.appearance?.thankYouMessageDescription || ''}\n forceDisableHtml={!!forceDisableHtml}\n contentType={survey.appearance?.thankYouMessageDescriptionContentType}\n appearance={survey.appearance || defaultSurveyAppearance}\n onClose={() => {\n hidePopupWithViewTransition()\n onCloseConfirmationMessage()\n }}\n />\n )}\n </div>\n </SurveyContext.Provider>\n )\n}\n\nexport function Questions({\n survey,\n forceDisableHtml,\n posthog,\n}: {\n survey: Survey\n forceDisableHtml: boolean\n posthog?: PostHog\n}) {\n // Initialize responses from localStorage or empty object\n const [questionsResponses, setQuestionsResponses] = useState(() => {\n const inProgressSurveyData = getInProgressSurveyState(survey)\n if (inProgressSurveyData?.responses) {\n logger.info('Survey is already in progress, filling in initial responses')\n }\n return inProgressSurveyData?.responses || {}\n })\n const { previewPageIndex, onPopupSurveyDismissed, isPopup, onPreviewSubmit, surveySubmissionId, isPreviewMode } =\n useContext(SurveyContext)\n const [currentQuestionIndex, setCurrentQuestionIndex] = useState(() => {\n const inProgressSurveyData = getInProgressSurveyState(survey)\n return previewPageIndex || inProgressSurveyData?.lastQuestionIndex || 0\n })\n const surveyQuestions = useMemo(() => getDisplayOrderQuestions(survey), [survey])\n\n // Sync preview state\n useEffect(() => {\n if (isPreviewMode && !isUndefined(previewPageIndex)) {\n setCurrentQuestionIndex(previewPageIndex)\n }\n }, [previewPageIndex, isPreviewMode])\n\n const onNextButtonClick = ({\n res,\n displayQuestionIndex,\n questionId,\n }: {\n res: string | string[] | number | null\n displayQuestionIndex: number\n questionId?: string\n }) => {\n if (!posthog) {\n logger.error('onNextButtonClick called without a PostHog instance.')\n return\n }\n\n if (!questionId) {\n logger.error('onNextButtonClick called without a questionId.')\n return\n }\n\n const responseKey = getSurveyResponseKey(questionId)\n\n const newResponses = { ...questionsResponses, [responseKey]: res }\n setQuestionsResponses(newResponses)\n\n const nextStep = getNextSurveyStep(survey, displayQuestionIndex, res)\n const isSurveyCompleted = nextStep === SurveyQuestionBranchingType.End\n\n if (!isSurveyCompleted) {\n setCurrentQuestionIndex(nextStep)\n setInProgressSurveyState(survey, {\n surveySubmissionId: surveySubmissionId,\n responses: newResponses,\n lastQuestionIndex: nextStep,\n })\n }\n\n // If partial responses are enabled, send the survey sent event with with the responses,\n // otherwise only send the event when the survey is completed\n if (survey.enable_partial_responses || isSurveyCompleted) {\n sendSurveyEvent({\n responses: newResponses,\n survey,\n surveySubmissionId,\n isSurveyCompleted,\n posthog,\n })\n }\n }\n\n const currentQuestion = surveyQuestions.at(currentQuestionIndex)\n\n if (!currentQuestion) {\n return null\n }\n\n return (\n <form className=\"survey-form\" name=\"surveyForm\">\n {isPopup && (\n <Cancel\n onClick={() => {\n onPopupSurveyDismissed()\n }}\n />\n )}\n <div className=\"survey-box\">\n {getQuestionComponent({\n question: currentQuestion,\n forceDisableHtml,\n displayQuestionIndex: currentQuestionIndex,\n appearance: survey.appearance || defaultSurveyAppearance,\n onSubmit: (res) =>\n onNextButtonClick({\n res,\n displayQuestionIndex: currentQuestionIndex,\n questionId: currentQuestion.id,\n }),\n onPreviewSubmit,\n initialValue: currentQuestion.id\n ? questionsResponses[getSurveyResponseKey(currentQuestion.id)]\n : undefined,\n })}\n </div>\n </form>\n )\n}\n\nexport function FeedbackWidget({\n survey,\n forceDisableHtml,\n posthog,\n readOnly,\n}: {\n survey: Survey\n forceDisableHtml?: boolean\n posthog?: PostHog\n readOnly?: boolean\n}): JSX.Element | null {\n const [isFeedbackButtonVisible, setIsFeedbackButtonVisible] = useState(true)\n const [showSurvey, setShowSurvey] = useState(false)\n const [styleOverrides, setStyleOverrides] = useState<React.CSSProperties>({})\n\n const toggleSurvey = () => {\n setShowSurvey(!showSurvey)\n }\n\n useEffect(() => {\n if (!posthog) {\n logger.error('FeedbackWidget called without a PostHog instance.')\n return\n }\n if (readOnly) {\n return\n }\n\n if (survey.appearance?.widgetType === 'tab') {\n setStyleOverrides({\n top: '50%',\n bottom: 'auto',\n })\n }\n const handleShowSurvey = (event: Event) => {\n const customEvent = event as CustomEvent\n // Check if the event is for this specific survey instance\n if (customEvent.detail?.surveyId === survey.id) {\n logger.info(`Received show event for feedback button survey ${survey.id}`)\n setStyleOverrides(customEvent.detail.position || {})\n toggleSurvey()\n }\n }\n\n addEventListener(window, DISPATCH_FEEDBACK_WIDGET_EVENT, handleShowSurvey)\n\n // Cleanup listener on component unmount\n return () => {\n window.removeEventListener(DISPATCH_FEEDBACK_WIDGET_EVENT, handleShowSurvey)\n }\n }, [\n posthog,\n readOnly,\n survey.id,\n survey.appearance?.widgetType,\n survey.appearance?.widgetSelector,\n survey.appearance?.borderColor,\n ])\n\n useHideSurveyOnURLChange({\n survey,\n setSurveyVisible: setIsFeedbackButtonVisible,\n })\n\n if (!isFeedbackButtonVisible) {\n return null\n }\n\n const resetShowSurvey = () => {\n // hide the feedback button after answering or closing the survey if it's not always show\n if (survey.schedule !== SurveySchedule.Always) {\n setIsFeedbackButtonVisible(false)\n }\n // important so our view transition has time to run\n setTimeout(() => {\n setShowSurvey(false)\n }, 200)\n }\n\n return (\n <Preact.Fragment>\n {survey.appearance?.widgetType === 'tab' && (\n <button\n className={`ph-survey-widget-tab ${survey.appearance?.tabPosition === SurveyTabPosition.Top ? 'widget-tab-top' : ''}`}\n onClick={toggleSurvey}\n disabled={readOnly}\n style={getTabPositionStyles(survey.appearance?.tabPosition)}\n >\n {survey.appearance?.widgetLabel || ''}\n </button>\n )}\n {showSurvey && (\n <SurveyPopup\n posthog={posthog}\n survey={survey}\n forceDisableHtml={forceDisableHtml}\n style={styleOverrides}\n onPopupSurveyDismissed={resetShowSurvey}\n onCloseConfirmationMessage={resetShowSurvey}\n />\n )}\n </Preact.Fragment>\n )\n}\n\ninterface GetQuestionComponentProps extends CommonQuestionProps {\n question: SurveyQuestion\n displayQuestionIndex: number\n}\n\nconst getQuestionComponent = ({\n question,\n forceDisableHtml,\n displayQuestionIndex,\n appearance,\n onSubmit,\n onPreviewSubmit,\n initialValue,\n}: GetQuestionComponentProps): JSX.Element | null => {\n const baseProps = {\n forceDisableHtml,\n appearance,\n onPreviewSubmit: (res: string | string[] | number | null) => {\n onPreviewSubmit(res)\n },\n onSubmit: (res: string | string[] | number | null) => {\n onSubmit(res)\n },\n initialValue,\n displayQuestionIndex,\n }\n\n switch (question.type) {\n case SurveyQuestionType.Open:\n return <OpenTextQuestion {...baseProps} question={question} key={question.id} />\n case SurveyQuestionType.Link:\n return <LinkQuestion {...baseProps} question={question} key={question.id} />\n case SurveyQuestionType.Rating:\n return <RatingQuestion {...baseProps} question={question} key={question.id} />\n case SurveyQuestionType.SingleChoice:\n case SurveyQuestionType.MultipleChoice:\n return <MultipleChoiceQuestion {...baseProps} question={question} key={question.id} />\n default:\n logger.error(`Unsupported question type: ${(question as any).type}`)\n return null\n }\n}\n"]}
|
package/package.json
CHANGED