posthog-js 1.89.2 → 1.90.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"surveys.js","sourceRoot":"","sources":["../../../src/extensions/surveys.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAElD,IAAM,cAAc,GAChB,yzBAAyzB,CAAA;AAC7zB,IAAM,YAAY,GACd,muBAAmuB,CAAA;AACvuB,IAAM,iBAAiB,GACnB,k1BAAk1B,CAAA;AACt1B,IAAM,qBAAqB,GACvB,wnBAAwnB,CAAA;AAC5nB,IAAM,kBAAkB,GACpB,87BAA87B,CAAA;AACl8B,IAAM,SAAS,GACX,+sBAA+sB,CAAA;AACntB,IAAM,WAAW,GACb,s1MAAs1M,CAAA;AAC11M,IAAM,QAAQ,GACV,+rBAA+rB,CAAA;AAEnsB,IAAM,KAAK,GAAG,UAAC,EAAU,EAAE,UAAmC;IAC1D,IAAM,SAAS,GAAG;QACd,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,cAAc;QACrB,MAAM,EAAE,gFAGL;KACN,CAAA;IACD,OAAO,8BACS,EAAE,2aAQK,QAAQ,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,KAAI,KAAK,CAAC,yCACzC,QAAQ,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,KAAI,OAAO,CAAC,kDAC5B,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,WAAW,KAAI,SAAS,6FAGxD,SAAS,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,KAAI,OAAO,CAAC,IAAI,cAAc,8CAExD,EAAE,kPAQF,EAAE,uFAEM,CAAA,UAAU,aAAV,UAAU,uBAAV,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cesContent":["import { PostHog } from 'posthog-core'\nimport {\n BasicSurveyQuestion,\n LinkSurveyQuestion,\n MultipleSurveyQuestion,\n RatingSurveyQuestion,\n Survey,\n SurveyAppearance,\n SurveyQuestion,\n} from '../posthog-surveys-types'\n\nimport { _isUndefined } from '../utils/type-utils'\n\nconst satisfiedEmoji =\n '<svg class=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\"><path d=\"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146 272q66 0 121.5-35.5T682-393h-52q-23 40-63 61.5T480.5-310q-46.5 0-87-21T331-393h-53q26 61 81 96.5T480-261Zm0 181q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z\"/></svg>'\nconst neutralEmoji =\n '<svg class=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\"><path d=\"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm20 194h253v-49H354v49ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z\"/></svg>'\nconst dissatisfiedEmoji =\n '<svg class=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\"><path d=\"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146.174 116Q413-417 358.5-379.5T278-280h53q22-42 62.173-65t87.5-23Q528-368 567.5-344.5T630-280h52q-25-63-79.826-100-54.826-37-122-37ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z\"/></svg>'\nconst veryDissatisfiedEmoji =\n '<svg class=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\"><path d=\"M480-417q-67 0-121.5 37.5T278-280h404q-25-63-80-100t-122-37Zm-183-72 50-45 45 45 31-36-45-45 45-45-31-36-45 45-50-45-31 36 45 45-45 45 31 36Zm272 0 44-45 51 45 31-36-45-45 45-45-31-36-51 45-44-45-31 36 44 45-44 45 31 36ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142 0 241-99t99-241q0-142-99-241t-241-99q-142 0-241 99t-99 241q0 142 99 241t241 99Z\"/></svg>'\nconst verySatisfiedEmoji =\n '<svg class=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\"><path d=\"M479.504-261Q537-261 585.5-287q48.5-26 78.5-72.4 6-11.6-.75-22.6-6.75-11-20.25-11H316.918Q303-393 296.5-382t-.5 22.6q30 46.4 78.5 72.4 48.5 26 105.004 26ZM347-578l27 27q7.636 8 17.818 8Q402-543 410-551q8-8 8-18t-8-18l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.636-8 17.818Q276-559 284-551q8 8 18 8t18-8l27-27Zm267 0 27 27q7.714 8 18 8t18-8q8-7.636 8-17.818Q685-579 677-587l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.714-8 18t8 18q7.636 8 17.818 8Q579-543 587-551l27-27ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z\"/></svg>'\nconst cancelSVG =\n '<svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M0.164752 0.164752C0.384422 -0.0549175 0.740578 -0.0549175 0.960248 0.164752L6 5.20451L11.0398 0.164752C11.2594 -0.0549175 11.6156 -0.0549175 11.8352 0.164752C12.0549 0.384422 12.0549 0.740578 11.8352 0.960248L6.79549 6L11.8352 11.0398C12.0549 11.2594 12.0549 11.6156 11.8352 11.8352C11.6156 12.0549 11.2594 12.0549 11.0398 11.8352L6 6.79549L0.960248 11.8352C0.740578 12.0549 0.384422 12.0549 0.164752 11.8352C-0.0549175 11.6156 -0.0549175 11.2594 0.164752 11.0398L5.20451 6L0.164752 0.960248C-0.0549175 0.740578 -0.0549175 0.384422 0.164752 0.164752Z\" fill=\"black\"/></svg>'\nconst posthogLogo =\n '<svg width=\"77\" height=\"14\" viewBox=\"0 0 77 14\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><g clip-path=\"url(#clip0_2415_6911)\"><mask id=\"mask0_2415_6911\" style=\"mask-type:luminance\" maskUnits=\"userSpaceOnUse\" x=\"0\" y=\"0\" width=\"77\" height=\"14\"><path d=\"M0.5 0H76.5V14H0.5V0Z\" fill=\"white\"/></mask><g mask=\"url(#mask0_2415_6911)\"><path d=\"M5.77226 8.02931C5.59388 8.37329 5.08474 8.37329 4.90634 8.02931L4.4797 7.20672C4.41155 7.07535 4.41155 6.9207 4.4797 6.78933L4.90634 5.96669C5.08474 5.62276 5.59388 5.62276 5.77226 5.96669L6.19893 6.78933C6.26709 6.9207 6.26709 7.07535 6.19893 7.20672L5.77226 8.02931ZM5.77226 12.6946C5.59388 13.0386 5.08474 13.0386 4.90634 12.6946L4.4797 11.872C4.41155 11.7406 4.41155 11.586 4.4797 11.4546L4.90634 10.632C5.08474 10.288 5.59388 10.288 5.77226 10.632L6.19893 11.4546C6.26709 11.586 6.26709 11.7406 6.19893 11.872L5.77226 12.6946Z\" fill=\"#1D4AFF\"/><path d=\"M0.5 10.9238C0.5 10.508 1.02142 10.2998 1.32637 10.5938L3.54508 12.7327C3.85003 13.0267 3.63405 13.5294 3.20279 13.5294H0.984076C0.716728 13.5294 0.5 13.3205 0.5 13.0627V10.9238ZM0.5 8.67083C0.5 8.79459 0.551001 8.91331 0.641783 9.00081L5.19753 13.3927C5.28831 13.4802 5.41144 13.5294 5.53982 13.5294H8.0421C8.47337 13.5294 8.68936 13.0267 8.3844 12.7327L1.32637 5.92856C1.02142 5.63456 0.5 5.84278 0.5 6.25854V8.67083ZM0.5 4.00556C0.5 4.12932 0.551001 4.24802 0.641783 4.33554L10.0368 13.3927C10.1276 13.4802 10.2508 13.5294 10.3791 13.5294H12.8814C13.3127 13.5294 13.5287 13.0267 13.2237 12.7327L1.32637 1.26329C1.02142 0.969312 0.5 1.17752 0.5 1.59327V4.00556ZM5.33931 4.00556C5.33931 4.12932 5.39033 4.24802 5.4811 4.33554L14.1916 12.7327C14.4965 13.0267 15.0179 12.8185 15.0179 12.4028V9.99047C15.0179 9.86671 14.9669 9.74799 14.8762 9.66049L6.16568 1.26329C5.86071 0.969307 5.33931 1.17752 5.33931 1.59327V4.00556ZM11.005 1.26329C10.7 0.969307 10.1786 1.17752 10.1786 1.59327V4.00556C10.1786 4.12932 10.2296 4.24802 10.3204 4.33554L14.1916 8.06748C14.4965 8.36148 15.0179 8.15325 15.0179 7.7375V5.3252C15.0179 5.20144 14.9669 5.08272 14.8762 4.99522L11.005 1.26329Z\" fill=\"#F9BD2B\"/><path d=\"M21.0852 10.981L16.5288 6.58843C16.2238 6.29443 15.7024 6.50266 15.7024 6.91841V13.0627C15.7024 13.3205 15.9191 13.5294 16.1865 13.5294H23.2446C23.5119 13.5294 23.7287 13.3205 23.7287 13.0627V12.5032C23.7287 12.2455 23.511 12.0396 23.2459 12.0063C22.4323 11.9042 21.6713 11.546 21.0852 10.981ZM18.0252 12.0365C17.5978 12.0365 17.251 11.7021 17.251 11.2901C17.251 10.878 17.5978 10.5436 18.0252 10.5436C18.4527 10.5436 18.7996 10.878 18.7996 11.2901C18.7996 11.7021 18.4527 12.0365 18.0252 12.0365Z\" fill=\"currentColor\"/><path d=\"M0.5 13.0627C0.5 13.3205 0.716728 13.5294 0.984076 13.5294H3.20279C3.63405 13.5294 3.85003 13.0267 3.54508 12.7327L1.32637 10.5938C1.02142 10.2998 0.5 10.508 0.5 10.9238V13.0627ZM5.33931 5.13191L1.32637 1.26329C1.02142 0.969306 0.5 1.17752 0.5 1.59327V4.00556C0.5 4.12932 0.551001 4.24802 0.641783 4.33554L5.33931 8.86412V5.13191ZM1.32637 5.92855C1.02142 5.63455 0.5 5.84278 0.5 6.25853V8.67083C0.5 8.79459 0.551001 8.91331 0.641783 9.00081L5.33931 13.5294V9.79717L1.32637 5.92855Z\" fill=\"#1D4AFF\"/><path d=\"M10.1787 5.3252C10.1787 5.20144 10.1277 5.08272 10.0369 4.99522L6.16572 1.26329C5.8608 0.969306 5.33936 1.17752 5.33936 1.59327V4.00556C5.33936 4.12932 5.39037 4.24802 5.48114 4.33554L10.1787 8.86412V5.3252ZM5.33936 13.5294H8.04214C8.47341 13.5294 8.6894 13.0267 8.38443 12.7327L5.33936 9.79717V13.5294ZM5.33936 5.13191V8.67083C5.33936 8.79459 5.39037 8.91331 5.48114 9.00081L10.1787 13.5294V9.99047C10.1787 9.86671 10.1277 9.74803 10.0369 9.66049L5.33936 5.13191Z\" fill=\"#F54E00\"/><path d=\"M29.375 11.6667H31.3636V8.48772H33.0249C34.8499 8.48772 36.0204 7.4443 36.0204 5.83052C36.0204 4.21681 34.8499 3.17334 33.0249 3.17334H29.375V11.6667ZM31.3636 6.84972V4.81136H32.8236C33.5787 4.81136 34.0318 5.19958 34.0318 5.83052C34.0318 6.4615 33.5787 6.84972 32.8236 6.84972H31.3636ZM39.618 11.7637C41.5563 11.7637 42.9659 10.429 42.9659 8.60905C42.9659 6.78905 41.5563 5.45438 39.618 5.45438C37.6546 5.45438 36.2701 6.78905 36.2701 8.60905C36.2701 10.429 37.6546 11.7637 39.618 11.7637ZM38.1077 8.60905C38.1077 7.63838 38.7118 6.97105 39.618 6.97105C40.5116 6.97105 41.1157 7.63838 41.1157 8.60905C41.1157 9.57972 40.5116 10.2471 39.618 10.2471C38.7118 10.2471 38.1077 9.57972 38.1077 8.60905ZM46.1482 11.7637C47.6333 11.7637 48.6402 10.8658 48.6402 9.81025C48.6402 7.33505 45.2294 8.13585 45.2294 7.16518C45.2294 6.8983 45.5189 6.72843 45.9342 6.72843C46.3622 6.72843 46.8782 6.98318 47.0418 7.54132L48.527 6.94678C48.2375 6.06105 47.1677 5.45438 45.8713 5.45438C44.4743 5.45438 43.6058 6.25518 43.6058 7.21372C43.6058 9.53118 46.9663 8.88812 46.9663 9.84665C46.9663 10.1864 46.6391 10.417 46.1482 10.417C45.4434 10.417 44.9525 9.94376 44.8015 9.3735L43.3164 9.93158C43.6436 10.8537 44.6001 11.7637 46.1482 11.7637ZM53.4241 11.606L53.2982 10.0651C53.0843 10.1743 52.8074 10.2106 52.5808 10.2106C52.1278 10.2106 51.8257 9.89523 51.8257 9.34918V7.03172H53.3612V5.55145H51.8257V3.78001H49.9755V5.55145H48.9687V7.03172H49.9755V9.57972C49.9755 11.06 51.0202 11.7637 52.3921 11.7637C52.7696 11.7637 53.122 11.7031 53.4241 11.606ZM59.8749 3.17334V6.47358H56.376V3.17334H54.3874V11.6667H56.376V8.11158H59.8749V11.6667H61.8761V3.17334H59.8749ZM66.2899 11.7637C68.2281 11.7637 69.6378 10.429 69.6378 8.60905C69.6378 6.78905 68.2281 5.45438 66.2899 5.45438C64.3265 5.45438 62.942 6.78905 62.942 8.60905C62.942 10.429 64.3265 11.7637 66.2899 11.7637ZM64.7796 8.60905C64.7796 7.63838 65.3837 6.97105 66.2899 6.97105C67.1835 6.97105 67.7876 7.63838 67.7876 8.60905C67.7876 9.57972 67.1835 10.2471 66.2899 10.2471C65.3837 10.2471 64.7796 9.57972 64.7796 8.60905ZM73.2088 11.4725C73.901 11.4725 74.5177 11.242 74.845 10.8416V11.424C74.845 12.1034 74.2786 12.5767 73.4102 12.5767C72.7935 12.5767 72.2523 12.2854 72.1642 11.788L70.4776 12.0428C70.7042 13.1955 71.925 13.972 73.4102 13.972C75.361 13.972 76.6574 12.8679 76.6574 11.2298V5.55145H74.8324V6.07318C74.4926 5.69705 73.9136 5.45438 73.171 5.45438C71.409 5.45438 70.3014 6.61918 70.3014 8.46345C70.3014 10.3077 71.409 11.4725 73.2088 11.4725ZM72.1012 8.46345C72.1012 7.55345 72.655 6.97105 73.5109 6.97105C74.3793 6.97105 74.9331 7.55345 74.9331 8.46345C74.9331 9.37345 74.3793 9.95585 73.5109 9.95585C72.655 9.95585 72.1012 9.37345 72.1012 8.46345Z\" fill=\"currentColor\"/></g></g><defs><clipPath id=\"clip0_2415_6911\"><rect width=\"76\" height=\"14\" fill=\"white\" transform=\"translate(0.5)\"/></clipPath></defs></svg>'\nconst checkSVG =\n '<svg width=\"16\" height=\"12\" viewBox=\"0 0 16 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M5.30769 10.6923L4.77736 11.2226C4.91801 11.3633 5.10878 11.4423 5.30769 11.4423C5.5066 11.4423 5.69737 11.3633 5.83802 11.2226L5.30769 10.6923ZM15.5303 1.53033C15.8232 1.23744 15.8232 0.762563 15.5303 0.46967C15.2374 0.176777 14.7626 0.176777 14.4697 0.46967L15.5303 1.53033ZM1.53033 5.85429C1.23744 5.56139 0.762563 5.56139 0.46967 5.85429C0.176777 6.14718 0.176777 6.62205 0.46967 6.91495L1.53033 5.85429ZM5.83802 11.2226L15.5303 1.53033L14.4697 0.46967L4.77736 10.162L5.83802 11.2226ZM0.46967 6.91495L4.77736 11.2226L5.83802 10.162L1.53033 5.85429L0.46967 6.91495Z\" fill=\"currentColor\"/></svg>'\n\nconst style = (id: string, appearance: SurveyAppearance | null) => {\n const positions = {\n left: 'left: 30px;',\n right: 'right: 30px;',\n center: `\n left: 50%;\n transform: translateX(-50%);\n `,\n }\n return `\n .survey-${id}-form {\n position: fixed;\n margin: 0px;\n bottom: 0px;\n color: black;\n font-weight: normal;\n font-family: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", \"Roboto\", Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n text-align: left;\n max-width: ${parseInt(appearance?.maxWidth || '290')}px;\n z-index: ${parseInt(appearance?.zIndex || '99999')};\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n border-bottom: 0px;\n width: 100%;\n ${positions[appearance?.position || 'right'] || 'right: 30px;'}\n }\n .survey-${id}-form .tab {\n display: none;\n }\n .form-submit[disabled] {\n opacity: 0.6;\n filter: grayscale(100%);\n cursor: not-allowed;\n }\n .survey-${id}-form {\n flex-direction: column;\n background: ${appearance?.backgroundColor || '#eeeded'};\n border-top-left-radius: 10px;\n border-top-right-radius: 10px;\n box-shadow: -6px 0 16px -8px rgb(0 0 0 / 8%), -9px 0 28px 0 rgb(0 0 0 / 5%), -12px 0 48px 16px rgb(0 0 0 / 3%);\n }\n .survey-${id}-form textarea {\n color: #2d2d2d;\n font-size: 14px;\n font-family: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", \"Roboto\", Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n background: white;\n color: black;\n outline: none;\n padding-left: 10px;\n padding-right: 10px;\n padding-top: 10px;\n border-radius: 6px;\n border-color: ${appearance?.borderColor || '#c9c6c6'};\n margin-top: 14px; \n }\n .form-submit {\n box-sizing: border-box;\n margin: 0;\n font-family: inherit;\n overflow: visible;\n text-transform: none;\n position: relative;\n display: inline-block;\n font-weight: 700;\n white-space: nowrap;\n text-align: center;\n border: 1.5px solid transparent;\n cursor: pointer;\n user-select: none;\n touch-action: manipulation;\n padding: 12px;\n font-size: 14px;\n border-radius: 6px;\n outline: 0;\n background: ${appearance?.submitButtonColor || 'black'} !important;\n text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.12);\n box-shadow: 0 2px 0 rgba(0, 0, 0, 0.045);\n width: 100%;\n }\n .form-cancel {\n float: right;\n border: none;\n background: none;\n cursor: pointer;\n }\n .cancel-btn-wrapper {\n position: absolute;\n width: 35px;\n height: 35px;\n border-radius: 100%;\n top: 0;\n right: 0;\n transform: translate(50%, -50%);\n background: white;\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .bolded { font-weight: 600; }\n .buttons {\n display: flex;\n justify-content: center;\n }\n .footer-branding {\n font-size: 11px;\n margin-top: 10px;\n text-align: center;\n display: flex;\n justify-content: center;\n gap: 4px;\n align-items: center;\n font-weight: 500;\n background: ${appearance?.backgroundColor || '#eeeded'};\n text-decoration: none;\n }\n .survey-${id}-box {\n padding: 20px 25px 10px;\n display: flex;\n flex-direction: column;\n }\n .survey-question {\n font-weight: 500;\n font-size: 14px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .question-textarea-wrapper {\n display: flex;\n flex-direction: column;\n }\n .description {\n font-size: 13px;\n margin-top: 5px;\n opacity: .60;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .ratings-number {\n background-color: ${appearance?.ratingButtonColor || 'white'};\n font-size: 14px;\n padding: 8px 0px;\n border: none;\n }\n .ratings-number:hover {\n cursor: pointer;\n }\n .rating-options {\n margin-top: 14px;\n }\n .rating-options-buttons {\n display: grid;\n border-radius: 6px;\n overflow: hidden;\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n }\n .rating-options-buttons > .ratings-number {\n border-right: 1px solid ${appearance?.borderColor || '#c9c6c6'};\n }\n .rating-options-buttons > .ratings-number:last-of-type {\n border-right: 0px;\n }\n .rating-options-buttons .rating-active {\n background: ${appearance?.ratingButtonActiveColor || 'black'};\n }\n .rating-options-emoji {\n display: flex;\n justify-content: space-between;\n }\n .ratings-emoji {\n font-size: 16px;\n background-color: transparent;\n border: none;\n padding: 0px;\n }\n .ratings-emoji:hover {\n cursor: pointer;\n }\n .ratings-emoji.rating-active svg {\n fill: ${appearance?.ratingButtonActiveColor || 'black'};\n }\n .emoji-svg {\n fill: ${appearance?.ratingButtonColor || '#c9c6c6'};\n }\n .rating-text {\n display: flex;\n flex-direction: row;\n font-size: 11px;\n justify-content: space-between;\n margin-top: 6px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n opacity: .60;\n }\n .multiple-choice-options {\n margin-top: 13px;\n font-size: 14px;\n }\n .multiple-choice-options .choice-option {\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 13px;\n cursor: pointer;\n margin-bottom: 5px;\n position: relative;\n }\n .multiple-choice-options > .choice-option:last-of-type {\n margin-bottom: 0px;\n }\n \n .multiple-choice-options input {\n cursor: pointer;\n position: absolute;\n opacity: 0;\n }\n .choice-check {\n position: absolute;\n right: 10px;\n background: white;\n }\n .choice-check svg {\n display: none;\n }\n .multiple-choice-options .choice-option:hover .choice-check svg {\n display: inline-block;\n opacity: .25;\n }\n .multiple-choice-options input:checked + label + .choice-check svg {\n display: inline-block;\n opacity: 100% !important;\n }\n .multiple-choice-options input[type=checkbox]:checked + label {\n font-weight: bold;\n }\n .multiple-choice-options input:checked + label {\n border: 1.5px solid rgba(0,0,0);\n }\n .multiple-choice-options label {\n width: 100%;\n cursor: pointer;\n padding: 10px;\n border: 1.5px solid rgba(0,0,0,.25);\n border-radius: 4px;\n background: white;\n }\n .thank-you-message {\n position: fixed;\n bottom: 0px;\n z-index: ${parseInt(appearance?.zIndex || '99999')};\n box-shadow: -6px 0 16px -8px rgb(0 0 0 / 8%), -9px 0 28px 0 rgb(0 0 0 / 5%), -12px 0 48px 16px rgb(0 0 0 / 3%);\n font-family: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", \"Roboto\", Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n border-top-left-radius: 10px;\n border-top-right-radius: 10px;\n padding: 20px 25px 10px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n text-align: center;\n max-width: ${parseInt(appearance?.maxWidth || '290')}px;\n min-width: 150px;\n width: 100%;\n ${positions[appearance?.position || 'right'] || 'right: 30px;'}\n }\n .thank-you-message-body {\n margin-top: 6px;\n font-size: 14px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .thank-you-message-header {\n margin: 10px 0px 0px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .thank-you-message-container .form-submit {\n margin-top: 20px;\n margin-bottom: 10px;\n }\n .thank-you-message-countdown {\n margin-left: 6px;\n }\n .bottom-section {\n margin-top: 14px;\n }\n `\n}\n\nexport const createShadow = (styleSheet: string, surveyId: string) => {\n const div = document.createElement('div')\n div.className = `PostHogSurvey${surveyId}`\n const shadow = div.attachShadow({ mode: 'open' })\n if (styleSheet) {\n const styleElement = Object.assign(document.createElement('style'), {\n innerText: styleSheet,\n })\n shadow.appendChild(styleElement)\n }\n document.body.appendChild(div)\n return shadow\n}\n\nexport const closeSurveyPopup = (surveyId: string, surveyPopup: HTMLFormElement) => {\n Object.assign(surveyPopup.style, { display: 'none' })\n localStorage.setItem(`seenSurvey_${surveyId}`, 'true')\n window.setTimeout(() => {\n window.dispatchEvent(new Event('PHSurveyClosed'))\n }, 2000)\n surveyPopup.reset()\n}\n\nexport const createOpenTextOrLinkPopup = (\n posthog: PostHog,\n survey: Survey,\n question: BasicSurveyQuestion | LinkSurveyQuestion,\n questionIndex: number\n) => {\n const surveyQuestionType = question.type\n const surveyDescription = question.description\n const questionText = question.question\n const isOptional = !!question.optional\n const form = `\n <div class=\"survey-${survey.id}-box\">\n <div class=\"cancel-btn-wrapper\">\n <button class=\"form-cancel\" type=\"cancel\">${cancelSVG}</button>\n </div>\n <div class=\"question-textarea-wrapper\">\n <div class=\"survey-question auto-text-color\">${questionText}</div>\n ${surveyDescription ? `<span class=\"description auto-text-color\">${surveyDescription}</span>` : ''}\n ${\n surveyQuestionType === 'open'\n ? `<textarea class=\"survey-textarea-question${questionIndex}\" name=\"survey\" rows=4 placeholder=\"${\n survey.appearance?.placeholder || ''\n }\"></textarea>`\n : ''\n }\n </div>\n <div class=\"bottom-section\">\n <div class=\"buttons\">\n <button class=\"form-submit auto-text-color\" type=\"submit\">${\n survey.appearance?.submitButtonText || 'Submit'\n }</button>\n </div>\n <a href=\"https://posthog.com\" target=\"_blank\" rel=\"noopener\" class=\"footer-branding auto-text-color\">Survey by ${posthogLogo}</a>\n </div>\n </div>\n`\n let formElement: HTMLFormElement | HTMLDivElement\n if (survey.questions.length === 1) {\n formElement = Object.assign(document.createElement('form'), {\n className: `survey-${survey.id}-form`,\n innerHTML: form,\n onsubmit: function (e: any) {\n e.preventDefault()\n const surveyQuestionType = question.type\n posthog.capture('survey sent', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_question: survey.questions[0].question,\n $survey_response: surveyQuestionType === 'open' ? e.target.survey.value : 'link clicked',\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n $set: {\n [`$survey_responded/${survey.id}`]: true,\n },\n })\n if (surveyQuestionType === 'link') {\n window.open(question.link || undefined)\n }\n window.setTimeout(() => {\n window.dispatchEvent(new Event('PHSurveySent'))\n }, 200)\n closeSurveyPopup(survey.id, formElement as HTMLFormElement)\n },\n })\n } else {\n formElement = Object.assign(document.createElement('div'), {\n innerHTML: form,\n })\n const submitButton = formElement.querySelector('.form-submit') as HTMLButtonElement\n submitButton.addEventListener('click', () => {\n if (surveyQuestionType === 'link') {\n window.open(question.link || undefined)\n }\n })\n }\n if (!isOptional) {\n if (surveyQuestionType === 'open') {\n ;(formElement.querySelector('.form-submit') as HTMLButtonElement).disabled = true\n }\n formElement.addEventListener('input', (e: any) => {\n if (formElement.querySelector('.form-submit')) {\n const submitButton = formElement.querySelector('.form-submit') as HTMLButtonElement\n submitButton.disabled = !e.target.value\n }\n })\n }\n\n return formElement\n}\n\nexport const createThankYouMessage = (survey: Survey) => {\n const thankYouHTML = `\n <div class=\"thank-you-message-container\">\n <div class=\"cancel-btn-wrapper\">\n <button class=\"form-cancel\" type=\"cancel\">${cancelSVG}</button>\n </div>\n <h3 class=\"thank-you-message-header auto-text-color\">${\n survey.appearance?.thankYouMessageHeader || 'Thank you!'\n }</h3>\n <div class=\"thank-you-message-body auto-text-color\">${survey.appearance?.thankYouMessageDescription || ''}</div>\n <button class=\"form-submit auto-text-color\"><span>Close</span><span class=\"thank-you-message-countdown\"></span></button>\n ${\n survey.appearance?.whiteLabel\n ? ''\n : `<a href=\"https://posthog.com\" target=\"_blank\" rel=\"noopener\" class=\"footer-branding auto-text-color\">Survey by ${posthogLogo}</a>`\n }\n </div>\n `\n const thankYouElement = Object.assign(document.createElement('div'), {\n className: `thank-you-message`,\n innerHTML: thankYouHTML,\n })\n return thankYouElement\n}\n\nexport const addCancelListeners = (\n posthog: PostHog,\n surveyPopup: HTMLFormElement,\n surveyId: string,\n surveyEventName: string\n) => {\n const cancelButtons = surveyPopup.getElementsByClassName('form-cancel')\n for (const button of cancelButtons) {\n button.addEventListener('click', (e) => {\n e.preventDefault()\n closeSurveyPopup(surveyId, surveyPopup)\n posthog.capture('survey dismissed', {\n $survey_name: surveyEventName,\n $survey_id: surveyId,\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n $set: {\n [`$survey_dismissed/${surveyId}`]: true,\n },\n })\n })\n }\n window.dispatchEvent(new Event('PHSurveyClosed'))\n}\n\nexport const createRatingsPopup = (\n posthog: PostHog,\n survey: Survey,\n question: RatingSurveyQuestion,\n questionIndex: number\n) => {\n const scale = question.scale\n const starting = question.scale === 10 ? 0 : 1\n const displayType = question.display\n const isOptional = !!question.optional\n const ratingOptionsElement = document.createElement('div')\n if (displayType === 'number') {\n ratingOptionsElement.className = 'rating-options-buttons'\n ratingOptionsElement.style.gridTemplateColumns = `repeat(${scale - starting + 1}, minmax(0, 1fr))`\n for (let i = starting; i <= scale; i++) {\n const buttonElement = document.createElement('button')\n buttonElement.className = `ratings-number question-${questionIndex}-rating-${i} auto-text-color`\n buttonElement.type = 'submit'\n buttonElement.value = `${i}`\n buttonElement.innerHTML = `${i}`\n ratingOptionsElement.append(buttonElement)\n }\n } else if (displayType === 'emoji') {\n ratingOptionsElement.className = 'rating-options-emoji'\n const threeEmojis = [dissatisfiedEmoji, neutralEmoji, satisfiedEmoji]\n const fiveEmojis = [veryDissatisfiedEmoji, dissatisfiedEmoji, neutralEmoji, satisfiedEmoji, verySatisfiedEmoji]\n for (let i = 1; i <= scale; i++) {\n const emojiElement = document.createElement('button')\n emojiElement.className = `ratings-emoji question-${questionIndex}-rating-${i}`\n emojiElement.type = 'submit'\n emojiElement.value = `${i}`\n emojiElement.innerHTML = scale === 3 ? threeEmojis[i - 1] : fiveEmojis[i - 1]\n ratingOptionsElement.append(emojiElement)\n }\n }\n const ratingsForm = `\n <div class=\"survey-${survey.id}-box\">\n <div class=\"cancel-btn-wrapper\">\n <button class=\"form-cancel\" type=\"cancel\">${cancelSVG}</button>\n </div>\n <div class=\"survey-question auto-text-color\">${question.question}</div>\n ${question.description ? `<span class=\"description auto-text-color\">${question.description}</span>` : ''}\n <div class=\"rating-section\">\n <div class=\"rating-options\">\n </div>\n ${\n question.lowerBoundLabel || question.upperBoundLabel\n ? `<div class=\"rating-text auto-text-color\">\n <div>${question.lowerBoundLabel || ''}</div>\n <div>${question.upperBoundLabel || ''}</div>\n </div>`\n : ''\n }\n <div class=\"bottom-section\">\n <div class=\"buttons\">\n <button class=\"form-submit auto-text-color\" type=\"submit\" ${isOptional ? '' : 'disabled'}>${\n survey.appearance?.submitButtonText || 'Submit'\n }</button>\n </div>\n <a href=\"https://posthog.com\" target=\"_blank\" rel=\"noopener\" class=\"footer-branding auto-text-color\">Survey by ${posthogLogo}</a>\n </div>\n </div>\n </div>\n `\n let formElement: HTMLFormElement | HTMLDivElement\n if (survey.questions.length === 1) {\n formElement = Object.assign(document.createElement('form'), {\n className: `survey-${survey.id}-form`,\n innerHTML: ratingsForm,\n onsubmit: (e: Event) => {\n e.preventDefault()\n const activeRatingEl = formElement.querySelector('.rating-active')\n posthog.capture('survey sent', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_question: question.question,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore // TODO: Fix this, error because it doesn't know that the target is a button\n $survey_response: parseInt(activeRatingEl?.value),\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n $set: {\n [`$survey_responded/${survey.id}`]: true,\n },\n })\n window.setTimeout(() => {\n window.dispatchEvent(new Event('PHSurveySent'))\n }, 200)\n closeSurveyPopup(survey.id, formElement as HTMLFormElement)\n },\n })\n } else {\n formElement = Object.assign(document.createElement('div'), {\n innerHTML: ratingsForm,\n })\n }\n formElement.getElementsByClassName('rating-options')[0].insertAdjacentElement('afterbegin', ratingOptionsElement)\n const allElements =\n question.scale === 10 ? [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] : question.scale === 5 ? [1, 2, 3, 4, 5] : [1, 2, 3]\n for (const x of allElements) {\n const ratingEl = formElement.getElementsByClassName(`question-${questionIndex}-rating-${x}`)[0]\n ratingEl.addEventListener('click', (e) => {\n e.preventDefault()\n for (const activeRatingEl of formElement.getElementsByClassName('rating-active')) {\n activeRatingEl.classList.remove('rating-active')\n }\n ratingEl.classList.add('rating-active')\n if (formElement.querySelector('.form-submit')) {\n ;(formElement.querySelector('.form-submit') as HTMLButtonElement).disabled = false\n }\n setTextColors(formElement)\n })\n }\n\n return formElement\n}\n\nexport const createMultipleChoicePopup = (\n posthog: PostHog,\n survey: Survey,\n question: MultipleSurveyQuestion,\n questionIndex: number\n) => {\n const surveyQuestion = question.question\n const surveyDescription = question.description\n const surveyQuestionChoices = question.choices\n const singleOrMultiSelect = question.type\n const isOptional = !!question.optional\n\n const form = `\n <div class=\"survey-${survey.id}-box\">\n <div class=\"cancel-btn-wrapper\">\n <button class=\"form-cancel\" type=\"cancel\">${cancelSVG}</button>\n </div>\n <div class=\"survey-question auto-text-color\">${surveyQuestion}</div>\n ${surveyDescription ? `<span class=\"description auto-text-color\">${surveyDescription}</span>` : ''}\n <div class=\"multiple-choice-options\">\n ${surveyQuestionChoices\n .map((option, idx) => {\n const inputType = singleOrMultiSelect === 'single_choice' ? 'radio' : 'checkbox'\n const singleOrMultiSelectString = `<div class=\"choice-option\"><input type=${inputType} id=surveyQuestion${questionIndex}Choice${idx} name=\"question${questionIndex}\" value=\"${option}\">\n <label class=\"auto-text-color\" for=surveyQuestion${questionIndex}Choice${idx}>${option}</label><span class=\"choice-check auto-text-color\">${checkSVG}</span></div>`\n return singleOrMultiSelectString\n })\n .join(' ')}\n </div>\n <div class=\"bottom-section\">\n <div class=\"buttons\">\n <button class=\"form-submit auto-text-color\" type=\"submit\" ${isOptional ? '' : 'disabled'}>${\n survey.appearance?.submitButtonText || 'Submit'\n }</button>\n </div>\n <a href=\"https://posthog.com\" target=\"_blank\" rel=\"noopener\" class=\"footer-branding auto-text-color\">Survey by ${posthogLogo}</a>\n </div>\n\n </div>\n `\n let formElement: HTMLFormElement | HTMLDivElement\n if (survey.questions.length === 1) {\n formElement = Object.assign(document.createElement('form'), {\n className: `survey-${survey.id}-form`,\n innerHTML: form,\n onsubmit: (e: Event) => {\n e.preventDefault()\n const targetElement = e.target as HTMLFormElement\n const selectedChoices =\n singleOrMultiSelect === 'single_choice'\n ? (targetElement.querySelector('input[type=radio]:checked') as HTMLInputElement)?.value\n : [\n ...(targetElement.querySelectorAll(\n 'input[type=checkbox]:checked'\n ) as NodeListOf<HTMLInputElement>),\n ].map((choice) => choice.value)\n posthog.capture('survey sent', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_question: survey.questions[0].question,\n $survey_response: selectedChoices,\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n $set: {\n [`$survey_responded/${survey.id}`]: true,\n },\n })\n window.setTimeout(() => {\n window.dispatchEvent(new Event('PHSurveySent'))\n }, 200)\n closeSurveyPopup(survey.id, formElement as HTMLFormElement)\n },\n })\n } else {\n formElement = Object.assign(document.createElement('div'), {\n innerHTML: form,\n })\n }\n if (!isOptional) {\n formElement.addEventListener('change', () => {\n const selectedChoices: NodeListOf<HTMLInputElement> =\n singleOrMultiSelect === 'single_choice'\n ? formElement.querySelectorAll('input[type=radio]:checked')\n : formElement.querySelectorAll('input[type=checkbox]:checked')\n if ((selectedChoices.length ?? 0) > 0) {\n ;(formElement.querySelector('.form-submit') as HTMLButtonElement).disabled = false\n } else {\n ;(formElement.querySelector('.form-submit') as HTMLButtonElement).disabled = true\n }\n })\n }\n\n return formElement\n}\n\nexport const callSurveys = (posthog: PostHog, forceReload: boolean = false) => {\n posthog?.getActiveMatchingSurveys((surveys) => {\n const nonAPISurveys = surveys.filter((survey) => survey.type !== 'api')\n nonAPISurveys.forEach((survey) => {\n if (document.querySelectorAll(\"div[class^='PostHogSurvey']\").length === 0) {\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 if (!localStorage.getItem(`seenSurvey_${survey.id}`)) {\n const shadow = createShadow(style(survey.id, survey?.appearance), survey.id)\n let surveyPopup\n if (survey.questions.length < 2) {\n surveyPopup = createSingleQuestionSurvey(\n posthog,\n survey,\n survey.questions[0]\n ) as HTMLFormElement\n } else {\n surveyPopup = createMultipleQuestionSurvey(posthog, survey)\n }\n if (surveyPopup) {\n addCancelListeners(posthog, surveyPopup, survey.id, survey.name)\n if (survey.appearance?.whiteLabel) {\n const allBrandingElements = surveyPopup.getElementsByClassName('footer-branding')\n for (const brandingElement of allBrandingElements) {\n ;(brandingElement as HTMLAnchorElement).style.display = 'none'\n }\n }\n shadow.appendChild(surveyPopup)\n }\n if (survey.questions.length > 1) {\n const currentQuestion = 0\n showQuestion(currentQuestion, survey.id)\n }\n setTextColors(shadow)\n window.dispatchEvent(new Event('PHSurveyShown'))\n posthog.capture('survey shown', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n })\n localStorage.setItem(`lastSeenSurveyDate`, new Date().toISOString())\n if (survey.appearance?.displayThankYouMessage) {\n window.addEventListener('PHSurveySent', () => {\n const thankYouElement = createThankYouMessage(survey)\n shadow.appendChild(thankYouElement)\n const cancelButtons = thankYouElement.querySelectorAll('.form-cancel, .form-submit')\n for (const button of cancelButtons) {\n button.addEventListener('click', () => {\n thankYouElement.remove()\n })\n }\n const countdownEl = thankYouElement.querySelector('.thank-you-message-countdown')\n if (countdownEl) {\n let count = 3\n countdownEl.textContent = `(${count})`\n const countdown = setInterval(() => {\n count -= 1\n if (count <= 0) {\n clearInterval(countdown)\n thankYouElement.remove()\n return\n }\n countdownEl.textContent = `(${count})`\n }, 1000)\n }\n setTextColors(shadow)\n })\n }\n }\n }\n })\n }, forceReload)\n}\n\nexport const createMultipleQuestionSurvey = (posthog: PostHog, survey: Survey) => {\n const questions = survey.questions\n const questionTypeMapping = {\n open: createOpenTextOrLinkPopup,\n link: createOpenTextOrLinkPopup,\n rating: createRatingsPopup,\n single_choice: createMultipleChoicePopup,\n multiple_choice: createMultipleChoicePopup,\n }\n const multipleQuestionForm = Object.assign(document.createElement('form'), {\n className: `survey-${survey.id}-form`,\n onsubmit: (e: Event) => {\n e.preventDefault()\n const multipleQuestionResponses: Record<string, string | number | string[] | null> = {}\n const allTabs = (e.target as HTMLDivElement).getElementsByClassName('tab')\n for (const [index, tab] of [...allTabs].entries()) {\n const classes = tab.classList\n const questionType = classes[2]\n let response\n if (questionType === 'open') {\n response = tab.querySelector('textarea')?.value\n } else if (questionType === 'link') {\n response = 'link clicked'\n } else if (questionType === 'rating') {\n response = parseInt((tab.querySelector('.rating-active') as HTMLButtonElement)?.value)\n } else if (questionType === 'single_choice' || questionType === 'multiple_choice') {\n const selectedChoices =\n questionType === 'single_choice'\n ? (tab.querySelector('input[type=radio]:checked') as HTMLInputElement).value\n : [\n ...(tab.querySelectorAll(\n 'input[type=checkbox]:checked'\n ) as NodeListOf<HTMLInputElement>),\n ].map((choice) => choice.value)\n response = selectedChoices\n }\n const isQuestionOptional = survey.questions[index].optional\n if (isQuestionOptional && _isUndefined(response)) {\n response = null\n }\n if (!_isUndefined(response)) {\n if (index === 0) {\n multipleQuestionResponses['$survey_response'] = response\n } else {\n multipleQuestionResponses[`$survey_response_${index}`] = response\n }\n }\n }\n posthog.capture('survey sent', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_questions: survey.questions.map((question) => question.question),\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n ...multipleQuestionResponses,\n $set: {\n [`$survey_responded/${survey.id}`]: true,\n },\n })\n window.setTimeout(() => {\n window.dispatchEvent(new Event('PHSurveySent'))\n }, 200)\n closeSurveyPopup(survey.id, multipleQuestionForm)\n },\n })\n\n questions.map((question, idx) => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore // TODO: Fix this, error because of survey question type mapping\n const questionElement = questionTypeMapping[question.type](posthog, survey, question, idx)\n const questionTab = document.createElement('div')\n questionTab.className = `tab question-${idx} ${question.type}`\n if (idx < questions.length - 1) {\n const questionElementSubmitButton = questionElement.getElementsByClassName(\n 'form-submit'\n )[0] as HTMLButtonElement\n questionElementSubmitButton.innerText = 'Next'\n questionElementSubmitButton.type = 'button'\n questionElementSubmitButton.addEventListener('click', () => {\n nextQuestion(idx, survey.id)\n })\n }\n questionTab.insertAdjacentElement('beforeend', questionElement)\n\n multipleQuestionForm.insertAdjacentElement('beforeend', questionTab)\n })\n\n return multipleQuestionForm\n}\n\nconst createSingleQuestionSurvey = (posthog: PostHog, survey: Survey, question: SurveyQuestion) => {\n const questionType = question.type\n if (questionType === 'rating') {\n return createRatingsPopup(posthog, survey, question, 0)\n } else if (questionType === 'open' || questionType === 'link') {\n return createOpenTextOrLinkPopup(posthog, survey, question, 0)\n } else if (questionType === 'single_choice' || questionType === 'multiple_choice') {\n return createMultipleChoicePopup(posthog, survey, question, 0)\n }\n return null\n}\n\nfunction getTextColor(el: HTMLElement) {\n const backgroundColor = window.getComputedStyle(el).backgroundColor\n if (backgroundColor === 'rgba(0, 0, 0, 0)') {\n return 'black'\n }\n const colorMatch = backgroundColor.match(/^rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*(\\d+(?:\\.\\d+)?))?\\)$/)\n if (!colorMatch) return 'black'\n\n const r = parseInt(colorMatch[1])\n const g = parseInt(colorMatch[2])\n const b = parseInt(colorMatch[3])\n const hsp = Math.sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b))\n return hsp > 127.5 ? 'black' : 'white'\n}\n\nfunction setTextColors(parentEl: any) {\n for (const el of parentEl.querySelectorAll('.auto-text-color')) {\n el.style.color = getTextColor(el)\n }\n}\n\nfunction showQuestion(n: number, surveyId: string) {\n // This function will display the specified tab of the form...\n const tabs = document\n .getElementsByClassName(`PostHogSurvey${surveyId}`)[0]\n ?.shadowRoot?.querySelectorAll('.tab') as NodeListOf<HTMLElement>\n tabs[n].style.display = 'block'\n}\n\nfunction nextQuestion(currentQuestionIdx: number, surveyId: string) {\n // figure out which tab to display\n const tabs = document\n .getElementsByClassName(`PostHogSurvey${surveyId}`)[0]\n ?.shadowRoot?.querySelectorAll('.tab') as NodeListOf<HTMLElement>\n\n tabs[currentQuestionIdx].style.display = 'none'\n showQuestion(currentQuestionIdx + 1, surveyId)\n}\n\nexport function generateSurveys(posthog: PostHog) {\n callSurveys(posthog, true)\n\n // recalculate surveys every 3 seconds to check if URL or selectors have changed\n setInterval(() => {\n callSurveys(posthog, false)\n }, 3000)\n}\n"]}
1
+ {"version":3,"file":"surveys.js","sourceRoot":"","sources":["../../../src/extensions/surveys.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAElD,IAAM,cAAc,GAChB,yzBAAyzB,CAAA;AAC7zB,IAA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,WAAA;YACT,EAAE,CAAC,KAAK,CAAC,KAAK,GAAG,YAAY,CAAC,EAAE,CAAC,CAAA;SACpC;;;;;;;;;AACL,CAAC;AAED,SAAS,YAAY,CAAC,CAAS,EAAE,QAAgB;;IAC7C,8DAA8D;IAC9D,IAAM,IAAI,GAAG,MAAA,MAAA,QAAQ;SAChB,sBAAsB,CAAC,uBAAgB,QAAQ,CAAE,CAAC,CAAC,CAAC,CAAC,0CACpD,UAAU,0CAAE,gBAAgB,CAAC,MAAM,CAA4B,CAAA;IACrE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAA;AACnC,CAAC;AAED,SAAS,YAAY,CAAC,kBAA0B,EAAE,QAAgB;;IAC9D,kCAAkC;IAClC,IAAM,IAAI,GAAG,MAAA,MAAA,QAAQ;SAChB,sBAAsB,CAAC,uBAAgB,QAAQ,CAAE,CAAC,CAAC,CAAC,CAAC,0CACpD,UAAU,0CAAE,gBAAgB,CAAC,MAAM,CAA4B,CAAA;IAErE,IAAI,CAAC,kBAAkB,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAA;IAC/C,YAAY,CAAC,kBAAkB,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAA;AAClD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC5C,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IAE1B,gFAAgF;IAChF,WAAW,CAAC;QACR,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC/B,CAAC,EAAE,IAAI,CAAC,CAAA;AACZ,CAAC","sourcesContent":["import { PostHog } from 'posthog-core'\nimport {\n BasicSurveyQuestion,\n LinkSurveyQuestion,\n MultipleSurveyQuestion,\n RatingSurveyQuestion,\n Survey,\n SurveyAppearance,\n SurveyQuestion,\n} from '../posthog-surveys-types'\n\nimport { _isUndefined } from '../utils/type-utils'\n\nconst satisfiedEmoji =\n '<svg class=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\"><path d=\"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146 272q66 0 121.5-35.5T682-393h-52q-23 40-63 61.5T480.5-310q-46.5 0-87-21T331-393h-53q26 61 81 96.5T480-261Zm0 181q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z\"/></svg>'\nconst neutralEmoji =\n '<svg class=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\"><path d=\"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm20 194h253v-49H354v49ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z\"/></svg>'\nconst dissatisfiedEmoji =\n '<svg class=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\"><path d=\"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146.174 116Q413-417 358.5-379.5T278-280h53q22-42 62.173-65t87.5-23Q528-368 567.5-344.5T630-280h52q-25-63-79.826-100-54.826-37-122-37ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z\"/></svg>'\nconst veryDissatisfiedEmoji =\n '<svg class=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\"><path d=\"M480-417q-67 0-121.5 37.5T278-280h404q-25-63-80-100t-122-37Zm-183-72 50-45 45 45 31-36-45-45 45-45-31-36-45 45-50-45-31 36 45 45-45 45 31 36Zm272 0 44-45 51 45 31-36-45-45 45-45-31-36-51 45-44-45-31 36 44 45-44 45 31 36ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142 0 241-99t99-241q0-142-99-241t-241-99q-142 0-241 99t-99 241q0 142 99 241t241 99Z\"/></svg>'\nconst verySatisfiedEmoji =\n '<svg class=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\"><path d=\"M479.504-261Q537-261 585.5-287q48.5-26 78.5-72.4 6-11.6-.75-22.6-6.75-11-20.25-11H316.918Q303-393 296.5-382t-.5 22.6q30 46.4 78.5 72.4 48.5 26 105.004 26ZM347-578l27 27q7.636 8 17.818 8Q402-543 410-551q8-8 8-18t-8-18l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.636-8 17.818Q276-559 284-551q8 8 18 8t18-8l27-27Zm267 0 27 27q7.714 8 18 8t18-8q8-7.636 8-17.818Q685-579 677-587l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.714-8 18t8 18q7.636 8 17.818 8Q579-543 587-551l27-27ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z\"/></svg>'\nconst cancelSVG =\n '<svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M0.164752 0.164752C0.384422 -0.0549175 0.740578 -0.0549175 0.960248 0.164752L6 5.20451L11.0398 0.164752C11.2594 -0.0549175 11.6156 -0.0549175 11.8352 0.164752C12.0549 0.384422 12.0549 0.740578 11.8352 0.960248L6.79549 6L11.8352 11.0398C12.0549 11.2594 12.0549 11.6156 11.8352 11.8352C11.6156 12.0549 11.2594 12.0549 11.0398 11.8352L6 6.79549L0.960248 11.8352C0.740578 12.0549 0.384422 12.0549 0.164752 11.8352C-0.0549175 11.6156 -0.0549175 11.2594 0.164752 11.0398L5.20451 6L0.164752 0.960248C-0.0549175 0.740578 -0.0549175 0.384422 0.164752 0.164752Z\" fill=\"black\"/></svg>'\nconst posthogLogo =\n '<svg width=\"77\" height=\"14\" viewBox=\"0 0 77 14\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><g clip-path=\"url(#clip0_2415_6911)\"><mask id=\"mask0_2415_6911\" style=\"mask-type:luminance\" maskUnits=\"userSpaceOnUse\" x=\"0\" y=\"0\" width=\"77\" height=\"14\"><path d=\"M0.5 0H76.5V14H0.5V0Z\" fill=\"white\"/></mask><g mask=\"url(#mask0_2415_6911)\"><path d=\"M5.77226 8.02931C5.59388 8.37329 5.08474 8.37329 4.90634 8.02931L4.4797 7.20672C4.41155 7.07535 4.41155 6.9207 4.4797 6.78933L4.90634 5.96669C5.08474 5.62276 5.59388 5.62276 5.77226 5.96669L6.19893 6.78933C6.26709 6.9207 6.26709 7.07535 6.19893 7.20672L5.77226 8.02931ZM5.77226 12.6946C5.59388 13.0386 5.08474 13.0386 4.90634 12.6946L4.4797 11.872C4.41155 11.7406 4.41155 11.586 4.4797 11.4546L4.90634 10.632C5.08474 10.288 5.59388 10.288 5.77226 10.632L6.19893 11.4546C6.26709 11.586 6.26709 11.7406 6.19893 11.872L5.77226 12.6946Z\" fill=\"#1D4AFF\"/><path d=\"M0.5 10.9238C0.5 10.508 1.02142 10.2998 1.32637 10.5938L3.54508 12.7327C3.85003 13.0267 3.63405 13.5294 3.20279 13.5294H0.984076C0.716728 13.5294 0.5 13.3205 0.5 13.0627V10.9238ZM0.5 8.67083C0.5 8.79459 0.551001 8.91331 0.641783 9.00081L5.19753 13.3927C5.28831 13.4802 5.41144 13.5294 5.53982 13.5294H8.0421C8.47337 13.5294 8.68936 13.0267 8.3844 12.7327L1.32637 5.92856C1.02142 5.63456 0.5 5.84278 0.5 6.25854V8.67083ZM0.5 4.00556C0.5 4.12932 0.551001 4.24802 0.641783 4.33554L10.0368 13.3927C10.1276 13.4802 10.2508 13.5294 10.3791 13.5294H12.8814C13.3127 13.5294 13.5287 13.0267 13.2237 12.7327L1.32637 1.26329C1.02142 0.969312 0.5 1.17752 0.5 1.59327V4.00556ZM5.33931 4.00556C5.33931 4.12932 5.39033 4.24802 5.4811 4.33554L14.1916 12.7327C14.4965 13.0267 15.0179 12.8185 15.0179 12.4028V9.99047C15.0179 9.86671 14.9669 9.74799 14.8762 9.66049L6.16568 1.26329C5.86071 0.969307 5.33931 1.17752 5.33931 1.59327V4.00556ZM11.005 1.26329C10.7 0.969307 10.1786 1.17752 10.1786 1.59327V4.00556C10.1786 4.12932 10.2296 4.24802 10.3204 4.33554L14.1916 8.06748C14.4965 8.36148 15.0179 8.15325 15.0179 7.7375V5.3252C15.0179 5.20144 14.9669 5.08272 14.8762 4.99522L11.005 1.26329Z\" fill=\"#F9BD2B\"/><path d=\"M21.0852 10.981L16.5288 6.58843C16.2238 6.29443 15.7024 6.50266 15.7024 6.91841V13.0627C15.7024 13.3205 15.9191 13.5294 16.1865 13.5294H23.2446C23.5119 13.5294 23.7287 13.3205 23.7287 13.0627V12.5032C23.7287 12.2455 23.511 12.0396 23.2459 12.0063C22.4323 11.9042 21.6713 11.546 21.0852 10.981ZM18.0252 12.0365C17.5978 12.0365 17.251 11.7021 17.251 11.2901C17.251 10.878 17.5978 10.5436 18.0252 10.5436C18.4527 10.5436 18.7996 10.878 18.7996 11.2901C18.7996 11.7021 18.4527 12.0365 18.0252 12.0365Z\" fill=\"currentColor\"/><path d=\"M0.5 13.0627C0.5 13.3205 0.716728 13.5294 0.984076 13.5294H3.20279C3.63405 13.5294 3.85003 13.0267 3.54508 12.7327L1.32637 10.5938C1.02142 10.2998 0.5 10.508 0.5 10.9238V13.0627ZM5.33931 5.13191L1.32637 1.26329C1.02142 0.969306 0.5 1.17752 0.5 1.59327V4.00556C0.5 4.12932 0.551001 4.24802 0.641783 4.33554L5.33931 8.86412V5.13191ZM1.32637 5.92855C1.02142 5.63455 0.5 5.84278 0.5 6.25853V8.67083C0.5 8.79459 0.551001 8.91331 0.641783 9.00081L5.33931 13.5294V9.79717L1.32637 5.92855Z\" fill=\"#1D4AFF\"/><path d=\"M10.1787 5.3252C10.1787 5.20144 10.1277 5.08272 10.0369 4.99522L6.16572 1.26329C5.8608 0.969306 5.33936 1.17752 5.33936 1.59327V4.00556C5.33936 4.12932 5.39037 4.24802 5.48114 4.33554L10.1787 8.86412V5.3252ZM5.33936 13.5294H8.04214C8.47341 13.5294 8.6894 13.0267 8.38443 12.7327L5.33936 9.79717V13.5294ZM5.33936 5.13191V8.67083C5.33936 8.79459 5.39037 8.91331 5.48114 9.00081L10.1787 13.5294V9.99047C10.1787 9.86671 10.1277 9.74803 10.0369 9.66049L5.33936 5.13191Z\" fill=\"#F54E00\"/><path d=\"M29.375 11.6667H31.3636V8.48772H33.0249C34.8499 8.48772 36.0204 7.4443 36.0204 5.83052C36.0204 4.21681 34.8499 3.17334 33.0249 3.17334H29.375V11.6667ZM31.3636 6.84972V4.81136H32.8236C33.5787 4.81136 34.0318 5.19958 34.0318 5.83052C34.0318 6.4615 33.5787 6.84972 32.8236 6.84972H31.3636ZM39.618 11.7637C41.5563 11.7637 42.9659 10.429 42.9659 8.60905C42.9659 6.78905 41.5563 5.45438 39.618 5.45438C37.6546 5.45438 36.2701 6.78905 36.2701 8.60905C36.2701 10.429 37.6546 11.7637 39.618 11.7637ZM38.1077 8.60905C38.1077 7.63838 38.7118 6.97105 39.618 6.97105C40.5116 6.97105 41.1157 7.63838 41.1157 8.60905C41.1157 9.57972 40.5116 10.2471 39.618 10.2471C38.7118 10.2471 38.1077 9.57972 38.1077 8.60905ZM46.1482 11.7637C47.6333 11.7637 48.6402 10.8658 48.6402 9.81025C48.6402 7.33505 45.2294 8.13585 45.2294 7.16518C45.2294 6.8983 45.5189 6.72843 45.9342 6.72843C46.3622 6.72843 46.8782 6.98318 47.0418 7.54132L48.527 6.94678C48.2375 6.06105 47.1677 5.45438 45.8713 5.45438C44.4743 5.45438 43.6058 6.25518 43.6058 7.21372C43.6058 9.53118 46.9663 8.88812 46.9663 9.84665C46.9663 10.1864 46.6391 10.417 46.1482 10.417C45.4434 10.417 44.9525 9.94376 44.8015 9.3735L43.3164 9.93158C43.6436 10.8537 44.6001 11.7637 46.1482 11.7637ZM53.4241 11.606L53.2982 10.0651C53.0843 10.1743 52.8074 10.2106 52.5808 10.2106C52.1278 10.2106 51.8257 9.89523 51.8257 9.34918V7.03172H53.3612V5.55145H51.8257V3.78001H49.9755V5.55145H48.9687V7.03172H49.9755V9.57972C49.9755 11.06 51.0202 11.7637 52.3921 11.7637C52.7696 11.7637 53.122 11.7031 53.4241 11.606ZM59.8749 3.17334V6.47358H56.376V3.17334H54.3874V11.6667H56.376V8.11158H59.8749V11.6667H61.8761V3.17334H59.8749ZM66.2899 11.7637C68.2281 11.7637 69.6378 10.429 69.6378 8.60905C69.6378 6.78905 68.2281 5.45438 66.2899 5.45438C64.3265 5.45438 62.942 6.78905 62.942 8.60905C62.942 10.429 64.3265 11.7637 66.2899 11.7637ZM64.7796 8.60905C64.7796 7.63838 65.3837 6.97105 66.2899 6.97105C67.1835 6.97105 67.7876 7.63838 67.7876 8.60905C67.7876 9.57972 67.1835 10.2471 66.2899 10.2471C65.3837 10.2471 64.7796 9.57972 64.7796 8.60905ZM73.2088 11.4725C73.901 11.4725 74.5177 11.242 74.845 10.8416V11.424C74.845 12.1034 74.2786 12.5767 73.4102 12.5767C72.7935 12.5767 72.2523 12.2854 72.1642 11.788L70.4776 12.0428C70.7042 13.1955 71.925 13.972 73.4102 13.972C75.361 13.972 76.6574 12.8679 76.6574 11.2298V5.55145H74.8324V6.07318C74.4926 5.69705 73.9136 5.45438 73.171 5.45438C71.409 5.45438 70.3014 6.61918 70.3014 8.46345C70.3014 10.3077 71.409 11.4725 73.2088 11.4725ZM72.1012 8.46345C72.1012 7.55345 72.655 6.97105 73.5109 6.97105C74.3793 6.97105 74.9331 7.55345 74.9331 8.46345C74.9331 9.37345 74.3793 9.95585 73.5109 9.95585C72.655 9.95585 72.1012 9.37345 72.1012 8.46345Z\" fill=\"currentColor\"/></g></g><defs><clipPath id=\"clip0_2415_6911\"><rect width=\"76\" height=\"14\" fill=\"white\" transform=\"translate(0.5)\"/></clipPath></defs></svg>'\nconst checkSVG =\n '<svg width=\"16\" height=\"12\" viewBox=\"0 0 16 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M5.30769 10.6923L4.77736 11.2226C4.91801 11.3633 5.10878 11.4423 5.30769 11.4423C5.5066 11.4423 5.69737 11.3633 5.83802 11.2226L5.30769 10.6923ZM15.5303 1.53033C15.8232 1.23744 15.8232 0.762563 15.5303 0.46967C15.2374 0.176777 14.7626 0.176777 14.4697 0.46967L15.5303 1.53033ZM1.53033 5.85429C1.23744 5.56139 0.762563 5.56139 0.46967 5.85429C0.176777 6.14718 0.176777 6.62205 0.46967 6.91495L1.53033 5.85429ZM5.83802 11.2226L15.5303 1.53033L14.4697 0.46967L4.77736 10.162L5.83802 11.2226ZM0.46967 6.91495L4.77736 11.2226L5.83802 10.162L1.53033 5.85429L0.46967 6.91495Z\" fill=\"currentColor\"/></svg>'\n\nconst style = (id: string, appearance: SurveyAppearance | null) => {\n const positions = {\n left: 'left: 30px;',\n right: 'right: 30px;',\n center: `\n left: 50%;\n transform: translateX(-50%);\n `,\n }\n return `\n .survey-${id}-form {\n position: fixed;\n margin: 0px;\n bottom: 0px;\n color: black;\n font-weight: normal;\n font-family: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", \"Roboto\", Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n text-align: left;\n max-width: ${parseInt(appearance?.maxWidth || '290')}px;\n z-index: ${parseInt(appearance?.zIndex || '99999')};\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n border-bottom: 0px;\n width: 100%;\n ${positions[appearance?.position || 'right'] || 'right: 30px;'}\n }\n .survey-${id}-form .tab {\n display: none;\n }\n .form-submit[disabled] {\n opacity: 0.6;\n filter: grayscale(100%);\n cursor: not-allowed;\n }\n .survey-${id}-form {\n flex-direction: column;\n background: ${appearance?.backgroundColor || '#eeeded'};\n border-top-left-radius: 10px;\n border-top-right-radius: 10px;\n box-shadow: -6px 0 16px -8px rgb(0 0 0 / 8%), -9px 0 28px 0 rgb(0 0 0 / 5%), -12px 0 48px 16px rgb(0 0 0 / 3%);\n }\n .survey-${id}-form textarea {\n color: #2d2d2d;\n font-size: 14px;\n font-family: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", \"Roboto\", Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n background: white;\n color: black;\n outline: none;\n padding-left: 10px;\n padding-right: 10px;\n padding-top: 10px;\n border-radius: 6px;\n border-color: ${appearance?.borderColor || '#c9c6c6'};\n margin-top: 14px; \n }\n .form-submit {\n box-sizing: border-box;\n margin: 0;\n font-family: inherit;\n overflow: visible;\n text-transform: none;\n position: relative;\n display: inline-block;\n font-weight: 700;\n white-space: nowrap;\n text-align: center;\n border: 1.5px solid transparent;\n cursor: pointer;\n user-select: none;\n touch-action: manipulation;\n padding: 12px;\n font-size: 14px;\n border-radius: 6px;\n outline: 0;\n background: ${appearance?.submitButtonColor || 'black'} !important;\n text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.12);\n box-shadow: 0 2px 0 rgba(0, 0, 0, 0.045);\n width: 100%;\n }\n .form-cancel {\n float: right;\n border: none;\n background: none;\n cursor: pointer;\n }\n .cancel-btn-wrapper {\n position: absolute;\n width: 35px;\n height: 35px;\n border-radius: 100%;\n top: 0;\n right: 0;\n transform: translate(50%, -50%);\n background: white;\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .bolded { font-weight: 600; }\n .buttons {\n display: flex;\n justify-content: center;\n }\n .footer-branding {\n font-size: 11px;\n margin-top: 10px;\n text-align: center;\n display: flex;\n justify-content: center;\n gap: 4px;\n align-items: center;\n font-weight: 500;\n background: ${appearance?.backgroundColor || '#eeeded'};\n text-decoration: none;\n }\n .survey-${id}-box {\n padding: 20px 25px 10px;\n display: flex;\n flex-direction: column;\n }\n .survey-question {\n font-weight: 500;\n font-size: 14px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .question-textarea-wrapper {\n display: flex;\n flex-direction: column;\n }\n .description {\n font-size: 13px;\n margin-top: 5px;\n opacity: .60;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .ratings-number {\n background-color: ${appearance?.ratingButtonColor || 'white'};\n font-size: 14px;\n padding: 8px 0px;\n border: none;\n }\n .ratings-number:hover {\n cursor: pointer;\n }\n .rating-options {\n margin-top: 14px;\n }\n .rating-options-buttons {\n display: grid;\n border-radius: 6px;\n overflow: hidden;\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n }\n .rating-options-buttons > .ratings-number {\n border-right: 1px solid ${appearance?.borderColor || '#c9c6c6'};\n }\n .rating-options-buttons > .ratings-number:last-of-type {\n border-right: 0px;\n }\n .rating-options-buttons .rating-active {\n background: ${appearance?.ratingButtonActiveColor || 'black'};\n }\n .rating-options-emoji {\n display: flex;\n justify-content: space-between;\n }\n .ratings-emoji {\n font-size: 16px;\n background-color: transparent;\n border: none;\n padding: 0px;\n }\n .ratings-emoji:hover {\n cursor: pointer;\n }\n .ratings-emoji.rating-active svg {\n fill: ${appearance?.ratingButtonActiveColor || 'black'};\n }\n .emoji-svg {\n fill: ${appearance?.ratingButtonColor || '#c9c6c6'};\n }\n .rating-text {\n display: flex;\n flex-direction: row;\n font-size: 11px;\n justify-content: space-between;\n margin-top: 6px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n opacity: .60;\n }\n .multiple-choice-options {\n margin-top: 13px;\n font-size: 14px;\n }\n .multiple-choice-options .choice-option {\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 13px;\n cursor: pointer;\n margin-bottom: 5px;\n position: relative;\n }\n .multiple-choice-options > .choice-option:last-of-type {\n margin-bottom: 0px;\n }\n \n .multiple-choice-options input {\n cursor: pointer;\n position: absolute;\n opacity: 0;\n }\n .choice-check {\n position: absolute;\n right: 10px;\n background: white;\n }\n .choice-check svg {\n display: none;\n }\n .multiple-choice-options .choice-option:hover .choice-check svg {\n display: inline-block;\n opacity: .25;\n }\n .multiple-choice-options input:checked + label + .choice-check svg {\n display: inline-block;\n opacity: 100% !important;\n }\n .multiple-choice-options input[type=checkbox]:checked + label {\n font-weight: bold;\n }\n .multiple-choice-options input:checked + label {\n border: 1.5px solid rgba(0,0,0);\n }\n .multiple-choice-options label {\n width: 100%;\n cursor: pointer;\n padding: 10px;\n border: 1.5px solid rgba(0,0,0,.25);\n border-radius: 4px;\n background: white;\n }\n .thank-you-message {\n position: fixed;\n bottom: 0px;\n z-index: ${parseInt(appearance?.zIndex || '99999')};\n box-shadow: -6px 0 16px -8px rgb(0 0 0 / 8%), -9px 0 28px 0 rgb(0 0 0 / 5%), -12px 0 48px 16px rgb(0 0 0 / 3%);\n font-family: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", \"Roboto\", Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n border-top-left-radius: 10px;\n border-top-right-radius: 10px;\n padding: 20px 25px 10px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n text-align: center;\n max-width: ${parseInt(appearance?.maxWidth || '290')}px;\n min-width: 150px;\n width: 100%;\n ${positions[appearance?.position || 'right'] || 'right: 30px;'}\n }\n .thank-you-message-body {\n margin-top: 6px;\n font-size: 14px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .thank-you-message-header {\n margin: 10px 0px 0px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .thank-you-message-container .form-submit {\n margin-top: 20px;\n margin-bottom: 10px;\n }\n .thank-you-message-countdown {\n margin-left: 6px;\n }\n .bottom-section {\n margin-top: 14px;\n }\n `\n}\n\nexport const createShadow = (styleSheet: string, surveyId: string) => {\n const div = document.createElement('div')\n div.className = `PostHogSurvey${surveyId}`\n const shadow = div.attachShadow({ mode: 'open' })\n if (styleSheet) {\n const styleElement = Object.assign(document.createElement('style'), {\n innerText: styleSheet,\n })\n shadow.appendChild(styleElement)\n }\n document.body.appendChild(div)\n return shadow\n}\n\nexport const closeSurveyPopup = (surveyId: string, surveyPopup: HTMLFormElement) => {\n Object.assign(surveyPopup.style, { display: 'none' })\n localStorage.setItem(`seenSurvey_${surveyId}`, 'true')\n window.setTimeout(() => {\n window.dispatchEvent(new Event('PHSurveyClosed'))\n }, 2000)\n surveyPopup.reset()\n}\n\nexport const createOpenTextOrLinkPopup = (\n posthog: PostHog,\n survey: Survey,\n question: BasicSurveyQuestion | LinkSurveyQuestion,\n questionIndex: number\n) => {\n const surveyQuestionType = question.type\n const surveyDescription = question.description\n const questionText = question.question\n const isOptional = !!question.optional\n const form = `\n <div class=\"survey-${survey.id}-box\">\n <div class=\"cancel-btn-wrapper\">\n <button class=\"form-cancel\" type=\"cancel\">${cancelSVG}</button>\n </div>\n <div class=\"question-textarea-wrapper\">\n <div class=\"survey-question auto-text-color\">${questionText}</div>\n ${surveyDescription ? `<span class=\"description auto-text-color\">${surveyDescription}</span>` : ''}\n ${\n surveyQuestionType === 'open'\n ? `<textarea class=\"survey-textarea-question${questionIndex}\" name=\"survey\" rows=4 placeholder=\"${\n survey.appearance?.placeholder || ''\n }\"></textarea>`\n : ''\n }\n </div>\n <div class=\"bottom-section\">\n <div class=\"buttons\">\n <button class=\"form-submit auto-text-color\" type=\"submit\">${\n question.buttonText || survey.appearance?.submitButtonText || 'Submit'\n }</button>\n </div>\n <a href=\"https://posthog.com\" target=\"_blank\" rel=\"noopener\" class=\"footer-branding auto-text-color\">Survey by ${posthogLogo}</a>\n </div>\n </div>\n`\n let formElement: HTMLFormElement | HTMLDivElement\n if (survey.questions.length === 1) {\n formElement = Object.assign(document.createElement('form'), {\n className: `survey-${survey.id}-form`,\n innerHTML: form,\n onsubmit: function (e: any) {\n e.preventDefault()\n const surveyQuestionType = question.type\n posthog.capture('survey sent', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_question: survey.questions[0].question,\n $survey_response: surveyQuestionType === 'open' ? e.target.survey.value : 'link clicked',\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n $set: {\n [`$survey_responded/${survey.id}`]: true,\n },\n })\n if (surveyQuestionType === 'link') {\n window.open(question.link || undefined)\n }\n window.setTimeout(() => {\n window.dispatchEvent(new Event('PHSurveySent'))\n }, 200)\n closeSurveyPopup(survey.id, formElement as HTMLFormElement)\n },\n })\n } else {\n formElement = Object.assign(document.createElement('div'), {\n innerHTML: form,\n })\n const submitButton = formElement.querySelector('.form-submit') as HTMLButtonElement\n submitButton.addEventListener('click', () => {\n if (surveyQuestionType === 'link') {\n window.open(question.link || undefined)\n }\n })\n }\n if (!isOptional) {\n if (surveyQuestionType === 'open') {\n ;(formElement.querySelector('.form-submit') as HTMLButtonElement).disabled = true\n }\n formElement.addEventListener('input', (e: any) => {\n if (formElement.querySelector('.form-submit')) {\n const submitButton = formElement.querySelector('.form-submit') as HTMLButtonElement\n submitButton.disabled = !e.target.value\n }\n })\n }\n\n return formElement\n}\n\nexport const createThankYouMessage = (survey: Survey) => {\n const thankYouHTML = `\n <div class=\"thank-you-message-container\">\n <div class=\"cancel-btn-wrapper\">\n <button class=\"form-cancel\" type=\"cancel\">${cancelSVG}</button>\n </div>\n <h3 class=\"thank-you-message-header auto-text-color\">${\n survey.appearance?.thankYouMessageHeader || 'Thank you!'\n }</h3>\n <div class=\"thank-you-message-body auto-text-color\">${survey.appearance?.thankYouMessageDescription || ''}</div>\n <button class=\"form-submit auto-text-color\"><span>Close</span><span class=\"thank-you-message-countdown\"></span></button>\n ${\n survey.appearance?.whiteLabel\n ? ''\n : `<a href=\"https://posthog.com\" target=\"_blank\" rel=\"noopener\" class=\"footer-branding auto-text-color\">Survey by ${posthogLogo}</a>`\n }\n </div>\n `\n const thankYouElement = Object.assign(document.createElement('div'), {\n className: `thank-you-message`,\n innerHTML: thankYouHTML,\n })\n return thankYouElement\n}\n\nexport const addCancelListeners = (\n posthog: PostHog,\n surveyPopup: HTMLFormElement,\n surveyId: string,\n surveyEventName: string\n) => {\n const cancelButtons = surveyPopup.getElementsByClassName('form-cancel')\n for (const button of cancelButtons) {\n button.addEventListener('click', (e) => {\n e.preventDefault()\n closeSurveyPopup(surveyId, surveyPopup)\n posthog.capture('survey dismissed', {\n $survey_name: surveyEventName,\n $survey_id: surveyId,\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n $set: {\n [`$survey_dismissed/${surveyId}`]: true,\n },\n })\n })\n }\n window.dispatchEvent(new Event('PHSurveyClosed'))\n}\n\nexport const createRatingsPopup = (\n posthog: PostHog,\n survey: Survey,\n question: RatingSurveyQuestion,\n questionIndex: number\n) => {\n const scale = question.scale\n const starting = question.scale === 10 ? 0 : 1\n const displayType = question.display\n const isOptional = !!question.optional\n const ratingOptionsElement = document.createElement('div')\n if (displayType === 'number') {\n ratingOptionsElement.className = 'rating-options-buttons'\n ratingOptionsElement.style.gridTemplateColumns = `repeat(${scale - starting + 1}, minmax(0, 1fr))`\n for (let i = starting; i <= scale; i++) {\n const buttonElement = document.createElement('button')\n buttonElement.className = `ratings-number question-${questionIndex}-rating-${i} auto-text-color`\n buttonElement.type = 'submit'\n buttonElement.value = `${i}`\n buttonElement.innerHTML = `${i}`\n ratingOptionsElement.append(buttonElement)\n }\n } else if (displayType === 'emoji') {\n ratingOptionsElement.className = 'rating-options-emoji'\n const threeEmojis = [dissatisfiedEmoji, neutralEmoji, satisfiedEmoji]\n const fiveEmojis = [veryDissatisfiedEmoji, dissatisfiedEmoji, neutralEmoji, satisfiedEmoji, verySatisfiedEmoji]\n for (let i = 1; i <= scale; i++) {\n const emojiElement = document.createElement('button')\n emojiElement.className = `ratings-emoji question-${questionIndex}-rating-${i}`\n emojiElement.type = 'submit'\n emojiElement.value = `${i}`\n emojiElement.innerHTML = scale === 3 ? threeEmojis[i - 1] : fiveEmojis[i - 1]\n ratingOptionsElement.append(emojiElement)\n }\n }\n const ratingsForm = `\n <div class=\"survey-${survey.id}-box\">\n <div class=\"cancel-btn-wrapper\">\n <button class=\"form-cancel\" type=\"cancel\">${cancelSVG}</button>\n </div>\n <div class=\"survey-question auto-text-color\">${question.question}</div>\n ${question.description ? `<span class=\"description auto-text-color\">${question.description}</span>` : ''}\n <div class=\"rating-section\">\n <div class=\"rating-options\">\n </div>\n ${\n question.lowerBoundLabel || question.upperBoundLabel\n ? `<div class=\"rating-text auto-text-color\">\n <div>${question.lowerBoundLabel || ''}</div>\n <div>${question.upperBoundLabel || ''}</div>\n </div>`\n : ''\n }\n <div class=\"bottom-section\">\n <div class=\"buttons\">\n <button class=\"form-submit auto-text-color\" type=\"submit\" ${isOptional ? '' : 'disabled'}>${\n question.buttonText || survey.appearance?.submitButtonText || 'Submit'\n }</button>\n </div>\n <a href=\"https://posthog.com\" target=\"_blank\" rel=\"noopener\" class=\"footer-branding auto-text-color\">Survey by ${posthogLogo}</a>\n </div>\n </div>\n </div>\n `\n let formElement: HTMLFormElement | HTMLDivElement\n if (survey.questions.length === 1) {\n formElement = Object.assign(document.createElement('form'), {\n className: `survey-${survey.id}-form`,\n innerHTML: ratingsForm,\n onsubmit: (e: Event) => {\n e.preventDefault()\n const activeRatingEl = formElement.querySelector('.rating-active')\n posthog.capture('survey sent', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_question: question.question,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore // TODO: Fix this, error because it doesn't know that the target is a button\n $survey_response: parseInt(activeRatingEl?.value),\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n $set: {\n [`$survey_responded/${survey.id}`]: true,\n },\n })\n window.setTimeout(() => {\n window.dispatchEvent(new Event('PHSurveySent'))\n }, 200)\n closeSurveyPopup(survey.id, formElement as HTMLFormElement)\n },\n })\n } else {\n formElement = Object.assign(document.createElement('div'), {\n innerHTML: ratingsForm,\n })\n }\n formElement.getElementsByClassName('rating-options')[0].insertAdjacentElement('afterbegin', ratingOptionsElement)\n const allElements =\n question.scale === 10 ? [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] : question.scale === 5 ? [1, 2, 3, 4, 5] : [1, 2, 3]\n for (const x of allElements) {\n const ratingEl = formElement.getElementsByClassName(`question-${questionIndex}-rating-${x}`)[0]\n ratingEl.addEventListener('click', (e) => {\n e.preventDefault()\n for (const activeRatingEl of formElement.getElementsByClassName('rating-active')) {\n activeRatingEl.classList.remove('rating-active')\n }\n ratingEl.classList.add('rating-active')\n if (formElement.querySelector('.form-submit')) {\n ;(formElement.querySelector('.form-submit') as HTMLButtonElement).disabled = false\n }\n setTextColors(formElement)\n })\n }\n\n return formElement\n}\n\nexport const createMultipleChoicePopup = (\n posthog: PostHog,\n survey: Survey,\n question: MultipleSurveyQuestion,\n questionIndex: number\n) => {\n const surveyQuestion = question.question\n const surveyDescription = question.description\n const surveyQuestionChoices = question.choices\n const singleOrMultiSelect = question.type\n const isOptional = !!question.optional\n\n const form = `\n <div class=\"survey-${survey.id}-box\">\n <div class=\"cancel-btn-wrapper\">\n <button class=\"form-cancel\" type=\"cancel\">${cancelSVG}</button>\n </div>\n <div class=\"survey-question auto-text-color\">${surveyQuestion}</div>\n ${surveyDescription ? `<span class=\"description auto-text-color\">${surveyDescription}</span>` : ''}\n <div class=\"multiple-choice-options\">\n ${surveyQuestionChoices\n .map((option, idx) => {\n const inputType = singleOrMultiSelect === 'single_choice' ? 'radio' : 'checkbox'\n const singleOrMultiSelectString = `<div class=\"choice-option\"><input type=${inputType} id=surveyQuestion${questionIndex}Choice${idx} name=\"question${questionIndex}\" value=\"${option}\">\n <label class=\"auto-text-color\" for=surveyQuestion${questionIndex}Choice${idx}>${option}</label><span class=\"choice-check auto-text-color\">${checkSVG}</span></div>`\n return singleOrMultiSelectString\n })\n .join(' ')}\n </div>\n <div class=\"bottom-section\">\n <div class=\"buttons\">\n <button class=\"form-submit auto-text-color\" type=\"submit\" ${isOptional ? '' : 'disabled'}>${\n question.buttonText || survey.appearance?.submitButtonText || 'Submit'\n }</button>\n </div>\n <a href=\"https://posthog.com\" target=\"_blank\" rel=\"noopener\" class=\"footer-branding auto-text-color\">Survey by ${posthogLogo}</a>\n </div>\n\n </div>\n `\n let formElement: HTMLFormElement | HTMLDivElement\n if (survey.questions.length === 1) {\n formElement = Object.assign(document.createElement('form'), {\n className: `survey-${survey.id}-form`,\n innerHTML: form,\n onsubmit: (e: Event) => {\n e.preventDefault()\n const targetElement = e.target as HTMLFormElement\n const selectedChoices =\n singleOrMultiSelect === 'single_choice'\n ? (targetElement.querySelector('input[type=radio]:checked') as HTMLInputElement)?.value\n : [\n ...(targetElement.querySelectorAll(\n 'input[type=checkbox]:checked'\n ) as NodeListOf<HTMLInputElement>),\n ].map((choice) => choice.value)\n posthog.capture('survey sent', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_question: survey.questions[0].question,\n $survey_response: selectedChoices,\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n $set: {\n [`$survey_responded/${survey.id}`]: true,\n },\n })\n window.setTimeout(() => {\n window.dispatchEvent(new Event('PHSurveySent'))\n }, 200)\n closeSurveyPopup(survey.id, formElement as HTMLFormElement)\n },\n })\n } else {\n formElement = Object.assign(document.createElement('div'), {\n innerHTML: form,\n })\n }\n if (!isOptional) {\n formElement.addEventListener('change', () => {\n const selectedChoices: NodeListOf<HTMLInputElement> =\n singleOrMultiSelect === 'single_choice'\n ? formElement.querySelectorAll('input[type=radio]:checked')\n : formElement.querySelectorAll('input[type=checkbox]:checked')\n if ((selectedChoices.length ?? 0) > 0) {\n ;(formElement.querySelector('.form-submit') as HTMLButtonElement).disabled = false\n } else {\n ;(formElement.querySelector('.form-submit') as HTMLButtonElement).disabled = true\n }\n })\n }\n\n return formElement\n}\n\nexport const callSurveys = (posthog: PostHog, forceReload: boolean = false) => {\n posthog?.getActiveMatchingSurveys((surveys) => {\n const nonAPISurveys = surveys.filter((survey) => survey.type !== 'api')\n nonAPISurveys.forEach((survey) => {\n if (document.querySelectorAll(\"div[class^='PostHogSurvey']\").length === 0) {\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 if (!localStorage.getItem(`seenSurvey_${survey.id}`)) {\n const shadow = createShadow(style(survey.id, survey?.appearance), survey.id)\n let surveyPopup\n if (survey.questions.length < 2) {\n surveyPopup = createSingleQuestionSurvey(\n posthog,\n survey,\n survey.questions[0]\n ) as HTMLFormElement\n } else {\n surveyPopup = createMultipleQuestionSurvey(posthog, survey)\n }\n if (surveyPopup) {\n addCancelListeners(posthog, surveyPopup, survey.id, survey.name)\n if (survey.appearance?.whiteLabel) {\n const allBrandingElements = surveyPopup.getElementsByClassName('footer-branding')\n for (const brandingElement of allBrandingElements) {\n ;(brandingElement as HTMLAnchorElement).style.display = 'none'\n }\n }\n shadow.appendChild(surveyPopup)\n }\n if (survey.questions.length > 1) {\n const currentQuestion = 0\n showQuestion(currentQuestion, survey.id)\n }\n setTextColors(shadow)\n window.dispatchEvent(new Event('PHSurveyShown'))\n posthog.capture('survey shown', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n })\n localStorage.setItem(`lastSeenSurveyDate`, new Date().toISOString())\n if (survey.appearance?.displayThankYouMessage) {\n window.addEventListener('PHSurveySent', () => {\n const thankYouElement = createThankYouMessage(survey)\n shadow.appendChild(thankYouElement)\n const cancelButtons = thankYouElement.querySelectorAll('.form-cancel, .form-submit')\n for (const button of cancelButtons) {\n button.addEventListener('click', () => {\n thankYouElement.remove()\n })\n }\n const countdownEl = thankYouElement.querySelector('.thank-you-message-countdown')\n if (survey.appearance?.autoDisappear && countdownEl) {\n let count = 3\n countdownEl.textContent = `(${count})`\n const countdown = setInterval(() => {\n count -= 1\n if (count <= 0) {\n clearInterval(countdown)\n thankYouElement.remove()\n return\n }\n countdownEl.textContent = `(${count})`\n }, 1000)\n }\n setTextColors(shadow)\n })\n }\n }\n }\n })\n }, forceReload)\n}\n\nexport const createMultipleQuestionSurvey = (posthog: PostHog, survey: Survey) => {\n const questions = survey.questions\n const questionTypeMapping = {\n open: createOpenTextOrLinkPopup,\n link: createOpenTextOrLinkPopup,\n rating: createRatingsPopup,\n single_choice: createMultipleChoicePopup,\n multiple_choice: createMultipleChoicePopup,\n }\n const multipleQuestionForm = Object.assign(document.createElement('form'), {\n className: `survey-${survey.id}-form`,\n onsubmit: (e: Event) => {\n e.preventDefault()\n const multipleQuestionResponses: Record<string, string | number | string[] | null> = {}\n const allTabs = (e.target as HTMLDivElement).getElementsByClassName('tab')\n for (const [index, tab] of [...allTabs].entries()) {\n const classes = tab.classList\n const questionType = classes[2]\n let response\n if (questionType === 'open') {\n response = tab.querySelector('textarea')?.value\n } else if (questionType === 'link') {\n response = 'link clicked'\n } else if (questionType === 'rating') {\n response = parseInt((tab.querySelector('.rating-active') as HTMLButtonElement)?.value)\n } else if (questionType === 'single_choice' || questionType === 'multiple_choice') {\n const selectedChoices =\n questionType === 'single_choice'\n ? (tab.querySelector('input[type=radio]:checked') as HTMLInputElement).value\n : [\n ...(tab.querySelectorAll(\n 'input[type=checkbox]:checked'\n ) as NodeListOf<HTMLInputElement>),\n ].map((choice) => choice.value)\n response = selectedChoices\n }\n const isQuestionOptional = survey.questions[index].optional\n if (isQuestionOptional && _isUndefined(response)) {\n response = null\n }\n if (!_isUndefined(response)) {\n if (index === 0) {\n multipleQuestionResponses['$survey_response'] = response\n } else {\n multipleQuestionResponses[`$survey_response_${index}`] = response\n }\n }\n }\n posthog.capture('survey sent', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_questions: survey.questions.map((question) => question.question),\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n ...multipleQuestionResponses,\n $set: {\n [`$survey_responded/${survey.id}`]: true,\n },\n })\n window.setTimeout(() => {\n window.dispatchEvent(new Event('PHSurveySent'))\n }, 200)\n closeSurveyPopup(survey.id, multipleQuestionForm)\n },\n })\n\n questions.map((question, idx) => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore // TODO: Fix this, error because of survey question type mapping\n const questionElement = questionTypeMapping[question.type](posthog, survey, question, idx)\n const questionTab = document.createElement('div')\n questionTab.className = `tab question-${idx} ${question.type}`\n if (idx < questions.length - 1) {\n const questionElementSubmitButton = questionElement.getElementsByClassName(\n 'form-submit'\n )[0] as HTMLButtonElement\n questionElementSubmitButton.innerText = 'Next'\n questionElementSubmitButton.type = 'button'\n questionElementSubmitButton.addEventListener('click', () => {\n nextQuestion(idx, survey.id)\n })\n }\n questionTab.insertAdjacentElement('beforeend', questionElement)\n\n multipleQuestionForm.insertAdjacentElement('beforeend', questionTab)\n })\n\n return multipleQuestionForm\n}\n\nconst createSingleQuestionSurvey = (posthog: PostHog, survey: Survey, question: SurveyQuestion) => {\n const questionType = question.type\n if (questionType === 'rating') {\n return createRatingsPopup(posthog, survey, question, 0)\n } else if (questionType === 'open' || questionType === 'link') {\n return createOpenTextOrLinkPopup(posthog, survey, question, 0)\n } else if (questionType === 'single_choice' || questionType === 'multiple_choice') {\n return createMultipleChoicePopup(posthog, survey, question, 0)\n }\n return null\n}\n\nfunction getTextColor(el: HTMLElement) {\n const backgroundColor = window.getComputedStyle(el).backgroundColor\n if (backgroundColor === 'rgba(0, 0, 0, 0)') {\n return 'black'\n }\n const colorMatch = backgroundColor.match(/^rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*(\\d+(?:\\.\\d+)?))?\\)$/)\n if (!colorMatch) return 'black'\n\n const r = parseInt(colorMatch[1])\n const g = parseInt(colorMatch[2])\n const b = parseInt(colorMatch[3])\n const hsp = Math.sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b))\n return hsp > 127.5 ? 'black' : 'white'\n}\n\nfunction setTextColors(parentEl: any) {\n for (const el of parentEl.querySelectorAll('.auto-text-color')) {\n el.style.color = getTextColor(el)\n }\n}\n\nfunction showQuestion(n: number, surveyId: string) {\n // This function will display the specified tab of the form...\n const tabs = document\n .getElementsByClassName(`PostHogSurvey${surveyId}`)[0]\n ?.shadowRoot?.querySelectorAll('.tab') as NodeListOf<HTMLElement>\n tabs[n].style.display = 'block'\n}\n\nfunction nextQuestion(currentQuestionIdx: number, surveyId: string) {\n // figure out which tab to display\n const tabs = document\n .getElementsByClassName(`PostHogSurvey${surveyId}`)[0]\n ?.shadowRoot?.querySelectorAll('.tab') as NodeListOf<HTMLElement>\n\n tabs[currentQuestionIdx].style.display = 'none'\n showQuestion(currentQuestionIdx + 1, surveyId)\n}\n\nexport function generateSurveys(posthog: PostHog) {\n callSurveys(posthog, true)\n\n // recalculate surveys every 3 seconds to check if URL or selectors have changed\n setInterval(() => {\n callSurveys(posthog, false)\n }, 3000)\n}\n"]}
@@ -13,6 +13,7 @@ export interface SurveyAppearance {
13
13
  ratingButtonActiveColor?: string;
14
14
  ratingButtonHoverColor?: string;
15
15
  whiteLabel?: boolean;
16
+ autoDisappear?: boolean;
16
17
  displayThankYouMessage?: boolean;
17
18
  thankYouMessageHeader?: string;
18
19
  thankYouMessageDescription?: string;
@@ -31,6 +32,7 @@ interface SurveyQuestionBase {
31
32
  question: string;
32
33
  description?: string | null;
33
34
  optional?: boolean;
35
+ buttonText?: string;
34
36
  }
35
37
  export interface BasicSurveyQuestion extends SurveyQuestionBase {
36
38
  type: SurveyQuestionType.Open;
@@ -1 +1 @@
1
- {"version":3,"file":"posthog-surveys-types.js","sourceRoot":"","sources":["../../src/posthog-surveys-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwBH,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IAClB,iCAAmB,CAAA;IACnB,yBAAW,CAAA;AACf,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB;AAgCD,MAAM,CAAN,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC1B,mCAAa,CAAA;IACb,wDAAkC,CAAA;IAClC,oDAA8B,CAAA;IAC9B,uCAAiB,CAAA;IACjB,mCAAa,CAAA;AACjB,CAAC,EANW,kBAAkB,KAAlB,kBAAkB,QAM7B","sourcesContent":["/**\n * Having Survey types in types.ts was confusing tsc\n * and generating an invalid module.d.ts\n * See https://github.com/PostHog/posthog-js/issues/698\n */\n\nexport interface SurveyAppearance {\n // keep in sync with frontend/src/types.ts -> SurveyAppearance\n backgroundColor?: string\n submitButtonColor?: string\n textColor?: string\n submitButtonText?: string\n descriptionTextColor?: string\n ratingButtonColor?: string\n ratingButtonActiveColor?: string\n ratingButtonHoverColor?: string\n whiteLabel?: boolean\n displayThankYouMessage?: boolean\n thankYouMessageHeader?: string\n thankYouMessageDescription?: string\n borderColor?: string\n position?: 'left' | 'right' | 'center'\n placeholder?: string\n // questionable: Not in frontend/src/types.ts -> SurveyAppearance, but used in site app\n maxWidth?: string\n zIndex?: string\n}\n\nexport enum SurveyType {\n Popover = 'popover',\n API = 'api',\n}\n\nexport type SurveyQuestion = BasicSurveyQuestion | LinkSurveyQuestion | RatingSurveyQuestion | MultipleSurveyQuestion\n\ninterface SurveyQuestionBase {\n question: string\n description?: string | null\n optional?: boolean\n}\n\nexport interface BasicSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.Open\n}\n\nexport interface LinkSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.Link\n link: string | null\n}\n\nexport interface RatingSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.Rating\n display: 'number' | 'emoji'\n scale: number\n lowerBoundLabel: string\n upperBoundLabel: string\n}\n\nexport interface MultipleSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.SingleChoice | SurveyQuestionType.MultipleChoice\n choices: string[]\n}\n\nexport enum SurveyQuestionType {\n Open = 'open',\n MultipleChoice = 'multiple_choice',\n SingleChoice = 'single_choice',\n Rating = 'rating',\n Link = 'link',\n}\n\nexport interface SurveyResponse {\n surveys: Survey[]\n}\n\nexport type SurveyCallback = (surveys: Survey[]) => void\n\nexport type SurveyUrlMatchType = 'regex' | 'exact' | 'icontains'\n\nexport interface Survey {\n // Sync this with the backend's SurveyAPISerializer!\n id: string\n name: string\n description: string\n type: SurveyType\n linked_flag_key: string | null\n targeting_flag_key: string | null\n questions: SurveyQuestion[]\n appearance: SurveyAppearance | null\n conditions: {\n url?: string\n selector?: string\n seenSurveyWaitPeriodInDays?: number\n urlMatchType?: SurveyUrlMatchType\n } | null\n start_date: string | null\n end_date: string | null\n}\n"]}
1
+ {"version":3,"file":"posthog-surveys-types.js","sourceRoot":"","sources":["../../src/posthog-surveys-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA0BH,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IAClB,iCAAmB,CAAA;IACnB,yBAAW,CAAA;AACf,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB;AAiCD,MAAM,CAAN,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC1B,mCAAa,CAAA;IACb,wDAAkC,CAAA;IAClC,oDAA8B,CAAA;IAC9B,uCAAiB,CAAA;IACjB,mCAAa,CAAA;AACjB,CAAC,EANW,kBAAkB,KAAlB,kBAAkB,QAM7B","sourcesContent":["/**\n * Having Survey types in types.ts was confusing tsc\n * and generating an invalid module.d.ts\n * See https://github.com/PostHog/posthog-js/issues/698\n */\n\nexport interface SurveyAppearance {\n // keep in sync with frontend/src/types.ts -> SurveyAppearance\n backgroundColor?: string\n submitButtonColor?: string\n textColor?: string\n // deprecate submit button text eventually\n submitButtonText?: string\n descriptionTextColor?: string\n ratingButtonColor?: string\n ratingButtonActiveColor?: string\n ratingButtonHoverColor?: string\n whiteLabel?: boolean\n autoDisappear?: boolean\n displayThankYouMessage?: boolean\n thankYouMessageHeader?: string\n thankYouMessageDescription?: string\n borderColor?: string\n position?: 'left' | 'right' | 'center'\n placeholder?: string\n // questionable: Not in frontend/src/types.ts -> SurveyAppearance, but used in site app\n maxWidth?: string\n zIndex?: string\n}\n\nexport enum SurveyType {\n Popover = 'popover',\n API = 'api',\n}\n\nexport type SurveyQuestion = BasicSurveyQuestion | LinkSurveyQuestion | RatingSurveyQuestion | MultipleSurveyQuestion\n\ninterface SurveyQuestionBase {\n question: string\n description?: string | null\n optional?: boolean\n buttonText?: string\n}\n\nexport interface BasicSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.Open\n}\n\nexport interface LinkSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.Link\n link: string | null\n}\n\nexport interface RatingSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.Rating\n display: 'number' | 'emoji'\n scale: number\n lowerBoundLabel: string\n upperBoundLabel: string\n}\n\nexport interface MultipleSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.SingleChoice | SurveyQuestionType.MultipleChoice\n choices: string[]\n}\n\nexport enum SurveyQuestionType {\n Open = 'open',\n MultipleChoice = 'multiple_choice',\n SingleChoice = 'single_choice',\n Rating = 'rating',\n Link = 'link',\n}\n\nexport interface SurveyResponse {\n surveys: Survey[]\n}\n\nexport type SurveyCallback = (surveys: Survey[]) => void\n\nexport type SurveyUrlMatchType = 'regex' | 'exact' | 'icontains'\n\nexport interface Survey {\n // Sync this with the backend's SurveyAPISerializer!\n id: string\n name: string\n description: string\n type: SurveyType\n linked_flag_key: string | null\n targeting_flag_key: string | null\n questions: SurveyQuestion[]\n appearance: SurveyAppearance | null\n conditions: {\n url?: string\n selector?: string\n seenSurveyWaitPeriodInDays?: number\n urlMatchType?: SurveyUrlMatchType\n } | null\n start_date: string | null\n end_date: string | null\n}\n"]}
@@ -1,4 +1,19 @@
1
1
  import { PersistentStore } from './types';
2
+ /**
3
+ * Browsers don't offer a way to check if something is a public suffix
4
+ * e.g. `.com.au`, `.io`, `.org.uk`
5
+ *
6
+ * But they do reject cookies set on public suffixes
7
+ * Setting a cookie on `.co.uk` would mean it was sent for every `.co.uk` site visited
8
+ *
9
+ * So, we can use this to check if a domain is a public suffix
10
+ * by trying to set a cookie on a subdomain of the provided hostname
11
+ * until the browser accepts it
12
+ *
13
+ * inspired by https://github.com/AngusFu/browser-root-domain
14
+ */
15
+ export declare function seekFirstNonPublicSubDomain(hostname: string, cookieJar?: Document): string;
16
+ export declare function chooseCookieDomain(hostname: string, cross_subdomain: boolean | undefined): string;
2
17
  export declare const cookieStore: PersistentStore;
3
18
  export declare const localStore: PersistentStore;
4
19
  export declare const localPlusCookieStore: PersistentStore;
@@ -13,7 +13,61 @@ import { _extend } from './utils';
13
13
  import { DISTINCT_ID, SESSION_ID, SESSION_RECORDING_IS_SAMPLED } from './constants';
14
14
  import { _isNull, _isUndefined } from './utils/type-utils';
15
15
  import { logger } from './utils/logger';
16
+ var Y1970 = 'Thu, 01 Jan 1970 00:00:00 GMT';
17
+ /**
18
+ * Browsers don't offer a way to check if something is a public suffix
19
+ * e.g. `.com.au`, `.io`, `.org.uk`
20
+ *
21
+ * But they do reject cookies set on public suffixes
22
+ * Setting a cookie on `.co.uk` would mean it was sent for every `.co.uk` site visited
23
+ *
24
+ * So, we can use this to check if a domain is a public suffix
25
+ * by trying to set a cookie on a subdomain of the provided hostname
26
+ * until the browser accepts it
27
+ *
28
+ * inspired by https://github.com/AngusFu/browser-root-domain
29
+ */
30
+ export function seekFirstNonPublicSubDomain(hostname, cookieJar) {
31
+ if (cookieJar === void 0) { cookieJar = document; }
32
+ if (['localhost', '127.0.0.1'].includes(hostname))
33
+ return '';
34
+ var list = hostname.split('.');
35
+ var len = list.length;
36
+ var key = 'dmn_chk_' + +new Date();
37
+ var R = new RegExp('(^|;)\\s*' + key + '=1');
38
+ while (len--) {
39
+ var candidate = list.slice(len).join('.');
40
+ var candidateCookieValue = key + '=1;domain=.' + candidate;
41
+ // try to set cookie
42
+ cookieJar.cookie = candidateCookieValue;
43
+ if (R.test(cookieJar.cookie)) {
44
+ // the cookie was accepted by the browser, remove the test cookie
45
+ cookieJar.cookie = candidateCookieValue + ';expires=' + Y1970;
46
+ return candidate;
47
+ }
48
+ }
49
+ return '';
50
+ }
16
51
  var DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;
52
+ var originalCookieDomainFn = function (hostname) {
53
+ var matches = hostname.match(DOMAIN_MATCH_REGEX);
54
+ return matches ? matches[0] : '';
55
+ };
56
+ export function chooseCookieDomain(hostname, cross_subdomain) {
57
+ if (cross_subdomain) {
58
+ // NOTE: Could we use this for cross domain tracking?
59
+ var matchedSubDomain = seekFirstNonPublicSubDomain(hostname);
60
+ if (!matchedSubDomain) {
61
+ var originalMatch = originalCookieDomainFn(hostname);
62
+ if (originalMatch !== matchedSubDomain) {
63
+ logger.info('Warning: cookie subdomain discovery mismatch', originalMatch, matchedSubDomain);
64
+ }
65
+ matchedSubDomain = originalMatch;
66
+ }
67
+ return matchedSubDomain ? '; domain=.' + matchedSubDomain : '';
68
+ }
69
+ return '';
70
+ }
17
71
  // Methods partially borrowed from quirksmode.org/js/cookies.html
18
72
  export var cookieStore = {
19
73
  is_supported: function () { return true; },
@@ -49,12 +103,8 @@ export var cookieStore = {
49
103
  },
50
104
  set: function (name, value, days, cross_subdomain, is_secure) {
51
105
  try {
52
- var cdomain = '', expires = '', secure = '';
53
- if (cross_subdomain) {
54
- // NOTE: Could we use this for cross domain tracking?
55
- var matches = document.location.hostname.match(DOMAIN_MATCH_REGEX), domain = matches ? matches[0] : '';
56
- cdomain = domain ? '; domain=.' + domain : '';
57
- }
106
+ var expires = '', secure = '';
107
+ var cdomain = chooseCookieDomain(document.location.hostname, cross_subdomain);
58
108
  if (days) {
59
109
  var date = new Date();
60
110
  date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
@@ -1 +1 @@
1
- {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/storage.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAEnF,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEvC,IAAM,kBAAkB,GAAG,iCAAiC,CAAA;AAE5D,iEAAiE;AACjE,MAAM,CAAC,IAAM,WAAW,GAAoB;IACxC,YAAY,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;IAExB,KAAK,EAAE,UAAU,GAAG;QAChB,MAAM,CAAC,KAAK,CAAC,qBAAqB,GAAG,GAAG,CAAC,CAAA;IAC7C,CAAC;IAED,GAAG,EAAE,UAAU,IAAI;QACf,IAAI;YACA,IAAM,MAAM,GAAG,IAAI,GAAG,GAAG,CAAA;YACzB,IAAM,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,MAAM,EAAR,CAAQ,CAAC,CAAA;YAC7D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAChC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAA;gBACb,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE;oBACvB,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAA;iBAC/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D;QAAC,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;SAC1B;IACL,CAAC;IAED,MAAM,EAAE,UAAU,IAAI;QAClB,IAAI;YACA,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;SACzC;QAAC,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;SAC1B;IACL,CAAC;CACJ,CAAA","sourcesContent":["import { _extend } from './utils'\nimport { PersistentStore, Properties } from './types'\nimport { DISTINCT_ID, SESSION_ID, SESSION_RECORDING_IS_SAMPLED } from './constants'\n\nimport { _isNull, _isUndefined } from './utils/type-utils'\nimport { logger } from './utils/logger'\n\nconst DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\\.[a-z]{2,}$/i\n\n// Methods partially borrowed from quirksmode.org/js/cookies.html\nexport const cookieStore: PersistentStore = {\n is_supported: () => true,\n\n error: function (msg) {\n logger.error('cookieStore error: ' + msg)\n },\n\n get: function (name) {\n try {\n const nameEQ = name + '='\n const ca = document.cookie.split(';').filter((x) => x.length)\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i]\n while (c.charAt(0) == ' ') {\n c = c.substring(1, c.length)\n }\n if (c.indexOf(nameEQ) === 0) {\n return decodeURIComponent(c.substring(nameEQ.length, c.length))\n }\n }\n } catch (err) {}\n return null\n },\n\n parse: function (name) {\n let cookie\n try {\n cookie = JSON.parse(cookieStore.get(name)) || {}\n } catch (err) {\n // noop\n }\n return cookie\n },\n\n set: function (name, value, days, cross_subdomain, is_secure) {\n try {\n let cdomain = '',\n expires = '',\n secure = ''\n\n if (cross_subdomain) {\n // NOTE: Could we use this for cross domain tracking?\n const matches = document.location.hostname.match(DOMAIN_MATCH_REGEX),\n domain = matches ? matches[0] : ''\n\n cdomain = domain ? '; domain=.' + domain : ''\n }\n\n if (days) {\n const date = new Date()\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000)\n expires = '; expires=' + date.toUTCString()\n }\n\n if (is_secure) {\n secure = '; secure'\n }\n\n const new_cookie_val =\n name +\n '=' +\n encodeURIComponent(JSON.stringify(value)) +\n expires +\n '; SameSite=Lax; path=/' +\n cdomain +\n secure\n document.cookie = new_cookie_val\n return new_cookie_val\n } catch (err) {\n return\n }\n },\n\n remove: function (name, cross_subdomain) {\n try {\n cookieStore.set(name, '', -1, cross_subdomain)\n } catch (err) {\n return\n }\n },\n}\n\nlet _localStorage_supported: boolean | null = null\n\nexport const localStore: PersistentStore = {\n is_supported: function () {\n if (!_isNull(_localStorage_supported)) {\n return _localStorage_supported\n }\n\n let supported = true\n if (!_isUndefined(window)) {\n try {\n const key = '__mplssupport__',\n val = 'xyz'\n localStore.set(key, val)\n if (localStore.get(key) !== '\"xyz\"') {\n supported = false\n }\n localStore.remove(key)\n } catch (err) {\n supported = false\n }\n } else {\n supported = false\n }\n if (!supported) {\n logger.error('localStorage unsupported; falling back to cookie store')\n }\n\n _localStorage_supported = supported\n return supported\n },\n\n error: function (msg) {\n logger.error('localStorage error: ' + msg)\n },\n\n get: function (name) {\n try {\n return window.localStorage.getItem(name)\n } catch (err) {\n localStore.error(err)\n }\n return null\n },\n\n parse: function (name) {\n try {\n return JSON.parse(localStore.get(name)) || {}\n } catch (err) {\n // noop\n }\n return null\n },\n\n set: function (name, value) {\n try {\n window.localStorage.setItem(name, JSON.stringify(value))\n } catch (err) {\n localStore.error(err)\n }\n },\n\n remove: function (name) {\n try {\n window.localStorage.removeItem(name)\n } catch (err) {\n localStore.error(err)\n }\n },\n}\n\n// Use localstorage for most data but still use cookie for COOKIE_PERSISTED_PROPERTIES\n// This solves issues with cookies having too much data in them causing headers too large\n// Also makes sure we don't have to send a ton of data to the server\nconst COOKIE_PERSISTED_PROPERTIES = [DISTINCT_ID, SESSION_ID, SESSION_RECORDING_IS_SAMPLED]\n\nexport const localPlusCookieStore: PersistentStore = {\n ...localStore,\n parse: function (name) {\n try {\n let extend: Properties = {}\n try {\n // See if there's a cookie stored with data.\n extend = cookieStore.parse(name) || {}\n } catch (err) {}\n const value = _extend(extend, JSON.parse(localStore.get(name) || '{}'))\n localStore.set(name, value)\n return value\n } catch (err) {\n // noop\n }\n return null\n },\n\n set: function (name, value, days, cross_subdomain, is_secure) {\n try {\n localStore.set(name, value)\n const cookiePersistedProperties: Record<string, any> = {}\n COOKIE_PERSISTED_PROPERTIES.forEach((key) => {\n if (value[key]) {\n cookiePersistedProperties[key] = value[key]\n }\n })\n\n if (Object.keys(cookiePersistedProperties).length) {\n cookieStore.set(name, cookiePersistedProperties, days, cross_subdomain, is_secure)\n }\n } catch (err) {\n localStore.error(err)\n }\n },\n\n remove: function (name, cross_subdomain) {\n try {\n window.localStorage.removeItem(name)\n cookieStore.remove(name, cross_subdomain)\n } catch (err) {\n localStore.error(err)\n }\n },\n}\n\nconst memoryStorage: Properties = {}\n\n// Storage that only lasts the length of the pageview if we don't want to use cookies\nexport const memoryStore: PersistentStore = {\n is_supported: function () {\n return true\n },\n\n error: function (msg) {\n logger.error('memoryStorage error: ' + msg)\n },\n\n get: function (name) {\n return memoryStorage[name] || null\n },\n\n parse: function (name) {\n return memoryStorage[name] || null\n },\n\n set: function (name, value) {\n memoryStorage[name] = value\n },\n\n remove: function (name) {\n delete memoryStorage[name]\n },\n}\n\nlet sessionStorageSupported: boolean | null = null\nexport const resetSessionStorageSupported = () => {\n sessionStorageSupported = null\n}\n// Storage that only lasts the length of a tab/window. Survives page refreshes\nexport const sessionStore: PersistentStore = {\n is_supported: function () {\n if (!_isNull(sessionStorageSupported)) {\n return sessionStorageSupported\n }\n sessionStorageSupported = true\n if (!_isUndefined(window)) {\n try {\n const key = '__support__',\n val = 'xyz'\n sessionStore.set(key, val)\n if (sessionStore.get(key) !== '\"xyz\"') {\n sessionStorageSupported = false\n }\n sessionStore.remove(key)\n } catch (err) {\n sessionStorageSupported = false\n }\n } else {\n sessionStorageSupported = false\n }\n return sessionStorageSupported\n },\n\n error: function (msg) {\n logger.error('sessionStorage error: ', msg)\n },\n\n get: function (name) {\n try {\n return window.sessionStorage.getItem(name)\n } catch (err) {\n sessionStore.error(err)\n }\n return null\n },\n\n parse: function (name) {\n try {\n return JSON.parse(sessionStore.get(name)) || null\n } catch (err) {\n // noop\n }\n return null\n },\n\n set: function (name, value) {\n try {\n window.sessionStorage.setItem(name, JSON.stringify(value))\n } catch (err) {\n sessionStore.error(err)\n }\n },\n\n remove: function (name) {\n try {\n window.sessionStorage.removeItem(name)\n } catch (err) {\n sessionStore.error(err)\n }\n },\n}\n"]}
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/storage.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAEnF,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEvC,IAAM,KAAK,GAAG,+BAA+B,CAAA;AAE7C;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,2BAA2B,CAAC,QAAgB,EAAE,SAAoB;IAApB,0BAAA,EAAA,oBAAoB;IAC9E,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,EAAE,CAAA;IAE5D,IAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAChC,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,CAAA;IACrB,IAAM,GAAG,GAAG,UAAU,GAAG,CAAC,IAAI,IAAI,EAAE,CAAA;IACpC,IAAM,CAAC,GAAG,IAAI,MAAM,CAAC,WAAW,GAAG,GAAG,GAAG,IAAI,CAAC,CAAA;IAE9C,OAAO,GAAG,EAAE,EAAE;QACV,IAAM,SAAS,GAAG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C;QAAC,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;SAC1B;QACD,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK,EAAE,UAAU,IAAI;QACjB,IAAI;YACA,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAA;SACpD;QAAC,OAAO,GAAG,EAAE;YACV,OAAO;SACV;QACD,OAAO,IAAI,CAAA;IACf,CAAC;IAED,GAAG,EAAE,UAAU,IAAI,EAAE,KAAK;QACtB,IAAI;YACA,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;SAC7D;QAAC,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;SAC1B;IACL,CAAC;IAED,MAAM,EAAE,UAAU,IAAI;QAClB,IAAI;YACA,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;SACzC;QAAC,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;SAC1B;IACL,CAAC;CACJ,CAAA","sourcesContent":["import { _extend } from './utils'\nimport { PersistentStore, Properties } from './types'\nimport { DISTINCT_ID, SESSION_ID, SESSION_RECORDING_IS_SAMPLED } from './constants'\n\nimport { _isNull, _isUndefined } from './utils/type-utils'\nimport { logger } from './utils/logger'\n\nconst Y1970 = 'Thu, 01 Jan 1970 00:00:00 GMT'\n\n/**\n * Browsers don't offer a way to check if something is a public suffix\n * e.g. `.com.au`, `.io`, `.org.uk`\n *\n * But they do reject cookies set on public suffixes\n * Setting a cookie on `.co.uk` would mean it was sent for every `.co.uk` site visited\n *\n * So, we can use this to check if a domain is a public suffix\n * by trying to set a cookie on a subdomain of the provided hostname\n * until the browser accepts it\n *\n * inspired by https://github.com/AngusFu/browser-root-domain\n */\nexport function seekFirstNonPublicSubDomain(hostname: string, cookieJar = document): string {\n if (['localhost', '127.0.0.1'].includes(hostname)) return ''\n\n const list = hostname.split('.')\n let len = list.length\n const key = 'dmn_chk_' + +new Date()\n const R = new RegExp('(^|;)\\\\s*' + key + '=1')\n\n while (len--) {\n const candidate = list.slice(len).join('.')\n const candidateCookieValue = key + '=1;domain=.' + candidate\n\n // try to set cookie\n cookieJar.cookie = candidateCookieValue\n\n if (R.test(cookieJar.cookie)) {\n // the cookie was accepted by the browser, remove the test cookie\n cookieJar.cookie = candidateCookieValue + ';expires=' + Y1970\n return candidate\n }\n }\n return ''\n}\n\nconst DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\\.[a-z]{2,}$/i\nconst originalCookieDomainFn = (hostname: string): string => {\n const matches = hostname.match(DOMAIN_MATCH_REGEX)\n return matches ? matches[0] : ''\n}\n\nexport function chooseCookieDomain(hostname: string, cross_subdomain: boolean | undefined): string {\n if (cross_subdomain) {\n // NOTE: Could we use this for cross domain tracking?\n let matchedSubDomain = seekFirstNonPublicSubDomain(hostname)\n\n if (!matchedSubDomain) {\n const originalMatch = originalCookieDomainFn(hostname)\n if (originalMatch !== matchedSubDomain) {\n logger.info('Warning: cookie subdomain discovery mismatch', originalMatch, matchedSubDomain)\n }\n matchedSubDomain = originalMatch\n }\n\n return matchedSubDomain ? '; domain=.' + matchedSubDomain : ''\n }\n return ''\n}\n\n// Methods partially borrowed from quirksmode.org/js/cookies.html\nexport const cookieStore: PersistentStore = {\n is_supported: () => true,\n\n error: function (msg) {\n logger.error('cookieStore error: ' + msg)\n },\n\n get: function (name) {\n try {\n const nameEQ = name + '='\n const ca = document.cookie.split(';').filter((x) => x.length)\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i]\n while (c.charAt(0) == ' ') {\n c = c.substring(1, c.length)\n }\n if (c.indexOf(nameEQ) === 0) {\n return decodeURIComponent(c.substring(nameEQ.length, c.length))\n }\n }\n } catch (err) {}\n return null\n },\n\n parse: function (name) {\n let cookie\n try {\n cookie = JSON.parse(cookieStore.get(name)) || {}\n } catch (err) {\n // noop\n }\n return cookie\n },\n\n set: function (name, value, days, cross_subdomain, is_secure) {\n try {\n let expires = '',\n secure = ''\n\n const cdomain = chooseCookieDomain(document.location.hostname, cross_subdomain)\n\n if (days) {\n const date = new Date()\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000)\n expires = '; expires=' + date.toUTCString()\n }\n\n if (is_secure) {\n secure = '; secure'\n }\n\n const new_cookie_val =\n name +\n '=' +\n encodeURIComponent(JSON.stringify(value)) +\n expires +\n '; SameSite=Lax; path=/' +\n cdomain +\n secure\n document.cookie = new_cookie_val\n return new_cookie_val\n } catch (err) {\n return\n }\n },\n\n remove: function (name, cross_subdomain) {\n try {\n cookieStore.set(name, '', -1, cross_subdomain)\n } catch (err) {\n return\n }\n },\n}\n\nlet _localStorage_supported: boolean | null = null\n\nexport const localStore: PersistentStore = {\n is_supported: function () {\n if (!_isNull(_localStorage_supported)) {\n return _localStorage_supported\n }\n\n let supported = true\n if (!_isUndefined(window)) {\n try {\n const key = '__mplssupport__',\n val = 'xyz'\n localStore.set(key, val)\n if (localStore.get(key) !== '\"xyz\"') {\n supported = false\n }\n localStore.remove(key)\n } catch (err) {\n supported = false\n }\n } else {\n supported = false\n }\n if (!supported) {\n logger.error('localStorage unsupported; falling back to cookie store')\n }\n\n _localStorage_supported = supported\n return supported\n },\n\n error: function (msg) {\n logger.error('localStorage error: ' + msg)\n },\n\n get: function (name) {\n try {\n return window.localStorage.getItem(name)\n } catch (err) {\n localStore.error(err)\n }\n return null\n },\n\n parse: function (name) {\n try {\n return JSON.parse(localStore.get(name)) || {}\n } catch (err) {\n // noop\n }\n return null\n },\n\n set: function (name, value) {\n try {\n window.localStorage.setItem(name, JSON.stringify(value))\n } catch (err) {\n localStore.error(err)\n }\n },\n\n remove: function (name) {\n try {\n window.localStorage.removeItem(name)\n } catch (err) {\n localStore.error(err)\n }\n },\n}\n\n// Use localstorage for most data but still use cookie for COOKIE_PERSISTED_PROPERTIES\n// This solves issues with cookies having too much data in them causing headers too large\n// Also makes sure we don't have to send a ton of data to the server\nconst COOKIE_PERSISTED_PROPERTIES = [DISTINCT_ID, SESSION_ID, SESSION_RECORDING_IS_SAMPLED]\n\nexport const localPlusCookieStore: PersistentStore = {\n ...localStore,\n parse: function (name) {\n try {\n let extend: Properties = {}\n try {\n // See if there's a cookie stored with data.\n extend = cookieStore.parse(name) || {}\n } catch (err) {}\n const value = _extend(extend, JSON.parse(localStore.get(name) || '{}'))\n localStore.set(name, value)\n return value\n } catch (err) {\n // noop\n }\n return null\n },\n\n set: function (name, value, days, cross_subdomain, is_secure) {\n try {\n localStore.set(name, value)\n const cookiePersistedProperties: Record<string, any> = {}\n COOKIE_PERSISTED_PROPERTIES.forEach((key) => {\n if (value[key]) {\n cookiePersistedProperties[key] = value[key]\n }\n })\n\n if (Object.keys(cookiePersistedProperties).length) {\n cookieStore.set(name, cookiePersistedProperties, days, cross_subdomain, is_secure)\n }\n } catch (err) {\n localStore.error(err)\n }\n },\n\n remove: function (name, cross_subdomain) {\n try {\n window.localStorage.removeItem(name)\n cookieStore.remove(name, cross_subdomain)\n } catch (err) {\n localStore.error(err)\n }\n },\n}\n\nconst memoryStorage: Properties = {}\n\n// Storage that only lasts the length of the pageview if we don't want to use cookies\nexport const memoryStore: PersistentStore = {\n is_supported: function () {\n return true\n },\n\n error: function (msg) {\n logger.error('memoryStorage error: ' + msg)\n },\n\n get: function (name) {\n return memoryStorage[name] || null\n },\n\n parse: function (name) {\n return memoryStorage[name] || null\n },\n\n set: function (name, value) {\n memoryStorage[name] = value\n },\n\n remove: function (name) {\n delete memoryStorage[name]\n },\n}\n\nlet sessionStorageSupported: boolean | null = null\nexport const resetSessionStorageSupported = () => {\n sessionStorageSupported = null\n}\n// Storage that only lasts the length of a tab/window. Survives page refreshes\nexport const sessionStore: PersistentStore = {\n is_supported: function () {\n if (!_isNull(sessionStorageSupported)) {\n return sessionStorageSupported\n }\n sessionStorageSupported = true\n if (!_isUndefined(window)) {\n try {\n const key = '__support__',\n val = 'xyz'\n sessionStore.set(key, val)\n if (sessionStore.get(key) !== '\"xyz\"') {\n sessionStorageSupported = false\n }\n sessionStore.remove(key)\n } catch (err) {\n sessionStorageSupported = false\n }\n } else {\n sessionStorageSupported = false\n }\n return sessionStorageSupported\n },\n\n error: function (msg) {\n logger.error('sessionStorage error: ', msg)\n },\n\n get: function (name) {\n try {\n return window.sessionStorage.getItem(name)\n } catch (err) {\n sessionStore.error(err)\n }\n return null\n },\n\n parse: function (name) {\n try {\n return JSON.parse(sessionStore.get(name)) || null\n } catch (err) {\n // noop\n }\n return null\n },\n\n set: function (name, value) {\n try {\n window.sessionStorage.setItem(name, JSON.stringify(value))\n } catch (err) {\n sessionStore.error(err)\n }\n },\n\n remove: function (name) {\n try {\n window.sessionStorage.removeItem(name)\n } catch (err) {\n sessionStore.error(err)\n }\n },\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-js",
3
- "version": "1.89.2",
3
+ "version": "1.90.1",
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",