posthog-js 1.136.5 → 1.136.7

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 (40) hide show
  1. package/dist/array.full.js +2 -2
  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/lib/src/extensions/surveys/components/ConfirmationMessage.d.ts +3 -3
  8. package/dist/lib/src/extensions/surveys/components/QuestionTypes.d.ts +8 -12
  9. package/dist/lib/src/extensions/surveys/surveys-utils.d.ts +3 -3
  10. package/dist/lib/src/extensions/surveys.d.ts +3 -5
  11. package/dist/lib/src/posthog-surveys-types.d.ts +1 -1
  12. package/dist/module.d.ts +1 -1
  13. package/dist/module.js +1 -1
  14. package/dist/module.js.map +1 -1
  15. package/dist/surveys-module-previews.js +1 -1
  16. package/dist/surveys-module-previews.js.map +1 -1
  17. package/dist/surveys.js +1 -1
  18. package/dist/surveys.js.map +1 -1
  19. package/lib/package.json +1 -1
  20. package/lib/src/extensions/replay/sessionrecording.js +2 -0
  21. package/lib/src/extensions/replay/sessionrecording.js.map +1 -1
  22. package/lib/src/extensions/surveys/components/BottomSection.jsx +3 -3
  23. package/lib/src/extensions/surveys/components/BottomSection.jsx.map +1 -1
  24. package/lib/src/extensions/surveys/components/ConfirmationMessage.d.ts +3 -3
  25. package/lib/src/extensions/surveys/components/ConfirmationMessage.jsx +3 -3
  26. package/lib/src/extensions/surveys/components/ConfirmationMessage.jsx.map +1 -1
  27. package/lib/src/extensions/surveys/components/QuestionHeader.jsx +2 -2
  28. package/lib/src/extensions/surveys/components/QuestionHeader.jsx.map +1 -1
  29. package/lib/src/extensions/surveys/components/QuestionTypes.d.ts +8 -12
  30. package/lib/src/extensions/surveys/components/QuestionTypes.jsx +21 -17
  31. package/lib/src/extensions/surveys/components/QuestionTypes.jsx.map +1 -1
  32. package/lib/src/extensions/surveys/surveys-utils.d.ts +3 -3
  33. package/lib/src/extensions/surveys/surveys-utils.jsx +7 -7
  34. package/lib/src/extensions/surveys/surveys-utils.jsx.map +1 -1
  35. package/lib/src/extensions/surveys.d.ts +3 -5
  36. package/lib/src/extensions/surveys.jsx +104 -68
  37. package/lib/src/extensions/surveys.jsx.map +1 -1
  38. package/lib/src/posthog-surveys-types.d.ts +1 -1
  39. package/lib/src/posthog-surveys-types.js.map +1 -1
  40. package/package.json +1 -1
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-js",
3
- "version": "1.136.5",
3
+ "version": "1.136.7",
4
4
  "description": "Posthog-js allows you to automatically capture usage and send events to PostHog.",
5
5
  "repository": "https://github.com/PostHog/posthog-js",
6
6
  "author": "hey@posthog.com",
@@ -503,6 +503,8 @@ var SessionRecording = /** @class */ (function () {
503
503
  timeSinceLastActive: event.timestamp - this._lastActivityTimestamp,
504
504
  threshold: RECORDING_IDLE_ACTIVITY_TIMEOUT_MS,
505
505
  });
506
+ // don't take full snapshots while idle
507
+ clearTimeout(this._fullSnapshotTimer);
506
508
  }
507
509
  }
508
510
  var returningFromIdle = false;
