posthog-js 1.90.2 → 1.91.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/array.full.js +1 -1
  2. package/dist/array.full.js.map +1 -1
  3. package/dist/array.js +1 -1
  4. package/dist/array.js.map +1 -1
  5. package/dist/es.js +1 -1
  6. package/dist/es.js.map +1 -1
  7. package/dist/exception-autocapture.js +1 -1
  8. package/dist/exception-autocapture.js.map +1 -1
  9. package/dist/module.d.ts +3 -4
  10. package/dist/module.js +1 -1
  11. package/dist/module.js.map +1 -1
  12. package/dist/recorder-v2.js +1 -1
  13. package/dist/recorder-v2.js.map +1 -1
  14. package/dist/recorder.js +1 -1
  15. package/dist/recorder.js.map +1 -1
  16. package/dist/surveys.js +1 -1
  17. package/dist/surveys.js.map +1 -1
  18. package/lib/package.json +1 -1
  19. package/lib/src/autocapture-utils.js +2 -1
  20. package/lib/src/autocapture-utils.js.map +1 -1
  21. package/lib/src/autocapture.js +11 -4
  22. package/lib/src/autocapture.js.map +1 -1
  23. package/lib/src/decide.js +2 -1
  24. package/lib/src/decide.js.map +1 -1
  25. package/lib/src/extensions/exception-autocapture/index.js +6 -3
  26. package/lib/src/extensions/exception-autocapture/index.js.map +1 -1
  27. package/lib/src/extensions/replay/sessionrecording.js +8 -8
  28. package/lib/src/extensions/replay/sessionrecording.js.map +1 -1
  29. package/lib/src/extensions/replay/web-performance.js +1 -0
  30. package/lib/src/extensions/replay/web-performance.js.map +1 -1
  31. package/lib/src/extensions/surveys.js +10 -2
  32. package/lib/src/extensions/surveys.js.map +1 -1
  33. package/lib/src/extensions/toolbar.d.ts +2 -2
  34. package/lib/src/extensions/toolbar.js +16 -13
  35. package/lib/src/extensions/toolbar.js.map +1 -1
  36. package/lib/src/gdpr-utils.js +2 -2
  37. package/lib/src/gdpr-utils.js.map +1 -1
  38. package/lib/src/loader-exception-autocapture.js +4 -3
  39. package/lib/src/loader-exception-autocapture.js.map +1 -1
  40. package/lib/src/loader-recorder-v2.js +7 -4
  41. package/lib/src/loader-recorder-v2.js.map +1 -1
  42. package/lib/src/loader-recorder.js +6 -6
  43. package/lib/src/loader-recorder.js.map +1 -1
  44. package/lib/src/loader-surveys.js +5 -3
  45. package/lib/src/loader-surveys.js.map +1 -1
  46. package/lib/src/page-view.js +14 -11
  47. package/lib/src/page-view.js.map +1 -1
  48. package/lib/src/posthog-core.js +21 -22
  49. package/lib/src/posthog-core.js.map +1 -1
  50. package/lib/src/posthog-surveys.js +7 -4
  51. package/lib/src/posthog-surveys.js.map +1 -1
  52. package/lib/src/retry-queue.js +2 -1
  53. package/lib/src/retry-queue.js.map +1 -1
  54. package/lib/src/session-props.d.ts +1 -2
  55. package/lib/src/session-props.js +2 -2
  56. package/lib/src/session-props.js.map +1 -1
  57. package/lib/src/sessionid.js +1 -1
  58. package/lib/src/sessionid.js.map +1 -1
  59. package/lib/src/storage.d.ts +1 -1
  60. package/lib/src/storage.js +18 -8
  61. package/lib/src/storage.js.map +1 -1
  62. package/lib/src/utils/event-utils.js +16 -10
  63. package/lib/src/utils/event-utils.js.map +1 -1
  64. package/lib/src/utils/globals.d.ts +5 -4
  65. package/lib/src/utils/globals.js +7 -5
  66. package/lib/src/utils/globals.js.map +1 -1
  67. package/lib/src/utils/index.js +7 -4
  68. package/lib/src/utils/index.js.map +1 -1
  69. package/lib/src/utils/logger.js +5 -2
  70. package/lib/src/utils/logger.js.map +1 -1
  71. package/lib/src/uuidv7.js +1 -1
  72. package/lib/src/uuidv7.js.map +1 -1
  73. package/package.json +1 -1
