posthog-react-native 4.74.2 → 4.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PostHogErrorBoundary.js.map +1 -1
- package/dist/PostHogProvider.js.map +1 -1
- package/dist/autocapture.d.ts +1 -1
- package/dist/autocapture.js.map +1 -1
- package/dist/error-tracking/index.js.map +1 -1
- package/dist/error-tracking/utils.js.map +1 -1
- package/dist/frameworks/wix-navigation.js +1 -1
- package/dist/frameworks/wix-navigation.js.map +1 -1
- package/dist/hooks/useNavigationTracker.js.map +1 -1
- package/dist/logs-defaults.js +1 -1
- package/dist/logs-defaults.js.map +1 -1
- package/dist/optional/OptionalExpoUpdates.js.map +1 -1
- package/dist/optional/OptionalPlugin.js.map +1 -1
- package/dist/optional/OptionalReactNativeSafeArea.js.map +1 -1
- package/dist/optional/OptionalReactNativeSvg.js.map +1 -1
- package/dist/posthog-rn.js +1 -1
- package/dist/posthog-rn.js.map +1 -1
- package/dist/surveys/PostHogSurveyProvider.js +1 -1
- package/dist/surveys/PostHogSurveyProvider.js.map +1 -1
- package/dist/surveys/components/QuestionHeader.js.map +1 -1
- package/dist/surveys/components/QuestionTypes.js +1 -1
- package/dist/surveys/components/QuestionTypes.js.map +1 -1
- package/dist/surveys/components/SurveyModal.d.ts +5 -0
- package/dist/surveys/components/SurveyModal.js +1 -1
- package/dist/surveys/components/SurveyModal.js.map +1 -1
- package/dist/surveys/components/Surveys.d.ts +7 -4
- package/dist/surveys/components/Surveys.js +1 -1
- package/dist/surveys/components/Surveys.js.map +1 -1
- package/dist/surveys/getActiveMatchingSurveys.d.ts +1 -1
- package/dist/surveys/getActiveMatchingSurveys.js +1 -1
- package/dist/surveys/getActiveMatchingSurveys.js.map +1 -1
- package/dist/surveys/icons.js.map +1 -1
- package/dist/surveys/safeStyleSheet.js.map +1 -1
- package/dist/surveys/survey-progress.d.ts +23 -0
- package/dist/surveys/survey-progress.js +2 -0
- package/dist/surveys/survey-progress.js.map +1 -0
- package/dist/surveys/survey-shuffling.js.map +1 -1
- package/dist/surveys/surveys-utils.d.ts +1 -1
- package/dist/surveys/useActivatedSurveys.js +1 -1
- package/dist/surveys/useActivatedSurveys.js.map +1 -1
- package/dist/surveys/useSurveyStorage.d.ts +3 -1
- package/dist/surveys/useSurveyStorage.js +1 -1
- package/dist/surveys/useSurveyStorage.js.map +1 -1
- package/dist/tooling/expoconfig.d.ts +24 -4
- package/dist/tooling/expoconfig.js +1 -1
- package/dist/tooling/expoconfig.js.map +1 -1
- package/dist/tooling/metroconfig.js.map +1 -1
- package/dist/tooling/posthogMetroSerializer.js.map +1 -1
- package/dist/tooling/utils.js.map +1 -1
- package/dist/tooling/vendor/metro/countLines.d.ts +1 -1
- package/dist/tooling/vendor/metro/utils.js.map +1 -1
- package/dist/utils.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +6 -6
- package/tooling/posthog-xcode.sh +22 -1
- package/tooling/posthog.gradle +13 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SurveyModal.js","names":["_react","_interopRequireWildcard","require","_reactNative","_Cancel","_ConfirmationMessage","_IntroMessage","_safeStyleSheet","_surveysUtils","_OptionalReactNativeSafeArea","_Surveys","_jsxRuntime","_jsxFileName","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t2","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","VIEWPORT_BUFFER","MODAL_FADE_DURATION_MS","IOS_DISMISS_FALLBACK_MS","SurveyModal","props","survey","surveyLanguage","appearance","onShow","onCloseProp","onClose","_props$androidKeyboar","androidKeyboardBehavior","_useState","useState","_useState2","_slicedToArray2","isSurveySent","setIsSurveySent","_useState3","Boolean","displayIntroScreen","introScreenHeader","introScreenDescription","_useState4","showIntro","setShowIntro","_useState5","_useState6","responses","setResponses","_useState7","_useState8","isVisible","setIsVisible","_useState9","_useState0","contentMounted","setContentMounted","isClosingRef","useRef","closeNotifiedRef","closeTimerRef","notifyParentClosed","useCallback","current","requestAnimationFrame","fallbackDelay","Platform","OS","setTimeout","useEffect","clearTimeout","insets","useOptionalSafeAreaInsets","_useWindowDimensions","useWindowDimensions","windowHeight","height","_useState1","_useState10","keyboardHeight","setKeyboardHeight","_resolveSurveyAlignme","resolveSurveyAlignment","position","vertical","horizontal","isBottom","shouldShowConfirmation","thankYouMessageHeader","showEvent","hideEvent","showSub","Keyboard","addListener","endCoordinates","hideSub","remove","maxModalHeight","Math","max","top","bottom","keyboardBehavior","jsx","Modal","visible","animationType","transparent","onRequestClose","onDismiss","undefined","statusBarTranslucent","children","KeyboardAvoidingView","behavior","style","styles","fill","View","backdrop","justifyContent","onTouchStart","dismiss","modalRow","modalContent","pointerEvents","jsxs","event","stopPropagation","modalContentInner","borderColor","backgroundColor","marginTop","marginBottom","marginHorizontal","maxHeight","topIconContainer","Cancel","onPress","ConfirmationMessage","header","description","thankYouMessageDescription","contentType","thankYouMessageDescriptionContentType","isModal","IntroMessage","introScreenDescriptionContentType","onStart","Questions","onResponsesChange","onSubmit","createSafeStyleSheet","flex","flexDirection","width","maxWidth","borderRadius","borderWidth","padding","right","zIndex"],"sources":["../../../src/surveys/components/SurveyModal.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { Keyboard, KeyboardAvoidingView, Modal, Platform, View, useWindowDimensions } from 'react-native'\n\nimport { Cancel } from './Cancel'\nimport { ConfirmationMessage } from './ConfirmationMessage'\nimport { IntroMessage } from './IntroMessage'\nimport { createSafeStyleSheet } from '../safeStyleSheet'\nimport { SurveyAppearanceTheme, resolveSurveyAlignment } from '../surveys-utils'\nimport { Survey, type SurveyResponses } from '@posthog/core'\nimport { useOptionalSafeAreaInsets } from '../../optional/OptionalReactNativeSafeArea'\nimport { Questions } from './Surveys'\n\nexport type SurveyModalProps = {\n survey: Survey\n surveyLanguage: string | null\n appearance: SurveyAppearanceTheme\n onShow: () => void\n onClose: (submitted: boolean, responses: SurveyResponses) => void\n androidKeyboardBehavior?: 'padding' | 'height'\n}\n\n// No extra buffer — let the modal extend right up to the safe-area / keyboard\n// edges. Insets already keep it clear of the status bar and home indicator.\nconst VIEWPORT_BUFFER = 0\n\n// Matches RN Modal's fade animation duration (Android only).\nconst MODAL_FADE_DURATION_MS = 250\n\n// iOS normally notifies the parent via Modal.onDismiss, but Fabric can fail to fire it\n// (https://github.com/facebook/react-native/issues/48245). When that happens the parent never\n// clears the active survey, so this transparent full-screen Modal stays mounted and swallows\n// every touch — the app appears frozen. This is the safety-net delay after which we notify the\n// parent ourselves if onDismiss still hasn't fired. Longer than the dismiss animation so the\n// real onDismiss stays the primary path on the happy path.\nconst IOS_DISMISS_FALLBACK_MS = 1000\n\nexport function SurveyModal(props: SurveyModalProps): JSX.Element | null {\n const { survey, surveyLanguage, appearance, onShow, onClose: onCloseProp, androidKeyboardBehavior = 'height' } = props\n const [isSurveySent, setIsSurveySent] = useState(false)\n // The intro screen is a leading page mirroring the trailing confirmation message. Dismissing it\n // only flips local state — no response is recorded and no survey event is sent. It has no\n // default header, so an intro with no copy at all is skipped instead of drawing an empty box.\n const [showIntro, setShowIntro] = useState(\n Boolean(appearance.displayIntroScreen) && Boolean(appearance.introScreenHeader || appearance.introScreenDescription)\n )\n const [responses, setResponses] = useState<SurveyResponses>({})\n const [isVisible, setIsVisible] = useState(true)\n // Two-step hide for RN Fabric snapshot recycling — see\n // https://github.com/facebook/react-native/issues/48245\n const [contentMounted, setContentMounted] = useState(true)\n const isClosingRef = useRef(false)\n const closeNotifiedRef = useRef(false)\n const closeTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)\n const notifyParentClosed = useCallback(() => {\n if (closeNotifiedRef.current) return\n closeNotifiedRef.current = true\n onCloseProp(isSurveySent, responses)\n }, [isSurveySent, onCloseProp, responses])\n const onClose = useCallback(() => {\n if (isClosingRef.current) return\n isClosingRef.current = true\n setContentMounted(false)\n requestAnimationFrame(() => {\n setIsVisible(false)\n // Always schedule a fallback to notify the parent. On Android the Modal has no onDismiss,\n // so this is the only notification path (after the fade). On iOS onDismiss is the primary\n // path, but it can silently fail to fire — this timer guarantees the parent still unmounts\n // the Modal so it can never stay up intercepting touches. notifyParentClosed is idempotent,\n // so whichever fires first wins and the other becomes a no-op.\n const fallbackDelay = Platform.OS === 'ios' ? IOS_DISMISS_FALLBACK_MS : MODAL_FADE_DURATION_MS\n closeTimerRef.current = setTimeout(notifyParentClosed, fallbackDelay)\n })\n }, [notifyParentClosed])\n\n // Clear the pending fallback timer on unmount so it can't fire after the survey is gone.\n useEffect(() => {\n return () => {\n if (closeTimerRef.current) {\n clearTimeout(closeTimerRef.current)\n }\n }\n }, [])\n const insets = useOptionalSafeAreaInsets()\n const { height: windowHeight } = useWindowDimensions()\n const [keyboardHeight, setKeyboardHeight] = useState(0)\n const { vertical, horizontal } = resolveSurveyAlignment(appearance.position)\n const isBottom = vertical === 'flex-end'\n\n const shouldShowConfirmation = isSurveySent && appearance.thankYouMessageHeader\n\n useEffect(() => {\n if (isVisible) {\n onShow()\n }\n }, [isVisible, onShow])\n\n // Track keyboard height so we can cap the modal to the visible viewport.\n // KAV alone lifts the modal but doesn't shrink it — a tall modal would\n // still bleed past the screen top.\n useEffect(() => {\n const showEvent = Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow'\n const hideEvent = Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide'\n const showSub = Keyboard.addListener(showEvent, (e) => setKeyboardHeight(e.endCoordinates.height))\n const hideSub = Keyboard.addListener(hideEvent, () => setKeyboardHeight(0))\n return () => {\n showSub.remove()\n hideSub.remove()\n }\n }, [])\n\n const maxModalHeight = Math.max(windowHeight - keyboardHeight - insets.top - insets.bottom - VIEWPORT_BUFFER, 200)\n\n const keyboardBehavior = Platform.OS === 'ios' ? 'padding' : androidKeyboardBehavior\n\n return (\n <Modal\n visible={isVisible}\n animationType=\"fade\"\n transparent\n onRequestClose={onClose}\n onDismiss={Platform.OS === 'ios' ? notifyParentClosed : undefined}\n statusBarTranslucent={true}\n >\n {contentMounted && (\n <KeyboardAvoidingView behavior={keyboardBehavior} style={styles.fill}>\n <View style={[styles.fill, styles.backdrop, { justifyContent: vertical }]} onTouchStart={Keyboard.dismiss}>\n <View style={[styles.modalRow, { justifyContent: horizontal }]}>\n <View style={styles.modalContent} pointerEvents=\"box-none\">\n <View\n onTouchStart={(event) => event.stopPropagation()}\n style={[\n styles.modalContentInner,\n {\n borderColor: appearance.borderColor,\n backgroundColor: appearance.backgroundColor,\n marginTop: vertical === 'flex-start' ? insets.top + 10 : 0,\n // When keyboard is up, sit flush against it (no extra gap).\n // When keyboard is down, leave room for the home indicator.\n marginBottom: isBottom ? (keyboardHeight > 0 ? 0 : insets.bottom + 10) : 0,\n marginHorizontal: 10,\n maxHeight: maxModalHeight,\n },\n ]}\n >\n <View style={styles.topIconContainer}>\n <Cancel onPress={onClose} appearance={appearance} />\n </View>\n {isSurveySent ? (\n shouldShowConfirmation ? (\n <ConfirmationMessage\n appearance={appearance}\n header={appearance.thankYouMessageHeader}\n description={appearance.thankYouMessageDescription}\n contentType={appearance.thankYouMessageDescriptionContentType}\n onClose={onClose}\n isModal={true}\n />\n ) : null\n ) : showIntro ? (\n <IntroMessage\n appearance={appearance}\n header={appearance.introScreenHeader}\n description={appearance.introScreenDescription}\n contentType={appearance.introScreenDescriptionContentType}\n onStart={() => setShowIntro(false)}\n />\n ) : (\n <Questions\n survey={survey}\n surveyLanguage={surveyLanguage}\n appearance={appearance}\n responses={responses}\n onResponsesChange={setResponses}\n onSubmit={() => setIsSurveySent(true)}\n />\n )}\n </View>\n </View>\n </View>\n </View>\n </KeyboardAvoidingView>\n )}\n </Modal>\n )\n}\n\nconst styles = createSafeStyleSheet({\n fill: {\n flex: 1,\n },\n backdrop: {\n backgroundColor: 'rgba(0, 0, 0, 0.32)',\n },\n modalRow: {\n flexDirection: 'row',\n },\n modalContent: {\n width: '90%',\n maxWidth: 400,\n },\n modalContentInner: {\n borderRadius: 10,\n borderWidth: 1,\n padding: 20,\n },\n topIconContainer: {\n // Keep the close button inside the modal so it can never bleed off-screen\n // when the modal lifts above the keyboard.\n position: 'absolute',\n right: 8,\n top: 8,\n zIndex: 1,\n },\n})\n"],"mappings":"0UAAA,IAAAA,MAAA,CAAAC,uBAAA,CAAAC,OAAA,WACA,IAAAC,YAAA,CAAAD,OAAA,iBAEA,IAAAE,OAAA,CAAAF,OAAA,aACA,IAAAG,oBAAA,CAAAH,OAAA,0BACA,IAAAI,aAAA,CAAAJ,OAAA,mBACA,IAAAK,eAAA,CAAAL,OAAA,sBACA,IAAAM,aAAA,CAAAN,OAAA,qBAEA,IAAAO,4BAAA,CAAAP,OAAA,+CACA,IAAAQ,QAAA,CAAAR,OAAA,cAAqC,IAAAS,WAAA,CAAAT,OAAA,0BAAAU,YAAA,iHAAAX,wBAAAY,CAAA,CAAAC,CAAA,wBAAAC,OAAA,KAAAC,CAAA,KAAAD,OAAA,GAAAE,CAAA,KAAAF,OAAA,UAAAd,uBAAA,UAAAA,wBAAAY,CAAA,CAAAC,CAAA,MAAAA,CAAA,EAAAD,CAAA,EAAAA,CAAA,CAAAK,UAAA,QAAAL,CAAA,KAAAM,CAAA,CAAAC,CAAA,CAAAC,CAAA,EAAAC,SAAA,gBAAAT,CAAA,YAAAA,CAAA,YAAAU,OAAA,CAAAV,CAAA,sBAAAA,CAAA,QAAAQ,CAAA,IAAAF,CAAA,CAAAL,CAAA,CAAAG,CAAA,CAAAD,CAAA,KAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,SAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,CAAAM,CAAA,EAAAO,GAAA,CAAAb,CAAA,CAAAQ,CAAA,WAAAM,GAAA,IAAAd,CAAA,aAAAc,GAAA,KAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,CAAAc,GAAA,KAAAP,CAAA,EAAAD,CAAA,CAAAW,MAAA,CA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,CAAE,CACR+B,aAAa,CAAE,K,CAChB,CACD9B,YAAY,CAAE,CACZ+B,KAAK,CAAE,KAAK,CACZC,QAAQ,CAAE,G,CACX,CACD3B,iBAAiB,CAAE,CACjB4B,YAAY,CAAE,EAAE,CAChBC,WAAW,CAAE,CAAC,CACdC,OAAO,CAAE,E,CACV,CACDvB,gBAAgB,CAAE,CAGhBrD,QAAQ,CAAE,UAAU,CACpB6E,KAAK,CAAE,CAAC,CACR5D,GAAG,CAAE,CAAC,CACN6D,MAAM,CAAE,C,EAEX,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"SurveyModal.js","names":["_react","_interopRequireWildcard","require","_reactNative","_Cancel","_ConfirmationMessage","_IntroMessage","_safeStyleSheet","_surveysUtils","_OptionalReactNativeSafeArea","_Surveys","_jsxRuntime","_jsxFileName","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t2","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","VIEWPORT_BUFFER","MODAL_FADE_DURATION_MS","IOS_DISMISS_FALLBACK_MS","shouldShowIntro","appearance","progress","keys","_a","responses","length","Boolean","displayIntroScreen","introScreenHeader","introScreenDescription","SurveyModal","props","survey","surveyLanguage","onShow","onCloseProp","onClose","_props$androidKeyboar","androidKeyboardBehavior","_useState","useState","_useState2","_slicedToArray2","isSurveySent","setIsSurveySent","_useState3","initialProgress","_useState4","showIntro","setShowIntro","_useState5","_b","_useState6","setResponses","_useState7","_useState8","isVisible","setIsVisible","_useState9","_useState0","contentMounted","setContentMounted","isClosingRef","useRef","closeNotifiedRef","closeTimerRef","notifyParentClosed","useCallback","current","requestAnimationFrame","fallbackDelay","Platform","OS","setTimeout","useEffect","clearTimeout","insets","useOptionalSafeAreaInsets","_useWindowDimensions","useWindowDimensions","windowHeight","height","_useState1","_useState10","keyboardHeight","setKeyboardHeight","_resolveSurveyAlignme","resolveSurveyAlignment","position","vertical","horizontal","isBottom","shouldShowConfirmation","thankYouMessageHeader","showEvent","hideEvent","showSub","Keyboard","addListener","endCoordinates","hideSub","remove","maxModalHeight","Math","max","top","bottom","keyboardBehavior","jsx","Modal","visible","animationType","transparent","onRequestClose","onDismiss","undefined","statusBarTranslucent","children","KeyboardAvoidingView","behavior","style","styles","fill","View","backdrop","justifyContent","onTouchStart","dismiss","modalRow","modalContent","pointerEvents","jsxs","event","stopPropagation","modalContentInner","borderColor","backgroundColor","marginTop","marginBottom","marginHorizontal","maxHeight","topIconContainer","Cancel","onPress","ConfirmationMessage","header","description","thankYouMessageDescription","contentType","thankYouMessageDescriptionContentType","isModal","IntroMessage","introScreenDescriptionContentType","onStart","Questions","client","onProgressChange","onResponsesChange","onSubmit","createSafeStyleSheet","flex","flexDirection","width","maxWidth","borderRadius","borderWidth","padding","right","zIndex"],"sources":["../../../src/surveys/components/SurveyModal.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { Keyboard, KeyboardAvoidingView, Modal, Platform, View, useWindowDimensions } from 'react-native'\n\nimport { Cancel } from './Cancel'\nimport { ConfirmationMessage } from './ConfirmationMessage'\nimport { IntroMessage } from './IntroMessage'\nimport { createSafeStyleSheet } from '../safeStyleSheet'\nimport { SurveyAppearanceTheme, resolveSurveyAlignment } from '../surveys-utils'\nimport { Survey, type SurveyResponses } from '@posthog/core'\nimport { useOptionalSafeAreaInsets } from '../../optional/OptionalReactNativeSafeArea'\nimport { Questions } from './Surveys'\nimport type { SurveyProgress } from '../survey-progress'\nimport type { PostHog } from '../../posthog-rn'\n\nexport type SurveyModalProps = {\n survey: Survey\n client?: PostHog\n initialProgress?: SurveyProgress\n onProgressChange?: (progress: SurveyProgress, completed: boolean) => boolean\n surveyLanguage: string | null\n appearance: SurveyAppearanceTheme\n onShow: () => void\n onClose: (submitted: boolean, responses: SurveyResponses) => void\n androidKeyboardBehavior?: 'padding' | 'height'\n}\n\n// No extra buffer — let the modal extend right up to the safe-area / keyboard\n// edges. Insets already keep it clear of the status bar and home indicator.\nconst VIEWPORT_BUFFER = 0\n\n// Matches RN Modal's fade animation duration (Android only).\nconst MODAL_FADE_DURATION_MS = 250\n\n// iOS normally notifies the parent via Modal.onDismiss, but Fabric can fail to fire it\n// (https://github.com/facebook/react-native/issues/48245). When that happens the parent never\n// clears the active survey, so this transparent full-screen Modal stays mounted and swallows\n// every touch — the app appears frozen. This is the safety-net delay after which we notify the\n// parent ourselves if onDismiss still hasn't fired. Longer than the dismiss animation so the\n// real onDismiss stays the primary path on the happy path.\nconst IOS_DISMISS_FALLBACK_MS = 1000\n\nfunction shouldShowIntro(appearance: SurveyAppearanceTheme, progress?: SurveyProgress): boolean {\n if (Object.keys(progress?.responses ?? {}).length > 0) return false\n return (\n Boolean(appearance.displayIntroScreen) && Boolean(appearance.introScreenHeader || appearance.introScreenDescription)\n )\n}\n\nexport function SurveyModal(props: SurveyModalProps): JSX.Element | null {\n const { survey, surveyLanguage, appearance, onShow, onClose: onCloseProp, androidKeyboardBehavior = 'height' } = props\n const [isSurveySent, setIsSurveySent] = useState(false)\n // The intro screen is a leading page mirroring the trailing confirmation message. Dismissing it\n // only flips local state — no response is recorded and no survey event is sent. It has no\n // default header, so an intro with no copy at all is skipped instead of drawing an empty box.\n const [showIntro, setShowIntro] = useState(() => shouldShowIntro(appearance, props.initialProgress))\n const [responses, setResponses] = useState<SurveyResponses>(props.initialProgress?.responses ?? {})\n const [isVisible, setIsVisible] = useState(true)\n // Two-step hide for RN Fabric snapshot recycling — see\n // https://github.com/facebook/react-native/issues/48245\n const [contentMounted, setContentMounted] = useState(true)\n const isClosingRef = useRef(false)\n const closeNotifiedRef = useRef(false)\n const closeTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)\n const notifyParentClosed = useCallback(() => {\n if (closeNotifiedRef.current) return\n closeNotifiedRef.current = true\n onCloseProp(isSurveySent, responses)\n }, [isSurveySent, onCloseProp, responses])\n const onClose = useCallback(() => {\n if (isClosingRef.current) return\n isClosingRef.current = true\n setContentMounted(false)\n requestAnimationFrame(() => {\n setIsVisible(false)\n // Always schedule a fallback to notify the parent. On Android the Modal has no onDismiss,\n // so this is the only notification path (after the fade). On iOS onDismiss is the primary\n // path, but it can silently fail to fire — this timer guarantees the parent still unmounts\n // the Modal so it can never stay up intercepting touches. notifyParentClosed is idempotent,\n // so whichever fires first wins and the other becomes a no-op.\n const fallbackDelay = Platform.OS === 'ios' ? IOS_DISMISS_FALLBACK_MS : MODAL_FADE_DURATION_MS\n closeTimerRef.current = setTimeout(notifyParentClosed, fallbackDelay)\n })\n }, [notifyParentClosed])\n\n // Clear the pending fallback timer on unmount so it can't fire after the survey is gone.\n useEffect(() => {\n return () => {\n if (closeTimerRef.current) {\n clearTimeout(closeTimerRef.current)\n }\n }\n }, [])\n const insets = useOptionalSafeAreaInsets()\n const { height: windowHeight } = useWindowDimensions()\n const [keyboardHeight, setKeyboardHeight] = useState(0)\n const { vertical, horizontal } = resolveSurveyAlignment(appearance.position)\n const isBottom = vertical === 'flex-end'\n\n const shouldShowConfirmation = isSurveySent && appearance.thankYouMessageHeader\n\n useEffect(() => {\n if (isVisible) {\n onShow()\n }\n }, [isVisible, onShow])\n\n // Track keyboard height so we can cap the modal to the visible viewport.\n // KAV alone lifts the modal but doesn't shrink it — a tall modal would\n // still bleed past the screen top.\n useEffect(() => {\n const showEvent = Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow'\n const hideEvent = Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide'\n const showSub = Keyboard.addListener(showEvent, (e) => setKeyboardHeight(e.endCoordinates.height))\n const hideSub = Keyboard.addListener(hideEvent, () => setKeyboardHeight(0))\n return () => {\n showSub.remove()\n hideSub.remove()\n }\n }, [])\n\n const maxModalHeight = Math.max(windowHeight - keyboardHeight - insets.top - insets.bottom - VIEWPORT_BUFFER, 200)\n\n const keyboardBehavior = Platform.OS === 'ios' ? 'padding' : androidKeyboardBehavior\n\n return (\n <Modal\n visible={isVisible}\n animationType=\"fade\"\n transparent\n onRequestClose={onClose}\n onDismiss={Platform.OS === 'ios' ? notifyParentClosed : undefined}\n statusBarTranslucent={true}\n >\n {contentMounted && (\n <KeyboardAvoidingView behavior={keyboardBehavior} style={styles.fill}>\n <View style={[styles.fill, styles.backdrop, { justifyContent: vertical }]} onTouchStart={Keyboard.dismiss}>\n <View style={[styles.modalRow, { justifyContent: horizontal }]}>\n <View style={styles.modalContent} pointerEvents=\"box-none\">\n <View\n onTouchStart={(event) => event.stopPropagation()}\n style={[\n styles.modalContentInner,\n {\n borderColor: appearance.borderColor,\n backgroundColor: appearance.backgroundColor,\n marginTop: vertical === 'flex-start' ? insets.top + 10 : 0,\n // When keyboard is up, sit flush against it (no extra gap).\n // When keyboard is down, leave room for the home indicator.\n marginBottom: isBottom ? (keyboardHeight > 0 ? 0 : insets.bottom + 10) : 0,\n marginHorizontal: 10,\n maxHeight: maxModalHeight,\n },\n ]}\n >\n <View style={styles.topIconContainer}>\n <Cancel onPress={onClose} appearance={appearance} />\n </View>\n {isSurveySent ? (\n shouldShowConfirmation ? (\n <ConfirmationMessage\n appearance={appearance}\n header={appearance.thankYouMessageHeader}\n description={appearance.thankYouMessageDescription}\n contentType={appearance.thankYouMessageDescriptionContentType}\n onClose={onClose}\n isModal={true}\n />\n ) : null\n ) : showIntro ? (\n <IntroMessage\n appearance={appearance}\n header={appearance.introScreenHeader}\n description={appearance.introScreenDescription}\n contentType={appearance.introScreenDescriptionContentType}\n onStart={() => setShowIntro(false)}\n />\n ) : (\n <Questions\n client={props.client}\n initialProgress={props.initialProgress}\n onProgressChange={props.onProgressChange}\n survey={survey}\n surveyLanguage={surveyLanguage}\n appearance={appearance}\n onResponsesChange={setResponses}\n onSubmit={() => setIsSurveySent(true)}\n />\n )}\n </View>\n </View>\n </View>\n </View>\n </KeyboardAvoidingView>\n )}\n </Modal>\n )\n}\n\nconst styles = createSafeStyleSheet({\n fill: {\n flex: 1,\n },\n backdrop: {\n backgroundColor: 'rgba(0, 0, 0, 0.32)',\n },\n modalRow: {\n flexDirection: 'row',\n },\n modalContent: {\n width: '90%',\n maxWidth: 400,\n },\n modalContentInner: {\n borderRadius: 10,\n borderWidth: 1,\n padding: 20,\n },\n topIconContainer: {\n // Keep the close button inside the modal so it can never bleed off-screen\n // when the modal lifts above the keyboard.\n position: 'absolute',\n right: 8,\n top: 8,\n zIndex: 1,\n },\n})\n"],"mappings":"0UAAA,IAAAA,MAAA,CAAAC,uBAAA,CAAAC,OAAA,WACA,IAAAC,YAAA,CAAAD,OAAA,iBAEA,IAAAE,OAAA,CAAAF,OAAA,aACA,IAAAG,oBAAA,CAAAH,OAAA,0BACA,IAAAI,aAAA,CAAAJ,OAAA,mBACA,IAAAK,eAAA,CAAAL,OAAA,sBACA,IAAAM,aAAA,CAAAN,OAAA,qBAEA,IAAAO,4BAAA,CAAAP,OAAA,+CACA,IAAAQ,QAAA,CAAAR,OAAA,cAAqC,IAAAS,WAAA,CAAAT,OAAA,0BAAAU,YAAA,iHAAAX,wBAAAY,CAAA,CAAAC,CAAA,wBAAAC,OAAA,KAAAC,CAAA,KAAAD,OAAA,GAAAE,CAAA,KAAAF,OAAA,UAAAd,uBAAA,UAAAA,wBAAAY,CAAA,CAAAC,CAAA,MAAAA,CAAA,EAAAD,CAAA,EAAAA,CAAA,CAAAK,UAAA,QAAAL,CAAA,KAAAM,CAAA,CAAAC,CAAA,CAAAC,CAAA,EAAAC,SAAA,gBAAAT,CAAA,YAAAA,CAAA,YAAAU,OAAA,CAAAV,CAAA,sBAAAA,CAAA,QAAAQ,CAAA,IAAAF,CAAA,CAAAL,CAAA,CAAAG,CAAA,CAAAD,CAAA,KAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,SAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,CAAAM,CAAA,EAAAO,GAAA,CAAAb,CAAA,CAAAQ,CAAA,WAAAM,GAAA,IAAAd,CAAA,aAAAc,GAAA,KAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,CAAAc,GAAA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AAAkH,GAAA,EAACnH,QAAA,CAAAiK,SAAS,EACRC,MAAM,CAAE5H,KAAK,CAAC4H,MAAO,CACrB7G,eAAe,CAAEf,KAAK,CAACe,eAAgB,CACvC8G,gBAAgB,CAAE7H,KAAK,CAAC6H,gBAAiB,CACzC5H,MAAM,CAAEA,MAAO,CACfC,cAAc,CAAEA,cAAe,CAC/Bb,UAAU,CAAEA,UAAW,CACvByI,iBAAiB,CAAExG,YAAa,CAChCyG,QAAQ,CAAE,QAAV,CAAAA,QAAQA,CAAA,QAAQ,CAAAlH,eAAe,CAAC,IAAI,CAAC,EAAC,EAEzC,EACG,CACR,CAAM,CACR,CAAM,CACR,CAAM,CACR,CAAsB,CACvB,CACI,CAAC,CAEZ,CAEA,GAAM,CAAA6E,MAAM,CAAG,GAAAsC,oCAAoB,EAAC,CAClCrC,IAAI,CAAE,CACJsC,IAAI,CAAE,C,CACP,CACDpC,QAAQ,CAAE,CACRY,eAAe,CAAE,qB,CAClB,CACDR,QAAQ,CAAE,CACRiC,aAAa,CAAE,K,CAChB,CACDhC,YAAY,CAAE,CACZiC,KAAK,CAAE,KAAK,CACZC,QAAQ,CAAE,G,CACX,CACD7B,iBAAiB,CAAE,CACjB8B,YAAY,CAAE,EAAE,CAChBC,WAAW,CAAE,CAAC,CACdC,OAAO,CAAE,E,CACV,CACDzB,gBAAgB,CAAE,CAGhBrD,QAAQ,CAAE,UAAU,CACpB+E,KAAK,CAAE,CAAC,CACR9D,GAAG,CAAE,CAAC,CACN+D,MAAM,CAAE,C,EAEX,CAAC","ignoreList":[]}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { StyleProp, ViewStyle } from 'react-native';
|
|
2
2
|
import { SurveyAppearanceTheme } from '../surveys-utils';
|
|
3
|
+
import { SurveyProgress } from '../survey-progress';
|
|
3
4
|
import { Survey, type SurveyResponses } from '@posthog/core';
|
|
4
5
|
import { PostHog } from '../../posthog-rn';
|
|
5
6
|
export declare const sendSurveyShownEvent: (survey: Survey, posthog: PostHog, surveyLanguage?: string | null) => void;
|
|
6
|
-
export declare const sendSurveyEvent: (responses: SurveyResponses | undefined, survey: Survey, posthog: PostHog, surveyLanguage?: string | null) => void;
|
|
7
|
-
export declare const dismissedSurveyEvent: (survey: Survey, responses: SurveyResponses | undefined, posthog: PostHog, surveyLanguage?: string | null) => void;
|
|
8
|
-
export declare function Questions({ survey, surveyLanguage, appearance, styleOverrides,
|
|
7
|
+
export declare const sendSurveyEvent: (responses: SurveyResponses | undefined, survey: Survey, posthog: PostHog, surveyLanguage?: string | null, progress?: SurveyProgress, completed?: boolean) => void;
|
|
8
|
+
export declare const dismissedSurveyEvent: (survey: Survey, responses: SurveyResponses | undefined, posthog: PostHog, surveyLanguage?: string | null, progress?: SurveyProgress) => void;
|
|
9
|
+
export declare function Questions({ survey, client, surveyLanguage, appearance, styleOverrides, initialProgress, onProgressChange, onResponsesChange, onSubmit, }: {
|
|
9
10
|
survey: Survey;
|
|
11
|
+
client?: PostHog;
|
|
10
12
|
surveyLanguage?: string | null;
|
|
11
13
|
appearance: SurveyAppearanceTheme;
|
|
12
14
|
styleOverrides?: StyleProp<ViewStyle>;
|
|
13
|
-
|
|
15
|
+
initialProgress?: SurveyProgress;
|
|
16
|
+
onProgressChange?: (progress: SurveyProgress, completed: boolean) => boolean;
|
|
14
17
|
onResponsesChange?: (responses: SurveyResponses) => void;
|
|
15
18
|
onSubmit: () => void;
|
|
16
19
|
}): JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports.Questions=Questions;exports.sendSurveyShownEvent=exports.sendSurveyEvent=exports.dismissedSurveyEvent=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _react=_interopRequireWildcard(require("react"));var _surveysUtils=require("../surveys-utils");var _surveyShuffling=require("../survey-shuffling");var _core=require("@posthog/core");var _surveys=require("@posthog/core/surveys");var _QuestionTypes=require("./QuestionTypes");var _usePostHog=require("../../hooks/usePostHog");var _jsxRuntime=require("react/jsx-runtime");var _this=void 0,_jsxFileName="/home/runner/work/posthog-js/posthog-js/packages/react-native/dist/surveys/components/Surveys.js";function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap(),n=new WeakMap();return(_interopRequireWildcard=function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,"default":e};if(null===e||"object"!=_typeof(e)&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f);}for(var _t2 in e)"default"!==_t2&&{}.hasOwnProperty.call(e,_t2)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,_t2))&&(i.get||i.set)?o(f,_t2,i):f[_t2]=e[_t2]);return f;})(e,t);}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){(0,_defineProperty2["default"])(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}var
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports.Questions=Questions;exports.sendSurveyShownEvent=exports.sendSurveyEvent=exports.dismissedSurveyEvent=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _react=_interopRequireWildcard(require("react"));var _surveysUtils=require("../surveys-utils");var _surveyShuffling=require("../survey-shuffling");var _surveyProgress=require("../survey-progress");var _core=require("@posthog/core");var _surveys=require("@posthog/core/surveys");var _QuestionTypes=require("./QuestionTypes");var _usePostHog=require("../../hooks/usePostHog");var _jsxRuntime=require("react/jsx-runtime");var _this=void 0,_jsxFileName="/home/runner/work/posthog-js/posthog-js/packages/react-native/dist/surveys/components/Surveys.js";function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap(),n=new WeakMap();return(_interopRequireWildcard=function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,"default":e};if(null===e||"object"!=_typeof(e)&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f);}for(var _t2 in e)"default"!==_t2&&{}.hasOwnProperty.call(e,_t2)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,_t2))&&(i.get||i.set)?o(f,_t2,i):f[_t2]=e[_t2]);return f;})(e,t);}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){(0,_defineProperty2["default"])(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}var withOriginalQuestionIndices=function withOriginalQuestionIndices(survey){return{questions:survey.questions.map(function(question,originalQuestionIndex){return _objectSpread(_objectSpread({},question),{},{originalQuestionIndex:originalQuestionIndex});})};};var sendSurveyShownEvent=exports.sendSurveyShownEvent=function sendSurveyShownEvent(survey,posthog,surveyLanguage){posthog.capture('survey shown',_objectSpread(_objectSpread(_objectSpread({$survey_name:survey.name,$survey_id:survey.id},(0,_core.maybeAdd)('$survey_iteration',survey.current_iteration)),(0,_core.maybeAdd)('$survey_iteration_start_date',survey.current_iteration_start_date)),surveyLanguage?(0,_defineProperty2["default"])({},_surveys.SURVEY_LANGUAGE_PROPERTY,surveyLanguage):{}));};var sendSurveyEvent=exports.sendSurveyEvent=function sendSurveyEvent(){var responses=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var survey=arguments.length>1?arguments[1]:undefined;var posthog=arguments.length>2?arguments[2]:undefined;var surveyLanguage=arguments.length>3?arguments[3]:undefined;var progress=arguments.length>4?arguments[4]:undefined;var completed=arguments.length>5&&arguments[5]!==undefined?arguments[5]:true;posthog.capture('survey sent',_objectSpread(_objectSpread(_objectSpread(_objectSpread({$survey_name:survey.name,$survey_id:survey.id},(0,_core.maybeAdd)('$survey_iteration',survey.current_iteration)),(0,_core.maybeAdd)('$survey_iteration_start_date',survey.current_iteration_start_date)),(0,_surveys.buildSurveyResponseEventProperties)({event:'sent',survey:withOriginalQuestionIndices(survey),responses:responses,submissionId:progress===null||progress===void 0?void 0:progress.submissionId,completed:progress?completed:undefined,surveyLanguage:surveyLanguage,questionSnapshots:progress===null||progress===void 0?void 0:progress.questionSnapshots})),{},{$set:(0,_defineProperty2["default"])({},(0,_surveys.getSurveyInteractionProperty)(survey,'responded'),true)}));};var dismissedSurveyEvent=exports.dismissedSurveyEvent=function dismissedSurveyEvent(survey){var responses=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var posthog=arguments.length>2?arguments[2]:undefined;var surveyLanguage=arguments.length>3?arguments[3]:undefined;var progress=arguments.length>4?arguments[4]:undefined;posthog.capture('survey dismissed',_objectSpread(_objectSpread(_objectSpread(_objectSpread({$survey_name:survey.name,$survey_id:survey.id},(0,_core.maybeAdd)('$survey_iteration',survey.current_iteration)),(0,_core.maybeAdd)('$survey_iteration_start_date',survey.current_iteration_start_date)),(0,_surveys.buildSurveyResponseEventProperties)({event:'dismissed',survey:withOriginalQuestionIndices(survey),responses:responses,submissionId:progress===null||progress===void 0?void 0:progress.submissionId,surveyLanguage:surveyLanguage,questionSnapshots:progress===null||progress===void 0?void 0:progress.questionSnapshots})),{},{$set:(0,_defineProperty2["default"])({},(0,_surveys.getSurveyInteractionProperty)(survey,'dismissed'),true)}));};function nextQuestion(survey,progress,originalQuestionIndex,response){if(!(0,_surveyShuffling.shouldShuffleQuestions)(survey))return(0,_surveysUtils.getNextSurveyStep)(survey,originalQuestionIndex,response);return progress.questionIndex===progress.questionOrder.length-1?_core.SurveyQuestionBranchingType.End:progress.questionIndex+1;}function Questions(_ref2){var survey=_ref2.survey,client=_ref2.client,surveyLanguage=_ref2.surveyLanguage,appearance=_ref2.appearance,styleOverrides=_ref2.styleOverrides,initialProgress=_ref2.initialProgress,_ref2$onProgressChang=_ref2.onProgressChange,onProgressChange=_ref2$onProgressChang===void 0?function(){return true;}:_ref2$onProgressChang,_ref2$onResponsesChan=_ref2.onResponsesChange,onResponsesChange=_ref2$onResponsesChan===void 0?function(){}:_ref2$onResponsesChan,onSubmit=_ref2.onSubmit;var _useState=(0,_react.useState)(function(){return initialProgress!==null&&initialProgress!==void 0?initialProgress:(0,_surveyProgress.createSurveyProgress)(survey);}),_useState2=(0,_slicedToArray2["default"])(_useState,2),progress=_useState2[0],setProgress=_useState2[1];var completedRef=(0,_react.useRef)(false);var progressRef=(0,_react.useRef)(progress);var currentQuestionIndex=progress.questionIndex;var surveyQuestions=(0,_react.useMemo)(function(){return progress.questionOrder.map(function(index){return _objectSpread(_objectSpread({},survey.questions[index]),{},{originalQuestionIndex:index});});},[survey,progress.questionOrder]);var posthogFromHook=(0,_usePostHog.usePostHog)();var posthog=client!==null&&client!==void 0?client:posthogFromHook;var onNextButtonClick=function onNextButtonClick(_ref3){var res=_ref3.res,originalQuestionIndex=_ref3.originalQuestionIndex,questionId=_ref3.questionId;if(completedRef.current||progressRef.current!==progress||!(0,_surveyProgress.canCaptureSurvey)(posthog))return;var answer=(0,_surveys.recordSurveyAnswer)(progress,questionId,res,surveyQuestions[currentQuestionIndex]);var nextStep=nextQuestion(survey,progress,originalQuestionIndex,res);var completed=nextStep===_core.SurveyQuestionBranchingType.End;var nextProgress=_objectSpread(_objectSpread(_objectSpread({},progress),answer),{},{questionIndex:completed?currentQuestionIndex:nextStep,surveyLanguage:surveyLanguage});if(onProgressChange(nextProgress,completed)===false)return;progressRef.current=nextProgress;completedRef.current=completed;setProgress(nextProgress);onResponsesChange(answer.responses);if(survey.enable_partial_responses||completed){sendSurveyEvent(answer.responses,survey,posthog,surveyLanguage,nextProgress,completed);}if(completed)onSubmit();};var question=surveyQuestions[currentQuestionIndex];return getQuestionComponent({question:question,appearance:appearance,styleOverrides:styleOverrides,onSubmit:function onSubmit(res){return onNextButtonClick({res:res,originalQuestionIndex:question.originalQuestionIndex,questionId:question.id});}});}var getQuestionComponent=function getQuestionComponent(props){var questionComponents={open:_QuestionTypes.OpenTextQuestion,link:_QuestionTypes.LinkQuestion,rating:_QuestionTypes.RatingQuestion,multiple_choice:_QuestionTypes.MultipleChoiceQuestion,single_choice:_QuestionTypes.MultipleChoiceQuestion};var Component=questionComponents[props.question.type];return(0,_jsxRuntime.jsx)(Component,_objectSpread({},props),props.question.originalQuestionIndex);};
|
|
2
2
|
//# sourceMappingURL=Surveys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Surveys.js","names":["_react","_interopRequireWildcard","require","_surveysUtils","_surveyShuffling","_core","_surveys","_QuestionTypes","_usePostHog","_jsxRuntime","_this","_jsxFileName","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t2","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","buildConfiguredSurveyResponseProperties","responses","survey","buildSurveyResponseProperties","questions","map","question","originalQuestionIndex","sendSurveyShownEvent","exports","posthog","surveyLanguage","capture","$survey_name","name","$survey_id","id","maybeAdd","current_iteration","current_iteration_start_date","SURVEY_LANGUAGE_PROPERTY","sendSurveyEvent","undefined","$set","getSurveyInteractionProperty","dismissedSurveyEvent","$survey_partially_completed","surveyHasResponses","Questions","_ref4","appearance","styleOverrides","_ref4$responses","_ref4$onResponsesChan","onResponsesChange","onSubmit","_useState","useState","_useState2","_slicedToArray2","currentQuestionIndex","setCurrentQuestionIndex","surveyQuestions","useMemo","getDisplayOrderQuestions","questionsAreShuffled","shouldShuffleQuestions","usePostHog","onNextButtonClick","_ref5","res","questionId","responseKey","getSurveyResponseKey","allResponses","index","nextStep","getNextSurveyStep","SurveyQuestionBranchingType","End","getQuestionComponent","props","questionComponents","open","OpenTextQuestion","link","LinkQuestion","rating","RatingQuestion","multiple_choice","MultipleChoiceQuestion","single_choice","Component","type","jsx"],"sources":["../../../src/surveys/components/Surveys.tsx"],"sourcesContent":["import React, { useMemo, useState } from 'react'\nimport { StyleProp, ViewStyle } from 'react-native'\n\nimport { getNextSurveyStep, SurveyAppearanceTheme } from '../surveys-utils'\nimport { getDisplayOrderQuestions, shouldShuffleQuestions } from '../survey-shuffling'\nimport { Survey, SurveyQuestion, type SurveyResponses, maybeAdd, SurveyQuestionBranchingType } from '@posthog/core'\nimport {\n buildSurveyResponseProperties,\n getSurveyInteractionProperty,\n getSurveyResponseKey,\n SURVEY_LANGUAGE_PROPERTY,\n surveyHasResponses,\n} from '@posthog/core/surveys'\nimport { LinkQuestion, MultipleChoiceQuestion, OpenTextQuestion, RatingQuestion } from './QuestionTypes'\nimport { PostHog } from '../../posthog-rn'\nimport { usePostHog } from '../../hooks/usePostHog'\n\n// Events receive the configured survey, not its shuffled display copies. Supply\n// positional indices here so legacy response properties do not depend on rendering.\nconst buildConfiguredSurveyResponseProperties = (responses: SurveyResponses, survey: Survey) =>\n buildSurveyResponseProperties(responses, {\n questions: survey.questions.map((question, originalQuestionIndex) => ({\n ...question,\n originalQuestionIndex,\n })),\n })\n\nexport const sendSurveyShownEvent = (survey: Survey, posthog: PostHog, surveyLanguage?: string | null): void => {\n posthog.capture('survey shown', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n ...maybeAdd('$survey_iteration', survey.current_iteration),\n ...maybeAdd('$survey_iteration_start_date', survey.current_iteration_start_date),\n ...(surveyLanguage ? { [SURVEY_LANGUAGE_PROPERTY]: surveyLanguage } : {}),\n })\n}\n\nexport const sendSurveyEvent = (\n responses: SurveyResponses = {},\n survey: Survey,\n posthog: PostHog,\n surveyLanguage?: string | null\n): void => {\n posthog.capture('survey sent', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n ...maybeAdd('$survey_iteration', survey.current_iteration),\n ...maybeAdd('$survey_iteration_start_date', survey.current_iteration_start_date),\n ...(surveyLanguage ? { [SURVEY_LANGUAGE_PROPERTY]: surveyLanguage } : {}),\n ...buildConfiguredSurveyResponseProperties(responses, survey),\n $set: {\n [getSurveyInteractionProperty(survey, 'responded')]: true,\n },\n })\n}\n\nexport const dismissedSurveyEvent = (\n survey: Survey,\n responses: SurveyResponses = {},\n posthog: PostHog,\n surveyLanguage?: string | null\n): void => {\n posthog.capture('survey dismissed', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n ...maybeAdd('$survey_iteration', survey.current_iteration),\n ...maybeAdd('$survey_iteration_start_date', survey.current_iteration_start_date),\n ...(surveyLanguage ? { [SURVEY_LANGUAGE_PROPERTY]: surveyLanguage } : {}),\n $survey_partially_completed: surveyHasResponses(responses),\n ...buildConfiguredSurveyResponseProperties(responses, survey),\n $set: {\n [getSurveyInteractionProperty(survey, 'dismissed')]: true,\n },\n })\n}\n\nexport function Questions({\n survey,\n surveyLanguage,\n appearance,\n styleOverrides,\n responses = {},\n onResponsesChange = () => {},\n onSubmit,\n}: {\n survey: Survey\n surveyLanguage?: string | null\n appearance: SurveyAppearanceTheme\n styleOverrides?: StyleProp<ViewStyle>\n responses?: SurveyResponses\n onResponsesChange?: (responses: SurveyResponses) => void\n onSubmit: () => void\n}): JSX.Element {\n const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0)\n const surveyQuestions = useMemo(() => getDisplayOrderQuestions(survey), [survey])\n const questionsAreShuffled = shouldShuffleQuestions(survey)\n const posthog = usePostHog()\n\n const onNextButtonClick = ({\n res,\n originalQuestionIndex,\n questionId,\n }: {\n res: string | string[] | number | null\n originalQuestionIndex: number\n questionId: string\n }): void => {\n const responseKey = getSurveyResponseKey(questionId)\n\n const allResponses = {\n ...responses,\n [responseKey]: res,\n }\n onResponsesChange(allResponses)\n\n // Shuffled surveys cannot use branching and must advance through display order.\n // Non-shuffled surveys retain the configured/original-index branching semantics.\n if (questionsAreShuffled) {\n if (currentQuestionIndex === surveyQuestions.length - 1) {\n sendSurveyEvent(allResponses, survey, posthog, surveyLanguage)\n onSubmit()\n } else {\n setCurrentQuestionIndex((index) => index + 1)\n }\n return\n }\n\n const nextStep = getNextSurveyStep(survey, originalQuestionIndex, res)\n\n if (nextStep === SurveyQuestionBranchingType.End) {\n sendSurveyEvent(allResponses, survey, posthog, surveyLanguage)\n onSubmit()\n } else {\n setCurrentQuestionIndex(nextStep)\n }\n }\n\n const question = surveyQuestions[currentQuestionIndex]\n\n return getQuestionComponent({\n question,\n appearance,\n styleOverrides,\n onSubmit: (res) =>\n onNextButtonClick({\n res,\n originalQuestionIndex: question.originalQuestionIndex,\n questionId: question.id,\n }),\n })\n}\n\ntype GetQuestionComponentProps = {\n question: SurveyQuestion\n // The question components each declare `SurveyAppearanceTheme`; typing this\n // intermediate as the shared `SurveyAppearance` dropped every React\n // Native-only field, which the `as any` below then hid.\n appearance: SurveyAppearanceTheme\n styleOverrides?: StyleProp<ViewStyle>\n onSubmit: (res: string | string[] | number | null) => void\n}\n\nconst getQuestionComponent = (props: GetQuestionComponentProps): JSX.Element => {\n const questionComponents = {\n open: OpenTextQuestion,\n link: LinkQuestion,\n rating: RatingQuestion,\n multiple_choice: MultipleChoiceQuestion,\n single_choice: MultipleChoiceQuestion,\n }\n\n const Component = questionComponents[props.question.type]\n\n return <Component key={props.question.originalQuestionIndex} {...(props as any)} />\n}\n"],"mappings":"6fAAA,IAAAA,MAAA,CAAAC,uBAAA,CAAAC,OAAA,WAGA,IAAAC,aAAA,CAAAD,OAAA,qBACA,IAAAE,gBAAA,CAAAF,OAAA,wBACA,IAAAG,KAAA,CAAAH,OAAA,kBACA,IAAAI,QAAA,CAAAJ,OAAA,0BAOA,IAAAK,cAAA,CAAAL,OAAA,oBAEA,IAAAM,WAAA,CAAAN,OAAA,2BAAmD,IAAAO,WAAA,CAAAP,OAAA,0BAAAQ,KAAA,QAAAC,YAAA,6GAAAV,wBAAAW,CAAA,CAAAC,CAAA,wBAAAC,OAAA,KAAAC,CAAA,KAAAD,OAAA,GAAAE,CAAA,KAAAF,OAAA,UAAAb,uBAAA,UAAAA,wBAAAW,CAAA,CAAAC,CAAA,MAAAA,CAAA,EAAAD,CAAA,EAAAA,CAAA,CAAAK,UAAA,QAAAL,CAAA,KAAAM,CAAA,CAAAC,CAAA,CAAAC,CAAA,EAAAC,SAAA,gBAAAT,CAAA,YAAAA,CAAA,YAAAU,OAAA,CAAAV,CAAA,sBAAAA,CAAA,QAAAQ,CAAA,IAAAF,CAAA,CAAAL,CAAA,CAAAG,CAAA,CAAAD,CAAA,KAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,SAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,CAAAM,CAAA,EAAAO,GAAA,CAAAb,CAAA,CAAAQ,CAAA,WAAAM,GAAA,IAAAd,CAAA,aAAAc,GAAA,KAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,CAAAc,GAAA,KAAAP,CAAA,EAAAD,CAAA,CAAAW,MAAA,CAAAC,cAAA,GAAAD,MAAA,CAAAE,wBAAA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dA,cAAc,CACdI,QAAQ,CAAE,QAAV,CAAAA,QAAQA,CAAGe,GAAG,QACZ,CAAAF,iBAAiB,CAAC,CAChBE,GAAG,CAAHA,GAAG,CACH3C,qBAAqB,CAAED,QAAQ,CAACC,qBAAqB,CACrD4C,UAAU,CAAE7C,QAAQ,CAACU,E,CACtB,CAAC,E,CACL,CAAC,CACJ,CAYA,GAAM,CAAA4C,oBAAoB,CAAG,QAAvB,CAAAA,oBAAoBA,CAAIC,KAAgC,CAAiB,CAC7E,GAAM,CAAAC,kBAAkB,CAAG,CACzBC,IAAI,CAAEC,+BAAgB,CACtBC,IAAI,CAAEC,2BAAY,CAClBC,MAAM,CAAEC,6BAAc,CACtBC,eAAe,CAAEC,qCAAsB,CACvCC,aAAa,CAAED,qC,CAChB,CAED,GAAM,CAAAE,SAAS,CAAGV,kBAAkB,CAACD,KAAK,CAACvD,QAAQ,CAACmE,IAAI,CAAC,CAEzD,MAAO,GAAA9G,WAAA,CAAA+G,GAAA,EAACF,SAAS,CAAA/E,aAAA,IAAiDoE,KAAa,EAAxDA,KAAK,CAACvD,QAAQ,CAACC,qBAA0C,CAAG,CACrF,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Surveys.js","names":["_react","_interopRequireWildcard","require","_surveysUtils","_surveyShuffling","_surveyProgress","_core","_surveys","_QuestionTypes","_usePostHog","_jsxRuntime","_this","_jsxFileName","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t2","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","withOriginalQuestionIndices","survey","questions","map","question","originalQuestionIndex","sendSurveyShownEvent","exports","posthog","surveyLanguage","capture","$survey_name","name","$survey_id","id","maybeAdd","current_iteration","current_iteration_start_date","SURVEY_LANGUAGE_PROPERTY","sendSurveyEvent","responses","undefined","progress","completed","buildSurveyResponseEventProperties","event","submissionId","questionSnapshots","$set","getSurveyInteractionProperty","dismissedSurveyEvent","nextQuestion","response","shouldShuffleQuestions","getNextSurveyStep","questionIndex","questionOrder","SurveyQuestionBranchingType","End","Questions","_ref2","client","appearance","styleOverrides","initialProgress","_ref2$onProgressChang","onProgressChange","_ref2$onResponsesChan","onResponsesChange","onSubmit","_useState","useState","createSurveyProgress","_useState2","_slicedToArray2","setProgress","completedRef","useRef","progressRef","currentQuestionIndex","surveyQuestions","useMemo","index","posthogFromHook","usePostHog","onNextButtonClick","_ref3","res","questionId","current","canCaptureSurvey","answer","recordSurveyAnswer","nextStep","nextProgress","enable_partial_responses","getQuestionComponent","props","questionComponents","open","OpenTextQuestion","link","LinkQuestion","rating","RatingQuestion","multiple_choice","MultipleChoiceQuestion","single_choice","Component","type","jsx"],"sources":["../../../src/surveys/components/Surveys.tsx"],"sourcesContent":["import React, { useMemo, useRef, useState } from 'react'\nimport { StyleProp, ViewStyle } from 'react-native'\n\nimport { getNextSurveyStep, SurveyAppearanceTheme } from '../surveys-utils'\nimport { shouldShuffleQuestions } from '../survey-shuffling'\nimport { canCaptureSurvey, createSurveyProgress, SurveyProgress } from '../survey-progress'\nimport { Survey, SurveyQuestion, type SurveyResponses, maybeAdd, SurveyQuestionBranchingType } from '@posthog/core'\nimport {\n buildSurveyResponseEventProperties,\n getSurveyInteractionProperty,\n recordSurveyAnswer,\n SURVEY_LANGUAGE_PROPERTY,\n} from '@posthog/core/surveys'\nimport { LinkQuestion, MultipleChoiceQuestion, OpenTextQuestion, RatingQuestion } from './QuestionTypes'\nimport { PostHog } from '../../posthog-rn'\nimport { usePostHog } from '../../hooks/usePostHog'\n\n// Events receive the configured survey, not its shuffled display copies. Supply\n// positional indices here so legacy response properties do not depend on rendering.\nconst withOriginalQuestionIndices = (survey: Survey) => ({\n questions: survey.questions.map((question, originalQuestionIndex) => ({\n ...question,\n originalQuestionIndex,\n })),\n})\n\nexport const sendSurveyShownEvent = (survey: Survey, posthog: PostHog, surveyLanguage?: string | null): void => {\n posthog.capture('survey shown', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n ...maybeAdd('$survey_iteration', survey.current_iteration),\n ...maybeAdd('$survey_iteration_start_date', survey.current_iteration_start_date),\n ...(surveyLanguage ? { [SURVEY_LANGUAGE_PROPERTY]: surveyLanguage } : {}),\n })\n}\n\nexport const sendSurveyEvent = (\n responses: SurveyResponses = {},\n survey: Survey,\n posthog: PostHog,\n surveyLanguage?: string | null,\n progress?: SurveyProgress,\n completed = true\n): void => {\n posthog.capture('survey sent', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n ...maybeAdd('$survey_iteration', survey.current_iteration),\n ...maybeAdd('$survey_iteration_start_date', survey.current_iteration_start_date),\n ...buildSurveyResponseEventProperties({\n event: 'sent',\n survey: withOriginalQuestionIndices(survey),\n responses,\n submissionId: progress?.submissionId,\n completed: progress ? completed : undefined,\n surveyLanguage,\n questionSnapshots: progress?.questionSnapshots,\n }),\n $set: {\n [getSurveyInteractionProperty(survey, 'responded')]: true,\n },\n })\n}\n\nexport const dismissedSurveyEvent = (\n survey: Survey,\n responses: SurveyResponses = {},\n posthog: PostHog,\n surveyLanguage?: string | null,\n progress?: SurveyProgress\n): void => {\n posthog.capture('survey dismissed', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n ...maybeAdd('$survey_iteration', survey.current_iteration),\n ...maybeAdd('$survey_iteration_start_date', survey.current_iteration_start_date),\n ...buildSurveyResponseEventProperties({\n event: 'dismissed',\n survey: withOriginalQuestionIndices(survey),\n responses,\n submissionId: progress?.submissionId,\n surveyLanguage,\n questionSnapshots: progress?.questionSnapshots,\n }),\n $set: {\n [getSurveyInteractionProperty(survey, 'dismissed')]: true,\n },\n })\n}\n\nfunction nextQuestion(\n survey: Survey,\n progress: SurveyProgress,\n originalQuestionIndex: number,\n response: string | string[] | number | null\n) {\n if (!shouldShuffleQuestions(survey)) return getNextSurveyStep(survey, originalQuestionIndex, response)\n // Shuffled surveys cannot use branching and must advance through display order.\n // Non-shuffled surveys retain the configured/original-index branching semantics.\n return progress.questionIndex === progress.questionOrder.length - 1\n ? SurveyQuestionBranchingType.End\n : progress.questionIndex + 1\n}\n\nexport function Questions({\n survey,\n client,\n surveyLanguage,\n appearance,\n styleOverrides,\n initialProgress,\n onProgressChange = () => true,\n onResponsesChange = () => {},\n onSubmit,\n}: {\n survey: Survey\n client?: PostHog\n surveyLanguage?: string | null\n appearance: SurveyAppearanceTheme\n styleOverrides?: StyleProp<ViewStyle>\n initialProgress?: SurveyProgress\n onProgressChange?: (progress: SurveyProgress, completed: boolean) => boolean\n onResponsesChange?: (responses: SurveyResponses) => void\n onSubmit: () => void\n}): JSX.Element {\n const [progress, setProgress] = useState(() => initialProgress ?? createSurveyProgress(survey))\n const completedRef = useRef(false)\n const progressRef = useRef(progress)\n const currentQuestionIndex = progress.questionIndex\n const surveyQuestions = useMemo(\n () =>\n progress.questionOrder.map((index) => ({\n ...survey.questions[index],\n originalQuestionIndex: index,\n })),\n [survey, progress.questionOrder]\n )\n const posthogFromHook = usePostHog()\n const posthog = client ?? posthogFromHook\n\n const onNextButtonClick = ({\n res,\n originalQuestionIndex,\n questionId,\n }: {\n res: string | string[] | number | null\n originalQuestionIndex: number\n questionId: string\n }): void => {\n if (completedRef.current || progressRef.current !== progress || !canCaptureSurvey(posthog)) return\n const answer = recordSurveyAnswer(progress, questionId, res, surveyQuestions[currentQuestionIndex])\n const nextStep = nextQuestion(survey, progress, originalQuestionIndex, res)\n const completed = nextStep === SurveyQuestionBranchingType.End\n const nextProgress: SurveyProgress = {\n ...progress,\n ...answer,\n questionIndex: completed ? currentQuestionIndex : nextStep,\n surveyLanguage,\n }\n if (onProgressChange(nextProgress, completed) === false) return\n progressRef.current = nextProgress\n completedRef.current = completed\n setProgress(nextProgress)\n onResponsesChange(answer.responses)\n if (survey.enable_partial_responses || completed) {\n sendSurveyEvent(answer.responses, survey, posthog, surveyLanguage, nextProgress, completed)\n }\n if (completed) onSubmit()\n }\n\n const question = surveyQuestions[currentQuestionIndex]\n\n return getQuestionComponent({\n question,\n appearance,\n styleOverrides,\n onSubmit: (res) =>\n onNextButtonClick({\n res,\n originalQuestionIndex: question.originalQuestionIndex,\n questionId: question.id,\n }),\n })\n}\n\ntype GetQuestionComponentProps = {\n question: SurveyQuestion\n // The question components each declare `SurveyAppearanceTheme`; typing this\n // intermediate as the shared `SurveyAppearance` dropped every React\n // Native-only field, which the `as any` below then hid.\n appearance: SurveyAppearanceTheme\n styleOverrides?: StyleProp<ViewStyle>\n onSubmit: (res: string | string[] | number | null) => void\n}\n\nconst getQuestionComponent = (props: GetQuestionComponentProps): JSX.Element => {\n const questionComponents = {\n open: OpenTextQuestion,\n link: LinkQuestion,\n rating: RatingQuestion,\n multiple_choice: MultipleChoiceQuestion,\n single_choice: MultipleChoiceQuestion,\n }\n\n const Component = questionComponents[props.question.type]\n\n return <Component key={props.question.originalQuestionIndex} {...(props as any)} />\n}\n"],"mappings":"6fAAA,IAAAA,MAAA,CAAAC,uBAAA,CAAAC,OAAA,WAGA,IAAAC,aAAA,CAAAD,OAAA,qBACA,IAAAE,gBAAA,CAAAF,OAAA,wBACA,IAAAG,eAAA,CAAAH,OAAA,uBACA,IAAAI,KAAA,CAAAJ,OAAA,kBACA,IAAAK,QAAA,CAAAL,OAAA,0BAMA,IAAAM,cAAA,CAAAN,OAAA,oBAEA,IAAAO,WAAA,CAAAP,OAAA,2BAAmD,IAAAQ,WAAA,CAAAR,OAAA,0BAAAS,KAAA,QAAAC,YAAA,6GAAAX,wBAAAY,CAAA,CAAAC,CAAA,wBAAAC,OAAA,KAAAC,CAAA,KAAAD,OAAA,GAAAE,CAAA,KAAAF,OAAA,UAAAd,uBAAA,UAAAA,wBAAAY,CAAA,CAAAC,CAAA,MAAAA,CAAA,EAAAD,CAAA,EAAAA,CAAA,CAAAK,UAAA,QAAAL,CAAA,KAAAM,CAAA,CAAAC,CAAA,CAAAC,CAAA,EAAAC,SAAA,gBA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AoBA,CAAIC,KAAgC,CAAiB,CAC7E,GAAM,CAAAC,kBAAkB,CAAG,CACzBC,IAAI,CAAEC,+BAAgB,CACtBC,IAAI,CAAEC,2BAAY,CAClBC,MAAM,CAAEC,6BAAc,CACtBC,eAAe,CAAEC,qCAAsB,CACvCC,aAAa,CAAED,qC,CAChB,CAED,GAAM,CAAAE,SAAS,CAAGV,kBAAkB,CAACD,KAAK,CAACzE,QAAQ,CAACqF,IAAI,CAAC,CAEzD,MAAO,GAAA9H,WAAA,CAAA+H,GAAA,EAACF,SAAS,CAAA/F,aAAA,IAAiDoF,KAAa,EAAxDA,KAAK,CAACzE,QAAQ,CAACC,qBAA0C,CAAG,CACrF,CAAC","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { FeatureFlagValue, Survey } from '@posthog/core';
|
|
2
|
-
export declare function getActiveMatchingSurveys(surveys: Survey[], flags: Record<string, FeatureFlagValue>, seenSurveys: string[], activatedSurveys: ReadonlySet<string>): Survey[];
|
|
2
|
+
export declare function getActiveMatchingSurveys(surveys: Survey[], flags: Record<string, FeatureFlagValue>, seenSurveys: string[], activatedSurveys: ReadonlySet<string>, inProgressSurveys?: ReadonlySet<string>): Survey[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getActiveMatchingSurveys=getActiveMatchingSurveys;var _surveys=require("@posthog/core/surveys");var _nativeDeps=require("../native-deps");var _core=require("@posthog/core");var ANY_FLAG_VARIANT='any';function defaultMatchType(matchType){return matchType!==null&&matchType!==void 0?matchType:_core.SurveyMatchType.Icontains;}function doesSurveyDeviceTypesMatch(survey){var _a;if(!((_a=survey.conditions)===null||_a===void 0?void 0:_a.deviceTypes)||survey.conditions.deviceTypes.length===0){return true;}return _surveys.propertyComparisons[defaultMatchType(survey.conditions.deviceTypesMatchType)](survey.conditions.deviceTypes,[_nativeDeps.currentDeviceType]);}function isSurveyFlagEnabled(flagKey,flags){return flagKey?!!flags[flagKey]===true:true;}function getActiveMatchingSurveys(surveys,flags,seenSurveys,activatedSurveys){return surveys.filter(function(survey){var _a,_b,_c,_d,_e;if(!survey.start_date||survey.end_date){return false;}if(!doesSurveyDeviceTypesMatch(survey)){return false;}if(seenSurveys.includes((0,_surveys.getSurveyIterationKey)(survey))&&!(0,_surveys.canSurveyActivateRepeatedly)(survey)){return false;}if(((_a=survey.conditions)===null||_a===void 0?void 0:_a.url)&&survey.conditions.url!==''||((_b=survey.conditions)===null||_b===void 0?void 0:_b.selector)&&survey.conditions.selector!==''){return false;}if(!survey.linked_flag_key&&!survey.targeting_flag_key&&!survey.internal_targeting_flag_key&&!((_c=survey.feature_flag_keys)===null||_c===void 0?void 0:_c.length)){return true;}var linkedFlagCheck=isSurveyFlagEnabled(survey.linked_flag_key,flags);var linkedFlagVariant=(_d=survey.conditions)===null||_d===void 0?void 0:_d.linkedFlagVariant;var linkedFlagVariantCheck=true;if(linkedFlagVariant){linkedFlagVariantCheck=survey.linked_flag_key?flags[survey.linked_flag_key]===linkedFlagVariant||linkedFlagVariant===ANY_FLAG_VARIANT:true;}var targetingFlagCheck=isSurveyFlagEnabled(survey.targeting_flag_key,flags);var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getActiveMatchingSurveys=getActiveMatchingSurveys;var _surveys=require("@posthog/core/surveys");var _nativeDeps=require("../native-deps");var _core=require("@posthog/core");var ANY_FLAG_VARIANT='any';function defaultMatchType(matchType){return matchType!==null&&matchType!==void 0?matchType:_core.SurveyMatchType.Icontains;}function doesSurveyDeviceTypesMatch(survey){var _a;if(!((_a=survey.conditions)===null||_a===void 0?void 0:_a.deviceTypes)||survey.conditions.deviceTypes.length===0){return true;}return _surveys.propertyComparisons[defaultMatchType(survey.conditions.deviceTypesMatchType)](survey.conditions.deviceTypes,[_nativeDeps.currentDeviceType]);}function isSurveyFlagEnabled(flagKey,flags){return flagKey?!!flags[flagKey]===true:true;}function getActiveMatchingSurveys(surveys,flags,seenSurveys,activatedSurveys){var inProgressSurveys=arguments.length>4&&arguments[4]!==undefined?arguments[4]:new Set();return surveys.filter(function(survey){var _a,_b,_c,_d,_e;var hasProgress=inProgressSurveys.has((0,_surveys.getSurveyIterationKey)(survey));if(!survey.start_date||survey.end_date){return false;}if(!doesSurveyDeviceTypesMatch(survey)){return false;}if(seenSurveys.includes((0,_surveys.getSurveyIterationKey)(survey))&&!(0,_surveys.canSurveyActivateRepeatedly)(survey)&&!hasProgress){return false;}if(((_a=survey.conditions)===null||_a===void 0?void 0:_a.url)&&survey.conditions.url!==''||((_b=survey.conditions)===null||_b===void 0?void 0:_b.selector)&&survey.conditions.selector!==''){return false;}var eventBasedTargetingFlagCheck=!(0,_surveys.doesSurveyActivateByEvent)(survey)||hasProgress||activatedSurveys.has(survey.id);if(!eventBasedTargetingFlagCheck)return false;if(!survey.linked_flag_key&&!survey.targeting_flag_key&&!survey.internal_targeting_flag_key&&!((_c=survey.feature_flag_keys)===null||_c===void 0?void 0:_c.length)){return true;}var linkedFlagCheck=isSurveyFlagEnabled(survey.linked_flag_key,flags);var linkedFlagVariant=(_d=survey.conditions)===null||_d===void 0?void 0:_d.linkedFlagVariant;var linkedFlagVariantCheck=true;if(linkedFlagVariant){linkedFlagVariantCheck=survey.linked_flag_key?flags[survey.linked_flag_key]===linkedFlagVariant||linkedFlagVariant===ANY_FLAG_VARIANT:true;}var targetingFlagCheck=isSurveyFlagEnabled(survey.targeting_flag_key,flags);var internalTargetingFlagCheck=survey.internal_targeting_flag_key&&!(0,_surveys.canSurveyActivateRepeatedly)(survey)&&!hasProgress?isSurveyFlagEnabled(survey.internal_targeting_flag_key,flags):true;var flagsCheck=((_e=survey.feature_flag_keys)===null||_e===void 0?void 0:_e.length)?survey.feature_flag_keys.every(function(_ref){var key=_ref.key,value=_ref.value;return!key||!value||isSurveyFlagEnabled(value,flags);}):true;return linkedFlagCheck&&linkedFlagVariantCheck&&targetingFlagCheck&&internalTargetingFlagCheck&&eventBasedTargetingFlagCheck&&flagsCheck;});}
|
|
2
2
|
//# sourceMappingURL=getActiveMatchingSurveys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getActiveMatchingSurveys.js","names":["_surveys","require","_nativeDeps","_core","ANY_FLAG_VARIANT","defaultMatchType","matchType","SurveyMatchType","Icontains","doesSurveyDeviceTypesMatch","survey","_a","conditions","deviceTypes","length","propertyComparisons","deviceTypesMatchType","currentDeviceType","isSurveyFlagEnabled","flagKey","flags","getActiveMatchingSurveys","surveys","seenSurveys","activatedSurveys","filter","start_date","end_date","includes","
|
|
1
|
+
{"version":3,"file":"getActiveMatchingSurveys.js","names":["_surveys","require","_nativeDeps","_core","ANY_FLAG_VARIANT","defaultMatchType","matchType","SurveyMatchType","Icontains","doesSurveyDeviceTypesMatch","survey","_a","conditions","deviceTypes","length","propertyComparisons","deviceTypesMatchType","currentDeviceType","isSurveyFlagEnabled","flagKey","flags","getActiveMatchingSurveys","surveys","seenSurveys","activatedSurveys","inProgressSurveys","arguments","undefined","Set","filter","hasProgress","has","getSurveyIterationKey","start_date","end_date","includes","canSurveyActivateRepeatedly","url","_b","selector","eventBasedTargetingFlagCheck","doesSurveyActivateByEvent","id","linked_flag_key","targeting_flag_key","internal_targeting_flag_key","_c","feature_flag_keys","linkedFlagCheck","linkedFlagVariant","_d","linkedFlagVariantCheck","targetingFlagCheck","internalTargetingFlagCheck","flagsCheck","_e","every","_ref","key","value"],"sources":["../../src/surveys/getActiveMatchingSurveys.ts"],"sourcesContent":["import {\n canSurveyActivateRepeatedly,\n doesSurveyActivateByEvent,\n getSurveyIterationKey,\n propertyComparisons,\n} from '@posthog/core/surveys'\nimport { currentDeviceType } from '../native-deps'\nimport { FeatureFlagValue, Survey, SurveyMatchType } from '@posthog/core'\n\nconst ANY_FLAG_VARIANT = 'any'\n\nfunction defaultMatchType(matchType?: SurveyMatchType): SurveyMatchType {\n return matchType ?? SurveyMatchType.Icontains\n}\n\nfunction doesSurveyDeviceTypesMatch(survey: Survey): boolean {\n if (!survey.conditions?.deviceTypes || survey.conditions.deviceTypes.length === 0) {\n return true\n }\n\n return propertyComparisons[defaultMatchType(survey.conditions.deviceTypesMatchType)](survey.conditions.deviceTypes, [\n currentDeviceType,\n ])\n}\n\nfunction isSurveyFlagEnabled(flagKey: string | undefined, flags: Record<string, FeatureFlagValue>): boolean {\n return flagKey ? !!flags[flagKey] === true : true\n}\n\nexport function getActiveMatchingSurveys(\n surveys: Survey[],\n flags: Record<string, FeatureFlagValue>,\n seenSurveys: string[],\n activatedSurveys: ReadonlySet<string>,\n inProgressSurveys: ReadonlySet<string> = new Set()\n // lastSeenSurveyDate: Date | undefined\n): Survey[] {\n return surveys.filter((survey: Survey) => {\n const hasProgress = inProgressSurveys.has(getSurveyIterationKey(survey))\n // Is Active\n if (!survey.start_date || survey.end_date) {\n return false\n }\n\n // device type check\n if (!doesSurveyDeviceTypesMatch(survey)) {\n return false\n }\n\n if (seenSurveys.includes(getSurveyIterationKey(survey)) && !canSurveyActivateRepeatedly(survey) && !hasProgress) {\n return false\n }\n\n // const surveyWaitPeriodInDays = survey.conditions?.seenSurveyWaitPeriodInDays\n // if (surveyWaitPeriodInDays && lastSeenSurveyDate) {\n // const today = new Date()\n // const diff = Math.abs(today.getTime() - lastSeenSurveyDate.getTime())\n // const diffDaysFromToday = Math.ceil(diff / (1000 * 3600 * 24))\n // if (diffDaysFromToday < surveyWaitPeriodInDays) {\n // return false\n // }\n // }\n\n // Skip surveys with URL or CSS selector conditions (not supported in React Native)\n if (\n (survey.conditions?.url && survey.conditions.url !== '') ||\n (survey.conditions?.selector && survey.conditions.selector !== '')\n ) {\n return false\n }\n\n const eventBasedTargetingFlagCheck =\n !doesSurveyActivateByEvent(survey) || hasProgress || activatedSurveys.has(survey.id)\n if (!eventBasedTargetingFlagCheck) return false\n\n if (\n !survey.linked_flag_key &&\n !survey.targeting_flag_key &&\n !survey.internal_targeting_flag_key &&\n !survey.feature_flag_keys?.length\n ) {\n // Survey is targeting All Users with no conditions\n return true\n }\n\n const linkedFlagCheck = isSurveyFlagEnabled(survey.linked_flag_key, flags)\n\n const linkedFlagVariant = survey.conditions?.linkedFlagVariant\n let linkedFlagVariantCheck = true\n if (linkedFlagVariant) {\n linkedFlagVariantCheck = survey.linked_flag_key\n ? flags[survey.linked_flag_key] === linkedFlagVariant || linkedFlagVariant === ANY_FLAG_VARIANT\n : true\n }\n\n const targetingFlagCheck = isSurveyFlagEnabled(survey.targeting_flag_key, flags)\n\n const internalTargetingFlagCheck =\n survey.internal_targeting_flag_key && !canSurveyActivateRepeatedly(survey) && !hasProgress\n ? isSurveyFlagEnabled(survey.internal_targeting_flag_key, flags)\n : true\n const flagsCheck = survey.feature_flag_keys?.length\n ? survey.feature_flag_keys.every(({ key, value }: { key: string; value?: string }) => {\n return !key || !value || isSurveyFlagEnabled(value, flags)\n })\n : true\n\n return (\n linkedFlagCheck &&\n linkedFlagVariantCheck &&\n targetingFlagCheck &&\n internalTargetingFlagCheck &&\n eventBasedTargetingFlagCheck &&\n flagsCheck\n )\n })\n}\n"],"mappings":"gIAAA,IAAAA,QAAA,CAAAC,OAAA,0BAMA,IAAAC,WAAA,CAAAD,OAAA,mBACA,IAAAE,KAAA,CAAAF,OAAA,kBAEA,GAAM,CAAAG,gBAAgB,CAAG,KAAK,CAE9B,QAAS,CAAAC,gBAAgBA,CAACC,SAA2B,EACnD,MAAO,CAAAA,SAAS,SAATA,SAAS,UAATA,SAAS,CAAIC,qBAAe,CAACC,SAAS,CAC/C,CAEA,QAAS,CAAAC,0BAA0BA,CAACC,MAAc,E,OAChD,GAAI,EAAC,CAAAC,EAAA,CAAAD,MAAM,CAACE,UAAU,UAAAD,EAAA,iBAAAA,EAAA,CAAEE,WAAW,GAAIH,MAAM,CAACE,UAAU,CAACC,WAAW,CAACC,MAAM,GAAK,CAAC,CAAE,CACjF,MAAO,KAAI,CACb,CAEA,MAAO,CAAAC,4BAAmB,CAACV,gBAAgB,CAACK,MAAM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CAC9D,IAAI,CACV,GAAM,CAAAkC,UAAU,CAAG,EAAAC,EAAA,CAAA7C,MAAM,CAACqC,iBAAiB,UAAAQ,EAAA,iBAAAA,EAAA,CAAEzC,MAAM,EAC/CJ,MAAM,CAACqC,iBAAiB,CAACS,KAAK,CAAC,SAAAC,IAAA,CAAoD,IAAjD,CAAAC,GAAG,CAAAD,IAAA,CAAHC,GAAG,CAAEC,KAAK,CAAAF,IAAA,CAALE,KAAK,CAC1C,MAAO,CAACD,GAAG,EAAI,CAACC,KAAK,EAAIzC,mBAAmB,CAACyC,KAAK,CAAEvC,KAAK,CAAC,CAC5D,CAAC,CAAC,CACF,IAAI,CAER,MACE,CAAA4B,eAAe,EACfG,sBAAsB,EACtBC,kBAAkB,EAClBC,0BAA0B,EAC1Bb,4BAA4B,EAC5Bc,UAAU,CAEd,CAAC,CAAC,CACJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.js","names":["_react","_interopRequireDefault","require","_reactNative","_OptionalReactNativeSvg","_safeStyleSheet","_jsxRuntime","_this","_jsxFileName","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","Svg","OptionalReactNativeSvg","Path","getFallbackSize","value","fallback","parsed","Number","parseInt","isNaN","getFallbackColor","fill","getFallbackFontSize","label","height","Math","round","renderFallbackIcon","_ref","jsx","Text","allowFontScaling","style","styles","fallbackIcon","color","fontSize","lineHeight","width","children","renderSvgIcon","_ref2","props","viewBox","pathProps","_a","SatisfiedEmoji","exports","d","NeutralEmoji","DissatisfiedEmoji","VeryDissatisfiedEmoji","VerySatisfiedEmoji","ThumbsUpEmoji","ThumbsDownEmoji","CheckSVG","CancelSVG","fillRule","clipRule","createSafeStyleSheet","textAlign"],"sources":["../../src/surveys/icons.tsx"],"sourcesContent":["import React, { JSX } from 'react'\nimport { Text } from 'react-native'\nimport type { SvgProps } from 'react-native-svg'\n\nimport { OptionalReactNativeSvg } from '../optional/OptionalReactNativeSvg'\nimport { createSafeStyleSheet } from './safeStyleSheet'\n\nconst Svg = OptionalReactNativeSvg?.Svg as React.ComponentType<SvgProps> | undefined\nconst Path = OptionalReactNativeSvg?.Path as React.ComponentType<Record<string, unknown>> | undefined\n\nconst getFallbackSize = (value: unknown, fallback: number): number => {\n if (typeof value === 'number') {\n return value\n }\n\n if (typeof value === 'string') {\n const parsed = Number.parseInt(value, 10)\n return Number.isNaN(parsed) ? fallback : parsed\n }\n\n return fallback\n}\n\nconst getFallbackColor = (fill: unknown): string => {\n return typeof fill === 'string' && fill !== 'none' ? fill : 'black'\n}\n\nconst getFallbackFontSize = (label: string, height: number): number => {\n return label.length > 1 ? Math.round(height * 0.55) : height\n}\n\nconst renderFallbackIcon = ({\n label,\n fill,\n height,\n}: {\n label: string\n fill?: unknown\n height: number\n}): JSX.Element => (\n <Text\n allowFontScaling={false}\n style={[\n styles.fallbackIcon,\n {\n color: getFallbackColor(fill),\n fontSize: getFallbackFontSize(label, height),\n height,\n lineHeight: height,\n width: height,\n },\n ]}\n >\n {label}\n </Text>\n)\n\nconst renderSvgIcon = ({\n props,\n height,\n width,\n viewBox,\n pathProps,\n fallback,\n}: {\n props: SvgProps\n height: string\n width: string\n viewBox: string\n pathProps: Record<string, unknown>\n fallback: string\n}): JSX.Element => {\n if (!Svg || !Path) {\n return renderFallbackIcon({\n label: fallback,\n fill: (props as { fill?: unknown }).fill,\n height: getFallbackSize(props.height ?? height, 48),\n })\n }\n\n return (\n <Svg height={height} viewBox={viewBox} width={width} {...props}>\n <Path {...pathProps} />\n </Svg>\n )\n}\n\nexport const SatisfiedEmoji = (props: SvgProps): JSX.Element =>\n renderSvgIcon({\n props,\n height: '48',\n viewBox: '0 -960 960 960',\n width: '48',\n fallback: ':)',\n pathProps: {\n d: 'M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146 272q66 0 121.5-35.5T682-393h-52q-23 40-63 61.5T480.5-310q-46.5 0-87-21T331-393h-53q26 61 81 96.5T480-261Zm0 181q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z',\n },\n })\n\nexport const NeutralEmoji = (props: SvgProps): JSX.Element =>\n renderSvgIcon({\n props,\n height: '48',\n viewBox: '0 -960 960 960',\n width: '48',\n fallback: ':|',\n pathProps: {\n d: 'M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm20 194h253v-49H354v49ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z',\n },\n })\n\nexport const DissatisfiedEmoji = (props: SvgProps): JSX.Element =>\n renderSvgIcon({\n props,\n height: '48',\n viewBox: '0 -960 960 960',\n width: '48',\n fallback: ':(',\n pathProps: {\n d: 'M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146.174 116Q413-417 358.5-379.5T278-280h53q22-42 62.173-65t87.5-23Q528-368 567.5-344.5T630-280h52q-25-63-79.826-100-54.826-37-122-37ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z',\n },\n })\n\nexport const VeryDissatisfiedEmoji = (props: SvgProps): JSX.Element =>\n renderSvgIcon({\n props,\n height: '48',\n viewBox: '0 -960 960 960',\n width: '48',\n fallback: 'X(',\n pathProps: {\n d: 'M480-417q-67 0-121.5 37.5T278-280h404q-25-63-80-100t-122-37Zm-183-72 50-45 45 45 31-36-45-45 45-45-31-36-45 45-50-45-31 36 45 45-45 45 31 36Zm272 0 44-45 51 45 31-36-45-45 45-45-31-36-51 45-44-45-31 36 44 45-44 45 31 36ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142 0 241-99t99-241q0-142-99-241t-241-99q-142 0-241 99t-99 241q0 142 99 241t241 99Z',\n },\n })\n\nexport const VerySatisfiedEmoji = (props: SvgProps): JSX.Element =>\n renderSvgIcon({\n props,\n height: '48',\n viewBox: '0 -960 960 960',\n width: '48',\n fallback: ':D',\n pathProps: {\n d: 'M479.504-261Q537-261 585.5-287q48.5-26 78.5-72.4 6-11.6-.75-22.6-6.75-11-20.25-11H316.918Q303-393 296.5-382t-.5 22.6q30 46.4 78.5 72.4 48.5 26 105.004 26ZM347-578l27 27q7.636 8 17.818 8Q402-543 410-551q8-8 8-18t-8-18l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.636-8 17.818Q276-559 284-551q8 8 18 8t18-8l27-27Zm267 0 27 27q7.714 8 18 8t18-8q8-7.636 8-17.818Q685-579 677-587l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.714-8 18t8 18q7.636 8 17.818 8Q579-543 587-551l27-27ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z',\n },\n })\n\nexport const ThumbsUpEmoji = (props: SvgProps): JSX.Element =>\n renderSvgIcon({\n props,\n height: '48',\n viewBox: '0 0 24 24',\n width: '48',\n fallback: '+',\n pathProps: {\n d: 'M2 20h2c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1H2v11zm19.83-7.12c.11-.25.17-.52.17-.8V11c0-1.1-.9-2-2-2h-5.5l.92-4.65c.05-.22.02-.46-.08-.66-.23-.45-.52-.86-.88-1.22L14 2 7.59 8.41C7.21 8.79 7 9.3 7 9.83v7.84C7 18.95 8.05 20 9.34 20h8.11c.7 0 1.36-.37 1.72-.97l2.66-6.15z',\n },\n })\n\nexport const ThumbsDownEmoji = (props: SvgProps): JSX.Element =>\n renderSvgIcon({\n props,\n height: '48',\n viewBox: '0 0 24 24',\n width: '48',\n fallback: '-',\n pathProps: {\n d: 'M22 4h-2c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h2V4zM2.17 11.12c-.11.25-.17.52-.17.8V13c0 1.1.9 2 2 2h5.5l-.92 4.65c-.05.22-.02.46.08.66.23.45.52.86.88 1.22L10 22l6.41-6.41c.38-.38.59-.89.59-1.42V6.34C17 5.05 15.95 4 14.66 4H6.55c-.7 0-1.36.37-1.72.97l-2.66 6.15z',\n },\n })\n\nexport const CheckSVG = (props: SvgProps): JSX.Element =>\n renderSvgIcon({\n props,\n height: '16',\n viewBox: '0 0 16 12',\n width: '16',\n fallback: 'v',\n pathProps: {\n d: 'M5.30769 10.6923L4.77736 11.2226C4.91801 11.3633 5.10878 11.4423 5.30769 11.4423C5.5066 11.4423 5.69737 11.3633 5.83802 11.2226L5.30769 10.6923ZM15.5303 1.53033C15.8232 1.23744 15.8232 0.762563 15.5303 0.46967C15.2374 0.176777 14.7626 0.176777 14.4697 0.46967L15.5303 1.53033ZM1.53033 5.85429C1.23744 5.56139 0.762563 5.56139 0.46967 5.85429C0.176777 6.14718 0.176777 6.62205 0.46967 6.91495L1.53033 5.85429ZM5.83802 11.2226L15.5303 1.53033L14.4697 0.46967L4.77736 10.162L5.83802 11.2226ZM0.46967 6.91495L4.77736 11.2226L5.83802 10.162L1.53033 5.85429L0.46967 6.91495Z',\n },\n })\n\nexport const CancelSVG = (props: SvgProps): JSX.Element =>\n renderSvgIcon({\n props,\n height: '12',\n viewBox: '0 0 12 12',\n width: '12',\n fallback: 'x',\n pathProps: {\n fillRule: 'evenodd',\n clipRule: 'evenodd',\n d: 'M0.164752 0.164752C0.384422 -0.0549175 0.740578 -0.0549175 0.960248 0.164752L6 5.20451L11.0398 0.164752C11.2594 -0.0549175 11.6156 -0.0549175 11.8352 0.164752C12.0549 0.384422 12.0549 0.740578 11.8352 0.960248L6.79549 6L11.8352 11.0398C12.0549 11.2594 12.0549 11.6156 11.8352 11.8352C11.6156 12.0549 11.2594 12.0549 11.0398 11.8352L6 6.79549L0.960248 11.8352C0.740578 12.0549 0.384422 12.0549 0.164752 11.8352C-0.0549175 11.6156 -0.0549175 11.2594 0.164752 11.0398L5.20451 6L0.164752 0.960248C-0.0549175 0.740578 -0.0549175 0.384422 0.164752 0.164752Z',\n fill: props.fill ?? 'black',\n },\n })\n\nconst styles = createSafeStyleSheet({\n fallbackIcon: {\n textAlign: 'center',\n },\n})\n"],"mappings":"8cAAA,IAAAA,MAAA,CAAAC,sBAAA,CAAAC,OAAA,WACA,IAAAC,YAAA,CAAAD,OAAA,iBAGA,IAAAE,uBAAA,CAAAF,OAAA,uCACA,IAAAG,eAAA,CAAAH,OAAA,qBAAuD,IAAAI,WAAA,CAAAJ,OAAA,0BAAAK,KAAA,QAAAC,YAAA,gGAAAC,QAAAC,CAAA,CAAAC,CAAA,MAAAC,CAAA,CAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,KAAAG,MAAA,CAAAE,qBAAA,MAAAC,CAAA,CAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,CAAAC,CAAA,IAAAK,CAAA,CAAAA,CAAA,CAAAC,MAAA,UAAAN,CAAA,SAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,CAAAC,CAAA,EAAAQ,UAAA,KAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,CAAAI,CAAA,UAAAJ,CAAA,WAAAU,cAAAZ,CAAA,UAAAC,CAAA,GAAAA,CAAA,CAAAY,SAAA,CAAAC,MAAA,CAAAb,CAAA,QAAAC,CAAA,OAAAW,SAAA,CAAAZ,CAAA,EAAAY,SAAA,CAAAZ,CAAA,IAAAA,CAAA,IAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,MAAAa,OAAA,UAAAd,CAAA,KAAAe,gBAAA,aAAAhB,CAAA,CAAAC,CAAA,CAAAC,CAAA,CAAAD,CAAA,MAAAE,MAAA,CAAAc,yBAAA,CAAAd,MAAA,CAAAe,gBAAA,CAAAlB,CAAA,CAAAG,MAAA,CAAAc,yBAAA,CAAAf,CAAA,GAAAH,OA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CAALA,KAAK,CACLlB,MAAM,CAAE,IAAI,CACZmB,OAAO,CAAE,WAAW,CACpBL,KAAK,CAAE,IAAI,CACXvB,QAAQ,CAAE,GAAG,CACb6B,SAAS,CAAE,CACTI,CAAC,CAAE,0jB,EAEN,CAAC,GAEG,GAAM,CAAAQ,SAAS,CAAAT,OAAA,CAAAS,SAAA,CAAG,QAAZ,CAAAA,SAASA,CAAId,KAAe,CAAiB,C,OACxD,OAAAF,aAAa,CAAC,CACZE,KAAK,CAALA,KAAK,CACLlB,MAAM,CAAE,IAAI,CACZmB,OAAO,CAAE,WAAW,CACpBL,KAAK,CAAE,IAAI,CACXvB,QAAQ,CAAE,GAAG,CACb6B,SAAS,CAAE,CACTa,QAAQ,CAAE,SAAS,CACnBC,QAAQ,CAAE,SAAS,CACnBV,CAAC,CAAE,yiBAAyiB,CAC5iB3B,IAAI,CAAE,CAAAwB,EAAA,CAAAH,KAAK,CAACrB,IAAI,UAAAwB,EAAA,UAAAA,EAAA,CAAI,O,EAEvB,CAAC,C,CAAA,CAEJ,GAAM,CAAAZ,MAAM,CAAG,GAAA0B,oCAAoB,EAAC,CAClCzB,YAAY,CAAE,CACZ0B,SAAS,CAAE,Q,EAEd,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"icons.js","names":["_react","_interopRequireDefault","require","_reactNative","_OptionalReactNativeSvg","_safeStyleSheet","_jsxRuntime","_this","_jsxFileName","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","Svg","OptionalReactNativeSvg","Path","getFallbackSize","value","fallback","parsed","Number","parseInt","isNaN","getFallbackColor","fill","getFallbackFontSize","label","height","Math","round","renderFallbackIcon","_ref","jsx","Text","allowFontScaling","style","styles","fallbackIcon","color","fontSize","lineHeight","width","children","renderSvgIcon","_ref2","props","viewBox","pathProps","_a","SatisfiedEmoji","exports","d","NeutralEmoji","DissatisfiedEmoji","VeryDissatisfiedEmoji","VerySatisfiedEmoji","ThumbsUpEmoji","ThumbsDownEmoji","CheckSVG","CancelSVG","fillRule","clipRule","createSafeStyleSheet","textAlign"],"sources":["../../src/surveys/icons.tsx"],"sourcesContent":["import React, { JSX } from 'react'\nimport { Text } from 'react-native'\nimport type { SvgProps } from 'react-native-svg'\n\nimport { OptionalReactNativeSvg } from '../optional/OptionalReactNativeSvg'\nimport { createSafeStyleSheet } from './safeStyleSheet'\n\nconst Svg = OptionalReactNativeSvg?.Svg as React.ComponentType<SvgProps> | undefined\nconst Path = OptionalReactNativeSvg?.Path as React.ComponentType<Record<string, unknown>> | undefined\n\nconst getFallbackSize = (value: unknown, fallback: number): number => {\n if (typeof value === 'number') {\n return value\n }\n\n if (typeof value === 'string') {\n const parsed = Number.parseInt(value, 10)\n return Number.isNaN(parsed) ? fallback : parsed\n }\n\n return fallback\n}\n\nconst getFallbackColor = (fill: unknown): string => {\n return typeof fill === 'string' && fill !== 'none' ? fill : 'black'\n}\n\nconst getFallbackFontSize = (label: string, height: number): number => {\n return label.length > 1 ? Math.round(height * 0.55) : height\n}\n\nconst renderFallbackIcon = ({\n label,\n fill,\n height,\n}: {\n label: string\n fill?: unknown\n height: number\n}): JSX.Element => (\n <Text\n allowFontScaling={false}\n style={[\n styles.fallbackIcon,\n {\n color: getFallbackColor(fill),\n fontSize: getFallbackFontSize(label, height),\n height,\n lineHeight: height,\n width: height,\n },\n ]}\n >\n {label}\n </Text>\n)\n\nconst renderSvgIcon = ({\n props,\n height,\n width,\n viewBox,\n pathProps,\n fallback,\n}: {\n props: SvgProps\n height: string\n width: string\n viewBox: string\n pathProps: Record<string, unknown>\n fallback: string\n}): JSX.Element => {\n if (!Svg || !Path) {\n return renderFallbackIcon({\n label: fallback,\n fill: (props as { fill?: unknown }).fill,\n height: getFallbackSize(props.height ?? height, 48),\n })\n }\n\n return (\n <Svg height={height} viewBox={viewBox} width={width} {...props}>\n <Path {...pathProps} />\n </Svg>\n )\n}\n\nexport const SatisfiedEmoji = (props: SvgProps): JSX.Element =>\n renderSvgIcon({\n props,\n height: '48',\n viewBox: '0 -960 960 960',\n width: '48',\n fallback: ':)',\n pathProps: {\n d: 'M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146 272q66 0 121.5-35.5T682-393h-52q-23 40-63 61.5T480.5-310q-46.5 0-87-21T331-393h-53q26 61 81 96.5T480-261Zm0 181q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z',\n },\n })\n\nexport const NeutralEmoji = (props: SvgProps): JSX.Element =>\n renderSvgIcon({\n props,\n height: '48',\n viewBox: '0 -960 960 960',\n width: '48',\n fallback: ':|',\n pathProps: {\n d: 'M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm20 194h253v-49H354v49ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z',\n },\n })\n\nexport const DissatisfiedEmoji = (props: SvgProps): JSX.Element =>\n renderSvgIcon({\n props,\n height: '48',\n viewBox: '0 -960 960 960',\n width: '48',\n fallback: ':(',\n pathProps: {\n d: 'M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146.174 116Q413-417 358.5-379.5T278-280h53q22-42 62.173-65t87.5-23Q528-368 567.5-344.5T630-280h52q-25-63-79.826-100-54.826-37-122-37ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z',\n },\n })\n\nexport const VeryDissatisfiedEmoji = (props: SvgProps): JSX.Element =>\n renderSvgIcon({\n props,\n height: '48',\n viewBox: '0 -960 960 960',\n width: '48',\n fallback: 'X(',\n pathProps: {\n d: 'M480-417q-67 0-121.5 37.5T278-280h404q-25-63-80-100t-122-37Zm-183-72 50-45 45 45 31-36-45-45 45-45-31-36-45 45-50-45-31 36 45 45-45 45 31 36Zm272 0 44-45 51 45 31-36-45-45 45-45-31-36-51 45-44-45-31 36 44 45-44 45 31 36ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142 0 241-99t99-241q0-142-99-241t-241-99q-142 0-241 99t-99 241q0 142 99 241t241 99Z',\n },\n })\n\nexport const VerySatisfiedEmoji = (props: SvgProps): JSX.Element =>\n renderSvgIcon({\n props,\n height: '48',\n viewBox: '0 -960 960 960',\n width: '48',\n fallback: ':D',\n pathProps: {\n d: 'M479.504-261Q537-261 585.5-287q48.5-26 78.5-72.4 6-11.6-.75-22.6-6.75-11-20.25-11H316.918Q303-393 296.5-382t-.5 22.6q30 46.4 78.5 72.4 48.5 26 105.004 26ZM347-578l27 27q7.636 8 17.818 8Q402-543 410-551q8-8 8-18t-8-18l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.636-8 17.818Q276-559 284-551q8 8 18 8t18-8l27-27Zm267 0 27 27q7.714 8 18 8t18-8q8-7.636 8-17.818Q685-579 677-587l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.714-8 18t8 18q7.636 8 17.818 8Q579-543 587-551l27-27ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z',\n },\n })\n\nexport const ThumbsUpEmoji = (props: SvgProps): JSX.Element =>\n renderSvgIcon({\n props,\n height: '48',\n viewBox: '0 0 24 24',\n width: '48',\n fallback: '+',\n pathProps: {\n d: 'M2 20h2c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1H2v11zm19.83-7.12c.11-.25.17-.52.17-.8V11c0-1.1-.9-2-2-2h-5.5l.92-4.65c.05-.22.02-.46-.08-.66-.23-.45-.52-.86-.88-1.22L14 2 7.59 8.41C7.21 8.79 7 9.3 7 9.83v7.84C7 18.95 8.05 20 9.34 20h8.11c.7 0 1.36-.37 1.72-.97l2.66-6.15z',\n },\n })\n\nexport const ThumbsDownEmoji = (props: SvgProps): JSX.Element =>\n renderSvgIcon({\n props,\n height: '48',\n viewBox: '0 0 24 24',\n width: '48',\n fallback: '-',\n pathProps: {\n d: 'M22 4h-2c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h2V4zM2.17 11.12c-.11.25-.17.52-.17.8V13c0 1.1.9 2 2 2h5.5l-.92 4.65c-.05.22-.02.46.08.66.23.45.52.86.88 1.22L10 22l6.41-6.41c.38-.38.59-.89.59-1.42V6.34C17 5.05 15.95 4 14.66 4H6.55c-.7 0-1.36.37-1.72.97l-2.66 6.15z',\n },\n })\n\nexport const CheckSVG = (props: SvgProps): JSX.Element =>\n renderSvgIcon({\n props,\n height: '16',\n viewBox: '0 0 16 12',\n width: '16',\n fallback: 'v',\n pathProps: {\n d: 'M5.30769 10.6923L4.77736 11.2226C4.91801 11.3633 5.10878 11.4423 5.30769 11.4423C5.5066 11.4423 5.69737 11.3633 5.83802 11.2226L5.30769 10.6923ZM15.5303 1.53033C15.8232 1.23744 15.8232 0.762563 15.5303 0.46967C15.2374 0.176777 14.7626 0.176777 14.4697 0.46967L15.5303 1.53033ZM1.53033 5.85429C1.23744 5.56139 0.762563 5.56139 0.46967 5.85429C0.176777 6.14718 0.176777 6.62205 0.46967 6.91495L1.53033 5.85429ZM5.83802 11.2226L15.5303 1.53033L14.4697 0.46967L4.77736 10.162L5.83802 11.2226ZM0.46967 6.91495L4.77736 11.2226L5.83802 10.162L1.53033 5.85429L0.46967 6.91495Z',\n },\n })\n\nexport const CancelSVG = (props: SvgProps): JSX.Element =>\n renderSvgIcon({\n props,\n height: '12',\n viewBox: '0 0 12 12',\n width: '12',\n fallback: 'x',\n pathProps: {\n fillRule: 'evenodd',\n clipRule: 'evenodd',\n d: 'M0.164752 0.164752C0.384422 -0.0549175 0.740578 -0.0549175 0.960248 0.164752L6 5.20451L11.0398 0.164752C11.2594 -0.0549175 11.6156 -0.0549175 11.8352 0.164752C12.0549 0.384422 12.0549 0.740578 11.8352 0.960248L6.79549 6L11.8352 11.0398C12.0549 11.2594 12.0549 11.6156 11.8352 11.8352C11.6156 12.0549 11.2594 12.0549 11.0398 11.8352L6 6.79549L0.960248 11.8352C0.740578 12.0549 0.384422 12.0549 0.164752 11.8352C-0.0549175 11.6156 -0.0549175 11.2594 0.164752 11.0398L5.20451 6L0.164752 0.960248C-0.0549175 0.740578 -0.0549175 0.384422 0.164752 0.164752Z',\n fill: props.fill ?? 'black',\n },\n })\n\nconst styles = createSafeStyleSheet({\n fallbackIcon: {\n textAlign: 'center',\n },\n})\n"],"mappings":"8cAAA,IAAAA,MAAA,CAAAC,sBAAA,CAAAC,OAAA,WACA,IAAAC,YAAA,CAAAD,OAAA,iBAGA,IAAAE,uBAAA,CAAAF,OAAA,uCACA,IAAAG,eAAA,CAAAH,OAAA,qBAAuD,IAAAI,WAAA,CAAAJ,OAAA,0BAAAK,KAAA,QAAAC,YAAA,gGAAAC,QAAAC,CAAA,CAAAC,CAAA,MAAAC,CAAA,CAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,KAAAG,MAAA,CAAAE,qBAAA,MAAAC,CAAA,CAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,CAAAC,CAAA,IAAAK,CAAA,CAAAA,CAAA,CAAAC,MAAA,UAAAN,CAAA,SAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,CAAAC,CAAA,EAAAQ,UAAA,KAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,CAAAI,CAAA,UAAAJ,CAAA,WAAAU,cAAAZ,CAAA,UAAAC,CAAA,GAAAA,CAAA,CAAAY,SAAA,CAAAC,MAAA,CAAAb,CAAA,QAAAC,CAAA,OAAAW,SAAA,CAAAZ,CAAA,EAAAY,SAAA,CAAAZ,CAAA,IAAAA,CAAA,IAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,MAAAa,OAAA,UAAA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AAG,CACb6B,SAAS,CAAE,CACTI,CAAC,CAAE,oQ,EAEN,CAAC,GAEG,GAAM,CAAAO,QAAQ,CAAAR,OAAA,CAAAQ,QAAA,CAAG,QAAX,CAAAA,QAAQA,CAAIb,KAAe,QACtC,CAAAF,aAAa,CAAC,CACZE,KAAK,CAALA,KAAK,CACLlB,MAAM,CAAE,IAAI,CACZmB,OAAO,CAAE,WAAW,CACpBL,KAAK,CAAE,IAAI,CACXvB,QAAQ,CAAE,GAAG,CACb6B,SAAS,CAAE,CACTI,CAAC,CAAE,0jB,EAEN,CAAC,GAEG,GAAM,CAAAQ,SAAS,CAAAT,OAAA,CAAAS,SAAA,CAAG,QAAZ,CAAAA,SAASA,CAAId,KAAe,CAAiB,KAAAG,EAAA,OACxD,CAAAL,aAAa,CAAC,CACZE,KAAK,CAALA,KAAK,CACLlB,MAAM,CAAE,IAAI,CACZmB,OAAO,CAAE,WAAW,CACpBL,KAAK,CAAE,IAAI,CACXvB,QAAQ,CAAE,GAAG,CACb6B,SAAS,CAAE,CACTa,QAAQ,CAAE,SAAS,CACnBC,QAAQ,CAAE,SAAS,CACnBV,CAAC,CAAE,yiBAAyiB,CAC5iB3B,IAAI,EAAAwB,EAAA,CAAEH,KAAK,CAACrB,IAAI,UAAAwB,EAAA,UAAAA,EAAA,CAAI,O,EAEvB,CAAC,GAEJ,GAAM,CAAAZ,MAAM,CAAG,GAAA0B,oCAAoB,EAAC,CAClCzB,YAAY,CAAE,CACZ0B,SAAS,CAAE,Q,EAEd,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safeStyleSheet.js","names":["_reactNative","require","createSafeStyleSheet","exports","styles","StyleSheet","create"
|
|
1
|
+
{"version":3,"file":"safeStyleSheet.js","names":["_reactNative","require","createSafeStyleSheet","exports","styles","StyleSheet","create"],"sources":["../../src/surveys/safeStyleSheet.ts"],"sourcesContent":["import { StyleSheet } from 'react-native'\n\n/**\n * `StyleSheet.create` that returns the raw style map when the React Native\n * `StyleSheet` runtime is unavailable (e.g. Jest `testEnvironment: node` without\n * the RN preset), instead of throwing at import.\n * See https://github.com/PostHog/posthog-js/issues/3740.\n */\nexport const createSafeStyleSheet = <T extends StyleSheet.NamedStyles<T>>(styles: T): T => {\n try {\n return typeof StyleSheet?.create === 'function' ? StyleSheet.create(styles) : styles\n } catch {\n return styles\n }\n}\n"],"mappings":"0GAAA,IAAAA,YAAA,CAAAC,OAAA,iBAQO,GAAM,CAAAC,oBAAoB,CAAAC,OAAA,CAAAD,oBAAA,CAAG,QAAvB,CAAAA,oBAAoBA,CAAyCE,MAAS,CAAO,CACxF,GAAI,CACF,MAAO,QAAOC,uBAAU,SAAVA,uBAAU,iBAAVA,uBAAU,CAAEC,MAAM,IAAK,UAAU,CAAGD,uBAAU,CAACC,MAAM,CAACF,MAAM,CAAC,CAAGA,MAAM,CACtF,C,SAAQ,CACN,MAAO,CAAAA,MAAM,CACf,CACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Survey, SurveyResponses } from '@posthog/core';
|
|
2
|
+
import type { PostHog } from '../posthog-rn';
|
|
3
|
+
export type SurveyProgress = {
|
|
4
|
+
submissionId: string;
|
|
5
|
+
questionIndex: number;
|
|
6
|
+
questionOrder: number[];
|
|
7
|
+
responses: SurveyResponses;
|
|
8
|
+
questionSnapshots: Record<string, string>;
|
|
9
|
+
surveyLanguage?: string | null;
|
|
10
|
+
};
|
|
11
|
+
export declare function createSurveyProgress(survey: Survey): SurveyProgress;
|
|
12
|
+
export declare function canCaptureSurvey(posthog: PostHog): boolean;
|
|
13
|
+
export declare function getOtherProjectSurveyProgress(posthog: PostHog): unknown[];
|
|
14
|
+
export declare class SurveyProgressStore {
|
|
15
|
+
private readonly posthog;
|
|
16
|
+
constructor(posthog: PostHog);
|
|
17
|
+
private read;
|
|
18
|
+
private write;
|
|
19
|
+
load(survey: Survey): SurveyProgress | undefined;
|
|
20
|
+
save(survey: Survey, progress: SurveyProgress): void;
|
|
21
|
+
remove(survey: Survey): void;
|
|
22
|
+
reconcile(surveys: Survey[]): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.SurveyProgressStore=void 0;exports.canCaptureSurvey=canCaptureSurvey;exports.createSurveyProgress=createSurveyProgress;exports.getOtherProjectSurveyProgress=getOtherProjectSurveyProgress;var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _core=require("@posthog/core");var _surveys=require("@posthog/core/surveys");var _surveyShuffling=require("./survey-shuffling");function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){(0,_defineProperty2["default"])(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function createSurveyProgress(survey){return{submissionId:(0,_core.uuidv7)(),questionIndex:0,questionOrder:(0,_surveyShuffling.getDisplayOrderQuestions)(survey).map(function(question){return question.originalQuestionIndex;}),responses:{},questionSnapshots:{}};}function questionShape(question){var base={id:question.id,type:question.type,optional:question.optional,branching:question.branching};switch(question.type){case _core.SurveyQuestionType.SingleChoice:case _core.SurveyQuestionType.MultipleChoice:return _objectSpread(_objectSpread({},base),{},{choices:question.choices,hasOpenChoice:question.hasOpenChoice});case _core.SurveyQuestionType.Rating:return _objectSpread(_objectSpread({},base),{},{scale:question.scale,display:question.display});case _core.SurveyQuestionType.Link:return _objectSpread(_objectSpread({},base),{},{link:question.link});default:return base;}}function surveyShape(survey){var _a;return JSON.stringify([survey.current_iteration_start_date,survey.enable_partial_responses,(_a=survey.appearance)===null||_a===void 0?void 0:_a.shuffleQuestions,survey.questions.map(questionShape)]);}var MAX_PROGRESS=20;var MAX_AGE=30*24*60*60*1000;function isRecord(value){return(0,_typeof2["default"])(value)==='object'&&value!==null&&!Array.isArray(value);}function isNonEmptyString(value){return typeof value==='string'&&value.length>0;}function isQuestionIndex(value,count){return typeof value==='number'&&Number.isInteger(value)&&value>=0&&value<count;}function isQuestionOrder(value,count){if(!Array.isArray(value)||value.length!==count||new Set(value).size!==count)return false;return value.every(function(index){return isQuestionIndex(index,count);});}function isResponse(value){if(value===null||typeof value==='string')return true;if(typeof value==='number')return Number.isFinite(value);return Array.isArray(value)&&value.every(function(item){return typeof item==='string';});}function validResponses(value,survey){if(!isRecord(value))return false;var keys=new Set(survey.questions.map(function(question){return(0,_surveys.getSurveyResponseKey)(question.id);}));return Object.entries(value).every(function(_ref){var _ref2=(0,_slicedToArray2["default"])(_ref,2),key=_ref2[0],response=_ref2[1];return keys.has(key)&&isResponse(response);});}function validSnapshots(value,survey){if(!isRecord(value))return false;var ids=new Set(survey.questions.map(function(question){return question.id;}));return Object.entries(value).every(function(_ref3){var _ref4=(0,_slicedToArray2["default"])(_ref3,2),id=_ref4[0],text=_ref4[1];return ids.has(id)&&typeof text==='string';});}function validProgress(value,survey){if(!isRecord(value))return false;var submissionId=value.submissionId,questionIndex=value.questionIndex,questionOrder=value.questionOrder,responses=value.responses,questionSnapshots=value.questionSnapshots,surveyLanguage=value.surveyLanguage;var languageIsValid=surveyLanguage==null||typeof surveyLanguage==='string';return isNonEmptyString(submissionId)&&languageIsValid&&isQuestionIndex(questionIndex,survey.questions.length)&&isQuestionOrder(questionOrder,survey.questions.length)&&validResponses(responses,survey)&&validSnapshots(questionSnapshots,survey);}function isRecent(value){return typeof value==='number'&&value>Date.now()-MAX_AGE&&value<=Date.now();}function isSavedProgress(value,project){if(!isRecord(value))return false;return value.project===project&&typeof value.surveyKey==='string'&&isNonEmptyString(value.shape)&&isRecent(value.updatedAt)&&isRecord(value.progress);}function canCaptureSurvey(posthog){return!posthog.optedOut&&!posthog.isDisabled;}function getOtherProjectSurveyProgress(posthog){var raw=posthog.getPersistedProperty(_core.PostHogPersistedProperty.SurveysInProgress);if(!Array.isArray(raw))return[];var counts=new Map();return raw.filter(function(entry){var _a;if(!isRecord(entry)||!isNonEmptyString(entry.project)||entry.project===posthog.apiKey)return false;if(!isSavedProgress(entry,entry.project))return false;var count=(_a=counts.get(entry.project))!==null&&_a!==void 0?_a:0;if(count>=MAX_PROGRESS)return false;counts.set(entry.project,count+1);return true;});}var SurveyProgressStore=exports.SurveyProgressStore=function(){function SurveyProgressStore(posthog){(0,_classCallCheck2["default"])(this,SurveyProgressStore);this.posthog=posthog;}return(0,_createClass2["default"])(SurveyProgressStore,[{key:"read",value:function read(){var _this=this;var raw=this.posthog.getPersistedProperty(_core.PostHogPersistedProperty.SurveysInProgress);if(!Array.isArray(raw))return[];return raw.filter(function(entry){return isSavedProgress(entry,_this.posthog.apiKey);}).slice(0,MAX_PROGRESS);}},{key:"write",value:function write(entries){this.posthog.setPersistedProperty(_core.PostHogPersistedProperty.SurveysInProgress,[].concat((0,_toConsumableArray2["default"])(entries.slice(0,MAX_PROGRESS)),(0,_toConsumableArray2["default"])(getOtherProjectSurveyProgress(this.posthog))));}},{key:"load",value:function load(survey){var entry=this.read().find(function(entry){return entry.surveyKey===(0,_surveys.getSurveyIterationKey)(survey);});return(entry===null||entry===void 0?void 0:entry.shape)===surveyShape(survey)&&validProgress(entry.progress,survey)?entry.progress:undefined;}},{key:"save",value:function save(survey,progress){var surveyKey=(0,_surveys.getSurveyIterationKey)(survey);this.write([{project:this.posthog.apiKey,surveyKey:surveyKey,shape:surveyShape(survey),updatedAt:Date.now(),progress:progress}].concat((0,_toConsumableArray2["default"])(this.read().filter(function(entry){return entry.surveyKey!==surveyKey;}))));}},{key:"remove",value:function remove(survey){this.write(this.read().filter(function(entry){return entry.surveyKey!==(0,_surveys.getSurveyIterationKey)(survey);}));}},{key:"reconcile",value:function reconcile(surveys){var _this2=this;var validKeys=new Set(surveys.filter(function(survey){return survey.start_date&&!survey.end_date&&_this2.load(survey);}).map(_surveys.getSurveyIterationKey));this.write(this.read().filter(function(entry){return validKeys.has(entry.surveyKey);}));}}]);}();
|
|
2
|
+
//# sourceMappingURL=survey-progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"survey-progress.js","names":["_core","require","_surveys","_surveyShuffling","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","createSurveyProgress","survey","submissionId","uuidv7","questionIndex","questionOrder","getDisplayOrderQuestions","map","question","originalQuestionIndex","responses","questionSnapshots","questionShape","base","id","type","optional","branching","SurveyQuestionType","SingleChoice","MultipleChoice","choices","hasOpenChoice","Rating","scale","display","Link","link","surveyShape","JSON","stringify","current_iteration_start_date","enable_partial_responses","_a","appearance","shuffleQuestions","questions","MAX_PROGRESS","MAX_AGE","isRecord","value","_typeof2","Array","isArray","isNonEmptyString","isQuestionIndex","count","Number","isInteger","isQuestionOrder","Set","size","every","index","isResponse","isFinite","item","validResponses","getSurveyResponseKey","entries","_ref","_ref2","_slicedToArray2","key","response","has","validSnapshots","ids","_ref3","_ref4","text","validProgress","surveyLanguage","languageIsValid","isRecent","Date","now","isSavedProgress","project","surveyKey","shape","updatedAt","progress","canCaptureSurvey","posthog","optedOut","isDisabled","getOtherProjectSurveyProgress","raw","getPersistedProperty","PostHogPersistedProperty","SurveysInProgress","counts","Map","entry","apiKey","get","set","SurveyProgressStore","exports","_classCallCheck2","_createClass2","read","_this","slice","write","setPersistedProperty","concat","_toConsumableArray2","load","find","getSurveyIterationKey","undefined","save","remove","reconcile","surveys","_this2","validKeys","start_date","end_date"],"sources":["../../src/surveys/survey-progress.ts"],"sourcesContent":["import {\n PostHogPersistedProperty,\n Survey,\n SurveyQuestion,\n SurveyQuestionType,\n SurveyResponses,\n uuidv7,\n} from '@posthog/core'\nimport { getSurveyIterationKey, getSurveyResponseKey } from '@posthog/core/surveys'\nimport type { PostHog } from '../posthog-rn'\nimport { getDisplayOrderQuestions } from './survey-shuffling'\n\nexport type SurveyProgress = {\n submissionId: string\n questionIndex: number\n questionOrder: number[]\n responses: SurveyResponses\n questionSnapshots: Record<string, string>\n surveyLanguage?: string | null\n}\n\nexport function createSurveyProgress(survey: Survey): SurveyProgress {\n return {\n submissionId: uuidv7(),\n questionIndex: 0,\n questionOrder: getDisplayOrderQuestions(survey).map((question) => question.originalQuestionIndex),\n responses: {},\n questionSnapshots: {},\n }\n}\n\n// Copy changes (including translations) do not invalidate answers. Changes to\n// question identity, response shape or branching must start a new submission.\nfunction questionShape(question: SurveyQuestion): object {\n const base = { id: question.id, type: question.type, optional: question.optional, branching: question.branching }\n switch (question.type) {\n case SurveyQuestionType.SingleChoice:\n case SurveyQuestionType.MultipleChoice:\n return { ...base, choices: question.choices, hasOpenChoice: question.hasOpenChoice }\n case SurveyQuestionType.Rating:\n return { ...base, scale: question.scale, display: question.display }\n case SurveyQuestionType.Link:\n return { ...base, link: question.link }\n default:\n return base\n }\n}\n\nfunction surveyShape(survey: Survey): string {\n return JSON.stringify([\n survey.current_iteration_start_date,\n survey.enable_partial_responses,\n survey.appearance?.shuffleQuestions,\n survey.questions.map(questionShape),\n ])\n}\n\ntype SavedProgress = {\n project: string\n surveyKey: string\n shape: string\n updatedAt: number\n progress: SurveyProgress\n}\n\nconst MAX_PROGRESS = 20\nconst MAX_AGE = 30 * 24 * 60 * 60 * 1000\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === 'string' && value.length > 0\n}\n\nfunction isQuestionIndex(value: unknown, count: number): value is number {\n return typeof value === 'number' && Number.isInteger(value) && value >= 0 && value < count\n}\n\nfunction isQuestionOrder(value: unknown, count: number): value is number[] {\n if (!Array.isArray(value) || value.length !== count || new Set(value).size !== count) return false\n return value.every((index) => isQuestionIndex(index, count))\n}\n\nfunction isResponse(value: unknown): boolean {\n if (value === null || typeof value === 'string') return true\n if (typeof value === 'number') return Number.isFinite(value)\n return Array.isArray(value) && value.every((item) => typeof item === 'string')\n}\n\nfunction validResponses(value: unknown, survey: Survey): boolean {\n if (!isRecord(value)) return false\n const keys = new Set(survey.questions.map((question) => getSurveyResponseKey(question.id)))\n return Object.entries(value).every(([key, response]) => keys.has(key) && isResponse(response))\n}\n\nfunction validSnapshots(value: unknown, survey: Survey): boolean {\n if (!isRecord(value)) return false\n const ids = new Set(survey.questions.map((question) => question.id))\n return Object.entries(value).every(([id, text]) => ids.has(id) && typeof text === 'string')\n}\n\nfunction validProgress(value: unknown, survey: Survey): value is SurveyProgress {\n if (!isRecord(value)) return false\n const { submissionId, questionIndex, questionOrder, responses, questionSnapshots, surveyLanguage } = value\n const languageIsValid = surveyLanguage == null || typeof surveyLanguage === 'string'\n return (\n isNonEmptyString(submissionId) &&\n languageIsValid &&\n isQuestionIndex(questionIndex, survey.questions.length) &&\n isQuestionOrder(questionOrder, survey.questions.length) &&\n validResponses(responses, survey) &&\n validSnapshots(questionSnapshots, survey)\n )\n}\n\nfunction isRecent(value: unknown): boolean {\n return typeof value === 'number' && value > Date.now() - MAX_AGE && value <= Date.now()\n}\n\nfunction isSavedProgress(value: unknown, project: string): value is SavedProgress {\n if (!isRecord(value)) return false\n return (\n value.project === project &&\n typeof value.surveyKey === 'string' &&\n isNonEmptyString(value.shape) &&\n isRecent(value.updatedAt) &&\n isRecord(value.progress)\n )\n}\n\nexport function canCaptureSurvey(posthog: PostHog): boolean {\n return !posthog.optedOut && !posthog.isDisabled\n}\n\nexport function getOtherProjectSurveyProgress(posthog: PostHog): unknown[] {\n const raw = posthog.getPersistedProperty<unknown>(PostHogPersistedProperty.SurveysInProgress)\n if (!Array.isArray(raw)) return []\n const counts = new Map<string, number>()\n return raw.filter((entry) => {\n if (!isRecord(entry) || !isNonEmptyString(entry.project) || entry.project === posthog.apiKey) return false\n if (!isSavedProgress(entry, entry.project)) return false\n const count = counts.get(entry.project) ?? 0\n if (count >= MAX_PROGRESS) return false\n counts.set(entry.project, count + 1)\n return true\n })\n}\n\nexport class SurveyProgressStore {\n constructor(private readonly posthog: PostHog) {}\n\n private read(): SavedProgress[] {\n const raw = this.posthog.getPersistedProperty<unknown>(PostHogPersistedProperty.SurveysInProgress)\n if (!Array.isArray(raw)) return []\n return raw\n .filter((entry): entry is SavedProgress => isSavedProgress(entry, this.posthog.apiKey))\n .slice(0, MAX_PROGRESS)\n }\n\n private write(entries: SavedProgress[]): void {\n this.posthog.setPersistedProperty(PostHogPersistedProperty.SurveysInProgress, [\n ...entries.slice(0, MAX_PROGRESS),\n ...getOtherProjectSurveyProgress(this.posthog),\n ])\n }\n\n load(survey: Survey): SurveyProgress | undefined {\n const entry = this.read().find((entry) => entry.surveyKey === getSurveyIterationKey(survey))\n return entry?.shape === surveyShape(survey) && validProgress(entry.progress, survey) ? entry.progress : undefined\n }\n\n save(survey: Survey, progress: SurveyProgress): void {\n const surveyKey = getSurveyIterationKey(survey)\n this.write([\n {\n project: this.posthog.apiKey,\n surveyKey,\n shape: surveyShape(survey),\n updatedAt: Date.now(),\n progress,\n },\n ...this.read().filter((entry) => entry.surveyKey !== surveyKey),\n ])\n }\n\n remove(survey: Survey): void {\n this.write(this.read().filter((entry) => entry.surveyKey !== getSurveyIterationKey(survey)))\n }\n\n reconcile(surveys: Survey[]): void {\n const validKeys = new Set(\n surveys.filter((survey) => survey.start_date && !survey.end_date && this.load(survey)).map(getSurveyIterationKey)\n )\n this.write(this.read().filter((entry) => validKeys.has(entry.surveyKey)))\n }\n}\n"],"mappings":"83BAAA,IAAAA,KAAA,CAAAC,OAAA,kBAQA,IAAAC,QAAA,CAAAD,OAAA,0BAEA,IAAAE,gBAAA,CAAAF,OAAA,uBAA6D,SAAAG,QAAAC,CAAA,CAAAC,CAAA,MAAAC,CAAA,CAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,KAAAG,MAAA,CAAAE,qBAAA,MAAAC,CAAA,CAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,CAAAC,CAAA,IAAAK,CAAA,CAAAA,CAAA,CAAAC,MAAA,UAAAN,CAAA,SAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,CAAAC,CAAA,EAAAQ,UAAA,KAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,CAAAI,CAAA,UAAAJ,CAAA,WAAAU,cAAAZ,CAAA,UAAAC,CAAA,GAAAA,CAAA,CAAAY,SAAA,CAAAC,MAAA,CAAAb,CAAA,QAAAC,CAAA,OAAAW,SAAA,CAAAZ,CAAA,EAAAY,SAAA,CAAAZ,CAAA,IAAAA,CAAA,IAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,MAAAa,OAAA,UAAAd,CAAA,KAAAe,gBAAA,aAAAhB,CAAA,CAAAC,CAAA,CAAAC,CAAA,CAAAD,CAAA,MAAAE,MAAA,CAAAc,yBAAA,CAAAd,MAAA,CAAAe,gBAAA,CAAAlB,CAAA,CAAAG,MAAA,CAAAc,yBAAA,CAAAf,CAAA,GAAAH,OAAA,CAAAI,MAAA,CAAAD,CAAA,GAAAa,OAAA,UAAAd,CAAA,EAAAE,MAAA,CAAAgB,cAAA,CAAAnB,CAAA,CAAAC,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C9F,CAAC,GAAA8D,GAAA,aAAAvB,KAAA,CAED,SAAA2E,SAASA,CAACC,OAAiB,MAAAC,MAAA,MACzB,GAAM,CAAAC,SAAS,CAAG,GAAI,CAAApE,GAAG,CACvBkE,OAAO,CAACjI,MAAM,CAAC,SAACc,MAAM,QAAK,CAAAA,MAAM,CAACsH,UAAU,EAAI,CAACtH,MAAM,CAACuH,QAAQ,EAAIH,MAAI,CAACR,IAAI,CAAC5G,MAAM,CAAC,GAAC,CAACM,GAAG,CAACwG,8BAAqB,CAAC,CAClH,CACD,IAAI,CAACN,KAAK,CAAC,IAAI,CAACH,IAAI,EAAE,CAACnH,MAAM,CAAC,SAAC2G,KAAK,QAAK,CAAAwB,SAAS,CAACrD,GAAG,CAAC6B,KAAK,CAACf,SAAS,CAAC,GAAC,CAAC,CAC3E,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"survey-shuffling.js","names":["_surveys","require","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","hasBranching","survey","questions","some","question","_a","branching","type","shouldShuffleQuestions","exports","partialResponsesEnabled","enable_partial_responses","appearance","shuffleQuestions","reverseIfUnshuffled","unshuffled","shuffled","every","value","index","reverse","getDisplayOrderQuestions","map","originalQuestionIndex","shuffle"],"sources":["../../src/surveys/survey-shuffling.ts"],"sourcesContent":["import { shuffle } from '@posthog/core/surveys'\nexport { getDisplayOrderChoices, shuffle } from '@posthog/core/surveys'\nimport { Survey, SurveyQuestion } from '@posthog/core'\n\
|
|
1
|
+
{"version":3,"file":"survey-shuffling.js","names":["_surveys","require","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","hasBranching","survey","questions","some","question","_a","branching","type","shouldShuffleQuestions","exports","partialResponsesEnabled","enable_partial_responses","appearance","shuffleQuestions","reverseIfUnshuffled","unshuffled","shuffled","every","value","index","reverse","getDisplayOrderQuestions","map","originalQuestionIndex","shuffle"],"sources":["../../src/surveys/survey-shuffling.ts"],"sourcesContent":["import { shuffle } from '@posthog/core/surveys'\nexport { getDisplayOrderChoices, shuffle } from '@posthog/core/surveys'\nimport { Survey, SurveyQuestion } from '@posthog/core'\n\nconst hasBranching = (survey: Survey): boolean => survey.questions.some((question) => !!question.branching?.type)\n\nexport const shouldShuffleQuestions = (survey: Survey): boolean => {\n const partialResponsesEnabled = survey.enable_partial_responses\n\n return !!survey.appearance?.shuffleQuestions && !partialResponsesEnabled && !hasBranching(survey)\n}\n\nconst reverseIfUnshuffled = <T>(unshuffled: readonly T[], shuffled: T[]): T[] => {\n if (shuffled.length > 1 && unshuffled.every((value, index) => value === shuffled[index])) {\n return shuffled.reverse()\n }\n\n return shuffled\n}\n\nexport const getDisplayOrderQuestions = (survey: Survey): SurveyQuestion[] => {\n const questions = survey.questions.map((question, originalQuestionIndex) => ({\n ...question,\n originalQuestionIndex,\n }))\n\n if (!shouldShuffleQuestions(survey)) {\n return questions\n }\n\n return reverseIfUnshuffled(questions, shuffle(questions))\n}\n"],"mappings":"4iBAAA,IAAAA,QAAA,CAAAC,OAAA,0BAA+C,SAAAC,QAAAC,CAAA,CAAAC,CAAA,MAAAC,CAAA,CAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,KAAAG,MAAA,CAAAE,qBAAA,MAAAC,CAAA,CAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,CAAAC,CAAA,IAAAK,CAAA,CAAAA,CAAA,CAAAC,MAAA,UAAAN,CAAA,SAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,CAAAC,CAAA,EAAAQ,UAAA,KAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,CAAAI,CAAA,UAAAJ,C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AAG,QAAtB,CAAAA,mBAAmBA,CAAOC,UAAwB,CAAEC,QAAa,CAAS,CAC9E,GAAIA,QAAQ,CAACtB,MAAM,CAAG,CAAC,EAAIqB,UAAU,CAACE,KAAK,CAAC,SAACC,KAAK,CAAEC,KAAK,QAAK,CAAAD,KAAK,GAAKF,QAAQ,CAACG,KAAK,CAAC,GAAC,CAAE,CACxF,MAAO,CAAAH,QAAQ,CAACI,OAAO,EAAE,CAC3B,CAEA,MAAO,CAAAJ,QAAQ,CACjB,CAAC,CAEM,GAAM,CAAAK,wBAAwB,CAAAZ,OAAA,CAAAY,wBAAA,CAAG,QAA3B,CAAAA,wBAAwBA,CAAIpB,MAAc,CAAsB,CAC3E,GAAM,CAAAC,SAAS,CAAGD,MAAM,CAACC,SAAS,CAACoB,GAAG,CAAC,SAAClB,QAAQ,CAAEmB,qBAAqB,SAAA/B,aAAA,CAAAA,aAAA,IAClEY,QAAQ,MACXmB,qBAAqB,CAArBA,qBAAqB,IACrB,CAAC,CAEH,GAAI,CAACf,sBAAsB,CAACP,MAAM,CAAC,CAAE,CACnC,MAAO,CAAAC,SAAS,CAClB,CAEA,MAAO,CAAAY,mBAAmB,CAACZ,SAAS,CAAE,GAAAsB,gBAAO,EAACtB,SAAS,CAAC,CAAC,CAC3D,CAAC","ignoreList":[]}
|
|
@@ -10,7 +10,7 @@ export { isMatchingRegex, matchPropertyFilters, propertyComparisons as surveyVal
|
|
|
10
10
|
* @returns True if the description should be rendered, false otherwise
|
|
11
11
|
*/
|
|
12
12
|
export declare function shouldRenderDescription(description?: string | null, contentType?: SurveyQuestionDescriptionContentType): boolean;
|
|
13
|
-
export declare const defaultBackgroundColor:
|
|
13
|
+
export declare const defaultBackgroundColor: '#eeeded';
|
|
14
14
|
export declare const defaultDescriptionOpacity = 0.8;
|
|
15
15
|
export declare const defaultRatingLabelOpacity = 0.7;
|
|
16
16
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useActivatedSurveys=useActivatedSurveys;var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=require("react");var _surveys=require("@posthog/core/surveys");function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var _n=0,F=function F(){};return{s:F,n:function n(){return _n>=r.length?{done:!0}:{done:!1,value:r[_n++]};},e:function e(r){throw r;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}var SURVEY_SHOWN_EVENT_NAME='survey shown';function useActivatedSurveys(posthog,surveys){var _useState=(0,_react.useState)(new Set()),_useState2=(0,_slicedToArray2["default"])(_useState,2),activatedSurveys=_useState2[0],setActivatedSurveys=_useState2[1];var eventMap=(0,_react.useMemo)(function(){var _a,_b
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useActivatedSurveys=useActivatedSurveys;var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=require("react");var _surveys=require("@posthog/core/surveys");function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var _n=0,F=function F(){};return{s:F,n:function n(){return _n>=r.length?{done:!0}:{done:!1,value:r[_n++]};},e:function e(r){throw r;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}var SURVEY_SHOWN_EVENT_NAME='survey shown';function useActivatedSurveys(posthog,surveys){var _useState=(0,_react.useState)(new Set()),_useState2=(0,_slicedToArray2["default"])(_useState,2),activatedSurveys=_useState2[0],setActivatedSurveys=_useState2[1];(0,_react.useEffect)(function(){setActivatedSurveys(new Set());return posthog.on('surveysReset',function(){return setActivatedSurveys(new Set());});},[posthog]);var eventMap=(0,_react.useMemo)(function(){var _a,_b;var _c,_d;var newEventMap=new Map();var _iterator=_createForOfIteratorHelper(surveys.filter(_surveys.doesSurveyActivateByEvent)),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var survey=_step.value;var _iterator2=_createForOfIteratorHelper((_c=(_b=(_a=survey.conditions)===null||_a===void 0?void 0:_a.events)===null||_b===void 0?void 0:_b.values)!==null&&_c!==void 0?_c:[]),_step2;try{for(_iterator2.s();!(_step2=_iterator2.n()).done;){var event=_step2.value;var configs=(_d=newEventMap.get(event.name))!==null&&_d!==void 0?_d:[];configs.push({surveyId:survey.id,propertyFilters:event.propertyFilters});newEventMap.set(event.name,configs);}}catch(err){_iterator2.e(err);}finally{_iterator2.f();}}}catch(err){_iterator.e(err);}finally{_iterator.f();}return newEventMap;},[surveys]);(0,_react.useEffect)(function(){if(eventMap.size>0){return posthog.on('capture',function(payload){var _a;var _b;if(eventMap.has(payload.event)){var configs=(_b=eventMap.get(payload.event))!==null&&_b!==void 0?_b:[];var matchingSurveyIds=configs.filter(function(config){return(0,_surveys.matchPropertyFilters)(config.propertyFilters,payload.properties);}).map(function(config){return config.surveyId;});if(matchingSurveyIds.length>0){setActivatedSurveys(function(current){return new Set([].concat((0,_toConsumableArray2["default"])(current),(0,_toConsumableArray2["default"])(matchingSurveyIds)));});}}else if(payload.event===SURVEY_SHOWN_EVENT_NAME){var surveyId=(_a=payload.properties)===null||_a===void 0?void 0:_a.$survey_id;if(surveyId){setActivatedSurveys(function(current){if(!current.has(surveyId)){return current;}var next=new Set(current);next["delete"](surveyId);return next;});}}});}},[eventMap,posthog]);return activatedSurveys;}
|
|
2
2
|
//# sourceMappingURL=useActivatedSurveys.js.map
|