posthog-js 1.211.1 → 1.211.2

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/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-js",
3
- "version": "1.211.1",
3
+ "version": "1.211.2",
4
4
  "description": "Posthog-js allows you to automatically capture usage and send events to PostHog.",
5
5
  "repository": "https://github.com/PostHog/posthog-js",
6
6
  "author": "hey@posthog.com",
@@ -34,6 +34,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
34
34
  }
35
35
  return to.concat(ar || Array.prototype.slice.call(from));
36
36
  };
37
+ import { doesSurveyUrlMatch } from '../posthog-surveys';
37
38
  import { SurveyQuestionBranchingType, SurveyQuestionType, SurveyType, } from '../posthog-surveys-types';
38
39
  import * as Preact from 'preact';
39
40
  import { useContext, useEffect, useMemo, useRef, useState } from 'preact/hooks';
@@ -344,6 +345,50 @@ export function usePopupVisibility(survey, posthog, millisecondDelay, isPreviewM
344
345
  return handleShowSurveyImmediately();
345
346
  }
346
347
  }, []);
348
+ // Add URL change listener to hide survey when URL no longer matches
349
+ useEffect(function () {
350
+ var _a;
351
+ if (isPreviewMode || !((_a = survey.conditions) === null || _a === void 0 ? void 0 : _a.url)) {
352
+ return;
353
+ }
354
+ var checkUrlMatch = function () {
355
+ var urlCheck = doesSurveyUrlMatch(survey);
356
+ if (!urlCheck) {
357
+ setIsPopupVisible(false);
358
+ removeSurveyFromFocus(survey.id);
359
+ }
360
+ };
361
+ // Listen for browser back/forward browser history changes
362
+ window.addEventListener('popstate', checkUrlMatch);
363
+ // Listen for hash changes, for SPA frameworks that use hash-based routing
364
+ // 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).
365
+ window.addEventListener('hashchange', checkUrlMatch);
366
+ // Listen for SPA navigation
367
+ var originalPushState = window.history.pushState;
368
+ var originalReplaceState = window.history.replaceState;
369
+ window.history.pushState = function () {
370
+ var args = [];
371
+ for (var _i = 0; _i < arguments.length; _i++) {
372
+ args[_i] = arguments[_i];
373
+ }
374
+ originalPushState.apply(this, args);
375
+ checkUrlMatch();
376
+ };
377
+ window.history.replaceState = function () {
378
+ var args = [];
379
+ for (var _i = 0; _i < arguments.length; _i++) {
380
+ args[_i] = arguments[_i];
381
+ }
382
+ originalReplaceState.apply(this, args);
383
+ checkUrlMatch();
384
+ };
385
+ return function () {
386
+ window.removeEventListener('popstate', checkUrlMatch);
387
+ window.removeEventListener('hashchange', checkUrlMatch);
388
+ window.history.pushState = originalPushState;
389
+ window.history.replaceState = originalReplaceState;
390
+ };
391
+ }, [isPreviewMode, survey, removeSurveyFromFocus]);
347
392
  return { isPopupVisible: isPopupVisible, isSurveySent: isSurveySent, setIsPopupVisible: setIsPopupVisible };
348
393
  }