@@ -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,Y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AA;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"]}
1
+ {"version":3,"file":"surveys.js","sourceRoot":"","sources":["../../../src/extensions/surveys.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE3E,gGAAgG;AAChG,IAAM,MAAM,GAAG,OAAqC,CAAA;AACpD,IAAM,QAAQ,GAAG,SAAqB,CAAA;AAEtC,IAAM,cAAc,GAChB,yzBAAyzB,CAAA;AAC7zB,IAAM,YA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Appearance,\n SurveyQuestion,\n} from '../posthog-surveys-types'\n\nimport { _isUndefined } from '../utils/type-utils'\nimport { window as _window, document as _document } from '../utils/globals'\n\n// We cast the types here which is dangerous but protected by the top level generateSurveys call\nconst window = _window as Window & typeof globalThis\nconst document = _document as Document\n\nconst 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\n// This is the main exported function\nexport function generateSurveys(posthog: PostHog) {\n // NOTE: Important to ensure we never try and run surveys without a window environment\n if (!document || !window) {\n return\n }\n 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"]}
@@ -9,10 +9,10 @@ export declare class Toolbar {
9
9
  * 1. In the URL hash params
10
10
  * 2. From session storage under the key `toolbarParams` if the toolbar was initialized on a previous page
11
11
  */
12
- maybeLoadToolbar(location?: Location, localStorage?: Storage | undefined, history?: History): boolean;
12
+ maybeLoadToolbar(location?: Location | undefined, localStorage?: Storage | undefined, history?: History | undefined): boolean;
13
13
  loadToolbar(params?: ToolbarParams): boolean;
14
14
  /** @deprecated Use "loadToolbar" instead. */
15
15
  _loadEditor(params: ToolbarParams): boolean;
16
16
  /** @deprecated Use "maybeLoadToolbar" instead. */
17
- maybeLoadEditor(location?: Location, localStorage?: Storage | undefined, history?: History): boolean;
17
+ maybeLoadEditor(location?: Location | undefined, localStorage?: Storage | undefined, history?: History | undefined): boolean;
18
18
  }
@@ -24,10 +24,10 @@ import { _register_event, _try, loadScript } from '../utils';
24
24
  import { POSTHOG_MANAGED_HOSTS } from './cloud';
25
25
  import { _getHashParam } from '../utils/request-utils';
26
26
  import { logger } from '../utils/logger';
27
- import { window } from '../utils/globals';
27
+ import { window, document, assignableWindow } from '../utils/globals';
28
28
  // TRICKY: Many web frameworks will modify the route on load, potentially before posthog is initialized.
29
29
  // To get ahead of this we grab it as soon as the posthog-js is parsed
30
- var STATE_FROM_WINDOW = window.location
30
+ var STATE_FROM_WINDOW = (window === null || window === void 0 ? void 0 : window.location)
31
31
  ? _getHashParam(window.location.hash, '__posthog') || _getHashParam(location.hash, 'state')
32
32
  : null;