@@ -1 +1 @@
1
- {"version":3,"file":"sessionrecording.js","sourceRoot":"","sources":["../../../../src/extensions/replay/sessionrecording.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACH,yCAAyC,EACzC,kCAAkC,EAClC,qCAAqC,EACrC,4BAA4B,EAC5B,kCAAkC,EAClC,yCAAyC,EACzC,6BAA6B,GAChC,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACH,wBAAwB,EACxB,+BAA+B,EAC/B,eAAe,EACf,mBAAmB,EAGnB,wBAAwB,GAC3B,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EAAE,SAAS,EAA0D,MAAM,cAAc,CAAA;AAChG,OAAO,MAAM,MAAM,cAAc,CAAA;AACjC,OAAO,EAAE,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ACxB,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC;gBAC/B,KAAI,CAAC,YAAY,EAAE,CAAA;YACvB,CAAC,EAAE,wBAAwB,CAAC,CAAA;SAC/B;IACL,CAAC;IAEO,2CAAgB,GAAxB,UAAyB,UAAsB;QAC3C,oGAAoG;QACpG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE;YAC3C,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC;YACpE,WAAW,EAAE,IAAI;YACjB,SAAS,EAAE,2BAA2B;YACtC,WAAW,EAAE,IAAI,EAAE,sDAAsD;SAC5E,CAAC,CAAA;IACN,CAAC;IACL,uBAAC;AAAD,CAAC,AA3xBD,IA2xBC","sourcesContent":["import {\n CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE,\n SESSION_RECORDING_CANVAS_RECORDING,\n SESSION_RECORDING_ENABLED_SERVER_SIDE,\n SESSION_RECORDING_IS_SAMPLED,\n SESSION_RECORDING_MINIMUM_DURATION,\n SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE,\n SESSION_RECORDING_SAMPLE_RATE,\n} from '../../constants'\nimport {\n FULL_SNAPSHOT_EVENT_TYPE,\n INCREMENTAL_SNAPSHOT_EVENT_TYPE,\n META_EVENT_TYPE,\n MutationRateLimiter,\n recordOptions,\n rrwebRecord,\n truncateLargeConsoleLogs,\n} from './sessionrecording-utils'\nimport { PostHog } from '../../posthog-core'\nimport { DecideResponse, FlagVariant, NetworkRecordOptions, NetworkRequest, Properties } from '../../types'\nimport { EventType, type eventWithTime, type listenerHandler, RecordPlugin } from '@rrweb/types'\nimport Config from '../../config'\nimport { timestamp, loadScript } from '../../utils'\n\nimport {\n isBoolean,\n isFunction,\n isNull,\n isNullish,\n isNumber,\n isObject,\n isString,\n isUndefined,\n} from '../../utils/type-utils'\nimport { logger } from '../../utils/logger'\nimport { document, assignableWindow, window } from '../../utils/globals'\nimport { buildNetworkRequestOptions } from './config'\nimport { isLocalhost } from '../../utils/request-utils'\n\nconst BASE_ENDPOINT = '/s/'\n\nconst FIVE_MINUTES = 1000 * 60 * 5\nconst TWO_SECONDS = 2000\nexport const RECORDING_IDLE_ACTIVITY_TIMEOUT_MS = FIVE_MINUTES\nexport const RECORDING_MAX_EVENT_SIZE = 1024 * 1024 * 0.9 // ~1mb (with some wiggle room)\nexport const RECORDING_BUFFER_TIMEOUT = 2000 // 2 seconds\nexport const SESSION_RECORDING_BATCH_KEY = 'recordings'\n\n// NOTE: Importing this type is problematic as we can't safely bundle it to a TS definition so, instead we redefine.\n// import type { record } from 'rrweb2/typings'\n// import type { recordOptions } from 'rrweb/typings/types'\n\n// Copied from rrweb typings to avoid import\nenum IncrementalSource {\n Mutation = 0,\n MouseMove = 1,\n MouseInteraction = 2,\n Scroll = 3,\n ViewportResize = 4,\n Input = 5,\n TouchMove = 6,\n MediaInteraction = 7,\n StyleSheetRule = 8,\n CanvasMutation = 9,\n Font = 10,\n Log = 11,\n Drag = 12,\n StyleDeclaration = 13,\n Selection = 14,\n AdoptedStyleSheet = 15,\n}\n\nconst ACTIVE_SOURCES = [\n IncrementalSource.MouseMove,\n IncrementalSource.MouseInteraction,\n IncrementalSource.Scroll,\n IncrementalSource.ViewportResize,\n IncrementalSource.Input,\n IncrementalSource.TouchMove,\n IncrementalSource.MediaInteraction,\n IncrementalSource.Drag,\n]\n\n/**\n * Session recording starts in buffering mode while waiting for decide response\n * Once the response is received it might be disabled, active or sampled\n * When sampled that means a sample rate is set and the last time the session id was rotated\n * the sample rate determined this session should be sent to the server.\n */\ntype SessionRecordingStatus = 'disabled' | 'sampled' | 'active' | 'buffering'\n\ninterface SnapshotBuffer {\n size: number\n data: any[]\n sessionId: string\n windowId: string\n\n readonly mostRecentSnapshotTimestamp: number | null\n add(properties: Properties): void\n}\n\nclass InMemoryBuffer implements SnapshotBuffer {\n size: number\n data: any[]\n sessionId: string\n windowId: string\n\n get mostRecentSnapshotTimestamp(): number | null {\n return this.data.length ? this.data[this.data.length - 1].timestamp : null\n }\n\n constructor(sessionId: string, windowId: string) {\n this.size = 0\n this.data = []\n this.sessionId = sessionId\n this.windowId = windowId\n }\n\n add(properties: Properties) {\n this.size += properties.$snapshot_bytes\n this.data.push(properties.$snapshot_data)\n }\n}\n\ninterface QueuedRRWebEvent {\n rrwebMethod: () => void\n attempt: number\n // the timestamp this was first put into this queue\n enqueuedAt: number\n}\n\nconst newQueuedEvent = (rrwebMethod: () => void): QueuedRRWebEvent => ({\n rrwebMethod,\n enqueuedAt: Date.now(),\n attempt: 1,\n})\n\nconst LOGGER_PREFIX = '[SessionRecording]'\n\nexport class SessionRecording {\n private _endpoint: string\n private flushBufferTimer?: any\n\n // we have a buffer - that contains PostHog snapshot events ready to be sent to the server\n private buffer: SnapshotBuffer\n // and a queue - that contains rrweb events that we want to send to rrweb, but rrweb wasn't able to accept them yet\n private queuedRRWebEvents: QueuedRRWebEvent[] = []\n\n private mutationRateLimiter?: MutationRateLimiter\n private _captureStarted: boolean\n private stopRrweb: listenerHandler | undefined\n private receivedDecide: boolean\n private isIdle = false\n\n private _linkedFlagSeen: boolean = false\n private _lastActivityTimestamp: number = Date.now()\n private windowId: string\n private sessionId: string\n private _linkedFlag: string | FlagVariant | null = null\n\n private _fullSnapshotTimer?: ReturnType<typeof setInterval>\n\n // if pageview capture is disabled\n // then we can manually track href changes\n private _lastHref?: string\n\n // Util to help developers working on this feature manually override\n _forceAllowLocalhostNetworkCapture = false\n\n private get rrwebRecord(): rrwebRecord | undefined {\n return assignableWindow?.rrweb?.record\n }\n\n public get started(): boolean {\n // TODO could we use status instead of _captureStarted?\n return this._captureStarted\n }\n\n private get sessionManager() {\n if (!this.instance.sessionManager) {\n throw new Error(LOGGER_PREFIX + ' started without valid sessionManager. This is a bug.')\n }\n\n return this.instance.sessionManager\n }\n\n private get isSampled(): boolean | null {\n const currentValue = this.instance.get_property(SESSION_RECORDING_IS_SAMPLED)\n return isBoolean(currentValue) ? currentValue : null\n }\n\n private get sessionDuration(): number | null {\n const mostRecentSnapshotTimestamp = this.buffer.mostRecentSnapshotTimestamp\n const { sessionStartTimestamp } = this.sessionManager.checkAndGetSessionAndWindowId(true)\n return mostRecentSnapshotTimestamp ? mostRecentSnapshotTimestamp - sessionStartTimestamp : null\n }\n\n private get isRecordingEnabled() {\n const enabled_server_side = !!this.instance.get_property(SESSION_RECORDING_ENABLED_SERVER_SIDE)\n const enabled_client_side = !this.instance.config.disable_session_recording\n return window && enabled_server_side && enabled_client_side\n }\n\n private get isConsoleLogCaptureEnabled() {\n const enabled_server_side = !!this.instance.get_property(CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE)\n const enabled_client_side = this.instance.config.enable_recording_console_log\n return enabled_client_side ?? enabled_server_side\n }\n\n private get canvasRecording(): { enabled: boolean; fps: number; quality: number } | undefined {\n const canvasRecording_server_side = this.instance.get_property(SESSION_RECORDING_CANVAS_RECORDING)\n return canvasRecording_server_side && canvasRecording_server_side.fps && canvasRecording_server_side.quality\n ? {\n enabled: canvasRecording_server_side.enabled,\n fps: canvasRecording_server_side.fps,\n quality: canvasRecording_server_side.quality,\n }\n : undefined\n }\n\n // network payload capture config has three parts\n // each can be configured server side or client side\n private get networkPayloadCapture():\n | Pick<NetworkRecordOptions, 'recordHeaders' | 'recordBody' | 'recordPerformance'>\n | undefined {\n const networkPayloadCapture_server_side = this.instance.get_property(SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE)\n const networkPayloadCapture_client_side = {\n recordHeaders: this.instance.config.session_recording?.recordHeaders,\n recordBody: this.instance.config.session_recording?.recordBody,\n }\n const headersEnabled =\n networkPayloadCapture_client_side?.recordHeaders || networkPayloadCapture_server_side?.recordHeaders\n const bodyEnabled =\n networkPayloadCapture_client_side?.recordBody || networkPayloadCapture_server_side?.recordBody\n const performanceEnabled =\n this.instance.config.capture_performance || networkPayloadCapture_server_side?.capturePerformance\n\n return headersEnabled || bodyEnabled || performanceEnabled\n ? { recordHeaders: headersEnabled, recordBody: bodyEnabled, recordPerformance: performanceEnabled }\n : undefined\n }\n\n private get sampleRate(): number | null {\n const rate = this.instance.get_property(SESSION_RECORDING_SAMPLE_RATE)\n return isNumber(rate) ? rate : null\n }\n\n private get minimumDuration(): number | null {\n const duration = this.instance.get_property(SESSION_RECORDING_MINIMUM_DURATION)\n return isNumber(duration) ? duration : null\n }\n\n /**\n * defaults to buffering mode until a decide response is received\n * once a decide response is received status can be disabled, active or sampled\n */\n private get status(): SessionRecordingStatus {\n if (!this.receivedDecide) {\n return 'buffering'\n }\n\n if (!this.isRecordingEnabled) {\n return 'disabled'\n }\n\n if (!isNullish(this._linkedFlag) && !this._linkedFlagSeen) {\n return 'buffering'\n }\n\n if (isBoolean(this.isSampled)) {\n return this.isSampled ? 'sampled' : 'disabled'\n } else {\n return 'active'\n }\n }\n\n constructor(private readonly instance: PostHog) {\n this._captureStarted = false\n this._endpoint = BASE_ENDPOINT\n this.stopRrweb = undefined\n this.receivedDecide = false\n\n window?.addEventListener('beforeunload', () => {\n this._flushBuffer()\n })\n\n window?.addEventListener('offline', () => {\n this._tryAddCustomEvent('browser offline', {})\n })\n\n window?.addEventListener('online', () => {\n this._tryAddCustomEvent('browser online', {})\n })\n\n window?.addEventListener('visibilitychange', () => {\n if (document?.visibilityState) {\n const label = 'window ' + document.visibilityState\n this._tryAddCustomEvent(label, {})\n }\n })\n\n if (!this.instance.sessionManager) {\n logger.error(LOGGER_PREFIX + ' started without valid sessionManager')\n throw new Error(LOGGER_PREFIX + ' started without valid sessionManager. This is a bug.')\n }\n\n // we know there's a sessionManager, so don't need to start without a session id\n const { sessionId, windowId } = this.sessionManager.checkAndGetSessionAndWindowId()\n this.sessionId = sessionId\n this.windowId = windowId\n\n this.buffer = new InMemoryBuffer(this.sessionId, this.windowId)\n\n // on reload there might be an already sampled session that should be continued before decide response,\n // so we call this here _and_ in the decide response\n this._setupSampling()\n }\n\n startIfEnabledOrStop() {\n if (this.isRecordingEnabled) {\n this._startCapture()\n logger.info(LOGGER_PREFIX + ' started')\n } else {\n this.stopRecording()\n this.clearBuffer()\n }\n }\n\n stopRecording() {\n if (this._captureStarted && this.stopRrweb) {\n this.stopRrweb()\n this.stopRrweb = undefined\n this._captureStarted = false\n logger.info(LOGGER_PREFIX + ' stopped')\n }\n }\n\n private makeSamplingDecision(sessionId: string): void {\n const sessionIdChanged = this.sessionId !== sessionId\n\n // capture the current sample rate,\n // because it is re-used multiple times\n // and the bundler won't minimise any of the references\n const currentSampleRate = this.sampleRate\n\n if (!isNumber(currentSampleRate)) {\n this.instance.persistence?.register({\n [SESSION_RECORDING_IS_SAMPLED]: null,\n })\n return\n }\n\n const storedIsSampled = this.isSampled\n\n /**\n * if we get this far then we should make a sampling decision.\n * When the session id changes or there is no stored sampling decision for this session id\n * then we should make a new decision.\n *\n * Otherwise, we should use the stored decision.\n */\n let shouldSample: boolean\n const makeDecision = sessionIdChanged || !isBoolean(storedIsSampled)\n if (makeDecision) {\n const randomNumber = Math.random()\n shouldSample = randomNumber < currentSampleRate\n } else {\n shouldSample = storedIsSampled\n }\n\n if (!shouldSample && makeDecision) {\n logger.warn(\n LOGGER_PREFIX +\n ` Sample rate (${currentSampleRate}) has determined that this sessionId (${sessionId}) will not be sent to the server.`\n )\n }\n this._tryAddCustomEvent('samplingDecisionMade', {\n sampleRate: currentSampleRate,\n })\n\n this.instance.persistence?.register({\n [SESSION_RECORDING_IS_SAMPLED]: shouldSample,\n })\n }\n\n afterDecideResponse(response: DecideResponse) {\n this._persistDecideResponse(response)\n\n this._linkedFlag = response.sessionRecording?.linkedFlag || null\n\n if (response.sessionRecording?.endpoint) {\n this._endpoint = response.sessionRecording?.endpoint\n }\n\n this._setupSampling()\n\n if (!isNullish(this._linkedFlag)) {\n const linkedFlag = isString(this._linkedFlag) ? this._linkedFlag : this._linkedFlag.flag\n const linkedVariant = isString(this._linkedFlag) ? null : this._linkedFlag.variant\n this.instance.onFeatureFlags((_flags, variants) => {\n const flagIsPresent = isObject(variants) && linkedFlag in variants\n const linkedFlagMatches = linkedVariant ? variants[linkedFlag] === linkedVariant : flagIsPresent\n if (linkedFlagMatches) {\n const payload = {\n linkedFlag,\n linkedVariant,\n }\n const tag = 'linked flag matched'\n logger.info(LOGGER_PREFIX + ' ' + tag, payload)\n this._tryAddCustomEvent(tag, payload)\n }\n this._linkedFlagSeen = linkedFlagMatches\n })\n }\n\n this.receivedDecide = true\n this.startIfEnabledOrStop()\n }\n\n private _samplingSessionListener: (() => void) | null = null\n\n /**\n * This might be called more than once so needs to be idempotent\n */\n private _setupSampling() {\n if (isNumber(this.sampleRate) && isNull(this._samplingSessionListener)) {\n this._samplingSessionListener = this.sessionManager.onSessionId((sessionId) => {\n this.makeSamplingDecision(sessionId)\n })\n }\n }\n\n private _persistDecideResponse(response: DecideResponse): void {\n if (this.instance.persistence) {\n const persistence = this.instance.persistence\n\n const persistResponse = () => {\n const receivedSampleRate = response.sessionRecording?.sampleRate\n\n const parsedSampleRate = isNullish(receivedSampleRate) ? null : parseFloat(receivedSampleRate)\n const receivedMinimumDuration = response.sessionRecording?.minimumDurationMilliseconds\n\n persistence.register({\n [SESSION_RECORDING_ENABLED_SERVER_SIDE]: !!response['sessionRecording'],\n [CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE]: response.sessionRecording?.consoleLogRecordingEnabled,\n [SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE]: {\n capturePerformance: response.capturePerformance,\n ...response.sessionRecording?.networkPayloadCapture,\n },\n [SESSION_RECORDING_CANVAS_RECORDING]: {\n enabled: response.sessionRecording?.recordCanvas,\n fps: response.sessionRecording?.canvasFps,\n quality: response.sessionRecording?.canvasQuality,\n },\n [SESSION_RECORDING_SAMPLE_RATE]: parsedSampleRate,\n [SESSION_RECORDING_MINIMUM_DURATION]: isUndefined(receivedMinimumDuration)\n ? null\n : receivedMinimumDuration,\n })\n }\n\n persistResponse()\n this.sessionManager.onSessionId(persistResponse)\n }\n }\n\n log(message: string, level: 'log' | 'warn' | 'error' = 'log') {\n this.instance.sessionRecording?.onRRwebEmit({\n type: 6,\n data: {\n plugin: 'rrweb/console@1',\n payload: {\n level,\n trace: [],\n // Even though it is a string we stringify it as that's what rrweb expects\n payload: [JSON.stringify(message)],\n },\n },\n timestamp: timestamp(),\n })\n }\n private _startCapture() {\n if (isUndefined(Object.assign)) {\n // According to the rrweb docs, rrweb is not supported on IE11 and below:\n // \"rrweb does not support IE11 and below because it uses the MutationObserver API which was supported by these browsers.\"\n // https://github.com/rrweb-io/rrweb/blob/master/guide.md#compatibility-note\n //\n // However, MutationObserver does exist on IE11, it just doesn't work well and does not detect all changes.\n // Instead, when we load \"recorder.js\", the first JS error is about \"Object.assign\" being undefined.\n // Thus instead of MutationObserver, we look for this function and block recording if it's undefined.\n return\n }\n\n // We do not switch recorder versions midway through a recording.\n // do not start if explicitly disabled or if the user has opted out\n if (\n this._captureStarted ||\n this.instance.config.disable_session_recording ||\n this.instance.consent.isOptedOut()\n ) {\n return\n }\n\n this._captureStarted = true\n // We want to ensure the sessionManager is reset if necessary on load of the recorder\n this.sessionManager.checkAndGetSessionAndWindowId()\n\n // If recorder.js is already loaded (if array.full.js snippet is used or posthog-js/dist/recorder is\n // imported), don't load script. Otherwise, remotely import recorder.js from cdn since it hasn't been loaded.\n if (!this.rrwebRecord) {\n loadScript(\n this.instance.requestRouter.endpointFor('assets', `/static/recorder.js?v=${Config.LIB_VERSION}`),\n (err) => {\n if (err) {\n return logger.error(LOGGER_PREFIX + ` could not load recorder.js`, err)\n }\n\n this._onScriptLoaded()\n }\n )\n } else {\n this._onScriptLoaded()\n }\n }\n\n private isInteractiveEvent(event: eventWithTime) {\n return (\n event.type === INCREMENTAL_SNAPSHOT_EVENT_TYPE &&\n ACTIVE_SOURCES.indexOf(event.data?.source as IncrementalSource) !== -1\n )\n }\n\n private _updateWindowAndSessionIds(event: eventWithTime) {\n // Some recording events are triggered by non-user events (e.g. \"X minutes ago\" text updating on the screen).\n // We don't want to extend the session or trigger a new session in these cases. These events are designated by event\n // type -> incremental update, and source -> mutation.\n\n const isUserInteraction = this.isInteractiveEvent(event)\n\n if (!isUserInteraction && !this.isIdle) {\n // We check if the lastActivityTimestamp is old enough to go idle\n if (event.timestamp - this._lastActivityTimestamp > RECORDING_IDLE_ACTIVITY_TIMEOUT_MS) {\n this.isIdle = true\n this._tryAddCustomEvent('sessionIdle', {\n reason: 'user inactivity',\n timeSinceLastActive: event.timestamp - this._lastActivityTimestamp,\n threshold: RECORDING_IDLE_ACTIVITY_TIMEOUT_MS,\n })\n }\n }\n\n let returningFromIdle = false\n if (isUserInteraction) {\n this._lastActivityTimestamp = event.timestamp\n if (this.isIdle) {\n // Remove the idle state if set and trigger a full snapshot as we will have ignored previous mutations\n this.isIdle = false\n this._tryAddCustomEvent('sessionNoLongerIdle', {\n reason: 'user activity',\n type: event.type,\n })\n returningFromIdle = true\n }\n }\n\n if (this.isIdle) {\n return\n }\n\n // We only want to extend the session if it is an interactive event.\n const { windowId, sessionId } = this.sessionManager.checkAndGetSessionAndWindowId(\n !isUserInteraction,\n event.timestamp\n )\n\n const sessionIdChanged = this.sessionId !== sessionId\n const windowIdChanged = this.windowId !== windowId\n\n this.windowId = windowId\n this.sessionId = sessionId\n\n if (\n returningFromIdle ||\n ([FULL_SNAPSHOT_EVENT_TYPE, META_EVENT_TYPE].indexOf(event.type) === -1 &&\n (windowIdChanged || sessionIdChanged || isUndefined(this._fullSnapshotTimer)))\n ) {\n this._tryTakeFullSnapshot()\n }\n }\n\n private _tryRRWebMethod(queuedRRWebEvent: QueuedRRWebEvent): boolean {\n try {\n queuedRRWebEvent.rrwebMethod()\n return true\n } catch (e) {\n // Sometimes a race can occur where the recorder is not fully started yet\n if (this.queuedRRWebEvents.length < 10) {\n this.queuedRRWebEvents.push({\n enqueuedAt: queuedRRWebEvent.enqueuedAt || Date.now(),\n attempt: queuedRRWebEvent.attempt++,\n rrwebMethod: queuedRRWebEvent.rrwebMethod,\n })\n } else {\n logger.warn(LOGGER_PREFIX + ' could not emit queued rrweb event.', e, queuedRRWebEvent)\n }\n\n return false\n }\n }\n\n private _tryAddCustomEvent(tag: string, payload: any): boolean {\n return this._tryRRWebMethod(newQueuedEvent(() => this.rrwebRecord!.addCustomEvent(tag, payload)))\n }\n\n private _tryTakeFullSnapshot(): boolean {\n return this._tryRRWebMethod(newQueuedEvent(() => this.rrwebRecord!.takeFullSnapshot()))\n }\n\n private _onScriptLoaded() {\n // rrweb config info: https://github.com/rrweb-io/rrweb/blob/7d5d0033258d6c29599fb08412202d9a2c7b9413/src/record/index.ts#L28\n const sessionRecordingOptions: recordOptions<eventWithTime> = {\n // select set of rrweb config options we expose to our users\n // see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n blockClass: 'ph-no-capture',\n blockSelector: undefined,\n ignoreClass: 'ph-ignore-input',\n maskTextClass: 'ph-mask',\n maskTextSelector: undefined,\n maskTextFn: undefined,\n maskAllInputs: true,\n maskInputOptions: {},\n maskInputFn: undefined,\n slimDOMOptions: {},\n collectFonts: false,\n inlineStylesheet: true,\n recordCrossOriginIframes: false,\n }\n\n // only allows user to set our allow-listed options\n const userSessionRecordingOptions = this.instance.config.session_recording\n for (const [key, value] of Object.entries(userSessionRecordingOptions || {})) {\n if (key in sessionRecordingOptions) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n sessionRecordingOptions[key] = value\n }\n }\n\n if (this.canvasRecording && this.canvasRecording.enabled) {\n sessionRecordingOptions.recordCanvas = true\n sessionRecordingOptions.sampling = { canvas: this.canvasRecording.fps }\n sessionRecordingOptions.dataURLOptions = { type: 'image/webp', quality: this.canvasRecording.quality }\n }\n\n if (!this.rrwebRecord) {\n logger.error(\n LOGGER_PREFIX +\n 'onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.'\n )\n return\n }\n\n this.mutationRateLimiter =\n this.mutationRateLimiter ??\n new MutationRateLimiter(this.rrwebRecord, {\n onBlockedNode: (id, node) => {\n const message = `Too many mutations on node '${id}'. Rate limiting. This could be due to SVG animations or something similar`\n logger.info(message, {\n node: node,\n })\n\n this.log(LOGGER_PREFIX + ' ' + message, 'warn')\n },\n })\n\n const activePlugins = this._gatherRRWebPlugins()\n this.stopRrweb = this.rrwebRecord({\n emit: (event) => {\n this.onRRwebEmit(event)\n },\n plugins: activePlugins,\n ...sessionRecordingOptions,\n })\n\n // :TRICKY: rrweb does not capture navigation within SPA-s, so hook into our $pageview events to get access to all events.\n // Dropping the initial event is fine (it's always captured by rrweb).\n this.instance._addCaptureHook((eventName) => {\n // If anything could go wrong here it has the potential to block the main loop,\n // so we catch all errors.\n try {\n if (eventName === '$pageview') {\n const href = window ? this._maskUrl(window.location.href) : ''\n if (!href) {\n return\n }\n this._tryAddCustomEvent('$pageview', { href })\n this._tryTakeFullSnapshot()\n }\n } catch (e) {\n logger.error('Could not add $pageview to rrweb session', e)\n }\n })\n\n // We reset the last activity timestamp, resetting the idle timer\n this._lastActivityTimestamp = Date.now()\n this.isIdle = false\n\n this._tryAddCustomEvent('$session_options', {\n sessionRecordingOptions,\n activePlugins: activePlugins.map((p) => p?.name),\n })\n\n this._tryAddCustomEvent('$posthog_config', {\n config: this.instance.config,\n })\n }\n\n private _scheduleFullSnapshot(): void {\n if (this._fullSnapshotTimer) {\n clearInterval(this._fullSnapshotTimer)\n }\n\n this._fullSnapshotTimer = setInterval(() => {\n this._tryTakeFullSnapshot()\n }, FIVE_MINUTES) // 5 minutes\n }\n\n private _gatherRRWebPlugins() {\n const plugins: RecordPlugin<unknown>[] = []\n\n if (assignableWindow.rrwebConsoleRecord && this.isConsoleLogCaptureEnabled) {\n plugins.push(assignableWindow.rrwebConsoleRecord.getRecordConsolePlugin())\n }\n\n if (this.networkPayloadCapture && isFunction(assignableWindow.getRecordNetworkPlugin)) {\n const canRecordNetwork = !isLocalhost() || this._forceAllowLocalhostNetworkCapture\n\n if (canRecordNetwork) {\n plugins.push(\n assignableWindow.getRecordNetworkPlugin(\n buildNetworkRequestOptions(this.instance.config, this.networkPayloadCapture)\n )\n )\n } else {\n logger.info(LOGGER_PREFIX + ' NetworkCapture not started because we are on localhost.')\n }\n }\n\n return plugins\n }\n\n onRRwebEmit(rawEvent: eventWithTime) {\n this._processQueuedEvents()\n\n if (!rawEvent || !isObject(rawEvent)) {\n return\n }\n\n if (rawEvent.type === EventType.Meta) {\n const href = this._maskUrl(rawEvent.data.href)\n this._lastHref = href\n if (!href) {\n return\n }\n rawEvent.data.href = href\n } else {\n this._pageViewFallBack()\n }\n\n if (rawEvent.type === EventType.FullSnapshot) {\n // we're processing a full snapshot, so we should reset the timer\n this._scheduleFullSnapshot()\n }\n\n const throttledEvent = this.mutationRateLimiter\n ? this.mutationRateLimiter.throttleMutations(rawEvent)\n : rawEvent\n\n if (!throttledEvent) {\n return\n }\n\n // TODO: Re-add ensureMaxMessageSize once we are confident in it\n const event = truncateLargeConsoleLogs(throttledEvent)\n const size = JSON.stringify(event).length\n\n this._updateWindowAndSessionIds(event)\n\n // allow custom events even when idle\n if (this.isIdle && event.type !== EventType.Custom) {\n // When in an idle state we keep recording, but don't capture the events\n return\n }\n\n const properties = {\n $snapshot_bytes: size,\n $snapshot_data: event,\n $session_id: this.sessionId,\n $window_id: this.windowId,\n }\n\n if (this.status !== 'disabled') {\n this._captureSnapshotBuffered(properties)\n } else {\n this.clearBuffer()\n }\n }\n\n private _pageViewFallBack() {\n if (this.instance.config.capture_pageview || !window) {\n return\n }\n const currentUrl = this._maskUrl(window.location.href)\n if (this._lastHref !== currentUrl) {\n this._tryAddCustomEvent('$url_changed', { href: currentUrl })\n this._lastHref = currentUrl\n }\n }\n\n private _processQueuedEvents() {\n if (this.queuedRRWebEvents.length) {\n // if rrweb isn't ready to accept events earlier then we queued them up\n // now that emit has been called rrweb should be ready to accept them\n // so, before we process this event, we try our queued events _once_ each\n // we don't want to risk queuing more things and never exiting this loop!\n // if they fail here, they'll be pushed into a new queue,\n // and tried on the next loop.\n // there is a risk of this queue growing in an uncontrolled manner,\n // so its length is limited elsewhere\n // for now this is to help us ensure we can capture events that happen\n // and try to identify more about when it is failing\n const itemsToProcess = [...this.queuedRRWebEvents]\n this.queuedRRWebEvents = []\n itemsToProcess.forEach((queuedRRWebEvent) => {\n if (Date.now() - queuedRRWebEvent.enqueuedAt > TWO_SECONDS) {\n this._tryAddCustomEvent('rrwebQueueTimeout', {\n enqueuedAt: queuedRRWebEvent.enqueuedAt,\n attempt: queuedRRWebEvent.attempt,\n queueLength: itemsToProcess.length,\n })\n } else {\n if (this._tryRRWebMethod(queuedRRWebEvent)) {\n this._tryAddCustomEvent('rrwebQueueSuccess', {\n enqueuedAt: queuedRRWebEvent.enqueuedAt,\n attempt: queuedRRWebEvent.attempt,\n queueLength: itemsToProcess.length,\n })\n }\n }\n })\n }\n }\n\n private _maskUrl(url: string): string | undefined {\n const userSessionRecordingOptions = this.instance.config.session_recording\n\n if (userSessionRecordingOptions.maskNetworkRequestFn) {\n let networkRequest: NetworkRequest | null | undefined = {\n url,\n }\n\n // TODO we should deprecate this and use the same function for this masking and the rrweb/network plugin\n // TODO or deprecate this and provide a new clearer name so this would be `maskURLPerformanceFn` or similar\n networkRequest = userSessionRecordingOptions.maskNetworkRequestFn(networkRequest)\n\n return networkRequest?.url\n }\n\n return url\n }\n\n private clearBuffer(): void {\n this.buffer = new InMemoryBuffer(this.sessionId, this.windowId)\n }\n\n private _flushBuffer(): void {\n if (this.flushBufferTimer) {\n clearTimeout(this.flushBufferTimer)\n this.flushBufferTimer = undefined\n }\n\n const minimumDuration = this.minimumDuration\n const sessionDuration = this.sessionDuration\n // if we have old data in the buffer but the session has rotated then the\n // session duration might be negative, in that case we want to flush the buffer\n const isPositiveSessionDuration = isNumber(sessionDuration) && sessionDuration >= 0\n const isBelowMinimumDuration =\n isNumber(minimumDuration) && isPositiveSessionDuration && sessionDuration < minimumDuration\n\n if (this.status === 'buffering' || isBelowMinimumDuration) {\n this.flushBufferTimer = setTimeout(() => {\n this._flushBuffer()\n }, RECORDING_BUFFER_TIMEOUT)\n\n return\n }\n\n if (this.buffer.data.length > 0) {\n this._captureSnapshot({\n $snapshot_bytes: this.buffer.size,\n $snapshot_data: this.buffer.data,\n $session_id: this.buffer.sessionId,\n $window_id: this.buffer.windowId,\n })\n }\n this.clearBuffer()\n }\n\n private _captureSnapshotBuffered(properties: Properties) {\n const additionalBytes = 2 + (this.buffer?.data.length || 0) // 2 bytes for the array brackets and 1 byte for each comma\n if (\n this.buffer.size + properties.$snapshot_bytes + additionalBytes > RECORDING_MAX_EVENT_SIZE ||\n this.buffer.sessionId !== this.sessionId\n ) {\n this._flushBuffer()\n }\n\n this.buffer.add(properties)\n if (!this.flushBufferTimer) {\n this.flushBufferTimer = setTimeout(() => {\n this._flushBuffer()\n }, RECORDING_BUFFER_TIMEOUT)\n }\n }\n\n private _captureSnapshot(properties: Properties) {\n // :TRICKY: Make sure we batch these requests, use a custom endpoint and don't truncate the strings.\n this.instance.capture('$snapshot', properties, {\n _url: this.instance.requestRouter.endpointFor('api', this._endpoint),\n _noTruncate: true,\n _batchKey: SESSION_RECORDING_BATCH_KEY,\n _noHeatmaps: true, // Session Replay ingestion can't handle heatamap data\n })\n }\n}\n"]}
1
+ {"version":3,"file":"sessionrecording.js","sourceRoot":"","sources":["../../../../src/extensions/replay/sessionrecording.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACH,yCAAyC,EACzC,kCAAkC,EAClC,qCAAqC,EACrC,4BAA4B,EAC5B,kCAAkC,EAClC,yCAAyC,EACzC,6BAA6B,GAChC,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACH,wBAAwB,EACxB,+BAA+B,EAC/B,eAAe,EACf,mBAAmB,EAGnB,wBAAwB,GAC3B,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EAAE,SAAS,EAA0D,MAAM,cAAc,CAAA;AAChG,OAAO,MAAM,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ED,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QAC3B,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE;YACxB,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC;gBAC/B,KAAI,CAAC,YAAY,EAAE,CAAA;YACvB,CAAC,EAAE,wBAAwB,CAAC,CAAA;SAC/B;IACL,CAAC;IAEO,2CAAgB,GAAxB,UAAyB,UAAsB;QAC3C,oGAAoG;QACpG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE;YAC3C,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC;YACpE,WAAW,EAAE,IAAI;YACjB,SAAS,EAAE,2BAA2B;YACtC,WAAW,EAAE,IAAI,EAAE,sDAAsD;SAC5E,CAAC,CAAA;IACN,CAAC;IACL,uBAAC;AAAD,CAAC,AA7xBD,IA6xBC","sourcesContent":["import {\n CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE,\n SESSION_RECORDING_CANVAS_RECORDING,\n SESSION_RECORDING_ENABLED_SERVER_SIDE,\n SESSION_RECORDING_IS_SAMPLED,\n SESSION_RECORDING_MINIMUM_DURATION,\n SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE,\n SESSION_RECORDING_SAMPLE_RATE,\n} from '../../constants'\nimport {\n FULL_SNAPSHOT_EVENT_TYPE,\n INCREMENTAL_SNAPSHOT_EVENT_TYPE,\n META_EVENT_TYPE,\n MutationRateLimiter,\n recordOptions,\n rrwebRecord,\n truncateLargeConsoleLogs,\n} from './sessionrecording-utils'\nimport { PostHog } from '../../posthog-core'\nimport { DecideResponse, FlagVariant, NetworkRecordOptions, NetworkRequest, Properties } from '../../types'\nimport { EventType, type eventWithTime, type listenerHandler, RecordPlugin } from '@rrweb/types'\nimport Config from '../../config'\nimport { timestamp, loadScript } from '../../utils'\n\nimport {\n isBoolean,\n isFunction,\n isNull,\n isNullish,\n isNumber,\n isObject,\n isString,\n isUndefined,\n} from '../../utils/type-utils'\nimport { logger } from '../../utils/logger'\nimport { document, assignableWindow, window } from '../../utils/globals'\nimport { buildNetworkRequestOptions } from './config'\nimport { isLocalhost } from '../../utils/request-utils'\n\nconst BASE_ENDPOINT = '/s/'\n\nconst FIVE_MINUTES = 1000 * 60 * 5\nconst TWO_SECONDS = 2000\nexport const RECORDING_IDLE_ACTIVITY_TIMEOUT_MS = FIVE_MINUTES\nexport const RECORDING_MAX_EVENT_SIZE = 1024 * 1024 * 0.9 // ~1mb (with some wiggle room)\nexport const RECORDING_BUFFER_TIMEOUT = 2000 // 2 seconds\nexport const SESSION_RECORDING_BATCH_KEY = 'recordings'\n\n// NOTE: Importing this type is problematic as we can't safely bundle it to a TS definition so, instead we redefine.\n// import type { record } from 'rrweb2/typings'\n// import type { recordOptions } from 'rrweb/typings/types'\n\n// Copied from rrweb typings to avoid import\nenum IncrementalSource {\n Mutation = 0,\n MouseMove = 1,\n MouseInteraction = 2,\n Scroll = 3,\n ViewportResize = 4,\n Input = 5,\n TouchMove = 6,\n MediaInteraction = 7,\n StyleSheetRule = 8,\n CanvasMutation = 9,\n Font = 10,\n Log = 11,\n Drag = 12,\n StyleDeclaration = 13,\n Selection = 14,\n AdoptedStyleSheet = 15,\n}\n\nconst ACTIVE_SOURCES = [\n IncrementalSource.MouseMove,\n IncrementalSource.MouseInteraction,\n IncrementalSource.Scroll,\n IncrementalSource.ViewportResize,\n IncrementalSource.Input,\n IncrementalSource.TouchMove,\n IncrementalSource.MediaInteraction,\n IncrementalSource.Drag,\n]\n\n/**\n * Session recording starts in buffering mode while waiting for decide response\n * Once the response is received it might be disabled, active or sampled\n * When sampled that means a sample rate is set and the last time the session id was rotated\n * the sample rate determined this session should be sent to the server.\n */\ntype SessionRecordingStatus = 'disabled' | 'sampled' | 'active' | 'buffering'\n\ninterface SnapshotBuffer {\n size: number\n data: any[]\n sessionId: string\n windowId: string\n\n readonly mostRecentSnapshotTimestamp: number | null\n add(properties: Properties): void\n}\n\nclass InMemoryBuffer implements SnapshotBuffer {\n size: number\n data: any[]\n sessionId: string\n windowId: string\n\n get mostRecentSnapshotTimestamp(): number | null {\n return this.data.length ? this.data[this.data.length - 1].timestamp : null\n }\n\n constructor(sessionId: string, windowId: string) {\n this.size = 0\n this.data = []\n this.sessionId = sessionId\n this.windowId = windowId\n }\n\n add(properties: Properties) {\n this.size += properties.$snapshot_bytes\n this.data.push(properties.$snapshot_data)\n }\n}\n\ninterface QueuedRRWebEvent {\n rrwebMethod: () => void\n attempt: number\n // the timestamp this was first put into this queue\n enqueuedAt: number\n}\n\nconst newQueuedEvent = (rrwebMethod: () => void): QueuedRRWebEvent => ({\n rrwebMethod,\n enqueuedAt: Date.now(),\n attempt: 1,\n})\n\nconst LOGGER_PREFIX = '[SessionRecording]'\n\nexport class SessionRecording {\n private _endpoint: string\n private flushBufferTimer?: any\n\n // we have a buffer - that contains PostHog snapshot events ready to be sent to the server\n private buffer: SnapshotBuffer\n // and a queue - that contains rrweb events that we want to send to rrweb, but rrweb wasn't able to accept them yet\n private queuedRRWebEvents: QueuedRRWebEvent[] = []\n\n private mutationRateLimiter?: MutationRateLimiter\n private _captureStarted: boolean\n private stopRrweb: listenerHandler | undefined\n private receivedDecide: boolean\n private isIdle = false\n\n private _linkedFlagSeen: boolean = false\n private _lastActivityTimestamp: number = Date.now()\n private windowId: string\n private sessionId: string\n private _linkedFlag: string | FlagVariant | null = null\n\n private _fullSnapshotTimer?: ReturnType<typeof setInterval>\n\n // if pageview capture is disabled\n // then we can manually track href changes\n private _lastHref?: string\n\n // Util to help developers working on this feature manually override\n _forceAllowLocalhostNetworkCapture = false\n\n private get rrwebRecord(): rrwebRecord | undefined {\n return assignableWindow?.rrweb?.record\n }\n\n public get started(): boolean {\n // TODO could we use status instead of _captureStarted?\n return this._captureStarted\n }\n\n private get sessionManager() {\n if (!this.instance.sessionManager) {\n throw new Error(LOGGER_PREFIX + ' started without valid sessionManager. This is a bug.')\n }\n\n return this.instance.sessionManager\n }\n\n private get isSampled(): boolean | null {\n const currentValue = this.instance.get_property(SESSION_RECORDING_IS_SAMPLED)\n return isBoolean(currentValue) ? currentValue : null\n }\n\n private get sessionDuration(): number | null {\n const mostRecentSnapshotTimestamp = this.buffer.mostRecentSnapshotTimestamp\n const { sessionStartTimestamp } = this.sessionManager.checkAndGetSessionAndWindowId(true)\n return mostRecentSnapshotTimestamp ? mostRecentSnapshotTimestamp - sessionStartTimestamp : null\n }\n\n private get isRecordingEnabled() {\n const enabled_server_side = !!this.instance.get_property(SESSION_RECORDING_ENABLED_SERVER_SIDE)\n const enabled_client_side = !this.instance.config.disable_session_recording\n return window && enabled_server_side && enabled_client_side\n }\n\n private get isConsoleLogCaptureEnabled() {\n const enabled_server_side = !!this.instance.get_property(CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE)\n const enabled_client_side = this.instance.config.enable_recording_console_log\n return enabled_client_side ?? enabled_server_side\n }\n\n private get canvasRecording(): { enabled: boolean; fps: number; quality: number } | undefined {\n const canvasRecording_server_side = this.instance.get_property(SESSION_RECORDING_CANVAS_RECORDING)\n return canvasRecording_server_side && canvasRecording_server_side.fps && canvasRecording_server_side.quality\n ? {\n enabled: canvasRecording_server_side.enabled,\n fps: canvasRecording_server_side.fps,\n quality: canvasRecording_server_side.quality,\n }\n : undefined\n }\n\n // network payload capture config has three parts\n // each can be configured server side or client side\n private get networkPayloadCapture():\n | Pick<NetworkRecordOptions, 'recordHeaders' | 'recordBody' | 'recordPerformance'>\n | undefined {\n const networkPayloadCapture_server_side = this.instance.get_property(SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE)\n const networkPayloadCapture_client_side = {\n recordHeaders: this.instance.config.session_recording?.recordHeaders,\n recordBody: this.instance.config.session_recording?.recordBody,\n }\n const headersEnabled =\n networkPayloadCapture_client_side?.recordHeaders || networkPayloadCapture_server_side?.recordHeaders\n const bodyEnabled =\n networkPayloadCapture_client_side?.recordBody || networkPayloadCapture_server_side?.recordBody\n const performanceEnabled =\n this.instance.config.capture_performance || networkPayloadCapture_server_side?.capturePerformance\n\n return headersEnabled || bodyEnabled || performanceEnabled\n ? { recordHeaders: headersEnabled, recordBody: bodyEnabled, recordPerformance: performanceEnabled }\n : undefined\n }\n\n private get sampleRate(): number | null {\n const rate = this.instance.get_property(SESSION_RECORDING_SAMPLE_RATE)\n return isNumber(rate) ? rate : null\n }\n\n private get minimumDuration(): number | null {\n const duration = this.instance.get_property(SESSION_RECORDING_MINIMUM_DURATION)\n return isNumber(duration) ? duration : null\n }\n\n /**\n * defaults to buffering mode until a decide response is received\n * once a decide response is received status can be disabled, active or sampled\n */\n private get status(): SessionRecordingStatus {\n if (!this.receivedDecide) {\n return 'buffering'\n }\n\n if (!this.isRecordingEnabled) {\n return 'disabled'\n }\n\n if (!isNullish(this._linkedFlag) && !this._linkedFlagSeen) {\n return 'buffering'\n }\n\n if (isBoolean(this.isSampled)) {\n return this.isSampled ? 'sampled' : 'disabled'\n } else {\n return 'active'\n }\n }\n\n constructor(private readonly instance: PostHog) {\n this._captureStarted = false\n this._endpoint = BASE_ENDPOINT\n this.stopRrweb = undefined\n this.receivedDecide = false\n\n window?.addEventListener('beforeunload', () => {\n this._flushBuffer()\n })\n\n window?.addEventListener('offline', () => {\n this._tryAddCustomEvent('browser offline', {})\n })\n\n window?.addEventListener('online', () => {\n this._tryAddCustomEvent('browser online', {})\n })\n\n window?.addEventListener('visibilitychange', () => {\n if (document?.visibilityState) {\n const label = 'window ' + document.visibilityState\n this._tryAddCustomEvent(label, {})\n }\n })\n\n if (!this.instance.sessionManager) {\n logger.error(LOGGER_PREFIX + ' started without valid sessionManager')\n throw new Error(LOGGER_PREFIX + ' started without valid sessionManager. This is a bug.')\n }\n\n // we know there's a sessionManager, so don't need to start without a session id\n const { sessionId, windowId } = this.sessionManager.checkAndGetSessionAndWindowId()\n this.sessionId = sessionId\n this.windowId = windowId\n\n this.buffer = new InMemoryBuffer(this.sessionId, this.windowId)\n\n // on reload there might be an already sampled session that should be continued before decide response,\n // so we call this here _and_ in the decide response\n this._setupSampling()\n }\n\n startIfEnabledOrStop() {\n if (this.isRecordingEnabled) {\n this._startCapture()\n logger.info(LOGGER_PREFIX + ' started')\n } else {\n this.stopRecording()\n this.clearBuffer()\n }\n }\n\n stopRecording() {\n if (this._captureStarted && this.stopRrweb) {\n this.stopRrweb()\n this.stopRrweb = undefined\n this._captureStarted = false\n logger.info(LOGGER_PREFIX + ' stopped')\n }\n }\n\n private makeSamplingDecision(sessionId: string): void {\n const sessionIdChanged = this.sessionId !== sessionId\n\n // capture the current sample rate,\n // because it is re-used multiple times\n // and the bundler won't minimise any of the references\n const currentSampleRate = this.sampleRate\n\n if (!isNumber(currentSampleRate)) {\n this.instance.persistence?.register({\n [SESSION_RECORDING_IS_SAMPLED]: null,\n })\n return\n }\n\n const storedIsSampled = this.isSampled\n\n /**\n * if we get this far then we should make a sampling decision.\n * When the session id changes or there is no stored sampling decision for this session id\n * then we should make a new decision.\n *\n * Otherwise, we should use the stored decision.\n */\n let shouldSample: boolean\n const makeDecision = sessionIdChanged || !isBoolean(storedIsSampled)\n if (makeDecision) {\n const randomNumber = Math.random()\n shouldSample = randomNumber < currentSampleRate\n } else {\n shouldSample = storedIsSampled\n }\n\n if (!shouldSample && makeDecision) {\n logger.warn(\n LOGGER_PREFIX +\n ` Sample rate (${currentSampleRate}) has determined that this sessionId (${sessionId}) will not be sent to the server.`\n )\n }\n this._tryAddCustomEvent('samplingDecisionMade', {\n sampleRate: currentSampleRate,\n })\n\n this.instance.persistence?.register({\n [SESSION_RECORDING_IS_SAMPLED]: shouldSample,\n })\n }\n\n afterDecideResponse(response: DecideResponse) {\n this._persistDecideResponse(response)\n\n this._linkedFlag = response.sessionRecording?.linkedFlag || null\n\n if (response.sessionRecording?.endpoint) {\n this._endpoint = response.sessionRecording?.endpoint\n }\n\n this._setupSampling()\n\n if (!isNullish(this._linkedFlag)) {\n const linkedFlag = isString(this._linkedFlag) ? this._linkedFlag : this._linkedFlag.flag\n const linkedVariant = isString(this._linkedFlag) ? null : this._linkedFlag.variant\n this.instance.onFeatureFlags((_flags, variants) => {\n const flagIsPresent = isObject(variants) && linkedFlag in variants\n const linkedFlagMatches = linkedVariant ? variants[linkedFlag] === linkedVariant : flagIsPresent\n if (linkedFlagMatches) {\n const payload = {\n linkedFlag,\n linkedVariant,\n }\n const tag = 'linked flag matched'\n logger.info(LOGGER_PREFIX + ' ' + tag, payload)\n this._tryAddCustomEvent(tag, payload)\n }\n this._linkedFlagSeen = linkedFlagMatches\n })\n }\n\n this.receivedDecide = true\n this.startIfEnabledOrStop()\n }\n\n private _samplingSessionListener: (() => void) | null = null\n\n /**\n * This might be called more than once so needs to be idempotent\n */\n private _setupSampling() {\n if (isNumber(this.sampleRate) && isNull(this._samplingSessionListener)) {\n this._samplingSessionListener = this.sessionManager.onSessionId((sessionId) => {\n this.makeSamplingDecision(sessionId)\n })\n }\n }\n\n private _persistDecideResponse(response: DecideResponse): void {\n if (this.instance.persistence) {\n const persistence = this.instance.persistence\n\n const persistResponse = () => {\n const receivedSampleRate = response.sessionRecording?.sampleRate\n\n const parsedSampleRate = isNullish(receivedSampleRate) ? null : parseFloat(receivedSampleRate)\n const receivedMinimumDuration = response.sessionRecording?.minimumDurationMilliseconds\n\n persistence.register({\n [SESSION_RECORDING_ENABLED_SERVER_SIDE]: !!response['sessionRecording'],\n [CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE]: response.sessionRecording?.consoleLogRecordingEnabled,\n [SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE]: {\n capturePerformance: response.capturePerformance,\n ...response.sessionRecording?.networkPayloadCapture,\n },\n [SESSION_RECORDING_CANVAS_RECORDING]: {\n enabled: response.sessionRecording?.recordCanvas,\n fps: response.sessionRecording?.canvasFps,\n quality: response.sessionRecording?.canvasQuality,\n },\n [SESSION_RECORDING_SAMPLE_RATE]: parsedSampleRate,\n [SESSION_RECORDING_MINIMUM_DURATION]: isUndefined(receivedMinimumDuration)\n ? null\n : receivedMinimumDuration,\n })\n }\n\n persistResponse()\n this.sessionManager.onSessionId(persistResponse)\n }\n }\n\n log(message: string, level: 'log' | 'warn' | 'error' = 'log') {\n this.instance.sessionRecording?.onRRwebEmit({\n type: 6,\n data: {\n plugin: 'rrweb/console@1',\n payload: {\n level,\n trace: [],\n // Even though it is a string we stringify it as that's what rrweb expects\n payload: [JSON.stringify(message)],\n },\n },\n timestamp: timestamp(),\n })\n }\n private _startCapture() {\n if (isUndefined(Object.assign)) {\n // According to the rrweb docs, rrweb is not supported on IE11 and below:\n // \"rrweb does not support IE11 and below because it uses the MutationObserver API which was supported by these browsers.\"\n // https://github.com/rrweb-io/rrweb/blob/master/guide.md#compatibility-note\n //\n // However, MutationObserver does exist on IE11, it just doesn't work well and does not detect all changes.\n // Instead, when we load \"recorder.js\", the first JS error is about \"Object.assign\" being undefined.\n // Thus instead of MutationObserver, we look for this function and block recording if it's undefined.\n return\n }\n\n // We do not switch recorder versions midway through a recording.\n // do not start if explicitly disabled or if the user has opted out\n if (\n this._captureStarted ||\n this.instance.config.disable_session_recording ||\n this.instance.consent.isOptedOut()\n ) {\n return\n }\n\n this._captureStarted = true\n // We want to ensure the sessionManager is reset if necessary on load of the recorder\n this.sessionManager.checkAndGetSessionAndWindowId()\n\n // If recorder.js is already loaded (if array.full.js snippet is used or posthog-js/dist/recorder is\n // imported), don't load script. Otherwise, remotely import recorder.js from cdn since it hasn't been loaded.\n if (!this.rrwebRecord) {\n loadScript(\n this.instance.requestRouter.endpointFor('assets', `/static/recorder.js?v=${Config.LIB_VERSION}`),\n (err) => {\n if (err) {\n return logger.error(LOGGER_PREFIX + ` could not load recorder.js`, err)\n }\n\n this._onScriptLoaded()\n }\n )\n } else {\n this._onScriptLoaded()\n }\n }\n\n private isInteractiveEvent(event: eventWithTime) {\n return (\n event.type === INCREMENTAL_SNAPSHOT_EVENT_TYPE &&\n ACTIVE_SOURCES.indexOf(event.data?.source as IncrementalSource) !== -1\n )\n }\n\n private _updateWindowAndSessionIds(event: eventWithTime) {\n // Some recording events are triggered by non-user events (e.g. \"X minutes ago\" text updating on the screen).\n // We don't want to extend the session or trigger a new session in these cases. These events are designated by event\n // type -> incremental update, and source -> mutation.\n\n const isUserInteraction = this.isInteractiveEvent(event)\n\n if (!isUserInteraction && !this.isIdle) {\n // We check if the lastActivityTimestamp is old enough to go idle\n if (event.timestamp - this._lastActivityTimestamp > RECORDING_IDLE_ACTIVITY_TIMEOUT_MS) {\n this.isIdle = true\n this._tryAddCustomEvent('sessionIdle', {\n reason: 'user inactivity',\n timeSinceLastActive: event.timestamp - this._lastActivityTimestamp,\n threshold: RECORDING_IDLE_ACTIVITY_TIMEOUT_MS,\n })\n // don't take full snapshots while idle\n clearTimeout(this._fullSnapshotTimer)\n }\n }\n\n let returningFromIdle = false\n if (isUserInteraction) {\n this._lastActivityTimestamp = event.timestamp\n if (this.isIdle) {\n // Remove the idle state if set and trigger a full snapshot as we will have ignored previous mutations\n this.isIdle = false\n this._tryAddCustomEvent('sessionNoLongerIdle', {\n reason: 'user activity',\n type: event.type,\n })\n returningFromIdle = true\n }\n }\n\n if (this.isIdle) {\n return\n }\n\n // We only want to extend the session if it is an interactive event.\n const { windowId, sessionId } = this.sessionManager.checkAndGetSessionAndWindowId(\n !isUserInteraction,\n event.timestamp\n )\n\n const sessionIdChanged = this.sessionId !== sessionId\n const windowIdChanged = this.windowId !== windowId\n\n this.windowId = windowId\n this.sessionId = sessionId\n\n if (\n returningFromIdle ||\n ([FULL_SNAPSHOT_EVENT_TYPE, META_EVENT_TYPE].indexOf(event.type) === -1 &&\n (windowIdChanged || sessionIdChanged || isUndefined(this._fullSnapshotTimer)))\n ) {\n this._tryTakeFullSnapshot()\n }\n }\n\n private _tryRRWebMethod(queuedRRWebEvent: QueuedRRWebEvent): boolean {\n try {\n queuedRRWebEvent.rrwebMethod()\n return true\n } catch (e) {\n // Sometimes a race can occur where the recorder is not fully started yet\n if (this.queuedRRWebEvents.length < 10) {\n this.queuedRRWebEvents.push({\n enqueuedAt: queuedRRWebEvent.enqueuedAt || Date.now(),\n attempt: queuedRRWebEvent.attempt++,\n rrwebMethod: queuedRRWebEvent.rrwebMethod,\n })\n } else {\n logger.warn(LOGGER_PREFIX + ' could not emit queued rrweb event.', e, queuedRRWebEvent)\n }\n\n return false\n }\n }\n\n private _tryAddCustomEvent(tag: string, payload: any): boolean {\n return this._tryRRWebMethod(newQueuedEvent(() => this.rrwebRecord!.addCustomEvent(tag, payload)))\n }\n\n private _tryTakeFullSnapshot(): boolean {\n return this._tryRRWebMethod(newQueuedEvent(() => this.rrwebRecord!.takeFullSnapshot()))\n }\n\n private _onScriptLoaded() {\n // rrweb config info: https://github.com/rrweb-io/rrweb/blob/7d5d0033258d6c29599fb08412202d9a2c7b9413/src/record/index.ts#L28\n const sessionRecordingOptions: recordOptions<eventWithTime> = {\n // select set of rrweb config options we expose to our users\n // see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n blockClass: 'ph-no-capture',\n blockSelector: undefined,\n ignoreClass: 'ph-ignore-input',\n maskTextClass: 'ph-mask',\n maskTextSelector: undefined,\n maskTextFn: undefined,\n maskAllInputs: true,\n maskInputOptions: {},\n maskInputFn: undefined,\n slimDOMOptions: {},\n collectFonts: false,\n inlineStylesheet: true,\n recordCrossOriginIframes: false,\n }\n\n // only allows user to set our allow-listed options\n const userSessionRecordingOptions = this.instance.config.session_recording\n for (const [key, value] of Object.entries(userSessionRecordingOptions || {})) {\n if (key in sessionRecordingOptions) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n sessionRecordingOptions[key] = value\n }\n }\n\n if (this.canvasRecording && this.canvasRecording.enabled) {\n sessionRecordingOptions.recordCanvas = true\n sessionRecordingOptions.sampling = { canvas: this.canvasRecording.fps }\n sessionRecordingOptions.dataURLOptions = { type: 'image/webp', quality: this.canvasRecording.quality }\n }\n\n if (!this.rrwebRecord) {\n logger.error(\n LOGGER_PREFIX +\n 'onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.'\n )\n return\n }\n\n this.mutationRateLimiter =\n this.mutationRateLimiter ??\n new MutationRateLimiter(this.rrwebRecord, {\n onBlockedNode: (id, node) => {\n const message = `Too many mutations on node '${id}'. Rate limiting. This could be due to SVG animations or something similar`\n logger.info(message, {\n node: node,\n })\n\n this.log(LOGGER_PREFIX + ' ' + message, 'warn')\n },\n })\n\n const activePlugins = this._gatherRRWebPlugins()\n this.stopRrweb = this.rrwebRecord({\n emit: (event) => {\n this.onRRwebEmit(event)\n },\n plugins: activePlugins,\n ...sessionRecordingOptions,\n })\n\n // :TRICKY: rrweb does not capture navigation within SPA-s, so hook into our $pageview events to get access to all events.\n // Dropping the initial event is fine (it's always captured by rrweb).\n this.instance._addCaptureHook((eventName) => {\n // If anything could go wrong here it has the potential to block the main loop,\n // so we catch all errors.\n try {\n if (eventName === '$pageview') {\n const href = window ? this._maskUrl(window.location.href) : ''\n if (!href) {\n return\n }\n this._tryAddCustomEvent('$pageview', { href })\n this._tryTakeFullSnapshot()\n }\n } catch (e) {\n logger.error('Could not add $pageview to rrweb session', e)\n }\n })\n\n // We reset the last activity timestamp, resetting the idle timer\n this._lastActivityTimestamp = Date.now()\n this.isIdle = false\n\n this._tryAddCustomEvent('$session_options', {\n sessionRecordingOptions,\n activePlugins: activePlugins.map((p) => p?.name),\n })\n\n this._tryAddCustomEvent('$posthog_config', {\n config: this.instance.config,\n })\n }\n\n private _scheduleFullSnapshot(): void {\n if (this._fullSnapshotTimer) {\n clearInterval(this._fullSnapshotTimer)\n }\n\n this._fullSnapshotTimer = setInterval(() => {\n this._tryTakeFullSnapshot()\n }, FIVE_MINUTES) // 5 minutes\n }\n\n private _gatherRRWebPlugins() {\n const plugins: RecordPlugin<unknown>[] = []\n\n if (assignableWindow.rrwebConsoleRecord && this.isConsoleLogCaptureEnabled) {\n plugins.push(assignableWindow.rrwebConsoleRecord.getRecordConsolePlugin())\n }\n\n if (this.networkPayloadCapture && isFunction(assignableWindow.getRecordNetworkPlugin)) {\n const canRecordNetwork = !isLocalhost() || this._forceAllowLocalhostNetworkCapture\n\n if (canRecordNetwork) {\n plugins.push(\n assignableWindow.getRecordNetworkPlugin(\n buildNetworkRequestOptions(this.instance.config, this.networkPayloadCapture)\n )\n )\n } else {\n logger.info(LOGGER_PREFIX + ' NetworkCapture not started because we are on localhost.')\n }\n }\n\n return plugins\n }\n\n onRRwebEmit(rawEvent: eventWithTime) {\n this._processQueuedEvents()\n\n if (!rawEvent || !isObject(rawEvent)) {\n return\n }\n\n if (rawEvent.type === EventType.Meta) {\n const href = this._maskUrl(rawEvent.data.href)\n this._lastHref = href\n if (!href) {\n return\n }\n rawEvent.data.href = href\n } else {\n this._pageViewFallBack()\n }\n\n if (rawEvent.type === EventType.FullSnapshot) {\n // we're processing a full snapshot, so we should reset the timer\n this._scheduleFullSnapshot()\n }\n\n const throttledEvent = this.mutationRateLimiter\n ? this.mutationRateLimiter.throttleMutations(rawEvent)\n : rawEvent\n\n if (!throttledEvent) {\n return\n }\n\n // TODO: Re-add ensureMaxMessageSize once we are confident in it\n const event = truncateLargeConsoleLogs(throttledEvent)\n const size = JSON.stringify(event).length\n\n this._updateWindowAndSessionIds(event)\n\n // allow custom events even when idle\n if (this.isIdle && event.type !== EventType.Custom) {\n // When in an idle state we keep recording, but don't capture the events\n return\n }\n\n const properties = {\n $snapshot_bytes: size,\n $snapshot_data: event,\n $session_id: this.sessionId,\n $window_id: this.windowId,\n }\n\n if (this.status !== 'disabled') {\n this._captureSnapshotBuffered(properties)\n } else {\n this.clearBuffer()\n }\n }\n\n private _pageViewFallBack() {\n if (this.instance.config.capture_pageview || !window) {\n return\n }\n const currentUrl = this._maskUrl(window.location.href)\n if (this._lastHref !== currentUrl) {\n this._tryAddCustomEvent('$url_changed', { href: currentUrl })\n this._lastHref = currentUrl\n }\n }\n\n private _processQueuedEvents() {\n if (this.queuedRRWebEvents.length) {\n // if rrweb isn't ready to accept events earlier then we queued them up\n // now that emit has been called rrweb should be ready to accept them\n // so, before we process this event, we try our queued events _once_ each\n // we don't want to risk queuing more things and never exiting this loop!\n // if they fail here, they'll be pushed into a new queue,\n // and tried on the next loop.\n // there is a risk of this queue growing in an uncontrolled manner,\n // so its length is limited elsewhere\n // for now this is to help us ensure we can capture events that happen\n // and try to identify more about when it is failing\n const itemsToProcess = [...this.queuedRRWebEvents]\n this.queuedRRWebEvents = []\n itemsToProcess.forEach((queuedRRWebEvent) => {\n if (Date.now() - queuedRRWebEvent.enqueuedAt > TWO_SECONDS) {\n this._tryAddCustomEvent('rrwebQueueTimeout', {\n enqueuedAt: queuedRRWebEvent.enqueuedAt,\n attempt: queuedRRWebEvent.attempt,\n queueLength: itemsToProcess.length,\n })\n } else {\n if (this._tryRRWebMethod(queuedRRWebEvent)) {\n this._tryAddCustomEvent('rrwebQueueSuccess', {\n enqueuedAt: queuedRRWebEvent.enqueuedAt,\n attempt: queuedRRWebEvent.attempt,\n queueLength: itemsToProcess.length,\n })\n }\n }\n })\n }\n }\n\n private _maskUrl(url: string): string | undefined {\n const userSessionRecordingOptions = this.instance.config.session_recording\n\n if (userSessionRecordingOptions.maskNetworkRequestFn) {\n let networkRequest: NetworkRequest | null | undefined = {\n url,\n }\n\n // TODO we should deprecate this and use the same function for this masking and the rrweb/network plugin\n // TODO or deprecate this and provide a new clearer name so this would be `maskURLPerformanceFn` or similar\n networkRequest = userSessionRecordingOptions.maskNetworkRequestFn(networkRequest)\n\n return networkRequest?.url\n }\n\n return url\n }\n\n private clearBuffer(): void {\n this.buffer = new InMemoryBuffer(this.sessionId, this.windowId)\n }\n\n private _flushBuffer(): void {\n if (this.flushBufferTimer) {\n clearTimeout(this.flushBufferTimer)\n this.flushBufferTimer = undefined\n }\n\n const minimumDuration = this.minimumDuration\n const sessionDuration = this.sessionDuration\n // if we have old data in the buffer but the session has rotated then the\n // session duration might be negative, in that case we want to flush the buffer\n const isPositiveSessionDuration = isNumber(sessionDuration) && sessionDuration >= 0\n const isBelowMinimumDuration =\n isNumber(minimumDuration) && isPositiveSessionDuration && sessionDuration < minimumDuration\n\n if (this.status === 'buffering' || isBelowMinimumDuration) {\n this.flushBufferTimer = setTimeout(() => {\n this._flushBuffer()\n }, RECORDING_BUFFER_TIMEOUT)\n\n return\n }\n\n if (this.buffer.data.length > 0) {\n this._captureSnapshot({\n $snapshot_bytes: this.buffer.size,\n $snapshot_data: this.buffer.data,\n $session_id: this.buffer.sessionId,\n $window_id: this.buffer.windowId,\n })\n }\n this.clearBuffer()\n }\n\n private _captureSnapshotBuffered(properties: Properties) {\n const additionalBytes = 2 + (this.buffer?.data.length || 0) // 2 bytes for the array brackets and 1 byte for each comma\n if (\n this.buffer.size + properties.$snapshot_bytes + additionalBytes > RECORDING_MAX_EVENT_SIZE ||\n this.buffer.sessionId !== this.sessionId\n ) {\n this._flushBuffer()\n }\n\n this.buffer.add(properties)\n if (!this.flushBufferTimer) {\n this.flushBufferTimer = setTimeout(() => {\n this._flushBuffer()\n }, RECORDING_BUFFER_TIMEOUT)\n }\n }\n\n private _captureSnapshot(properties: Properties) {\n // :TRICKY: Make sure we batch these requests, use a custom endpoint and don't truncate the strings.\n this.instance.capture('$snapshot', properties, {\n _url: this.instance.requestRouter.endpointFor('api', this._endpoint),\n _noTruncate: true,\n _batchKey: SESSION_RECORDING_BATCH_KEY,\n _noHeatmaps: true, // Session Replay ingestion can't handle heatamap data\n })\n }\n}\n"]}
@@ -4,12 +4,12 @@ import { useContext } from 'preact/hooks';
4
4
  import { SurveyContext, defaultBackgroundColor, defaultSurveyAppearance, getContrastingTextColor, } from '../surveys-utils';
5
5
  export function BottomSection(_a) {
6
6
  var text = _a.text, submitDisabled = _a.submitDisabled, appearance = _a.appearance, onSubmit = _a.onSubmit, link = _a.link;
7
- var readOnly = useContext(SurveyContext).readOnly;
7
+ var isPreviewMode = useContext(SurveyContext).isPreviewMode;
8
8
  var textColor = getContrastingTextColor(appearance.submitButtonColor || defaultSurveyAppearance.submitButtonColor);
9
9
  return (<div className="bottom-section">
10
10
  <div className="buttons">
11
- <button className="form-submit" disabled={submitDisabled && !readOnly} type="button" style={{ color: textColor }} onClick={function () {
12
- if (readOnly)
11
+ <button className="form-submit" disabled={submitDisabled && !isPreviewMode} type="button" style={{ color: textColor }} onClick={function () {
12
+ if (isPreviewMode)
13
13
  return;
14
14
  if (link) {
15
15
  window === null || window === void 0 ? void 0 : window.open(link);
@@ -1 +1 @@
1
- {"version":3,"file":"BottomSection.jsx","sourceRoot":"","sources":["../../../../../src/extensions/surveys/components/BottomSection.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAI/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EACH,aAAa,EACb,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,GAC1B,MAAM,kBAAkB,CAAA;AAEzB,MAAM,UAAU,aAAa,CAAC,EAY7B;QAXG,IAAI,UAAA,EACJ,cAAc,oBAAA,EACd,UAAU,gBAAA,EACV,QAAQ,cAAA,EACR,IAAI,UAAA;IAQI,IAAA,QAAQ,GAAK,UAAU,CAAC,aAAa,CAAC,SAA9B,CAA8B;IAC9C,IAAM,SAAS,GAAG,uBAAuB,CAAC,UAAU,CAAC,iBAAiB,IAAI,uBAAuB,CAAC,iBAAiB,CAAC,CAAA;IACpH,OAAO,CACH,CAAC,GAAG,CAAC,SAAS,CAAC,gBAAgB,CAC3B;YAAA,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CACpB;gBAAA,CAAC,MAAM,CACH,SAAS,CAAC,aAAa,CACvB,QAAQ,CAAC,CAAC,cAAc,IAAI,CAAC,QAAQ,CAAC,CACtC,IAAI,CAAC,QAAQ,CACb,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAC5B,OAAO,CAAC,CAAC;YACL,IAAI,QAAQ;gBAAE,OAAM;YACpB,IAAI,IAAI,EAAE;gBACN,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,CAAC,IAAI,CAAC,CAAA;aACrB;YACD,QAAQ,EAAE,CAAA;QACd,CAAC,CAAC,CAEF;oBAAA,CAAC,IAAI,CACT;gBAAA,EAAE,MAAM,CACZ;YAAA,EAAE,GAAG,CACL;YAAA,CAAC,CAAC,UAAU,CAAC,UAAU,IAAI,CACvB,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,UAAU,CAAC,eAAe,IAAI,sBAAsB,CAAC,EAAG,CACzF,CACL;QAAA,EAAE,GAAG,CAAC,CACT,CAAA;AACL,CAAC","sourcesContent":["import { window } from '../../../utils/globals'\n\nimport { SurveyAppearance } from '../../../posthog-surveys-types'\n\nimport { PostHogLogo } from './PostHogLogo'\nimport { useContext } from 'preact/hooks'\nimport {\n SurveyContext,\n defaultBackgroundColor,\n defaultSurveyAppearance,\n getContrastingTextColor,\n} from '../surveys-utils'\n\nexport function BottomSection({\n text,\n submitDisabled,\n appearance,\n onSubmit,\n link,\n}: {\n text: string\n submitDisabled: boolean\n appearance: SurveyAppearance\n onSubmit: () => void\n link?: string | null\n}) {\n const { readOnly } = useContext(SurveyContext)\n const textColor = getContrastingTextColor(appearance.submitButtonColor || defaultSurveyAppearance.submitButtonColor)\n return (\n <div className=\"bottom-section\">\n <div className=\"buttons\">\n <button\n className=\"form-submit\"\n disabled={submitDisabled && !readOnly}\n type=\"button\"\n style={{ color: textColor }}\n onClick={() => {\n if (readOnly) return\n if (link) {\n window?.open(link)\n }\n onSubmit()\n }}\n >\n {text}\n </button>\n </div>\n {!appearance.whiteLabel && (\n <PostHogLogo backgroundColor={appearance.backgroundColor || defaultBackgroundColor} />\n )}\n </div>\n )\n}\n"]}
1
+ {"version":3,"file":"BottomSection.jsx","sourceRoot":"","sources":["../../../../../src/extensions/surveys/components/BottomSection.tsx"],"names":[],"mapp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AAG,CACzF,CACL;QAAA,EAAE,GAAG,CAAC,CACT,CAAA;AACL,CAAC","sourcesContent":["import { window } from '../../../utils/globals'\n\nimport { SurveyAppearance } from '../../../posthog-surveys-types'\n\nimport { PostHogLogo } from './PostHogLogo'\nimport { useContext } from 'preact/hooks'\nimport {\n SurveyContext,\n defaultBackgroundColor,\n defaultSurveyAppearance,\n getContrastingTextColor,\n} from '../surveys-utils'\n\nexport function BottomSection({\n text,\n submitDisabled,\n appearance,\n onSubmit,\n link,\n}: {\n text: string\n submitDisabled: boolean\n appearance: SurveyAppearance\n onSubmit: () => void\n link?: string | null\n}) {\n const { isPreviewMode } = useContext(SurveyContext)\n const textColor = getContrastingTextColor(appearance.submitButtonColor || defaultSurveyAppearance.submitButtonColor)\n return (\n <div className=\"bottom-section\">\n <div className=\"buttons\">\n <button\n className=\"form-submit\"\n disabled={submitDisabled && !isPreviewMode}\n type=\"button\"\n style={{ color: textColor }}\n onClick={() => {\n if (isPreviewMode) return\n if (link) {\n window?.open(link)\n }\n onSubmit()\n }}\n >\n {text}\n </button>\n </div>\n {!appearance.whiteLabel && (\n <PostHogLogo backgroundColor={appearance.backgroundColor || defaultBackgroundColor} />\n )}\n </div>\n )\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { SurveyAppearance } from '../../../posthog-surveys-types';
2
- export declare function ConfirmationMessage({ confirmationHeader, confirmationDescription, appearance, onClose, styleOverrides, }: {
3
- confirmationHeader: string;
4
- confirmationDescription: string;
2
+ export declare function ConfirmationMessage({ header, description, appearance, onClose, styleOverrides, }: {
3
+ header: string;
4
+ description: string;
5
5
  appearance: SurveyAppearance;
6
6
  onClose: () => void;
7
7
  styleOverrides?: React.CSSProperties;
@@ -13,16 +13,16 @@ import { BottomSection } from './BottomSection';
13
13
  import { Cancel } from './QuestionHeader';
14
14
  import { defaultSurveyAppearance, getContrastingTextColor } from '../surveys-utils';
15
15
  export function ConfirmationMessage(_a) {
16
- var confirmationHeader = _a.confirmationHeader, confirmationDescription = _a.confirmationDescription, appearance = _a.appearance, onClose = _a.onClose, styleOverrides = _a.styleOverrides;
16
+ var header = _a.header, description = _a.description, appearance = _a.appearance, onClose = _a.onClose, styleOverrides = _a.styleOverrides;
17
17
  var textColor = getContrastingTextColor(appearance.backgroundColor || defaultSurveyAppearance.backgroundColor);
18
18
  return (<>
19
19
  <div className="thank-you-message" style={__assign({}, styleOverrides)}>
20
20
  <div className="thank-you-message-container">
21
21
  <Cancel onClick={function () { return onClose(); }}/>
22
22
  <h3 className="thank-you-message-header" style={{ color: textColor }}>
23
- {confirmationHeader}
23
+ {header}
24
24
  </h3>
25
- {confirmationDescription && (<div style={{ color: textColor }} className="thank-you-message-body" dangerouslySetInnerHTML={{ __html: confirmationDescription }}/>)}
25
+ {description && (<div style={{ color: textColor }} className="thank-you-message-body" dangerouslySetInnerHTML={{ __html: description }}/>)}
26
26
  <BottomSection text={'Close'} submitDisabled={false} appearance={appearance} onSubmit={function () { return onClose(); }}/>
27
27
  </div>
28
28
  </div>
@@ -1 +1 @@
1
- {"version":3,"file":"ConfirmationMessage.jsx","sourceRoot":"","sources":["../../../../../src/extensions/surveys/components/ConfirmationMessage.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAEnF,MAAM,UAAU,mBAAmB,CAAC,EAYnC;QAXG,kBAAkB,wBAAA,EAClB,uBAAuB,6BAAA,EACvB,UAAU,gBAAA,EACV,OAAO,aAAA,EACP,cAAc,oBAAA;IAQd,IAAM,SAAS,GAAG,uBAAuB,CAAC,UAAU,CAAC,eAAe,IAAI,uBAAuB,CAAC,eAAe,CAAC,CAAA;IAEhH,OAAO,CACH,EACI;YAAA,CAAC,GAAG,CAAC,SAAS,CAAC,mBAAmB,CAAC,KAAK,CAAC,cAAM,cAAc,EAAG,CAC5D;gBAAA,CAAC,GAAG,CAAC,SAAS,CAAC,6BAA6B,CACxC;oBAAA,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,cAAM,OAAA,OAAO,EAAE,EAAT,CAAS,CAAC,EACjC;oBAAA,CAAC,EAAE,CAAC,SAAS,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CACjE;wBAAA,CAAC,kBAAkB,CACvB;oBAAA,EAAE,EAAE,CACJ;oBAAA,CAAC,uBAAuB,IAAI,CACxB,CAAC,GAAG,CACA,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAC5B,SAAS,CAAC,wBAAwB,CAClC,uBAAuB,CAAC,CAAC,EAAE,MAAM,EAAE,uBAAuB,EAAE,CAAC,EAC/D,CACL,CACD;oBAAA,CAAC,aAAa,CACV,IAAI,CAAC,CAAC,OAAO,CAAC,CACd,cAAc,CAAC,CAAC,KAAK,CAAC,CACtB,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,QAAQ,CAAC,CAAC,cAAM,OAAA,OAAO,EAAE,EAAT,CAAS,CAAC,EAElC;gBAAA,EAAE,GAAG,CACT;YAAA,EAAE,GAAG,CACT;QAAA,GAAG,CACN,CAAA;AACL,CAAC","sourcesContent":["import { BottomSection } from './BottomSection'\nimport { Cancel } from './QuestionHeader'\nimport { SurveyAppearance } from '../../../posthog-surveys-types'\nimport { defaultSurveyAppearance, getContrastingTextColor } from '../surveys-utils'\n\nexport function ConfirmationMessage({\n confirmationHeader,\n confirmationDescription,\n appearance,\n onClose,\n styleOverrides,\n}: {\n confirmationHeader: string\n confirmationDescription: string\n appearance: SurveyAppearance\n onClose: () => void\n styleOverrides?: React.CSSProperties\n}) {\n const textColor = getContrastingTextColor(appearance.backgroundColor || defaultSurveyAppearance.backgroundColor)\n\n return (\n <>\n <div className=\"thank-you-message\" style={{ ...styleOverrides }}>\n <div className=\"thank-you-message-container\">\n <Cancel onClick={() => onClose()} />\n <h3 className=\"thank-you-message-header\" style={{ color: textColor }}>\n {confirmationHeader}\n </h3>\n {confirmationDescription && (\n <div\n style={{ color: textColor }}\n className=\"thank-you-message-body\"\n dangerouslySetInnerHTML={{ __html: confirmationDescription }}\n />\n )}\n <BottomSection\n text={'Close'}\n submitDisabled={false}\n appearance={appearance}\n onSubmit={() => onClose()}\n />\n </div>\n </div>\n </>\n )\n}\n"]}
1
+ {"version":3,"file":"ConfirmationMessage.jsx","sourceRoot":"","sources":["../../../../../src/extensions/surveys/components/ConfirmationMessage.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAEnF,MAAM,UAAU,mBAAmB,CAAC,EAYnC;QAXG,MAAM,YAAA,EACN,WAAW,iBAAA,EACX,UAAU,gBAAA,EACV,OAAO,aAAA,EACP,cAAc,oBAAA;IAQd,IAAM,SAAS,GAAG,uBAAuB,CAAC,UAAU,CAAC,eAAe,IAAI,uBAAuB,CAAC,eAAe,CAAC,CAAA;IAEhH,OAAO,CACH,EACI;YAAA,CAAC,GAAG,CAAC,SAAS,CAAC,mBAAmB,CAAC,KAAK,CAAC,cAAM,cAAc,EAAG,CAC5D;gBAAA,CAAC,GAAG,CAAC,SAAS,CAAC,6BAA6B,CACxC;oBAAA,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,cAAM,OAAA,OAAO,EAAE,EAAT,CAAS,CAAC,EACjC;oBAAA,CAAC,EAAE,CAAC,SAAS,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CACjE;wBAAA,CAAC,MAAM,CACX;oBAAA,EAAE,EAAE,CACJ;oBAAA,CAAC,WAAW,IAAI,CACZ,CAAC,GAAG,CACA,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAC5B,SAAS,CAAC,wBAAwB,CAClC,uBAAuB,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,EACnD,CACL,CACD;oBAAA,CAAC,aAAa,CACV,IAAI,CAAC,CAAC,OAAO,CAAC,CACd,cAAc,CAAC,CAAC,KAAK,CAAC,CACtB,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,QAAQ,CAAC,CAAC,cAAM,OAAA,OAAO,EAAE,EAAT,CAAS,CAAC,EAElC;gBAAA,EAAE,GAAG,CACT;YAAA,EAAE,GAAG,CACT;QAAA,GAAG,CACN,CAAA;AACL,CAAC","sourcesContent":["import { BottomSection } from './BottomSection'\nimport { Cancel } from './QuestionHeader'\nimport { SurveyAppearance } from '../../../posthog-surveys-types'\nimport { defaultSurveyAppearance, getContrastingTextColor } from '../surveys-utils'\n\nexport function ConfirmationMessage({\n header,\n description,\n appearance,\n onClose,\n styleOverrides,\n}: {\n header: string\n description: string\n appearance: SurveyAppearance\n onClose: () => void\n styleOverrides?: React.CSSProperties\n}) {\n const textColor = getContrastingTextColor(appearance.backgroundColor || defaultSurveyAppearance.backgroundColor)\n\n return (\n <>\n <div className=\"thank-you-message\" style={{ ...styleOverrides }}>\n <div className=\"thank-you-message-container\">\n <Cancel onClick={() => onClose()} />\n <h3 className=\"thank-you-message-header\" style={{ color: textColor }}>\n {header}\n </h3>\n {description && (\n <div\n style={{ color: textColor }}\n className=\"thank-you-message-body\"\n dangerouslySetInnerHTML={{ __html: description }}\n />\n )}\n <BottomSection\n text={'Close'}\n submitDisabled={false}\n appearance={appearance}\n onSubmit={() => onClose()}\n />\n </div>\n </div>\n </>\n )\n}\n"]}
@@ -10,9 +10,9 @@ export function QuestionHeader(_a) {
10
10
  }
11
11
  export function Cancel(_a) {
12
12
  var onClick = _a.onClick;
13
- var readOnly = useContext(SurveyContext).readOnly;
13
+ var isPreviewMode = useContext(SurveyContext).isPreviewMode;
14
14
  return (<div className="cancel-btn-wrapper">
15
- <button className="form-cancel" onClick={onClick} disabled={readOnly}>
15
+ <button className="form-cancel" onClick={onClick} disabled={isPreviewMode}>
16
16
  {cancelSVG}
17
17
  </button>
18
18
  </div>);
@@ -1 +1 @@
1
- {"version":3,"file":"QuestionHeader.jsx","sourceRoot":"","sources":["../../../../../src/extensions/surveys/components/QuestionHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,MAAM,UAAU,cAAc,CAAC,EAQ9B;QAPG,QAAQ,cAAA,EACR,WAAW,iBAAA,EACX,eAAe,qBAAA;IAMf,OAAO,CACH,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,EAAE,eAAe,IAAI,uBAAuB,CAAC,eAAe,EAAE,CAAC,CACxF;YAAA,CAAC,GAAG,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,QAAQ,CAAC,EAAE,GAAG,CAChD;YAAA,CAAC,WAAW,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,EAAG,CACrG;QAAA,EAAE,GAAG,CAAC,CACT,CAAA;AACL,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,EAAoC;QAAlC,OAAO,aAAA;IACpB,IAAA,QAAQ,GAAK,UAAU,CAAC,aAAa,CAAC,SAA9B,CAA8B;IAE9C,OAAO,CACH,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAC/B;YAAA,CAAC,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CACjE;gBAAA,CAAC,SAAS,CACd;YAAA,EAAE,MAAM,CACZ;QAAA,EAAE,GAAG,CAAC,CACT,CAAA;AACL,CAAC","sourcesContent":["import { SurveyContext, defaultSurveyAppearance } from '../surveys-utils'\nimport { cancelSVG } from '../icons'\nimport { useContext } from 'preact/hooks'\n\nexport function QuestionHeader({\n question,\n description,\n backgroundColor,\n}: {\n question: string\n description?: string | null\n backgroundColor?: string\n}) {\n return (\n <div style={{ backgroundColor: backgroundColor || defaultSurveyAppearance.backgroundColor }}>\n <div className=\"survey-question\">{question}</div>\n {description && <div className=\"description\" dangerouslySetInnerHTML={{ __html: description }} />}\n </div>\n )\n}\n\nexport function Cancel({ onClick }: { onClick: () => void }) {\n const { readOnly } = useContext(SurveyContext)\n\n return (\n <div className=\"cancel-btn-wrapper\">\n <button className=\"form-cancel\" onClick={onClick} disabled={readOnly}>\n {cancelSVG}\n </button>\n </div>\n )\n}\n"]}
1
+ {"version":3,"file":"QuestionHeader.jsx","sourceRoot":"","sources":["../../../../../src/extensions/surveys/components/QuestionHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,MAAM,UAAU,cAAc,CAAC,EAQ9B;QAPG,QAAQ,cAAA,EACR,WAAW,iBAAA,EACX,eAAe,qBAAA;IAMf,OAAO,CACH,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,EAAE,eAAe,IAAI,uBAAuB,CAAC,eAAe,EAAE,CAAC,CACxF;YAAA,CAAC,GAAG,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,QAAQ,CAAC,EAAE,GAAG,CAChD;YAAA,CAAC,WAAW,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,EAAG,CACrG;QAAA,EAAE,GAAG,CAAC,CACT,CAAA;AACL,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,EAAoC;QAAlC,OAAO,aAAA;IACpB,IAAA,aAAa,GAAK,UAAU,CAAC,aAAa,CAAC,cAA9B,CAA8B;IAEnD,OAAO,CACH,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAC/B;YAAA,CAAC,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,CACtE;gBAAA,CAAC,SAAS,CACd;YAAA,EAAE,MAAM,CACZ;QAAA,EAAE,GAAG,CAAC,CACT,CAAA;AACL,CAAC","sourcesContent":["import { SurveyContext, defaultSurveyAppearance } from '../surveys-utils'\nimport { cancelSVG } from '../icons'\nimport { useContext } from 'preact/hooks'\n\nexport function QuestionHeader({\n question,\n description,\n backgroundColor,\n}: {\n question: string\n description?: string | null\n backgroundColor?: string\n}) {\n return (\n <div style={{ backgroundColor: backgroundColor || defaultSurveyAppearance.backgroundColor }}>\n <div className=\"survey-question\">{question}</div>\n {description && <div className=\"description\" dangerouslySetInnerHTML={{ __html: description }} />}\n </div>\n )\n}\n\nexport function Cancel({ onClick }: { onClick: () => void }) {\n const { isPreviewMode } = useContext(SurveyContext)\n\n return (\n <div className=\"cancel-btn-wrapper\">\n <button className=\"form-cancel\" onClick={onClick} disabled={isPreviewMode}>\n {cancelSVG}\n </button>\n </div>\n )\n}\n"]}
@@ -1,34 +1,30 @@
1
1
  import { BasicSurveyQuestion, SurveyAppearance, LinkSurveyQuestion, RatingSurveyQuestion, MultipleSurveyQuestion } from '../../../posthog-surveys-types';
2
- export declare function OpenTextQuestion({ question, appearance, onSubmit, closeSurveyPopup, }: {
2
+ export declare function OpenTextQuestion({ question, appearance, onSubmit, }: {
3
3
  question: BasicSurveyQuestion;
4
4
  appearance: SurveyAppearance;
5
5
  onSubmit: (text: string) => void;
6
- closeSurveyPopup: () => void;
7
6
  }): JSX.Element;
8
- export declare function LinkQuestion({ question, appearance, onSubmit, closeSurveyPopup, }: {
7
+ export declare function LinkQuestion({ question, appearance, onSubmit, }: {
9
8
  question: LinkSurveyQuestion;
10
9
  appearance: SurveyAppearance;
11
10
  onSubmit: (clicked: string) => void;
12
- closeSurveyPopup: () => void;
13
11
  }): JSX.Element;
14
- export declare function RatingQuestion({ question, questionIndex, appearance, onSubmit, closeSurveyPopup, }: {
12
+ export declare function RatingQuestion({ question, displayQuestionIndex, appearance, onSubmit, }: {
15
13
  question: RatingSurveyQuestion;
16
- questionIndex: number;
14
+ displayQuestionIndex: number;
17
15
  appearance: SurveyAppearance;
18
16
  onSubmit: (rating: number | null) => void;
19
- closeSurveyPopup: () => void;
20
17
  }): JSX.Element;
21
- export declare function RatingButton({ num, active, questionIndex, appearance, setActiveNumber, }: {
18
+ export declare function RatingButton({ num, active, displayQuestionIndex, appearance, setActiveNumber, }: {
22
19
  num: number;
23
20
  active: boolean;
24
- questionIndex: number;
21
+ displayQuestionIndex: number;
25
22
  appearance: any;
26
23
  setActiveNumber: (num: number) => void;
27
24
  }): JSX.Element;
28
- export declare function MultipleChoiceQuestion({ question, questionIndex, appearance, onSubmit, closeSurveyPopup, }: {
25
+ export declare function MultipleChoiceQuestion({ question, displayQuestionIndex, appearance, onSubmit, }: {
29
26
  question: MultipleSurveyQuestion;
30
- questionIndex: number;
27
+ displayQuestionIndex: number;
31
28
  appearance: SurveyAppearance;
32
29
  onSubmit: (choices: string | string[] | null) => void;
33
- closeSurveyPopup: () => void;
34
30
  }): JSX.Element;
@@ -24,46 +24,49 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
24
24
  return to.concat(ar || Array.prototype.slice.call(from));
25
25
  };
26
26
  import { SurveyQuestionType, } from '../../../posthog-surveys-types';
27
- import { useRef, useState, useMemo } from 'preact/hooks';
27
+ import { useRef, useState, useMemo, useContext } from 'preact/hooks';
28
28
  import { isNull, isArray } from '../../../utils/type-utils';
29
29
  import { useContrastingTextColor } from '../hooks/useContrastingTextColor';
30
30
  import { checkSVG, dissatisfiedEmoji, neutralEmoji, satisfiedEmoji, veryDissatisfiedEmoji, verySatisfiedEmoji, } from '../icons';
31
- import { defaultSurveyAppearance, getDisplayOrderChoices } from '../surveys-utils';
31
+ import { defaultSurveyAppearance, getDisplayOrderChoices, SurveyContext } from '../surveys-utils';
32
32
  import { BottomSection } from './BottomSection';
33
33
  import { Cancel, QuestionHeader } from './QuestionHeader';
34
34
  export function OpenTextQuestion(_a) {
35
- var question = _a.question, appearance = _a.appearance, onSubmit = _a.onSubmit, closeSurveyPopup = _a.closeSurveyPopup;
35
+ var question = _a.question, appearance = _a.appearance, onSubmit = _a.onSubmit;
36
36
  var textRef = useRef(null);
37
37
  var _b = __read(useState(''), 2), text = _b[0], setText = _b[1];
38
+ var handleCloseSurveyPopup = useContext(SurveyContext).handleCloseSurveyPopup;
38
39
  return (<div className="survey-box" style={{ backgroundColor: appearance.backgroundColor || defaultSurveyAppearance.backgroundColor }} ref={textRef}>
39
- <Cancel onClick={function () { return closeSurveyPopup(); }}/>
40
+ <Cancel onClick={function () { return handleCloseSurveyPopup(); }}/>
40
41
  <QuestionHeader question={question.question} description={question.description} backgroundColor={appearance.backgroundColor}/>
41
42
  <textarea rows={4} placeholder={appearance === null || appearance === void 0 ? void 0 : appearance.placeholder} onInput={function (e) { return setText(e.currentTarget.value); }}/>
42
43
  <BottomSection text={question.buttonText || 'Submit'} submitDisabled={!text && !question.optional} appearance={appearance} onSubmit={function () { return onSubmit(text); }}/>
43
44
  </div>);
44
45
  }
45
46
  export function LinkQuestion(_a) {
46
- var question = _a.question, appearance = _a.appearance, onSubmit = _a.onSubmit, closeSurveyPopup = _a.closeSurveyPopup;
47
+ var question = _a.question, appearance = _a.appearance, onSubmit = _a.onSubmit;
48
+ var handleCloseSurveyPopup = useContext(SurveyContext).handleCloseSurveyPopup;
47
49
  return (<div className="survey-box">
48
- <Cancel onClick={function () { return closeSurveyPopup(); }}/>
50
+ <Cancel onClick={function () { return handleCloseSurveyPopup(); }}/>
49
51
  <QuestionHeader question={question.question} description={question.description}/>
50
52
  <BottomSection text={question.buttonText || 'Submit'} submitDisabled={false} link={question.link} appearance={appearance} onSubmit={function () { return onSubmit('link clicked'); }}/>
51
53
  </div>);
52
54
  }
53
55
  export function RatingQuestion(_a) {
54
- var question = _a.question, questionIndex = _a.questionIndex, appearance = _a.appearance, onSubmit = _a.onSubmit, closeSurveyPopup = _a.closeSurveyPopup;
56
+ var question = _a.question, displayQuestionIndex = _a.displayQuestionIndex, appearance = _a.appearance, onSubmit = _a.onSubmit;
55
57
  var scale = question.scale;
56
58
  var starting = question.scale === 10 ? 0 : 1;
57
59
  var _b = __read(useState(null), 2), rating = _b[0], setRating = _b[1];
60
+ var handleCloseSurveyPopup = useContext(SurveyContext).handleCloseSurveyPopup;
58
61
  return (<div className="survey-box">
59
- <Cancel onClick={function () { return closeSurveyPopup(); }}/>
62
+ <Cancel onClick={function () { return handleCloseSurveyPopup(); }}/>
60
63
  <QuestionHeader question={question.question} description={question.description} backgroundColor={appearance.backgroundColor}/>
61
64
  <div className="rating-section">
62
65
  <div className="rating-options">
63
66
  {question.display === 'emoji' && (<div className="rating-options-emoji">
64
67
  {(question.scale === 3 ? threeScaleEmojis : fiveScaleEmojis).map(function (emoji, idx) {
65
68
  var active = idx + 1 === rating;
66
- return (<button className={"ratings-emoji question-".concat(questionIndex, "-rating-").concat(idx, " ").concat(active ? 'rating-active' : null)} value={idx + 1} key={idx} type="button" onClick={function () {
69
+ return (<button className={"ratings-emoji question-".concat(displayQuestionIndex, "-rating-").concat(idx, " ").concat(active ? 'rating-active' : null)} value={idx + 1} key={idx} type="button" onClick={function () {
67
70
  setRating(idx + 1);
68
71
  }}>
69
72
  {emoji}
@@ -73,7 +76,7 @@ export function RatingQuestion(_a) {
73
76
  {question.display === 'number' && (<div className="rating-options-number" style={{ gridTemplateColumns: "repeat(".concat(scale - starting + 1, ", minmax(0, 1fr))") }}>
74
77
  {(question.scale === 5 ? fiveScaleNumbers : tenScaleNumbers).map(function (number, idx) {
75
78
  var active = rating === number;
76
- return (<RatingButton key={idx} questionIndex={questionIndex} active={active} appearance={appearance} num={number} setActiveNumber={function (num) {
79
+ return (<RatingButton key={idx} displayQuestionIndex={displayQuestionIndex} active={active} appearance={appearance} num={number} setActiveNumber={function (num) {
77
80
  setRating(num);
78
81
  }}/>);
79
82
  })}
@@ -88,9 +91,9 @@ export function RatingQuestion(_a) {
88
91
  </div>);
89
92
  }
90
93
  export function RatingButton(_a) {
91
- var num = _a.num, active = _a.active, questionIndex = _a.questionIndex, appearance = _a.appearance, setActiveNumber = _a.setActiveNumber;
94
+ var num = _a.num, active = _a.active, displayQuestionIndex = _a.displayQuestionIndex, appearance = _a.appearance, setActiveNumber = _a.setActiveNumber;
92
95
  var _b = useContrastingTextColor({ appearance: appearance, defaultTextColor: 'black', forceUpdate: active }), textColor = _b.textColor, ref = _b.ref;
93
- return (<button ref={ref} className={"ratings-number question-".concat(questionIndex, "-rating-").concat(num, " ").concat(active ? 'rating-active' : null)} type="button" onClick={function () {
96
+ return (<button ref={ref} className={"ratings-number question-".concat(displayQuestionIndex, "-rating-").concat(num, " ").concat(active ? 'rating-active' : null)} type="button" onClick={function () {
94
97
  setActiveNumber(num);
95
98
  }} style={{
96
99
  color: textColor,
@@ -101,15 +104,16 @@ export function RatingButton(_a) {
101
104
  </button>);
102
105
  }
103
106
  export function MultipleChoiceQuestion(_a) {
104
- var question = _a.question, questionIndex = _a.questionIndex, appearance = _a.appearance, onSubmit = _a.onSubmit, closeSurveyPopup = _a.closeSurveyPopup;
107
+ var question = _a.question, displayQuestionIndex = _a.displayQuestionIndex, appearance = _a.appearance, onSubmit = _a.onSubmit;
105
108
  var textRef = useRef(null);
106
109
  var choices = useMemo(function () { return getDisplayOrderChoices(question); }, [question]);
107
110
  var _b = __read(useState(question.type === SurveyQuestionType.MultipleChoice ? [] : null), 2), selectedChoices = _b[0], setSelectedChoices = _b[1];
108
111
  var _c = __read(useState(false), 2), openChoiceSelected = _c[0], setOpenChoiceSelected = _c[1];
109
112
  var _d = __read(useState(''), 2), openEndedInput = _d[0], setOpenEndedInput = _d[1];
113
+ var handleCloseSurveyPopup = useContext(SurveyContext).handleCloseSurveyPopup;
110
114
  var inputType = question.type === SurveyQuestionType.SingleChoice ? 'radio' : 'checkbox';
111
115
  return (<div className="survey-box" style={{ backgroundColor: appearance.backgroundColor || defaultSurveyAppearance.backgroundColor }} ref={textRef}>
112
- <Cancel onClick={function () { return closeSurveyPopup(); }}/>
116
+ <Cancel onClick={function () { return handleCloseSurveyPopup(); }}/>
113
117
  <QuestionHeader question={question.question} description={question.description} backgroundColor={appearance.backgroundColor}/>
114
118
  <div className="multiple-choice-options">
115
119
  {/* Remove the last element from the choices, if hasOpenChoice is set */}
@@ -123,7 +127,7 @@ export function MultipleChoiceQuestion(_a) {
123
127
  choiceClass += ' choice-option-open';
124
128
  }
125
129
  return (<div className={choiceClass}>
126
- <input type={inputType} id={"surveyQuestion".concat(questionIndex, "Choice").concat(idx)} name={"question".concat(questionIndex)} value={val} disabled={!val} onInput={function () {
130
+ <input type={inputType} id={"surveyQuestion".concat(displayQuestionIndex, "Choice").concat(idx)} name={"question".concat(displayQuestionIndex)} value={val} disabled={!val} onInput={function () {
127
131
  if (question.hasOpenChoice && idx === question.choices.length - 1) {
128
132
  return setOpenChoiceSelected(!openChoiceSelected);
129
133
  }
@@ -139,10 +143,10 @@ export function MultipleChoiceQuestion(_a) {
139
143
  return setSelectedChoices(__spreadArray(__spreadArray([], __read(selectedChoices), false), [val], false));
140
144
  }
141
145
  }}/>
142
- <label htmlFor={"surveyQuestion".concat(questionIndex, "Choice").concat(idx)} style={{ color: 'black' }}>
146
+ <label htmlFor={"surveyQuestion".concat(displayQuestionIndex, "Choice").concat(idx)} style={{ color: 'black' }}>
143
147
  {question.hasOpenChoice && idx === question.choices.length - 1 ? (<>
144
148
  <span>{option}:</span>
145
- <input type="text" id={"surveyQuestion".concat(questionIndex, "Choice").concat(idx, "Open")} name={"question".concat(questionIndex)} onInput={function (e) {
149
+ <input type="text" id={"surveyQuestion".concat(displayQuestionIndex, "Choice").concat(idx, "Open")} name={"question".concat(displayQuestionIndex)} onInput={function (e) {
146
150
  var userValue = e.currentTarget.value;
147
151
  if (question.type === SurveyQuestionType.SingleChoice) {
148
152
  return setSelectedChoices(userValue);