349
394
  export function SurveyPopup(_a) {
@@ -1 +1 @@
1
- {"version":3,"file":"surveys.jsx","sourceRoot":"","sources":["../../../src/extensions/surveys.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAIH,2BAA2B,EAC3B,kBAAkB,EAElB,UAAU,GACb,MAAM,0BAA0B,CAAA;AAEjC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC/E,OAAO,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAA;AAC9E,OAAO,E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AAsC;YAC7C,QAAQ,CAAC,GAAG,CAAC,CAAA;QACjB,CAAC;KACJ,CAAA;IAED,IAAM,eAAe;QACjB,GAAC,kBAAkB,CAAC,IAAI,IAAG,EAAE;QAC7B,GAAC,kBAAkB,CAAC,IAAI,IAAG,EAAE;QAC7B,GAAC,kBAAkB,CAAC,MAAM,IAAG,EAAE,oBAAoB,sBAAA,EAAE;QACrD,GAAC,kBAAkB,CAAC,YAAY,IAAG,EAAE,oBAAoB,sBAAA,EAAE;QAC3D,GAAC,kBAAkB,CAAC,cAAc,IAAG,EAAE,oBAAoB,sBAAA,EAAE;WAChE,CAAA;IAED,IAAM,SAAS,GAAG,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IACnD,IAAM,cAAc,yBAAQ,WAAW,GAAK,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAE,CAAA;IAE5E,OAAO,CAAC,SAAS,CAAC,IAAI,cAAc,CAAC,EAAG,CAAA;AAC5C,CAAC,CAAA","sourcesContent":["import { PostHog } from '../posthog-core'\nimport {\n Survey,\n SurveyAppearance,\n SurveyQuestion,\n SurveyQuestionBranchingType,\n SurveyQuestionType,\n SurveyRenderReason,\n SurveyType,\n} from '../posthog-surveys-types'\n\nimport * as Preact from 'preact'\nimport { useContext, useEffect, useMemo, useRef, useState } from 'preact/hooks'\nimport { document as _document, window as _window } from '../utils/globals'\nimport { createLogger } from '../utils/logger'\nimport { isNull, isNumber } from '../utils/type-utils'\nimport { createWidgetShadow, createWidgetStyle } from './surveys-widget'\nimport { ConfirmationMessage } from './surveys/components/ConfirmationMessage'\nimport { Cancel } from './surveys/components/QuestionHeader'\nimport {\n LinkQuestion,\n MultipleChoiceQuestion,\n OpenTextQuestion,\n RatingQuestion,\n} from './surveys/components/QuestionTypes'\nimport {\n createShadow,\n defaultSurveyAppearance,\n dismissedSurveyEvent,\n getContrastingTextColor,\n getDisplayOrderQuestions,\n getSurveySeen,\n sendSurveyEvent,\n style,\n SurveyContext,\n} from './surveys/surveys-utils'\nconst logger = createLogger('[Surveys]')\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\nexport class SurveyManager {\n private posthog: PostHog\n private surveyInFocus: string | null\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 canShowNextEventBasedSurvey = (): boolean => {\n // with event based surveys, we need to show the next survey without reloading the page.\n // A simple check for div elements with the class name pattern of PostHogSurvey_xyz doesn't work here\n // because preact leaves behind the div element for any surveys responded/dismissed with a <style> node.\n // To alleviate this, we check the last div in the dom and see if it has any elements other than a Style node.\n // if the last PostHogSurvey_xyz div has only one style node, we can show the next survey in the queue\n // without reloading the page.\n const surveyPopups = document.querySelectorAll(`div[class^=PostHogSurvey]`)\n if (surveyPopups.length > 0) {\n return surveyPopups[surveyPopups.length - 1].shadowRoot?.childElementCount === 1\n }\n return true\n }\n\n private handlePopoverSurvey = (survey: Survey): void => {\n const surveyWaitPeriodInDays = survey.conditions?.seenSurveyWaitPeriodInDays\n const lastSeenSurveyDate = localStorage.getItem(`lastSeenSurveyDate`)\n if (surveyWaitPeriodInDays && lastSeenSurveyDate) {\n const today = new Date()\n const diff = Math.abs(today.getTime() - new Date(lastSeenSurveyDate).getTime())\n const diffDaysFromToday = Math.ceil(diff / (1000 * 3600 * 24))\n if (diffDaysFromToday < surveyWaitPeriodInDays) {\n return\n }\n }\n\n const surveySeen = getSurveySeen(survey)\n if (!surveySeen) {\n this.addSurveyToFocus(survey.id)\n const shadow = createShadow(style(survey?.appearance), survey.id)\n Preact.render(\n <SurveyPopup\n key={'popover-survey'}\n posthog={this.posthog}\n survey={survey}\n removeSurveyFromFocus={this.removeSurveyFromFocus}\n isPopup={true}\n />,\n shadow\n )\n }\n }\n\n private handleWidget = (survey: Survey): void => {\n const shadow = createWidgetShadow(survey)\n const surveyStyleSheet = style(survey.appearance)\n shadow.appendChild(Object.assign(document.createElement('style'), { innerText: surveyStyleSheet }))\n Preact.render(\n <FeedbackWidget\n key={'feedback-survey'}\n posthog={this.posthog}\n survey={survey}\n removeSurveyFromFocus={this.removeSurveyFromFocus}\n />,\n shadow\n )\n }\n\n private handleWidgetSelector = (survey: Survey): void => {\n const selectorOnPage =\n survey.appearance?.widgetSelector && document.querySelector(survey.appearance.widgetSelector)\n if (selectorOnPage) {\n if (document.querySelectorAll(`.PostHogWidget${survey.id}`).length === 0) {\n this.handleWidget(survey)\n } else if (document.querySelectorAll(`.PostHogWidget${survey.id}`).length === 1) {\n // we have to check if user selector already has a survey listener attached to it because we always have to check if it's on the page or not\n if (!selectorOnPage.getAttribute('PHWidgetSurveyClickListener')) {\n const surveyPopup = document\n .querySelector(`.PostHogWidget${survey.id}`)\n ?.shadowRoot?.querySelector(`.survey-form`) as HTMLFormElement\n selectorOnPage.addEventListener('click', () => {\n if (surveyPopup) {\n surveyPopup.style.display = surveyPopup.style.display === 'none' ? 'block' : 'none'\n surveyPopup.addEventListener('PHSurveyClosed', () => {\n this.removeSurveyFromFocus(survey.id)\n surveyPopup.style.display = 'none'\n })\n }\n })\n selectorOnPage.setAttribute('PHWidgetSurveyClickListener', 'true')\n }\n }\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(\n (a, b) => (a.appearance?.surveyPopupDelaySeconds || 0) - (b.appearance?.surveyPopupDelaySeconds || 0)\n )\n }\n\n /**\n * Checks the feature flags associated with this Survey to see if the survey can be rendered.\n * @param survey\n * @param instance\n */\n public canRenderSurvey = (survey: Survey): SurveyRenderReason => {\n const renderReason: SurveyRenderReason = {\n visible: false,\n }\n\n if (survey.end_date) {\n renderReason.disabledReason = `survey was completed on ${survey.end_date}`\n return renderReason\n }\n\n if (survey.type != SurveyType.Popover) {\n renderReason.disabledReason = `Only Popover survey types can be rendered`\n return renderReason\n }\n\n const linkedFlagCheck = survey.linked_flag_key\n ? this.posthog.featureFlags.isFeatureEnabled(survey.linked_flag_key)\n : true\n\n if (!linkedFlagCheck) {\n renderReason.disabledReason = `linked feature flag ${survey.linked_flag_key} is false`\n return renderReason\n }\n\n const targetingFlagCheck = survey.targeting_flag_key\n ? this.posthog.featureFlags.isFeatureEnabled(survey.targeting_flag_key)\n : true\n\n if (!targetingFlagCheck) {\n renderReason.disabledReason = `targeting feature flag ${survey.targeting_flag_key} is false`\n return renderReason\n }\n\n const internalTargetingFlagCheck = survey.internal_targeting_flag_key\n ? this.posthog.featureFlags.isFeatureEnabled(survey.internal_targeting_flag_key)\n : true\n\n if (!internalTargetingFlagCheck) {\n renderReason.disabledReason = `internal targeting feature flag ${survey.internal_targeting_flag_key} is false`\n return renderReason\n }\n\n renderReason.visible = true\n return renderReason\n }\n\n public renderSurvey = (survey: Survey, selector: Element): void => {\n Preact.render(\n <SurveyPopup\n key={'popover-survey'}\n posthog={this.posthog}\n survey={survey}\n removeSurveyFromFocus={this.removeSurveyFromFocus}\n isPopup={false}\n />,\n selector\n )\n }\n\n public callSurveysAndEvaluateDisplayLogic = (forceReload: boolean = false): void => {\n this.posthog?.getActiveMatchingSurveys((surveys) => {\n const nonAPISurveys = surveys.filter((survey) => survey.type !== 'api')\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 nonAPISurveyQueue = this.sortSurveysByAppearanceDelay(nonAPISurveys)\n\n nonAPISurveyQueue.forEach((survey) => {\n // We only evaluate the display logic for one survey at a time\n if (!isNull(this.surveyInFocus)) {\n return\n }\n if (survey.type === SurveyType.Widget) {\n if (\n survey.appearance?.widgetType === 'tab' &&\n document.querySelectorAll(`.PostHogWidget${survey.id}`).length === 0\n ) {\n this.handleWidget(survey)\n }\n if (survey.appearance?.widgetType === 'selector' && survey.appearance?.widgetSelector) {\n this.handleWidgetSelector(survey)\n }\n }\n\n if (survey.type === SurveyType.Popover && this.canShowNextEventBasedSurvey()) {\n this.handlePopoverSurvey(survey)\n }\n })\n }, forceReload)\n }\n\n private addSurveyToFocus = (id: string): void => {\n if (!isNull(this.surveyInFocus)) {\n logger.error(`Survey ${[...this.surveyInFocus]} already in focus. Cannot add survey ${id}.`)\n }\n this.surveyInFocus = id\n }\n\n private removeSurveyFromFocus = (id: string): void => {\n if (this.surveyInFocus !== id) {\n logger.error(`Survey ${id} is not in focus. Cannot remove survey ${id}.`)\n }\n this.surveyInFocus = null\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 canShowNextEventBasedSurvey: this.canShowNextEventBasedSurvey,\n handleWidget: this.handleWidget,\n handlePopoverSurvey: this.handlePopoverSurvey,\n handleWidgetSelector: this.handleWidgetSelector,\n sortSurveysByAppearanceDelay: this.sortSurveysByAppearanceDelay,\n }\n }\n}\n\nexport const renderSurveysPreview = ({\n survey,\n parentElement,\n previewPageIndex,\n forceDisableHtml,\n onPreviewSubmit,\n}: {\n survey: Survey\n parentElement: HTMLElement\n previewPageIndex: number\n forceDisableHtml?: boolean\n onPreviewSubmit?: (res: string | string[] | number | null) => void\n}) => {\n const surveyStyleSheet = style(survey.appearance)\n const styleElement = Object.assign(document.createElement('style'), { innerText: surveyStyleSheet })\n\n // Remove previously attached <style>\n Array.from(parentElement.children).forEach((child) => {\n if (child instanceof HTMLStyleElement) {\n parentElement.removeChild(child)\n }\n })\n\n parentElement.appendChild(styleElement)\n const textColor = getContrastingTextColor(\n survey.appearance?.backgroundColor || defaultSurveyAppearance.backgroundColor || 'white'\n )\n\n Preact.render(\n <SurveyPopup\n key=\"surveys-render-preview\"\n survey={survey}\n forceDisableHtml={forceDisableHtml}\n style={{\n position: 'relative',\n right: 0,\n borderBottom: `1px solid ${survey.appearance?.borderColor}`,\n borderRadius: 10,\n color: textColor,\n }}\n onPreviewSubmit={onPreviewSubmit}\n previewPageIndex={previewPageIndex}\n removeSurveyFromFocus={() => {}}\n isPopup={true}\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 widgetStyleSheet = createWidgetStyle(survey.appearance?.widgetColor)\n const styleElement = Object.assign(document.createElement('style'), { innerText: widgetStyleSheet })\n root.appendChild(styleElement)\n Preact.render(\n <FeedbackWidget\n key={'feedback-render-preview'}\n forceDisableHtml={forceDisableHtml}\n survey={survey}\n readOnly={true}\n removeSurveyFromFocus={() => {}}\n />,\n root\n )\n}\n\n// This is the main exported function\nexport function generateSurveys(posthog: PostHog) {\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 surveyManager.callSurveysAndEvaluateDisplayLogic(true)\n\n // recalculate surveys every second to check if URL or selectors have changed\n setInterval(() => {\n surveyManager.callSurveysAndEvaluateDisplayLogic(false)\n }, 1000)\n return surveyManager\n}\n\nexport function usePopupVisibility(\n survey: Survey,\n posthog: PostHog | undefined,\n millisecondDelay: number,\n isPreviewMode: boolean,\n removeSurveyFromFocus: (id: string) => void\n) {\n const [isPopupVisible, setIsPopupVisible] = useState(isPreviewMode || millisecondDelay === 0)\n const [isSurveySent, setIsSurveySent] = useState(false)\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 handleSurveyClosed = () => {\n removeSurveyFromFocus(survey.id)\n setIsPopupVisible(false)\n }\n\n const handleSurveySent = () => {\n if (!survey.appearance?.displayThankYouMessage) {\n removeSurveyFromFocus(survey.id)\n setIsPopupVisible(false)\n } else {\n setIsSurveySent(true)\n removeSurveyFromFocus(survey.id)\n if (survey.appearance?.autoDisappear) {\n setTimeout(() => {\n setIsPopupVisible(false)\n }, 5000)\n }\n }\n }\n\n const showSurvey = () => {\n setIsPopupVisible(true)\n window.dispatchEvent(new Event('PHSurveyShown'))\n posthog.capture('survey shown', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_iteration: survey.current_iteration,\n $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 const handleShowSurveyWithDelay = () => {\n const timeoutId = setTimeout(() => {\n showSurvey()\n }, millisecondDelay)\n\n return () => {\n clearTimeout(timeoutId)\n window.removeEventListener('PHSurveyClosed', handleSurveyClosed)\n window.removeEventListener('PHSurveySent', handleSurveySent)\n }\n }\n\n const handleShowSurveyImmediately = () => {\n showSurvey()\n return () => {\n window.removeEventListener('PHSurveyClosed', handleSurveyClosed)\n window.removeEventListener('PHSurveySent', handleSurveySent)\n }\n }\n\n window.addEventListener('PHSurveyClosed', handleSurveyClosed)\n window.addEventListener('PHSurveySent', handleSurveySent)\n\n if (millisecondDelay > 0) {\n return handleShowSurveyWithDelay()\n } else {\n return handleShowSurveyImmediately()\n }\n }, [])\n\n return { isPopupVisible, isSurveySent, setIsPopupVisible }\n}\n\ninterface SurveyPopupProps {\n survey: Survey\n forceDisableHtml?: boolean\n posthog?: PostHog\n style?: React.CSSProperties\n previewPageIndex?: number | undefined\n removeSurveyFromFocus: (id: string) => void\n isPopup?: boolean\n onPreviewSubmit?: (res: string | string[] | number | null) => void\n}\n\nexport function SurveyPopup({\n survey,\n forceDisableHtml,\n posthog,\n style,\n previewPageIndex,\n removeSurveyFromFocus,\n isPopup,\n onPreviewSubmit = () => {},\n}: SurveyPopupProps) {\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, setIsPopupVisible } = usePopupVisibility(\n survey,\n posthog,\n surveyPopupDelayMilliseconds,\n isPreviewMode,\n removeSurveyFromFocus\n )\n const shouldShowConfirmation = isSurveySent || previewPageIndex === survey.questions.length\n const confirmationBoxLeftStyle = style?.left && isNumber(style?.left) ? { left: style.left - 40 } : {}\n\n if (isPreviewMode) {\n style = style || {}\n style.left = 'unset'\n style.right = 'unset'\n style.transform = 'unset'\n }\n\n return isPopupVisible ? (\n <SurveyContext.Provider\n value={{\n isPreviewMode,\n previewPageIndex: previewPageIndex,\n handleCloseSurveyPopup: () => dismissedSurveyEvent(survey, posthog, isPreviewMode),\n isPopup: isPopup || false,\n onPreviewSubmit,\n }}\n >\n {!shouldShowConfirmation ? (\n <Questions\n survey={survey}\n forceDisableHtml={!!forceDisableHtml}\n posthog={posthog}\n styleOverrides={style}\n />\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 styleOverrides={{ ...style, ...confirmationBoxLeftStyle }}\n onClose={() => setIsPopupVisible(false)}\n />\n )}\n </SurveyContext.Provider>\n ) : (\n <></>\n )\n}\n\nexport function Questions({\n survey,\n forceDisableHtml,\n posthog,\n styleOverrides,\n}: {\n survey: Survey\n forceDisableHtml: boolean\n posthog?: PostHog\n styleOverrides?: React.CSSProperties\n}) {\n const textColor = getContrastingTextColor(\n survey.appearance?.backgroundColor || defaultSurveyAppearance.backgroundColor\n )\n const [questionsResponses, setQuestionsResponses] = useState({})\n const { isPreviewMode, previewPageIndex, handleCloseSurveyPopup, isPopup, onPreviewSubmit } =\n useContext(SurveyContext)\n const [currentQuestionIndex, setCurrentQuestionIndex] = useState(previewPageIndex || 0)\n const surveyQuestions = useMemo(() => getDisplayOrderQuestions(survey), [survey])\n\n // Sync preview state\n useEffect(() => {\n setCurrentQuestionIndex(previewPageIndex ?? 0)\n }, [previewPageIndex])\n\n const onNextButtonClick = ({\n res,\n originalQuestionIndex,\n displayQuestionIndex,\n }: {\n res: string | string[] | number | null\n originalQuestionIndex: number\n displayQuestionIndex: number\n }) => {\n if (!posthog) {\n logger.error('onNextButtonClick called without a PostHog instance.')\n return\n }\n\n const responseKey =\n originalQuestionIndex === 0 ? `$survey_response` : `$survey_response_${originalQuestionIndex}`\n\n setQuestionsResponses({ ...questionsResponses, [responseKey]: res })\n\n // Old SDK, no branching\n if (!posthog.getNextSurveyStep) {\n const isLastDisplayedQuestion = displayQuestionIndex === survey.questions.length - 1\n if (isLastDisplayedQuestion) {\n sendSurveyEvent({ ...questionsResponses, [responseKey]: res }, survey, posthog)\n } else {\n setCurrentQuestionIndex(displayQuestionIndex + 1)\n }\n return\n }\n\n const nextStep = posthog.getNextSurveyStep(survey, displayQuestionIndex, res)\n if (nextStep === SurveyQuestionBranchingType.End) {\n sendSurveyEvent({ ...questionsResponses, [responseKey]: res }, survey, posthog)\n } else {\n setCurrentQuestionIndex(nextStep)\n }\n }\n\n return (\n <form\n className=\"survey-form\"\n style={\n isPopup\n ? {\n color: textColor,\n borderColor: survey.appearance?.borderColor,\n ...styleOverrides,\n }\n : {}\n }\n >\n {surveyQuestions.map((question, displayQuestionIndex) => {\n const { originalQuestionIndex } = question\n\n const isVisible = isPreviewMode\n ? currentQuestionIndex === originalQuestionIndex\n : currentQuestionIndex === displayQuestionIndex\n return (\n isVisible && (\n <div\n className=\"survey-box\"\n style={\n isPopup\n ? {\n backgroundColor:\n survey.appearance?.backgroundColor ||\n defaultSurveyAppearance.backgroundColor,\n }\n : {}\n }\n >\n {isPopup && <Cancel onClick={() => handleCloseSurveyPopup()} />}\n {getQuestionComponent({\n question,\n forceDisableHtml,\n displayQuestionIndex,\n appearance: survey.appearance || defaultSurveyAppearance,\n onSubmit: (res) =>\n onNextButtonClick({\n res,\n originalQuestionIndex,\n displayQuestionIndex,\n }),\n onPreviewSubmit,\n })}\n </div>\n )\n )\n })}\n </form>\n )\n}\n\nexport function FeedbackWidget({\n survey,\n forceDisableHtml,\n posthog,\n readOnly,\n removeSurveyFromFocus,\n}: {\n survey: Survey\n forceDisableHtml?: boolean\n posthog?: PostHog\n readOnly?: boolean\n removeSurveyFromFocus: (id: string) => void\n}): JSX.Element {\n const [showSurvey, setShowSurvey] = useState(false)\n const [styleOverrides, setStyle] = useState({})\n const widgetRef = useRef<HTMLDivElement>(null)\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 if (widgetRef.current) {\n const widgetPos = widgetRef.current.getBoundingClientRect()\n const style = {\n top: '50%',\n left: parseInt(`${widgetPos.right - 360}`),\n bottom: 'auto',\n borderRadius: 10,\n borderBottom: `1.5px solid ${survey.appearance?.borderColor || '#c9c6c6'}`,\n }\n setStyle(style)\n }\n }\n if (survey.appearance?.widgetType === 'selector') {\n const widget = document.querySelector(survey.appearance.widgetSelector || '')\n widget?.addEventListener('click', () => {\n setShowSurvey(!showSurvey)\n })\n widget?.setAttribute('PHWidgetSurveyClickListener', 'true')\n }\n }, [])\n\n return (\n <>\n {survey.appearance?.widgetType === 'tab' && (\n <div\n className=\"ph-survey-widget-tab\"\n ref={widgetRef}\n onClick={() => !readOnly && setShowSurvey(!showSurvey)}\n style={{ color: getContrastingTextColor(survey.appearance.widgetColor) }}\n >\n <div className=\"ph-survey-widget-tab-icon\"></div>\n {survey.appearance?.widgetLabel || ''}\n </div>\n )}\n {showSurvey && (\n <SurveyPopup\n key={'feedback-widget-survey'}\n posthog={posthog}\n survey={survey}\n forceDisableHtml={forceDisableHtml}\n style={styleOverrides}\n removeSurveyFromFocus={removeSurveyFromFocus}\n isPopup={true}\n />\n )}\n </>\n )\n}\n\ninterface GetQuestionComponentProps {\n question: SurveyQuestion\n forceDisableHtml: boolean\n displayQuestionIndex: number\n appearance: SurveyAppearance\n onSubmit: (res: string | string[] | number | null) => void\n onPreviewSubmit: (res: string | string[] | number | null) => void\n}\n\nconst getQuestionComponent = ({\n question,\n forceDisableHtml,\n displayQuestionIndex,\n appearance,\n onSubmit,\n onPreviewSubmit,\n}: GetQuestionComponentProps): JSX.Element => {\n const questionComponents = {\n [SurveyQuestionType.Open]: OpenTextQuestion,\n [SurveyQuestionType.Link]: LinkQuestion,\n [SurveyQuestionType.Rating]: RatingQuestion,\n [SurveyQuestionType.SingleChoice]: MultipleChoiceQuestion,\n [SurveyQuestionType.MultipleChoice]: MultipleChoiceQuestion,\n }\n\n const commonProps = {\n question,\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 }\n\n const additionalProps: Record<SurveyQuestionType, any> = {\n [SurveyQuestionType.Open]: {},\n [SurveyQuestionType.Link]: {},\n [SurveyQuestionType.Rating]: { displayQuestionIndex },\n [SurveyQuestionType.SingleChoice]: { displayQuestionIndex },\n [SurveyQuestionType.MultipleChoice]: { displayQuestionIndex },\n }\n\n const Component = questionComponents[question.type]\n const componentProps = { ...commonProps, ...additionalProps[question.type] }\n\n return <Component {...componentProps} />\n}\n"]}
1
+ {"version":3,"file":"surveys.jsx","sourceRoot":"","sources":["../../../src/extensions/surveys.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAIH,2BAA2B,EAC3B,kBAAkB,EAElB,UAAU,GACb,MAAM,0BAA0B,CAAA;AAEjC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAA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AC,CAAA","sourcesContent":["import { PostHog } from '../posthog-core'\nimport { doesSurveyUrlMatch } from '../posthog-surveys'\nimport {\n Survey,\n SurveyAppearance,\n SurveyQuestion,\n SurveyQuestionBranchingType,\n SurveyQuestionType,\n SurveyRenderReason,\n SurveyType,\n} from '../posthog-surveys-types'\n\nimport * as Preact from 'preact'\nimport { useContext, useEffect, useMemo, useRef, useState } from 'preact/hooks'\nimport { document as _document, window as _window } from '../utils/globals'\nimport { createLogger } from '../utils/logger'\nimport { isNull, isNumber } from '../utils/type-utils'\nimport { createWidgetShadow, createWidgetStyle } from './surveys-widget'\nimport { ConfirmationMessage } from './surveys/components/ConfirmationMessage'\nimport { Cancel } from './surveys/components/QuestionHeader'\nimport {\n LinkQuestion,\n MultipleChoiceQuestion,\n OpenTextQuestion,\n RatingQuestion,\n} from './surveys/components/QuestionTypes'\nimport {\n createShadow,\n defaultSurveyAppearance,\n dismissedSurveyEvent,\n getContrastingTextColor,\n getDisplayOrderQuestions,\n getSurveySeen,\n sendSurveyEvent,\n style,\n SurveyContext,\n} from './surveys/surveys-utils'\nconst logger = createLogger('[Surveys]')\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\nexport class SurveyManager {\n private posthog: PostHog\n private surveyInFocus: string | null\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 canShowNextEventBasedSurvey = (): boolean => {\n // with event based surveys, we need to show the next survey without reloading the page.\n // A simple check for div elements with the class name pattern of PostHogSurvey_xyz doesn't work here\n // because preact leaves behind the div element for any surveys responded/dismissed with a <style> node.\n // To alleviate this, we check the last div in the dom and see if it has any elements other than a Style node.\n // if the last PostHogSurvey_xyz div has only one style node, we can show the next survey in the queue\n // without reloading the page.\n const surveyPopups = document.querySelectorAll(`div[class^=PostHogSurvey]`)\n if (surveyPopups.length > 0) {\n return surveyPopups[surveyPopups.length - 1].shadowRoot?.childElementCount === 1\n }\n return true\n }\n\n private handlePopoverSurvey = (survey: Survey): void => {\n const surveyWaitPeriodInDays = survey.conditions?.seenSurveyWaitPeriodInDays\n const lastSeenSurveyDate = localStorage.getItem(`lastSeenSurveyDate`)\n if (surveyWaitPeriodInDays && lastSeenSurveyDate) {\n const today = new Date()\n const diff = Math.abs(today.getTime() - new Date(lastSeenSurveyDate).getTime())\n const diffDaysFromToday = Math.ceil(diff / (1000 * 3600 * 24))\n if (diffDaysFromToday < surveyWaitPeriodInDays) {\n return\n }\n }\n\n const surveySeen = getSurveySeen(survey)\n if (!surveySeen) {\n this.addSurveyToFocus(survey.id)\n const shadow = createShadow(style(survey?.appearance), survey.id)\n Preact.render(\n <SurveyPopup\n key={'popover-survey'}\n posthog={this.posthog}\n survey={survey}\n removeSurveyFromFocus={this.removeSurveyFromFocus}\n isPopup={true}\n />,\n shadow\n )\n }\n }\n\n private handleWidget = (survey: Survey): void => {\n const shadow = createWidgetShadow(survey)\n const surveyStyleSheet = style(survey.appearance)\n shadow.appendChild(Object.assign(document.createElement('style'), { innerText: surveyStyleSheet }))\n Preact.render(\n <FeedbackWidget\n key={'feedback-survey'}\n posthog={this.posthog}\n survey={survey}\n removeSurveyFromFocus={this.removeSurveyFromFocus}\n />,\n shadow\n )\n }\n\n private handleWidgetSelector = (survey: Survey): void => {\n const selectorOnPage =\n survey.appearance?.widgetSelector && document.querySelector(survey.appearance.widgetSelector)\n if (selectorOnPage) {\n if (document.querySelectorAll(`.PostHogWidget${survey.id}`).length === 0) {\n this.handleWidget(survey)\n } else if (document.querySelectorAll(`.PostHogWidget${survey.id}`).length === 1) {\n // we have to check if user selector already has a survey listener attached to it because we always have to check if it's on the page or not\n if (!selectorOnPage.getAttribute('PHWidgetSurveyClickListener')) {\n const surveyPopup = document\n .querySelector(`.PostHogWidget${survey.id}`)\n ?.shadowRoot?.querySelector(`.survey-form`) as HTMLFormElement\n selectorOnPage.addEventListener('click', () => {\n if (surveyPopup) {\n surveyPopup.style.display = surveyPopup.style.display === 'none' ? 'block' : 'none'\n surveyPopup.addEventListener('PHSurveyClosed', () => {\n this.removeSurveyFromFocus(survey.id)\n surveyPopup.style.display = 'none'\n })\n }\n })\n selectorOnPage.setAttribute('PHWidgetSurveyClickListener', 'true')\n }\n }\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(\n (a, b) => (a.appearance?.surveyPopupDelaySeconds || 0) - (b.appearance?.surveyPopupDelaySeconds || 0)\n )\n }\n\n /**\n * Checks the feature flags associated with this Survey to see if the survey can be rendered.\n * @param survey\n * @param instance\n */\n public canRenderSurvey = (survey: Survey): SurveyRenderReason => {\n const renderReason: SurveyRenderReason = {\n visible: false,\n }\n\n if (survey.end_date) {\n renderReason.disabledReason = `survey was completed on ${survey.end_date}`\n return renderReason\n }\n\n if (survey.type != SurveyType.Popover) {\n renderReason.disabledReason = `Only Popover survey types can be rendered`\n return renderReason\n }\n\n const linkedFlagCheck = survey.linked_flag_key\n ? this.posthog.featureFlags.isFeatureEnabled(survey.linked_flag_key)\n : true\n\n if (!linkedFlagCheck) {\n renderReason.disabledReason = `linked feature flag ${survey.linked_flag_key} is false`\n return renderReason\n }\n\n const targetingFlagCheck = survey.targeting_flag_key\n ? this.posthog.featureFlags.isFeatureEnabled(survey.targeting_flag_key)\n : true\n\n if (!targetingFlagCheck) {\n renderReason.disabledReason = `targeting feature flag ${survey.targeting_flag_key} is false`\n return renderReason\n }\n\n const internalTargetingFlagCheck = survey.internal_targeting_flag_key\n ? this.posthog.featureFlags.isFeatureEnabled(survey.internal_targeting_flag_key)\n : true\n\n if (!internalTargetingFlagCheck) {\n renderReason.disabledReason = `internal targeting feature flag ${survey.internal_targeting_flag_key} is false`\n return renderReason\n }\n\n renderReason.visible = true\n return renderReason\n }\n\n public renderSurvey = (survey: Survey, selector: Element): void => {\n Preact.render(\n <SurveyPopup\n key={'popover-survey'}\n posthog={this.posthog}\n survey={survey}\n removeSurveyFromFocus={this.removeSurveyFromFocus}\n isPopup={false}\n />,\n selector\n )\n }\n\n public callSurveysAndEvaluateDisplayLogic = (forceReload: boolean = false): void => {\n this.posthog?.getActiveMatchingSurveys((surveys) => {\n const nonAPISurveys = surveys.filter((survey) => survey.type !== 'api')\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 nonAPISurveyQueue = this.sortSurveysByAppearanceDelay(nonAPISurveys)\n\n nonAPISurveyQueue.forEach((survey) => {\n // We only evaluate the display logic for one survey at a time\n if (!isNull(this.surveyInFocus)) {\n return\n }\n if (survey.type === SurveyType.Widget) {\n if (\n survey.appearance?.widgetType === 'tab' &&\n document.querySelectorAll(`.PostHogWidget${survey.id}`).length === 0\n ) {\n this.handleWidget(survey)\n }\n if (survey.appearance?.widgetType === 'selector' && survey.appearance?.widgetSelector) {\n this.handleWidgetSelector(survey)\n }\n }\n\n if (survey.type === SurveyType.Popover && this.canShowNextEventBasedSurvey()) {\n this.handlePopoverSurvey(survey)\n }\n })\n }, forceReload)\n }\n\n private addSurveyToFocus = (id: string): void => {\n if (!isNull(this.surveyInFocus)) {\n logger.error(`Survey ${[...this.surveyInFocus]} already in focus. Cannot add survey ${id}.`)\n }\n this.surveyInFocus = id\n }\n\n private removeSurveyFromFocus = (id: string): void => {\n if (this.surveyInFocus !== id) {\n logger.error(`Survey ${id} is not in focus. Cannot remove survey ${id}.`)\n }\n this.surveyInFocus = null\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 canShowNextEventBasedSurvey: this.canShowNextEventBasedSurvey,\n handleWidget: this.handleWidget,\n handlePopoverSurvey: this.handlePopoverSurvey,\n handleWidgetSelector: this.handleWidgetSelector,\n sortSurveysByAppearanceDelay: this.sortSurveysByAppearanceDelay,\n }\n }\n}\n\nexport const renderSurveysPreview = ({\n survey,\n parentElement,\n previewPageIndex,\n forceDisableHtml,\n onPreviewSubmit,\n}: {\n survey: Survey\n parentElement: HTMLElement\n previewPageIndex: number\n forceDisableHtml?: boolean\n onPreviewSubmit?: (res: string | string[] | number | null) => void\n}) => {\n const surveyStyleSheet = style(survey.appearance)\n const styleElement = Object.assign(document.createElement('style'), { innerText: surveyStyleSheet })\n\n // Remove previously attached <style>\n Array.from(parentElement.children).forEach((child) => {\n if (child instanceof HTMLStyleElement) {\n parentElement.removeChild(child)\n }\n })\n\n parentElement.appendChild(styleElement)\n const textColor = getContrastingTextColor(\n survey.appearance?.backgroundColor || defaultSurveyAppearance.backgroundColor || 'white'\n )\n\n Preact.render(\n <SurveyPopup\n key=\"surveys-render-preview\"\n survey={survey}\n forceDisableHtml={forceDisableHtml}\n style={{\n position: 'relative',\n right: 0,\n borderBottom: `1px solid ${survey.appearance?.borderColor}`,\n borderRadius: 10,\n color: textColor,\n }}\n onPreviewSubmit={onPreviewSubmit}\n previewPageIndex={previewPageIndex}\n removeSurveyFromFocus={() => {}}\n isPopup={true}\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 widgetStyleSheet = createWidgetStyle(survey.appearance?.widgetColor)\n const styleElement = Object.assign(document.createElement('style'), { innerText: widgetStyleSheet })\n root.appendChild(styleElement)\n Preact.render(\n <FeedbackWidget\n key={'feedback-render-preview'}\n forceDisableHtml={forceDisableHtml}\n survey={survey}\n readOnly={true}\n removeSurveyFromFocus={() => {}}\n />,\n root\n )\n}\n\n// This is the main exported function\nexport function generateSurveys(posthog: PostHog) {\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 surveyManager.callSurveysAndEvaluateDisplayLogic(true)\n\n // recalculate surveys every second to check if URL or selectors have changed\n setInterval(() => {\n surveyManager.callSurveysAndEvaluateDisplayLogic(false)\n }, 1000)\n return surveyManager\n}\n\nexport function usePopupVisibility(\n survey: Survey,\n posthog: PostHog | undefined,\n millisecondDelay: number,\n isPreviewMode: boolean,\n removeSurveyFromFocus: (id: string) => void\n) {\n const [isPopupVisible, setIsPopupVisible] = useState(isPreviewMode || millisecondDelay === 0)\n const [isSurveySent, setIsSurveySent] = useState(false)\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 handleSurveyClosed = () => {\n removeSurveyFromFocus(survey.id)\n setIsPopupVisible(false)\n }\n\n const handleSurveySent = () => {\n if (!survey.appearance?.displayThankYouMessage) {\n removeSurveyFromFocus(survey.id)\n setIsPopupVisible(false)\n } else {\n setIsSurveySent(true)\n removeSurveyFromFocus(survey.id)\n if (survey.appearance?.autoDisappear) {\n setTimeout(() => {\n setIsPopupVisible(false)\n }, 5000)\n }\n }\n }\n\n const showSurvey = () => {\n setIsPopupVisible(true)\n window.dispatchEvent(new Event('PHSurveyShown'))\n posthog.capture('survey shown', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_iteration: survey.current_iteration,\n $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 const handleShowSurveyWithDelay = () => {\n const timeoutId = setTimeout(() => {\n showSurvey()\n }, millisecondDelay)\n\n return () => {\n clearTimeout(timeoutId)\n window.removeEventListener('PHSurveyClosed', handleSurveyClosed)\n window.removeEventListener('PHSurveySent', handleSurveySent)\n }\n }\n\n const handleShowSurveyImmediately = () => {\n showSurvey()\n return () => {\n window.removeEventListener('PHSurveyClosed', handleSurveyClosed)\n window.removeEventListener('PHSurveySent', handleSurveySent)\n }\n }\n\n window.addEventListener('PHSurveyClosed', handleSurveyClosed)\n window.addEventListener('PHSurveySent', handleSurveySent)\n\n if (millisecondDelay > 0) {\n return handleShowSurveyWithDelay()\n } else {\n return handleShowSurveyImmediately()\n }\n }, [])\n\n // Add URL change listener to hide survey when URL no longer matches\n useEffect(() => {\n if (isPreviewMode || !survey.conditions?.url) {\n return\n }\n\n const checkUrlMatch = () => {\n const urlCheck = doesSurveyUrlMatch(survey)\n if (!urlCheck) {\n setIsPopupVisible(false)\n removeSurveyFromFocus(survey.id)\n }\n }\n\n // Listen for browser back/forward browser history changes\n window.addEventListener('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 window.addEventListener('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])\n\n return { isPopupVisible, isSurveySent, setIsPopupVisible }\n}\n\ninterface SurveyPopupProps {\n survey: Survey\n forceDisableHtml?: boolean\n posthog?: PostHog\n style?: React.CSSProperties\n previewPageIndex?: number | undefined\n removeSurveyFromFocus: (id: string) => void\n isPopup?: boolean\n onPreviewSubmit?: (res: string | string[] | number | null) => void\n}\n\nexport function SurveyPopup({\n survey,\n forceDisableHtml,\n posthog,\n style,\n previewPageIndex,\n removeSurveyFromFocus,\n isPopup,\n onPreviewSubmit = () => {},\n}: SurveyPopupProps) {\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, setIsPopupVisible } = usePopupVisibility(\n survey,\n posthog,\n surveyPopupDelayMilliseconds,\n isPreviewMode,\n removeSurveyFromFocus\n )\n const shouldShowConfirmation = isSurveySent || previewPageIndex === survey.questions.length\n const confirmationBoxLeftStyle = style?.left && isNumber(style?.left) ? { left: style.left - 40 } : {}\n\n if (isPreviewMode) {\n style = style || {}\n style.left = 'unset'\n style.right = 'unset'\n style.transform = 'unset'\n }\n\n return isPopupVisible ? (\n <SurveyContext.Provider\n value={{\n isPreviewMode,\n previewPageIndex: previewPageIndex,\n handleCloseSurveyPopup: () => dismissedSurveyEvent(survey, posthog, isPreviewMode),\n isPopup: isPopup || false,\n onPreviewSubmit,\n }}\n >\n {!shouldShowConfirmation ? (\n <Questions\n survey={survey}\n forceDisableHtml={!!forceDisableHtml}\n posthog={posthog}\n styleOverrides={style}\n />\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 styleOverrides={{ ...style, ...confirmationBoxLeftStyle }}\n onClose={() => setIsPopupVisible(false)}\n />\n )}\n </SurveyContext.Provider>\n ) : (\n <></>\n )\n}\n\nexport function Questions({\n survey,\n forceDisableHtml,\n posthog,\n styleOverrides,\n}: {\n survey: Survey\n forceDisableHtml: boolean\n posthog?: PostHog\n styleOverrides?: React.CSSProperties\n}) {\n const textColor = getContrastingTextColor(\n survey.appearance?.backgroundColor || defaultSurveyAppearance.backgroundColor\n )\n const [questionsResponses, setQuestionsResponses] = useState({})\n const { isPreviewMode, previewPageIndex, handleCloseSurveyPopup, isPopup, onPreviewSubmit } =\n useContext(SurveyContext)\n const [currentQuestionIndex, setCurrentQuestionIndex] = useState(previewPageIndex || 0)\n const surveyQuestions = useMemo(() => getDisplayOrderQuestions(survey), [survey])\n\n // Sync preview state\n useEffect(() => {\n setCurrentQuestionIndex(previewPageIndex ?? 0)\n }, [previewPageIndex])\n\n const onNextButtonClick = ({\n res,\n originalQuestionIndex,\n displayQuestionIndex,\n }: {\n res: string | string[] | number | null\n originalQuestionIndex: number\n displayQuestionIndex: number\n }) => {\n if (!posthog) {\n logger.error('onNextButtonClick called without a PostHog instance.')\n return\n }\n\n const responseKey =\n originalQuestionIndex === 0 ? `$survey_response` : `$survey_response_${originalQuestionIndex}`\n\n setQuestionsResponses({ ...questionsResponses, [responseKey]: res })\n\n // Old SDK, no branching\n if (!posthog.getNextSurveyStep) {\n const isLastDisplayedQuestion = displayQuestionIndex === survey.questions.length - 1\n if (isLastDisplayedQuestion) {\n sendSurveyEvent({ ...questionsResponses, [responseKey]: res }, survey, posthog)\n } else {\n setCurrentQuestionIndex(displayQuestionIndex + 1)\n }\n return\n }\n\n const nextStep = posthog.getNextSurveyStep(survey, displayQuestionIndex, res)\n if (nextStep === SurveyQuestionBranchingType.End) {\n sendSurveyEvent({ ...questionsResponses, [responseKey]: res }, survey, posthog)\n } else {\n setCurrentQuestionIndex(nextStep)\n }\n }\n\n return (\n <form\n className=\"survey-form\"\n style={\n isPopup\n ? {\n color: textColor,\n borderColor: survey.appearance?.borderColor,\n ...styleOverrides,\n }\n : {}\n }\n >\n {surveyQuestions.map((question, displayQuestionIndex) => {\n const { originalQuestionIndex } = question\n\n const isVisible = isPreviewMode\n ? currentQuestionIndex === originalQuestionIndex\n : currentQuestionIndex === displayQuestionIndex\n return (\n isVisible && (\n <div\n className=\"survey-box\"\n style={\n isPopup\n ? {\n backgroundColor:\n survey.appearance?.backgroundColor ||\n defaultSurveyAppearance.backgroundColor,\n }\n : {}\n }\n >\n {isPopup && <Cancel onClick={() => handleCloseSurveyPopup()} />}\n {getQuestionComponent({\n question,\n forceDisableHtml,\n displayQuestionIndex,\n appearance: survey.appearance || defaultSurveyAppearance,\n onSubmit: (res) =>\n onNextButtonClick({\n res,\n originalQuestionIndex,\n displayQuestionIndex,\n }),\n onPreviewSubmit,\n })}\n </div>\n )\n )\n })}\n </form>\n )\n}\n\nexport function FeedbackWidget({\n survey,\n forceDisableHtml,\n posthog,\n readOnly,\n removeSurveyFromFocus,\n}: {\n survey: Survey\n forceDisableHtml?: boolean\n posthog?: PostHog\n readOnly?: boolean\n removeSurveyFromFocus: (id: string) => void\n}): JSX.Element {\n const [showSurvey, setShowSurvey] = useState(false)\n const [styleOverrides, setStyle] = useState({})\n const widgetRef = useRef<HTMLDivElement>(null)\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 if (widgetRef.current) {\n const widgetPos = widgetRef.current.getBoundingClientRect()\n const style = {\n top: '50%',\n left: parseInt(`${widgetPos.right - 360}`),\n bottom: 'auto',\n borderRadius: 10,\n borderBottom: `1.5px solid ${survey.appearance?.borderColor || '#c9c6c6'}`,\n }\n setStyle(style)\n }\n }\n if (survey.appearance?.widgetType === 'selector') {\n const widget = document.querySelector(survey.appearance.widgetSelector || '')\n widget?.addEventListener('click', () => {\n setShowSurvey(!showSurvey)\n })\n widget?.setAttribute('PHWidgetSurveyClickListener', 'true')\n }\n }, [])\n\n return (\n <>\n {survey.appearance?.widgetType === 'tab' && (\n <div\n className=\"ph-survey-widget-tab\"\n ref={widgetRef}\n onClick={() => !readOnly && setShowSurvey(!showSurvey)}\n style={{ color: getContrastingTextColor(survey.appearance.widgetColor) }}\n >\n <div className=\"ph-survey-widget-tab-icon\"></div>\n {survey.appearance?.widgetLabel || ''}\n </div>\n )}\n {showSurvey && (\n <SurveyPopup\n key={'feedback-widget-survey'}\n posthog={posthog}\n survey={survey}\n forceDisableHtml={forceDisableHtml}\n style={styleOverrides}\n removeSurveyFromFocus={removeSurveyFromFocus}\n isPopup={true}\n />\n )}\n </>\n )\n}\n\ninterface GetQuestionComponentProps {\n question: SurveyQuestion\n forceDisableHtml: boolean\n displayQuestionIndex: number\n appearance: SurveyAppearance\n onSubmit: (res: string | string[] | number | null) => void\n onPreviewSubmit: (res: string | string[] | number | null) => void\n}\n\nconst getQuestionComponent = ({\n question,\n forceDisableHtml,\n displayQuestionIndex,\n appearance,\n onSubmit,\n onPreviewSubmit,\n}: GetQuestionComponentProps): JSX.Element => {\n const questionComponents = {\n [SurveyQuestionType.Open]: OpenTextQuestion,\n [SurveyQuestionType.Link]: LinkQuestion,\n [SurveyQuestionType.Rating]: RatingQuestion,\n [SurveyQuestionType.SingleChoice]: MultipleChoiceQuestion,\n [SurveyQuestionType.MultipleChoice]: MultipleChoiceQuestion,\n }\n\n const commonProps = {\n question,\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 }\n\n const additionalProps: Record<SurveyQuestionType, any> = {\n [SurveyQuestionType.Open]: {},\n [SurveyQuestionType.Link]: {},\n [SurveyQuestionType.Rating]: { displayQuestionIndex },\n [SurveyQuestionType.SingleChoice]: { displayQuestionIndex },\n [SurveyQuestionType.MultipleChoice]: { displayQuestionIndex },\n }\n\n const Component = questionComponents[question.type]\n const componentProps = { ...commonProps, ...additionalProps[question.type] }\n\n return <Component {...componentProps} />\n}\n"]}
@@ -4,6 +4,7 @@ import { RemoteConfig } from './types';
4
4
  import { SurveyEventReceiver } from './utils/survey-event-receiver';
5
5
  export declare const surveyUrlValidationMap: Record<SurveyUrlMatchType, (conditionsUrl: string) => boolean>;
6
6
  export declare function getNextSurveyStep(survey: Survey, currentQuestionIndex: number, response: string | string[] | number | null): any;
7
+ export declare function doesSurveyUrlMatch(survey: Survey): boolean;
7
8
  export declare class PostHogSurveys {
8
9
  private readonly instance;
9
10
  private _decideServerResponse?;
@@ -104,6 +104,14 @@ export function getNextSurveyStep(survey, currentQuestionIndex, response) {
104
104
  logger.warn('Falling back to next question index due to unexpected branching type');
105
105
  return nextQuestionIndex;
106
106
  }
107
+ // use urlMatchType to validate url condition, fallback to contains for backwards compatibility
108
+ export function doesSurveyUrlMatch(survey) {
109
+ var _a, _b, _c;
110
+ if (!((_a = survey.conditions) === null || _a === void 0 ? void 0 : _a.url)) {
111
+ return true;
112
+ }
113
+ return surveyUrlValidationMap[(_c = (_b = survey.conditions) === null || _b === void 0 ? void 0 : _b.urlMatchType) !== null && _c !== void 0 ? _c : 'icontains'](survey.conditions.url);
114
+ }
107
115
  var PostHogSurveys = /** @class */ (function () {
108
116
  function PostHogSurveys(instance) {
109
117
  this.instance = instance;
@@ -223,15 +231,12 @@ var PostHogSurveys = /** @class */ (function () {
223
231
  return !!(survey.start_date && !survey.end_date);
224
232
  });
225
233
  var conditionMatchedSurveys = activeSurveys.filter(function (survey) {
226
- var _a, _b, _c, _d;
234
+ var _a;
227
235
  if (!survey.conditions) {
228
236
  return true;
229
237
  }
230
- // use urlMatchType to validate url condition, fallback to contains for backwards compatibility
231
- var urlCheck = ((_a = survey.conditions) === null || _a === void 0 ? void 0 : _a.url)
232
- ? surveyUrlValidationMap[(_c = (_b = survey.conditions) === null || _b === void 0 ? void 0 : _b.urlMatchType) !== null && _c !== void 0 ? _c : 'icontains'](survey.conditions.url)
233
- : true;
234
- var selectorCheck = ((_d = survey.conditions) === null || _d === void 0 ? void 0 : _d.selector)
238
+ var urlCheck = doesSurveyUrlMatch(survey);
239
+ var selectorCheck = ((_a = survey.conditions) === null || _a === void 0 ? void 0 : _a.selector)
235
240
  ? document === null || document === void 0 ? void 0 : document.querySelector(survey.conditions.selector)
236
241
  : true;
237
242
  return urlCheck && selectorCheck;
@@ -1 +1 @@
1
- {"version":3,"file":"posthog-surveys.js","sourceRoot":"","sources":["../../src/posthog-sur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C;YACjC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;YAClC,OAAM;QACV,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,UAAC,OAAO;YACpB,IAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,EAAE,KAAK,QAAQ,EAAjB,CAAiB,CAAC,CAAC,CAAC,CAAC,CAAA;YAC1D,KAAI,CAAC,cAAc,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;QAC/C,CAAC,CAAC,CAAA;IACN,CAAC;IAED,qCAAY,GAAZ,UAAa,QAAgB,EAAE,QAAgB;QAA/C,iBASC;QARG,IAAI,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;YACjC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;YAClC,OAAM;QACV,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,UAAC,OAAO;YACpB,IAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,EAAE,KAAK,QAAQ,EAAjB,CAAiB,CAAC,CAAC,CAAC,CAAC,CAAA;YAC1D,KAAI,CAAC,cAAc,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAA;QAC/E,CAAC,CAAC,CAAA;IACN,CAAC;IACL,qBAAC;AAAD,CAAC,AAnPD,IAmPC","sourcesContent":["import { SURVEYS } from './constants'\nimport { getSurveySeenStorageKeys } from './extensions/surveys/surveys-utils'\nimport { PostHog } from './posthog-core'\nimport {\n Survey,\n SurveyCallback,\n SurveyQuestionBranchingType,\n SurveyQuestionType,\n SurveyUrlMatchType,\n} from './posthog-surveys-types'\nimport { RemoteConfig } from './types'\nimport { assignableWindow, document, window } from './utils/globals'\nimport { createLogger } from './utils/logger'\nimport { isUrlMatchingRegex } from './utils/request-utils'\nimport { SurveyEventReceiver } from './utils/survey-event-receiver'\nimport { isNullish } from './utils/type-utils'\n\nconst logger = createLogger('[Surveys]')\n\nexport const surveyUrlValidationMap: Record<SurveyUrlMatchType, (conditionsUrl: string) => boolean> = {\n icontains: (conditionsUrl) =>\n !!window && window.location.href.toLowerCase().indexOf(conditionsUrl.toLowerCase()) > -1,\n not_icontains: (conditionsUrl) =>\n !!window && window.location.href.toLowerCase().indexOf(conditionsUrl.toLowerCase()) === -1,\n regex: (conditionsUrl) => !!window && isUrlMatchingRegex(window.location.href, conditionsUrl),\n not_regex: (conditionsUrl) => !!window && !isUrlMatchingRegex(window.location.href, conditionsUrl),\n exact: (conditionsUrl) => window?.location.href === conditionsUrl,\n is_not: (conditionsUrl) => window?.location.href !== conditionsUrl,\n}\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 const selectedChoiceIndex = question.choices.indexOf(`${response}`)\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\nexport class PostHogSurveys {\n private _decideServerResponse?: boolean\n public _surveyEventReceiver: SurveyEventReceiver | null\n private _surveyManager: any\n\n constructor(private readonly instance: PostHog) {\n // we set this to undefined here because we need the persistence storage for this type\n // but that's not initialized until loadIfEnabled is called.\n this._surveyEventReceiver = null\n }\n\n onRemoteConfig(response: RemoteConfig) {\n this._decideServerResponse = !!response['surveys']\n logger.info(`decideServerResponse set to ${this._decideServerResponse}`)\n\n this.loadIfEnabled()\n }\n\n reset(): void {\n localStorage.removeItem('lastSeenSurveyDate')\n const surveyKeys = getSurveySeenStorageKeys()\n surveyKeys.forEach((key) => localStorage.removeItem(key))\n }\n\n loadIfEnabled() {\n if (this._surveyManager) {\n // Surveys already loaded.\n return\n }\n\n const disableSurveys = this.instance.config.disable_surveys\n\n if (disableSurveys) {\n logger.info('Disabled. Not loading surveys.')\n return\n }\n\n const phExtensions = assignableWindow?.__PosthogExtensions__\n\n if (!phExtensions) {\n logger.error('PostHog Extensions not found.')\n return\n }\n\n const generateSurveys = phExtensions.generateSurveys\n\n if (!this._decideServerResponse) {\n logger.warn('Decide not loaded yet. Not loading surveys.')\n return\n }\n\n if (this._surveyEventReceiver == null) {\n this._surveyEventReceiver = new SurveyEventReceiver(this.instance)\n }\n\n if (!generateSurveys) {\n const loadExternalDependency = phExtensions.loadExternalDependency\n\n if (loadExternalDependency) {\n loadExternalDependency(this.instance, 'surveys', (err) => {\n if (err) {\n logger.error('Could not load surveys script', err)\n return\n }\n\n this._surveyManager = phExtensions.generateSurveys?.(this.instance)\n })\n } else {\n logger.error('PostHog loadExternalDependency extension not found. Cannot load remote config.')\n }\n } else {\n this._surveyManager = generateSurveys(this.instance)\n }\n }\n\n getSurveys(callback: SurveyCallback, forceReload = false) {\n // In case we manage to load the surveys script, but config says not to load surveys\n // then we shouldn't return survey data\n if (this.instance.config.disable_surveys) {\n logger.info('Disabled. Not loading surveys.')\n\n return callback([])\n }\n\n if (this._surveyEventReceiver == null) {\n this._surveyEventReceiver = new SurveyEventReceiver(this.instance)\n }\n\n const existingSurveys = this.instance.get_property(SURVEYS)\n\n if (!existingSurveys || forceReload) {\n this.instance._send_request({\n url: this.instance.requestRouter.endpointFor(\n 'api',\n `/api/surveys/?token=${this.instance.config.token}`\n ),\n method: 'GET',\n callback: (response) => {\n const statusCode = response.statusCode\n if (statusCode !== 200 || !response.json) {\n logger.error(`Surveys API could not be loaded, status: ${statusCode}`)\n return callback([])\n }\n const surveys = response.json.surveys || []\n\n const eventOrActionBasedSurveys = surveys.filter(\n (survey: Survey) =>\n (survey.conditions?.events &&\n survey.conditions?.events?.values &&\n survey.conditions?.events?.values?.length > 0) ||\n (survey.conditions?.actions &&\n survey.conditions?.actions?.values &&\n survey.conditions?.actions?.values?.length > 0)\n )\n\n if (eventOrActionBasedSurveys.length > 0) {\n this._surveyEventReceiver?.register(eventOrActionBasedSurveys)\n }\n\n this.instance.persistence?.register({ [SURVEYS]: surveys })\n return callback(surveys)\n },\n })\n } else {\n logger.info('Surveys already loaded, using existing data.')\n return callback(existingSurveys)\n }\n }\n\n getActiveMatchingSurveys(callback: SurveyCallback, forceReload = false) {\n this.getSurveys((surveys) => {\n const activeSurveys = surveys.filter((survey) => {\n return !!(survey.start_date && !survey.end_date)\n })\n\n const conditionMatchedSurveys = activeSurveys.filter((survey) => {\n if (!survey.conditions) {\n return true\n }\n\n // use urlMatchType to validate url condition, fallback to contains for backwards compatibility\n const urlCheck = survey.conditions?.url\n ? surveyUrlValidationMap[survey.conditions?.urlMatchType ?? 'icontains'](survey.conditions.url)\n : true\n const selectorCheck = survey.conditions?.selector\n ? document?.querySelector(survey.conditions.selector)\n : true\n return urlCheck && selectorCheck\n })\n\n // get all the surveys that have been activated so far with user actions.\n const activatedSurveys: string[] | undefined = this._surveyEventReceiver?.getSurveys()\n const targetingMatchedSurveys = conditionMatchedSurveys.filter((survey) => {\n if (\n !survey.linked_flag_key &&\n !survey.targeting_flag_key &&\n !survey.internal_targeting_flag_key &&\n !survey.feature_flag_keys?.length\n ) {\n return true\n }\n const linkedFlagCheck = survey.linked_flag_key\n ? this.instance.featureFlags.isFeatureEnabled(survey.linked_flag_key)\n : true\n const targetingFlagCheck = survey.targeting_flag_key\n ? this.instance.featureFlags.isFeatureEnabled(survey.targeting_flag_key)\n : true\n\n const hasEvents =\n survey.conditions?.events &&\n survey.conditions?.events?.values &&\n survey.conditions?.events?.values.length > 0\n\n const hasActions =\n survey.conditions?.actions &&\n survey.conditions?.actions?.values &&\n survey.conditions?.actions?.values.length > 0\n const eventBasedTargetingFlagCheck =\n hasEvents || hasActions ? activatedSurveys?.includes(survey.id) : true\n\n const overrideInternalTargetingFlagCheck = this._canActivateRepeatedly(survey)\n const internalTargetingFlagCheck =\n survey.internal_targeting_flag_key && !overrideInternalTargetingFlagCheck\n ? this.instance.featureFlags.isFeatureEnabled(survey.internal_targeting_flag_key)\n : true\n const flagsCheck = this.checkFlags(survey)\n return (\n linkedFlagCheck &&\n targetingFlagCheck &&\n internalTargetingFlagCheck &&\n eventBasedTargetingFlagCheck &&\n flagsCheck\n )\n })\n\n return callback(targetingMatchedSurveys)\n }, forceReload)\n }\n\n 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.instance.featureFlags.isFeatureEnabled(value)\n })\n }\n getNextSurveyStep = getNextSurveyStep\n\n // this method is lazily loaded onto the window to avoid loading preact and other dependencies if surveys is not enabled\n private _canActivateRepeatedly(survey: Survey) {\n if (isNullish(assignableWindow.__PosthogExtensions__?.canActivateRepeatedly)) {\n logger.warn('init was not called')\n return false // TODO does it make sense to have a default here?\n }\n return assignableWindow.__PosthogExtensions__.canActivateRepeatedly(survey)\n }\n\n canRenderSurvey(surveyId: string) {\n if (isNullish(this._surveyManager)) {\n logger.warn('init was not called')\n return\n }\n this.getSurveys((surveys) => {\n const survey = surveys.filter((x) => x.id === surveyId)[0]\n this._surveyManager.canRenderSurvey(survey)\n })\n }\n\n renderSurvey(surveyId: string, selector: string) {\n if (isNullish(this._surveyManager)) {\n logger.warn('init was not called')\n return\n }\n this.getSurveys((surveys) => {\n const survey = surveys.filter((x) => x.id === surveyId)[0]\n this._surveyManager.renderSurvey(survey, document?.querySelector(selector))\n })\n }\n}\n"]}
1
+ {"version":3,"file":"posthog-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qB,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAA;IAC/E,CAAC;IAED,wCAAe,GAAf,UAAgB,QAAgB;QAAhC,iBASC;QARG,IAAI,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;YACjC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;YAClC,OAAM;QACV,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,UAAC,OAAO;YACpB,IAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,EAAE,KAAK,QAAQ,EAAjB,CAAiB,CAAC,CAAC,CAAC,CAAC,CAAA;YAC1D,KAAI,CAAC,cAAc,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;QAC/C,CAAC,CAAC,CAAA;IACN,CAAC;IAED,qCAAY,GAAZ,UAAa,QAAgB,EAAE,QAAgB;QAA/C,iBASC;QARG,IAAI,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;YACjC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;YAClC,OAAM;QACV,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,UAAC,OAAO;YACpB,IAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,EAAE,KAAK,QAAQ,EAAjB,CAAiB,CAAC,CAAC,CAAC,CAAC,CAAA;YAC1D,KAAI,CAAC,cAAc,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAA;QAC/E,CAAC,CAAC,CAAA;IACN,CAAC;IACL,qBAAC;AAAD,CAAC,AAhPD,IAgPC","sourcesContent":["import { SURVEYS } from './constants'\nimport { getSurveySeenStorageKeys } from './extensions/surveys/surveys-utils'\nimport { PostHog } from './posthog-core'\nimport {\n Survey,\n SurveyCallback,\n SurveyQuestionBranchingType,\n SurveyQuestionType,\n SurveyUrlMatchType,\n} from './posthog-surveys-types'\nimport { RemoteConfig } from './types'\nimport { assignableWindow, document, window } from './utils/globals'\nimport { createLogger } from './utils/logger'\nimport { isUrlMatchingRegex } from './utils/request-utils'\nimport { SurveyEventReceiver } from './utils/survey-event-receiver'\nimport { isNullish } from './utils/type-utils'\n\nconst logger = createLogger('[Surveys]')\n\nexport const surveyUrlValidationMap: Record<SurveyUrlMatchType, (conditionsUrl: string) => boolean> = {\n icontains: (conditionsUrl) =>\n !!window && window.location.href.toLowerCase().indexOf(conditionsUrl.toLowerCase()) > -1,\n not_icontains: (conditionsUrl) =>\n !!window && window.location.href.toLowerCase().indexOf(conditionsUrl.toLowerCase()) === -1,\n regex: (conditionsUrl) => !!window && isUrlMatchingRegex(window.location.href, conditionsUrl),\n not_regex: (conditionsUrl) => !!window && !isUrlMatchingRegex(window.location.href, conditionsUrl),\n exact: (conditionsUrl) => window?.location.href === conditionsUrl,\n is_not: (conditionsUrl) => window?.location.href !== conditionsUrl,\n}\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 const selectedChoiceIndex = question.choices.indexOf(`${response}`)\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\n// use urlMatchType to validate url condition, fallback to contains for backwards compatibility\nexport function doesSurveyUrlMatch(survey: Survey): boolean {\n if (!survey.conditions?.url) {\n return true\n }\n\n return surveyUrlValidationMap[survey.conditions?.urlMatchType ?? 'icontains'](survey.conditions.url)\n}\n\nexport class PostHogSurveys {\n private _decideServerResponse?: boolean\n public _surveyEventReceiver: SurveyEventReceiver | null\n private _surveyManager: any\n\n constructor(private readonly instance: PostHog) {\n // we set this to undefined here because we need the persistence storage for this type\n // but that's not initialized until loadIfEnabled is called.\n this._surveyEventReceiver = null\n }\n\n onRemoteConfig(response: RemoteConfig) {\n this._decideServerResponse = !!response['surveys']\n logger.info(`decideServerResponse set to ${this._decideServerResponse}`)\n\n this.loadIfEnabled()\n }\n\n reset(): void {\n localStorage.removeItem('lastSeenSurveyDate')\n const surveyKeys = getSurveySeenStorageKeys()\n surveyKeys.forEach((key) => localStorage.removeItem(key))\n }\n\n loadIfEnabled() {\n if (this._surveyManager) {\n // Surveys already loaded.\n return\n }\n\n const disableSurveys = this.instance.config.disable_surveys\n\n if (disableSurveys) {\n logger.info('Disabled. Not loading surveys.')\n return\n }\n\n const phExtensions = assignableWindow?.__PosthogExtensions__\n\n if (!phExtensions) {\n logger.error('PostHog Extensions not found.')\n return\n }\n\n const generateSurveys = phExtensions.generateSurveys\n\n if (!this._decideServerResponse) {\n logger.warn('Decide not loaded yet. Not loading surveys.')\n return\n }\n\n if (this._surveyEventReceiver == null) {\n this._surveyEventReceiver = new SurveyEventReceiver(this.instance)\n }\n\n if (!generateSurveys) {\n const loadExternalDependency = phExtensions.loadExternalDependency\n\n if (loadExternalDependency) {\n loadExternalDependency(this.instance, 'surveys', (err) => {\n if (err) {\n logger.error('Could not load surveys script', err)\n return\n }\n\n this._surveyManager = phExtensions.generateSurveys?.(this.instance)\n })\n } else {\n logger.error('PostHog loadExternalDependency extension not found. Cannot load remote config.')\n }\n } else {\n this._surveyManager = generateSurveys(this.instance)\n }\n }\n\n getSurveys(callback: SurveyCallback, forceReload = false) {\n // In case we manage to load the surveys script, but config says not to load surveys\n // then we shouldn't return survey data\n if (this.instance.config.disable_surveys) {\n logger.info('Disabled. Not loading surveys.')\n\n return callback([])\n }\n\n if (this._surveyEventReceiver == null) {\n this._surveyEventReceiver = new SurveyEventReceiver(this.instance)\n }\n\n const existingSurveys = this.instance.get_property(SURVEYS)\n\n if (!existingSurveys || forceReload) {\n this.instance._send_request({\n url: this.instance.requestRouter.endpointFor(\n 'api',\n `/api/surveys/?token=${this.instance.config.token}`\n ),\n method: 'GET',\n callback: (response) => {\n const statusCode = response.statusCode\n if (statusCode !== 200 || !response.json) {\n logger.error(`Surveys API could not be loaded, status: ${statusCode}`)\n return callback([])\n }\n const surveys = response.json.surveys || []\n\n const eventOrActionBasedSurveys = surveys.filter(\n (survey: Survey) =>\n (survey.conditions?.events &&\n survey.conditions?.events?.values &&\n survey.conditions?.events?.values?.length > 0) ||\n (survey.conditions?.actions &&\n survey.conditions?.actions?.values &&\n survey.conditions?.actions?.values?.length > 0)\n )\n\n if (eventOrActionBasedSurveys.length > 0) {\n this._surveyEventReceiver?.register(eventOrActionBasedSurveys)\n }\n\n this.instance.persistence?.register({ [SURVEYS]: surveys })\n return callback(surveys)\n },\n })\n } else {\n logger.info('Surveys already loaded, using existing data.')\n return callback(existingSurveys)\n }\n }\n\n getActiveMatchingSurveys(callback: SurveyCallback, forceReload = false) {\n this.getSurveys((surveys) => {\n const activeSurveys = surveys.filter((survey) => {\n return !!(survey.start_date && !survey.end_date)\n })\n\n const conditionMatchedSurveys = activeSurveys.filter((survey) => {\n if (!survey.conditions) {\n return true\n }\n\n const urlCheck = doesSurveyUrlMatch(survey)\n const selectorCheck = survey.conditions?.selector\n ? document?.querySelector(survey.conditions.selector)\n : true\n return urlCheck && selectorCheck\n })\n\n // get all the surveys that have been activated so far with user actions.\n const activatedSurveys: string[] | undefined = this._surveyEventReceiver?.getSurveys()\n const targetingMatchedSurveys = conditionMatchedSurveys.filter((survey) => {\n if (\n !survey.linked_flag_key &&\n !survey.targeting_flag_key &&\n !survey.internal_targeting_flag_key &&\n !survey.feature_flag_keys?.length\n ) {\n return true\n }\n const linkedFlagCheck = survey.linked_flag_key\n ? this.instance.featureFlags.isFeatureEnabled(survey.linked_flag_key)\n : true\n const targetingFlagCheck = survey.targeting_flag_key\n ? this.instance.featureFlags.isFeatureEnabled(survey.targeting_flag_key)\n : true\n\n const hasEvents =\n survey.conditions?.events &&\n survey.conditions?.events?.values &&\n survey.conditions?.events?.values.length > 0\n\n const hasActions =\n survey.conditions?.actions &&\n survey.conditions?.actions?.values &&\n survey.conditions?.actions?.values.length > 0\n const eventBasedTargetingFlagCheck =\n hasEvents || hasActions ? activatedSurveys?.includes(survey.id) : true\n\n const overrideInternalTargetingFlagCheck = this._canActivateRepeatedly(survey)\n const internalTargetingFlagCheck =\n survey.internal_targeting_flag_key && !overrideInternalTargetingFlagCheck\n ? this.instance.featureFlags.isFeatureEnabled(survey.internal_targeting_flag_key)\n : true\n const flagsCheck = this.checkFlags(survey)\n return (\n linkedFlagCheck &&\n targetingFlagCheck &&\n internalTargetingFlagCheck &&\n eventBasedTargetingFlagCheck &&\n flagsCheck\n )\n })\n\n return callback(targetingMatchedSurveys)\n }, forceReload)\n }\n\n 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.instance.featureFlags.isFeatureEnabled(value)\n })\n }\n getNextSurveyStep = getNextSurveyStep\n\n // this method is lazily loaded onto the window to avoid loading preact and other dependencies if surveys is not enabled\n private _canActivateRepeatedly(survey: Survey) {\n if (isNullish(assignableWindow.__PosthogExtensions__?.canActivateRepeatedly)) {\n logger.warn('init was not called')\n return false // TODO does it make sense to have a default here?\n }\n return assignableWindow.__PosthogExtensions__.canActivateRepeatedly(survey)\n }\n\n canRenderSurvey(surveyId: string) {\n if (isNullish(this._surveyManager)) {\n logger.warn('init was not called')\n return\n }\n this.getSurveys((surveys) => {\n const survey = surveys.filter((x) => x.id === surveyId)[0]\n this._surveyManager.canRenderSurvey(survey)\n })\n }\n\n renderSurvey(surveyId: string, selector: string) {\n if (isNullish(this._surveyManager)) {\n logger.warn('init was not called')\n return\n }\n this.getSurveys((surveys) => {\n const survey = surveys.filter((x) => x.id === surveyId)[0]\n this._surveyManager.renderSurvey(survey, document?.querySelector(selector))\n })\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-js",
3
- "version": "1.211.1",
3
+ "version": "1.211.2",
4
4
  "description": "Posthog-js allows you to automatically capture usage and send events to PostHog.",
5
5
  "repository": "https://github.com/PostHog/posthog-js",
6
6
  "author": "hey@posthog.com",