33
33
  var Toolbar = /** @class */ (function () {
@@ -50,9 +50,14 @@ var Toolbar = /** @class */ (function () {
50
50
  * 2. From session storage under the key `toolbarParams` if the toolbar was initialized on a previous page
51
51
  */
52
52
  Toolbar.prototype.maybeLoadToolbar = function (location, localStorage, history) {
53
- if (location === void 0) { location = window.location; }
53
+ if (location === void 0) { location = undefined; }
54
54
  if (localStorage === void 0) { localStorage = undefined; }
55
- if (history === void 0) { history = window.history; }
55
+ if (history === void 0) { history = undefined; }
56
+ if (!window || !document) {
57
+ return false;
58
+ }
59
+ location = location !== null && location !== void 0 ? location : window.location;
60
+ history = history !== null && history !== void 0 ? history : window.history;
56
61
  try {
57
62
  // Before running the code we check if we can access localStorage, if not we opt-out
58
63
  if (!localStorage) {
@@ -64,7 +69,7 @@ var Toolbar = /** @class */ (function () {
64
69
  return false;
65
70
  }
66
71
  // If localStorage was undefined, and localStorage is supported we set the default value
67
- localStorage = window.localStorage;
72
+ localStorage = window === null || window === void 0 ? void 0 : window.localStorage;
68
73
  }
69
74
  /**
70
75
  * Info about the state
@@ -119,12 +124,11 @@ var Toolbar = /** @class */ (function () {
119
124
  };
120
125
  Toolbar.prototype.loadToolbar = function (params) {
121
126
  var _this = this;
122
- if (window['_postHogToolbarLoaded']) {
127
+ if (!window || assignableWindow['_postHogToolbarLoaded']) {
123
128
  return false;
124
129
  }
125
130
  // only load the toolbar once, even if there are multiple instances of PostHogLib
126
- ;
127
- window['_postHogToolbarLoaded'] = true;
131
+ assignableWindow['_postHogToolbarLoaded'] = true;
128
132
  var host = this.instance.config.api_host;
129
133
  // toolbar.js is served from the PostHog CDN, this has a TTL of 24 hours.
130
134
  // the toolbar asset includes a rotating "token" that is valid for 5 minutes.
@@ -143,13 +147,12 @@ var Toolbar = /** @class */ (function () {
143
147
  return;
144
148
  }
145
149
  ;
146
- (window['ph_load_toolbar'] || window['ph_load_editor'])(toolbarParams, _this.instance);
150
+ (assignableWindow['ph_load_toolbar'] || assignableWindow['ph_load_editor'])(toolbarParams, _this.instance);
147
151
  });
148
152
  // Turbolinks doesn't fire an onload event but does replace the entire body, including the toolbar.
149
153
  // Thus, we ensure the toolbar is only loaded inside the body, and then reloaded on turbolinks:load.
150
154
  _register_event(window, 'turbolinks:load', function () {
151
- ;
152
- window['_postHogToolbarLoaded'] = false;
155
+ assignableWindow['_postHogToolbarLoaded'] = false;
153
156
  _this.loadToolbar(toolbarParams);
154
157
  });
155
158
  return true;
@@ -160,9 +163,9 @@ var Toolbar = /** @class */ (function () {
160
163
  };
161
164
  /** @deprecated Use "maybeLoadToolbar" instead. */
162
165
  Toolbar.prototype.maybeLoadEditor = function (location, localStorage, history) {
163
- if (location === void 0) { location = window.location; }
166
+ if (location === void 0) { location = undefined; }
164
167
  if (localStorage === void 0) { localStorage = undefined; }
165
- if (history === void 0) { history = window.history; }
168
+ if (history === void 0) { history = undefined; }
166
169
  return this.maybeLoadToolbar(location, localStorage, history);
167
170
  };
168
171
  return Toolbar;
@@ -1 +1 @@
1
- {"version":3,"file":"toolbar.js","sourceRoot":"","sources":["../../../src/extensions/toolbar.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAG5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,wGAAwG;AACxG,sEAAsE;AACtE,IAAM,iBAAiB,GAAG,MAAM,CAAC,QAAQ;IACrC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,aAAa,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAC3F,CAAC,CAAC,IAAI,CAAA;AAEV;IAEI,iBAAY,QAAiB;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC5B,CAAC;IAED,qCAAmB,GAAnB,UAAoB,QAAwB;QACxC,IAAM,aAAa,GACf,QAAQ,CAAC,eAAe,CAAC;YACzB,QAAQ,CAAC,cAAc,CAAC;YACxB,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;QACtF,IACI,QAAQ,CAAC,iBAAiB,CAAC;YAC3B,aAAa,CAAC,gBAAgB,CAAC;YAC/B,aAAa,CAAC,gBAAgB,CAAC,CAAC,OAAO,C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,CAAC,KAAK,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAA;gBAC3C,OAAM;aACT;YACD,CAAC;YAAA,CAAE,MAAc,CAAC,iBAAiB,CAAC,IAAK,MAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC,aAAa,EAAE,KAAI,CAAC,QAAQ,CAAC,CAAA;QAC5G,CAAC,CAAC,CAAA;QACF,mGAAmG;QACnG,oGAAoG;QACpG,eAAe,CAAC,MAAM,EAAE,iBAAiB,EAAE;YACvC,CAAC;YAAC,MAAc,CAAC,uBAAuB,CAAC,GAAG,KAAK,CAAA;YACjD,KAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAA;QACnC,CAAC,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;IACf,CAAC;IAED,6CAA6C;IAC7C,6BAAW,GAAX,UAAY,MAAqB;QAC7B,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IACnC,CAAC;IAED,kDAAkD;IAClD,iCAAe,GAAf,UACI,QAA0B,EAC1B,YAA6C,EAC7C,OAAwB;QAFxB,yBAAA,EAAA,WAAW,MAAM,CAAC,QAAQ;QAC1B,6BAAA,EAAA,wBAA6C;QAC7C,wBAAA,EAAA,UAAU,MAAM,CAAC,OAAO;QAExB,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,CAAC,CAAA;IACjE,CAAC;IACL,cAAC;AAAD,CAAC,AA9JD,IA8JC","sourcesContent":["import { _register_event, _try, loadScript } from '../utils'\nimport { PostHog } from '../posthog-core'\nimport { DecideResponse, ToolbarParams } from '../types'\nimport { POSTHOG_MANAGED_HOSTS } from './cloud'\nimport { _getHashParam } from '../utils/request-utils'\nimport { logger } from '../utils/logger'\nimport { window } from '../utils/globals'\n\n// TRICKY: Many web frameworks will modify the route on load, potentially before posthog is initialized.\n// To get ahead of this we grab it as soon as the posthog-js is parsed\nconst STATE_FROM_WINDOW = window.location\n ? _getHashParam(window.location.hash, '__posthog') || _getHashParam(location.hash, 'state')\n : null\n\nexport class Toolbar {\n instance: PostHog\n constructor(instance: PostHog) {\n this.instance = instance\n }\n\n afterDecideResponse(response: DecideResponse) {\n const toolbarParams: ToolbarParams =\n response['toolbarParams'] ||\n response['editorParams'] ||\n (response['toolbarVersion'] ? { toolbarVersion: response['toolbarVersion'] } : {})\n if (\n response['isAuthenticated'] &&\n toolbarParams['toolbarVersion'] &&\n toolbarParams['toolbarVersion'].indexOf('toolbar') === 0\n ) {\n this.loadToolbar({\n ...toolbarParams,\n })\n }\n }\n\n /**\n * To load the toolbar, we need an access token and other state. That state comes from one of three places:\n * 1. In the URL hash params\n * 2. From session storage under the key `toolbarParams` if the toolbar was initialized on a previous page\n */\n maybeLoadToolbar(\n location = window.location,\n localStorage: Storage | undefined = undefined,\n history = window.history\n ): boolean {\n try {\n // Before running the code we check if we can access localStorage, if not we opt-out\n if (!localStorage) {\n try {\n window.localStorage.setItem('test', 'test')\n window.localStorage.removeItem('test')\n } catch (error) {\n return false\n }\n\n // If localStorage was undefined, and localStorage is supported we set the default value\n localStorage = window.localStorage\n }\n\n /**\n * Info about the state\n * The state is a json object\n * 1. (Legacy) The state can be `state={}` as a urlencoded object of info. In this case\n * 2. The state should now be found in `__posthog={}` and can be base64 encoded or urlencoded.\n * 3. Base64 encoding is preferred and will gradually be rolled out everywhere\n */\n\n const stateHash =\n STATE_FROM_WINDOW || _getHashParam(location.hash, '__posthog') || _getHashParam(location.hash, 'state')\n\n let toolbarParams: ToolbarParams\n const state = stateHash\n ? _try(() => JSON.parse(atob(decodeURIComponent(stateHash)))) ||\n _try(() => JSON.parse(decodeURIComponent(stateHash)))\n : null\n\n const parseFromUrl = state && state['action'] === 'ph_authorize'\n\n if (parseFromUrl) {\n // happens if they are initializing the toolbar using an old snippet\n toolbarParams = state\n toolbarParams.source = 'url'\n\n if (toolbarParams && Object.keys(toolbarParams).length > 0) {\n if (state['desiredHash']) {\n // hash that was in the url before the redirect\n location.hash = state['desiredHash']\n } else if (history) {\n history.replaceState('', document.title, location.pathname + location.search) // completely remove hash\n } else {\n location.hash = '' // clear hash (but leaves # unfortunately)\n }\n }\n } else {\n // get credentials from localStorage from a previous initialzation\n toolbarParams = JSON.parse(localStorage.getItem('_postHogToolbarParams') || '{}')\n toolbarParams.source = 'localstorage'\n\n // delete \"add-action\" or other intent from toolbarParams, otherwise we'll have the same intent\n // every time we open the page (e.g. you just visiting your own site an hour later)\n delete toolbarParams.userIntent\n }\n\n if (toolbarParams['token'] && this.instance.config.token === toolbarParams['token']) {\n this.loadToolbar(toolbarParams)\n return true\n } else {\n return false\n }\n } catch (e) {\n return false\n }\n }\n\n loadToolbar(params?: ToolbarParams): boolean {\n if ((window as any)['_postHogToolbarLoaded']) {\n return false\n }\n // only load the toolbar once, even if there are multiple instances of PostHogLib\n ;(window as any)['_postHogToolbarLoaded'] = true\n\n const host = this.instance.config.api_host\n // toolbar.js is served from the PostHog CDN, this has a TTL of 24 hours.\n // the toolbar asset includes a rotating \"token\" that is valid for 5 minutes.\n const fiveMinutesInMillis = 5 * 60 * 1000\n // this ensures that we bust the cache periodically\n const timestampToNearestFiveMinutes = Math.floor(Date.now() / fiveMinutesInMillis) * fiveMinutesInMillis\n const toolbarUrl = `${host}${host.endsWith('/') ? '' : '/'}static/toolbar.js?t=${timestampToNearestFiveMinutes}`\n const disableToolbarMetrics =\n !POSTHOG_MANAGED_HOSTS.includes(this.instance.config.api_host) &&\n this.instance.config.advanced_disable_toolbar_metrics\n\n const toolbarParams = {\n token: this.instance.config.token,\n ...params,\n apiURL: host, // defaults to api_host from the instance config if nothing else set\n ...(disableToolbarMetrics ? { instrument: false } : {}),\n }\n\n const { source: _discard, ...paramsToPersist } = toolbarParams // eslint-disable-line\n window.localStorage.setItem('_postHogToolbarParams', JSON.stringify(paramsToPersist))\n\n loadScript(toolbarUrl, (err) => {\n if (err) {\n logger.error('Failed to load toolbar', err)\n return\n }\n ;((window as any)['ph_load_toolbar'] || (window as any)['ph_load_editor'])(toolbarParams, this.instance)\n })\n // Turbolinks doesn't fire an onload event but does replace the entire body, including the toolbar.\n // Thus, we ensure the toolbar is only loaded inside the body, and then reloaded on turbolinks:load.\n _register_event(window, 'turbolinks:load', () => {\n ;(window as any)['_postHogToolbarLoaded'] = false\n this.loadToolbar(toolbarParams)\n })\n return true\n }\n\n /** @deprecated Use \"loadToolbar\" instead. */\n _loadEditor(params: ToolbarParams): boolean {\n return this.loadToolbar(params)\n }\n\n /** @deprecated Use \"maybeLoadToolbar\" instead. */\n maybeLoadEditor(\n location = window.location,\n localStorage: Storage | undefined = undefined,\n history = window.history\n ): boolean {\n return this.maybeLoadToolbar(location, localStorage, history)\n }\n}\n"]}
1
+ {"version":3,"file":"toolbar.js","sourceRoot":"","sources":["../../../src/extensions/toolbar.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAG5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAErE,wGAAwG;AACxG,sEAAsE;AACtE,IAAM,iBAAiB,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ;IACtC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,aAAa,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAC3F,CAAC,CAAC,IAAI,CAAA;AAEV;IAEI,iBAAY,QAAiB;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC5B,CAAC;IAED,qCAAmB,GAAnB,UAAoB,QAAwB;QAC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C,OAAwC;QAFxC,yBAAA,EAAA,oBAA0C;QAC1C,6BAAA,EAAA,wBAA6C;QAC7C,wBAAA,EAAA,mBAAwC;QAExC,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,CAAC,CAAA;IACjE,CAAC;IACL,cAAC;AAAD,CAAC,AApKD,IAoKC","sourcesContent":["import { _register_event, _try, loadScript } from '../utils'\nimport { PostHog } from '../posthog-core'\nimport { DecideResponse, ToolbarParams } from '../types'\nimport { POSTHOG_MANAGED_HOSTS } from './cloud'\nimport { _getHashParam } from '../utils/request-utils'\nimport { logger } from '../utils/logger'\nimport { window, document, assignableWindow } from '../utils/globals'\n\n// TRICKY: Many web frameworks will modify the route on load, potentially before posthog is initialized.\n// To get ahead of this we grab it as soon as the posthog-js is parsed\nconst STATE_FROM_WINDOW = window?.location\n ? _getHashParam(window.location.hash, '__posthog') || _getHashParam(location.hash, 'state')\n : null\n\nexport class Toolbar {\n instance: PostHog\n constructor(instance: PostHog) {\n this.instance = instance\n }\n\n afterDecideResponse(response: DecideResponse) {\n const toolbarParams: ToolbarParams =\n response['toolbarParams'] ||\n response['editorParams'] ||\n (response['toolbarVersion'] ? { toolbarVersion: response['toolbarVersion'] } : {})\n if (\n response['isAuthenticated'] &&\n toolbarParams['toolbarVersion'] &&\n toolbarParams['toolbarVersion'].indexOf('toolbar') === 0\n ) {\n this.loadToolbar({\n ...toolbarParams,\n })\n }\n }\n\n /**\n * To load the toolbar, we need an access token and other state. That state comes from one of three places:\n * 1. In the URL hash params\n * 2. From session storage under the key `toolbarParams` if the toolbar was initialized on a previous page\n */\n maybeLoadToolbar(\n location: Location | undefined = undefined,\n localStorage: Storage | undefined = undefined,\n history: History | undefined = undefined\n ): boolean {\n if (!window || !document) {\n return false\n }\n location = location ?? window.location\n history = history ?? window.history\n\n try {\n // Before running the code we check if we can access localStorage, if not we opt-out\n if (!localStorage) {\n try {\n window.localStorage.setItem('test', 'test')\n window.localStorage.removeItem('test')\n } catch (error) {\n return false\n }\n\n // If localStorage was undefined, and localStorage is supported we set the default value\n localStorage = window?.localStorage\n }\n\n /**\n * Info about the state\n * The state is a json object\n * 1. (Legacy) The state can be `state={}` as a urlencoded object of info. In this case\n * 2. The state should now be found in `__posthog={}` and can be base64 encoded or urlencoded.\n * 3. Base64 encoding is preferred and will gradually be rolled out everywhere\n */\n\n const stateHash =\n STATE_FROM_WINDOW || _getHashParam(location.hash, '__posthog') || _getHashParam(location.hash, 'state')\n\n let toolbarParams: ToolbarParams\n const state = stateHash\n ? _try(() => JSON.parse(atob(decodeURIComponent(stateHash)))) ||\n _try(() => JSON.parse(decodeURIComponent(stateHash)))\n : null\n\n const parseFromUrl = state && state['action'] === 'ph_authorize'\n\n if (parseFromUrl) {\n // happens if they are initializing the toolbar using an old snippet\n toolbarParams = state\n toolbarParams.source = 'url'\n\n if (toolbarParams && Object.keys(toolbarParams).length > 0) {\n if (state['desiredHash']) {\n // hash that was in the url before the redirect\n location.hash = state['desiredHash']\n } else if (history) {\n history.replaceState('', document.title, location.pathname + location.search) // completely remove hash\n } else {\n location.hash = '' // clear hash (but leaves # unfortunately)\n }\n }\n } else {\n // get credentials from localStorage from a previous initialzation\n toolbarParams = JSON.parse(localStorage.getItem('_postHogToolbarParams') || '{}')\n toolbarParams.source = 'localstorage'\n\n // delete \"add-action\" or other intent from toolbarParams, otherwise we'll have the same intent\n // every time we open the page (e.g. you just visiting your own site an hour later)\n delete toolbarParams.userIntent\n }\n\n if (toolbarParams['token'] && this.instance.config.token === toolbarParams['token']) {\n this.loadToolbar(toolbarParams)\n return true\n } else {\n return false\n }\n } catch (e) {\n return false\n }\n }\n\n loadToolbar(params?: ToolbarParams): boolean {\n if (!window || assignableWindow['_postHogToolbarLoaded']) {\n return false\n }\n // only load the toolbar once, even if there are multiple instances of PostHogLib\n assignableWindow['_postHogToolbarLoaded'] = true\n\n const host = this.instance.config.api_host\n // toolbar.js is served from the PostHog CDN, this has a TTL of 24 hours.\n // the toolbar asset includes a rotating \"token\" that is valid for 5 minutes.\n const fiveMinutesInMillis = 5 * 60 * 1000\n // this ensures that we bust the cache periodically\n const timestampToNearestFiveMinutes = Math.floor(Date.now() / fiveMinutesInMillis) * fiveMinutesInMillis\n const toolbarUrl = `${host}${host.endsWith('/') ? '' : '/'}static/toolbar.js?t=${timestampToNearestFiveMinutes}`\n const disableToolbarMetrics =\n !POSTHOG_MANAGED_HOSTS.includes(this.instance.config.api_host) &&\n this.instance.config.advanced_disable_toolbar_metrics\n\n const toolbarParams = {\n token: this.instance.config.token,\n ...params,\n apiURL: host, // defaults to api_host from the instance config if nothing else set\n ...(disableToolbarMetrics ? { instrument: false } : {}),\n }\n\n const { source: _discard, ...paramsToPersist } = toolbarParams // eslint-disable-line\n window.localStorage.setItem('_postHogToolbarParams', JSON.stringify(paramsToPersist))\n\n loadScript(toolbarUrl, (err) => {\n if (err) {\n logger.error('Failed to load toolbar', err)\n return\n }\n ;(assignableWindow['ph_load_toolbar'] || assignableWindow['ph_load_editor'])(toolbarParams, this.instance)\n })\n // Turbolinks doesn't fire an onload event but does replace the entire body, including the toolbar.\n // Thus, we ensure the toolbar is only loaded inside the body, and then reloaded on turbolinks:load.\n _register_event(window, 'turbolinks:load', () => {\n assignableWindow['_postHogToolbarLoaded'] = false\n this.loadToolbar(toolbarParams)\n })\n return true\n }\n\n /** @deprecated Use \"loadToolbar\" instead. */\n _loadEditor(params: ToolbarParams): boolean {\n return this.loadToolbar(params)\n }\n\n /** @deprecated Use \"maybeLoadToolbar\" instead. */\n maybeLoadEditor(\n location: Location | undefined = undefined,\n localStorage: Storage | undefined = undefined,\n history: History | undefined = undefined\n ): boolean {\n return this.maybeLoadToolbar(location, localStorage, history)\n }\n}\n"]}
@@ -141,10 +141,10 @@ function _getStorageValue(token, options) {
141
141
  function _hasDoNotTrackFlagOn(options) {
142
142
  if (options && options.respectDnt) {
143
143
  var win = (options && options.window) || window;
144
- var nav = win['navigator'] || {};
144
+ var nav = win === null || win === void 0 ? void 0 : win.navigator;
145
145
  var hasDntOn_1 = false;
146
146
  _each([
147
- nav['doNotTrack'],
147
+ nav === null || nav === void 0 ? void 0 : nav.doNotTrack,
148
148
  nav['msDoNotTrack'],
149
149
  win['doNotTrack'],
150
150
  ], function (dntValue) {