posthog-react-native 4.84.3 → 4.85.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.
@@ -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.PostHogSurveyProvider=PostHogSurveyProvider;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireWildcard(require("react"));var _Surveys=require("./components/Surveys");var _getActiveMatchingSurveys=require("./getActiveMatchingSurveys");var _useSurveyStorage2=require("./useSurveyStorage");var _surveyProgress=require("./survey-progress");var _surveys=require("@posthog/core/surveys");var _useActivatedSurveys=require("./useActivatedSurveys");var _SurveyModal=require("./components/SurveyModal");var _surveysUtils=require("./surveys-utils");var _core=require("@posthog/core");var _usePostHog=require("../hooks/usePostHog");var _useFeatureFlags=require("../hooks/useFeatureFlags");var _surveyTranslations=require("./survey-translations");var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="/home/runner/work/posthog-js/posthog-js/packages/react-native/dist/surveys/PostHogSurveyProvider.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 ActiveSurveyContext=_react["default"].createContext(undefined);var FeedbackSurveyContext=_react["default"].createContext(undefined);function PostHogSurveyProvider(props){var _a;var posthogFromHook=(0,_usePostHog.usePostHog)();var posthog=(_a=props.client)!==null&&_a!==void 0?_a:posthogFromHook;var _useSurveyStorage=(0,_useSurveyStorage2.useSurveyStorage)(posthog),seenSurveys=_useSurveyStorage.seenSurveys,setSeenSurvey=_useSurveyStorage.setSeenSurvey,lastSeenSurveyDate=_useSurveyStorage.lastSeenSurveyDate,setLastSeenSurveyDate=_useSurveyStorage.setLastSeenSurveyDate,isReady=_useSurveyStorage.isReady;var progressStore=(0,_react.useMemo)(function(){return new _surveyProgress.SurveyProgressStore(posthog);},[posthog]);var _useState=(0,_react.useState)([]),_useState2=(0,_slicedToArray2["default"])(_useState,2),surveys=_useState2[0],setSurveys=_useState2[1];var _useState3=(0,_react.useState)(undefined),_useState4=(0,_slicedToArray2["default"])(_useState3,2),activeSurvey=_useState4[0],setActiveSurvey=_useState4[1];var shownSurveyIdRef=(0,_react.useRef)(undefined);var sessionEpochRef=(0,_react.useRef)(0);var activeSessionRef=(0,_react.useRef)(undefined);var activatedSurveys=(0,_useActivatedSurveys.useActivatedSurveys)(posthog,surveys);var invalidateSession=(0,_react.useCallback)(function(){sessionEpochRef.current++;activeSessionRef.current=undefined;shownSurveyIdRef.current=undefined;},[]);var flags=(0,_useFeatureFlags.useFeatureFlags)(posthog);var _useState5=(0,_react.useState)(function(){return(0,_surveyTranslations.detectUserLanguage)(posthog);}),_useState6=(0,_slicedToArray2["default"])(_useState5,2),userLanguage=_useState6[0],setUserLanguage=_useState6[1];(0,_react.useEffect)(function(){var updateLanguage=function updateLanguage(){return setUserLanguage((0,_surveyTranslations.detectUserLanguage)(posthog));};var unsubscribe=posthog.on('personProperties',updateLanguage);updateLanguage();return unsubscribe;},[posthog]);(0,_react.useEffect)(function(){return posthog.on('surveysReset',function(){invalidateSession();setActiveSurvey(undefined);});},[posthog,invalidateSession]);(0,_react.useEffect)(function(){var mounted=true;setActiveSurvey(undefined);setSurveys([]);activeSessionRef.current=undefined;shownSurveyIdRef.current=undefined;posthog.ready().then(function(){return posthog._onSurveysReady();}).then(function(){setUserLanguage((0,_surveyTranslations.detectUserLanguage)(posthog));return posthog.getSurveys();}).then(function(loadedSurveys){if(!mounted)return;if(Array.isArray(posthog.getPersistedProperty(_core.PostHogPersistedProperty.Surveys))){progressStore.reconcile(loadedSurveys);}setSurveys(loadedSurveys);})["catch"](function(){});return function(){mounted=false;invalidateSession();};},[posthog,progressStore,invalidateSession]);(0,_react.useEffect)(function(){if(!isReady||!(0,_surveyProgress.canCaptureSurvey)(posthog))return;var isShown=!!activeSurvey&&shownSurveyIdRef.current===activeSurvey.id;if(isShown){return;}var activeSurveys=(0,_getActiveMatchingSurveys.getActiveMatchingSurveys)(surveys,flags!==null&&flags!==void 0?flags:{},seenSurveys,activatedSurveys,new Set(surveys.filter(function(survey){return progressStore.load(survey);}).map(_surveys.getSurveyIterationKey)),lastSeenSurveyDate);var popoverSurveys=activeSurveys.filter(function(survey){return survey.type===_core.SurveyType.Popover;}).sort(function(a,b){return Number(!!progressStore.load(b))-Number(!!progressStore.load(a));});if(activeSurvey&&popoverSurveys.some(function(survey){return survey.id===activeSurvey.id;})){return;}setActiveSurvey(popoverSurveys.length>0?popoverSurveys[0]:undefined);},[activeSurvey,flags,surveys,seenSurveys,lastSeenSurveyDate,activatedSurveys,isReady,posthog,progressStore]);var translatedActiveSurvey=(0,_react.useMemo)(function(){return activeSurvey?(0,_surveyTranslations.applySurveyTranslationForUser)(activeSurvey,posthog,userLanguage):undefined;},[activeSurvey,posthog,userLanguage]);var surveyAppearance=(0,_react.useMemo)(function(){var _a;var _b,_c,_d,_e;if(props.overrideAppearanceWithDefault||!translatedActiveSurvey){return _objectSpread(_objectSpread({},_surveysUtils.defaultSurveyAppearance),(_b=props.defaultSurveyAppearance)!==null&&_b!==void 0?_b:{});}return _objectSpread(_objectSpread(_objectSpread(_objectSpread({},_surveysUtils.defaultSurveyAppearance),(_c=props.defaultSurveyAppearance)!==null&&_c!==void 0?_c:{}),(_d=translatedActiveSurvey.survey.appearance)!==null&&_d!==void 0?_d:{}),((_a=translatedActiveSurvey.survey.appearance)===null||_a===void 0?void 0:_a.submitButtonColor)?{submitButtonTextColor:(_e=translatedActiveSurvey.survey.appearance.submitButtonTextColor)!==null&&_e!==void 0?_e:(0,_surveysUtils.getContrastingTextColor)(translatedActiveSurvey.survey.appearance.submitButtonColor)}:{});},[translatedActiveSurvey,props.defaultSurveyAppearance,props.overrideAppearanceWithDefault]);var activeSession=(0,_react.useMemo)(function(){var _a;return activeSurvey?{progress:(_a=progressStore.load(activeSurvey))!==null&&_a!==void 0?_a:(0,_surveyProgress.createSurveyProgress)(activeSurvey),completed:false,epoch:sessionEpochRef.current}:undefined;},[activeSurvey,progressStore]);var activeContext=(0,_react.useMemo)(function(){if(!activeSurvey||!translatedActiveSurvey||!activeSession){return undefined;}return{client:posthog,initialProgress:activeSession.progress,onProgressChange:function onProgressChange(progress,completed){var _a;if(activeSessionRef.current!==activeSession||!(0,_surveyProgress.canCaptureSurvey)(posthog)||((_a=progressStore.load(activeSurvey))===null||_a===void 0?void 0:_a.submissionId)!==activeSession.progress.submissionId)return false;activeSession.progress=progress;activeSession.completed=completed;if(completed){progressStore.remove(activeSurvey);setSeenSurvey(activeSurvey);}else{progressStore.save(activeSurvey,progress);}return true;},survey:translatedActiveSurvey.survey,surveyLanguage:translatedActiveSurvey.language,onShow:function onShow(){if(activeSession.epoch!==sessionEpochRef.current||!(0,_surveyProgress.canCaptureSurvey)(posthog))return;if(shownSurveyIdRef.current===activeSurvey.id){return;}activeSessionRef.current=activeSession;progressStore.save(activeSurvey,activeSession.progress);shownSurveyIdRef.current=activeSurvey.id;(0,_Surveys.sendSurveyShownEvent)(translatedActiveSurvey.survey,posthog,translatedActiveSurvey.language);setLastSeenSurveyDate(new Date());},onClose:function onClose(submitted,responses){if(activeSessionRef.current!==activeSession)return;activeSessionRef.current=undefined;progressStore.remove(activeSurvey);shownSurveyIdRef.current=undefined;setSeenSurvey(activeSurvey);setActiveSurvey(undefined);if(submitted||activeSession.completed)return;if((0,_surveyProgress.canCaptureSurvey)(posthog)){(0,_Surveys.dismissedSurveyEvent)(translatedActiveSurvey.survey,responses,posthog,Object.keys(activeSession.progress.responses).length>0?activeSession.progress.surveyLanguage:translatedActiveSurvey.language,activeSession.progress);}}};},[activeSurvey,activeSession,posthog,progressStore,setLastSeenSurveyDate,setSeenSurvey,translatedActiveSurvey]);var autoPresent=props.autoPresentSurveys!==false;var isAlreadyShown=!!activeSurvey&&shownSurveyIdRef.current===activeSurvey.id;var shouldShowModal=activeContext&&activeContext.survey.type===_core.SurveyType.Popover&&(autoPresent||isAlreadyShown);return(0,_jsxRuntime.jsx)(ActiveSurveyContext.Provider,{value:activeContext,children:(0,_jsxRuntime.jsxs)(FeedbackSurveyContext.Provider,{value:{surveys:surveys,activeSurvey:activeSurvey,setActiveSurvey:setActiveSurvey},children:[props.children,shouldShowModal&&(0,_jsxRuntime.jsx)(_SurveyModal.SurveyModal,_objectSpread({appearance:surveyAppearance,androidKeyboardBehavior:props.androidKeyboardBehavior},activeContext),activeSession===null||activeSession===void 0?void 0:activeSession.progress.submissionId)]})});}
1
+ "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports.PostHogSurveyProvider=PostHogSurveyProvider;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireWildcard(require("react"));var _Surveys=require("./components/Surveys");var _getActiveMatchingSurveys=require("./getActiveMatchingSurveys");var _useSurveyStorage2=require("./useSurveyStorage");var _surveyProgress=require("./survey-progress");var _surveys=require("@posthog/core/surveys");var _useActivatedSurveys=require("./useActivatedSurveys");var _SurveyModal=require("./components/SurveyModal");var _surveysUtils=require("./surveys-utils");var _core=require("@posthog/core");var _usePostHog=require("../hooks/usePostHog");var _useFeatureFlags=require("../hooks/useFeatureFlags");var _surveyTranslations=require("./survey-translations");var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="/home/runner/work/posthog-js/posthog-js/packages/react-native/dist/surveys/PostHogSurveyProvider.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 ActiveSurveyContext=_react["default"].createContext(undefined);var FeedbackSurveyContext=_react["default"].createContext(undefined);function PostHogSurveyProvider(props){var _a;var posthogFromHook=(0,_usePostHog.usePostHog)();var posthog=(_a=props.client)!==null&&_a!==void 0?_a:posthogFromHook;var _useSurveyStorage=(0,_useSurveyStorage2.useSurveyStorage)(posthog),seenSurveys=_useSurveyStorage.seenSurveys,setSeenSurvey=_useSurveyStorage.setSeenSurvey,lastSeenSurveyDate=_useSurveyStorage.lastSeenSurveyDate,setLastSeenSurveyDate=_useSurveyStorage.setLastSeenSurveyDate,isReady=_useSurveyStorage.isReady;var progressStore=(0,_react.useMemo)(function(){return new _surveyProgress.SurveyProgressStore(posthog);},[posthog]);var _useState=(0,_react.useState)([]),_useState2=(0,_slicedToArray2["default"])(_useState,2),surveys=_useState2[0],setSurveys=_useState2[1];var _useState3=(0,_react.useState)(undefined),_useState4=(0,_slicedToArray2["default"])(_useState3,2),activeSurvey=_useState4[0],setActiveSurvey=_useState4[1];var shownSurveyIdRef=(0,_react.useRef)(undefined);var sessionEpochRef=(0,_react.useRef)(0);var activeSessionRef=(0,_react.useRef)(undefined);var pendingSurveyRef=(0,_react.useRef)(undefined);var activatedSurveys=(0,_useActivatedSurveys.useActivatedSurveys)(posthog,surveys);var invalidateSession=(0,_react.useCallback)(function(){sessionEpochRef.current++;activeSessionRef.current=undefined;shownSurveyIdRef.current=undefined;pendingSurveyRef.current=undefined;},[]);var flags=(0,_useFeatureFlags.useFeatureFlags)(posthog);var _useState5=(0,_react.useState)(function(){return(0,_surveyTranslations.detectUserLanguage)(posthog);}),_useState6=(0,_slicedToArray2["default"])(_useState5,2),userLanguage=_useState6[0],setUserLanguage=_useState6[1];var defaultSurveyAppearance=(0,_react.useMemo)(function(){var _a;return(_a=props===null||props===void 0?void 0:props.defaultSurveyAppearance)!==null&&_a!==void 0?_a:{};},[props===null||props===void 0?void 0:props.defaultSurveyAppearance]);var overrideAppearanceWithDefault=props===null||props===void 0?void 0:props.overrideAppearanceWithDefault;(0,_react.useEffect)(function(){var updateLanguage=function updateLanguage(){return setUserLanguage((0,_surveyTranslations.detectUserLanguage)(posthog));};var unsubscribe=posthog.on('personProperties',updateLanguage);updateLanguage();return unsubscribe;},[posthog]);(0,_react.useEffect)(function(){return posthog.on('surveysReset',function(){invalidateSession();setActiveSurvey(undefined);});},[posthog,invalidateSession]);(0,_react.useEffect)(function(){var mounted=true;setActiveSurvey(undefined);setSurveys([]);activeSessionRef.current=undefined;shownSurveyIdRef.current=undefined;posthog.ready().then(function(){return posthog._onSurveysReady();}).then(function(){setUserLanguage((0,_surveyTranslations.detectUserLanguage)(posthog));return posthog.getSurveys();}).then(function(loadedSurveys){if(!mounted)return;if(Array.isArray(posthog.getPersistedProperty(_core.PostHogPersistedProperty.Surveys))){progressStore.reconcile(loadedSurveys);}setSurveys(loadedSurveys);})["catch"](function(){});return function(){mounted=false;invalidateSession();};},[posthog,progressStore,invalidateSession]);(0,_react.useEffect)(function(){var _a;var _b,_c;if(!isReady||!(0,_surveyProgress.canCaptureSurvey)(posthog)){pendingSurveyRef.current=undefined;return;}var isShown=!!activeSurvey&&shownSurveyIdRef.current===activeSurvey.id;if(isShown){return;}var inProgressSurveys=new Set(surveys.filter(function(survey){return progressStore.load(survey);}).map(_surveys.getSurveyIterationKey));var activeSurveys=(0,_getActiveMatchingSurveys.getActiveMatchingSurveys)(surveys,flags!==null&&flags!==void 0?flags:{},seenSurveys,activatedSurveys,inProgressSurveys,lastSeenSurveyDate);var defaultDelay=(_b=defaultSurveyAppearance.surveyPopupDelaySeconds)!==null&&_b!==void 0?_b:0;var getDelaySeconds=function getDelaySeconds(survey){var _a;var _b;return Math.max(0,overrideAppearanceWithDefault?defaultDelay:(_b=(_a=survey.appearance)===null||_a===void 0?void 0:_a.surveyPopupDelaySeconds)!==null&&_b!==void 0?_b:defaultDelay);};var popoverSurveys=activeSurveys.filter(function(survey){return survey.type===_core.SurveyType.Popover;}).sort(function(a,b){var progressPriority=Number(inProgressSurveys.has((0,_surveys.getSurveyIterationKey)(b)))-Number(inProgressSurveys.has((0,_surveys.getSurveyIterationKey)(a)));return progressPriority||getDelaySeconds(a)-getDelaySeconds(b);});if(activeSurvey&&popoverSurveys.some(function(survey){return survey.id===activeSurvey.id;})){return;}setActiveSurvey(undefined);var nextSurvey=(_c=popoverSurveys.find(function(survey){var _a;return(0,_surveys.getSurveyIterationKey)(survey)===((_a=pendingSurveyRef.current)===null||_a===void 0?void 0:_a.surveyKey);}))!==null&&_c!==void 0?_c:popoverSurveys[0];if(!nextSurvey){pendingSurveyRef.current=undefined;return;}var surveyKey=(0,_surveys.getSurveyIterationKey)(nextSurvey);if(((_a=pendingSurveyRef.current)===null||_a===void 0?void 0:_a.surveyKey)!==surveyKey){pendingSurveyRef.current={surveyKey:surveyKey,startedAt:Date.now()};}var elapsed=Math.max(0,Date.now()-pendingSurveyRef.current.startedAt);var remainingDelay=Math.max(0,getDelaySeconds(nextSurvey)*1000-elapsed);if(remainingDelay===0){pendingSurveyRef.current=undefined;setActiveSurvey(nextSurvey);return;}var surveyActivationTimeoutId=setTimeout(function(){pendingSurveyRef.current=undefined;if(!(0,_surveyProgress.canCaptureSurvey)(posthog))return;var currentActiveSurveys=(0,_getActiveMatchingSurveys.getActiveMatchingSurveys)(surveys,flags!==null&&flags!==void 0?flags:{},seenSurveys,activatedSurveys,new Set(surveys.filter(function(survey){return progressStore.load(survey);}).map(_surveys.getSurveyIterationKey)),lastSeenSurveyDate);var nextSurveyEligible=currentActiveSurveys.some(function(survey){return survey.id===nextSurvey.id;});if(nextSurveyEligible){setActiveSurvey(nextSurvey);}},remainingDelay);return function(){return clearTimeout(surveyActivationTimeoutId);};},[activeSurvey,flags,surveys,seenSurveys,lastSeenSurveyDate,defaultSurveyAppearance,overrideAppearanceWithDefault,activatedSurveys,isReady,posthog,progressStore]);var translatedActiveSurvey=(0,_react.useMemo)(function(){return activeSurvey?(0,_surveyTranslations.applySurveyTranslationForUser)(activeSurvey,posthog,userLanguage):undefined;},[activeSurvey,posthog,userLanguage]);var surveyAppearance=(0,_react.useMemo)(function(){var _a;var _b,_c;if(overrideAppearanceWithDefault||!translatedActiveSurvey){return _objectSpread(_objectSpread({},_surveysUtils.defaultSurveyAppearance),defaultSurveyAppearance);}return _objectSpread(_objectSpread(_objectSpread(_objectSpread({},_surveysUtils.defaultSurveyAppearance),defaultSurveyAppearance),(_b=translatedActiveSurvey.survey.appearance)!==null&&_b!==void 0?_b:{}),((_a=translatedActiveSurvey.survey.appearance)===null||_a===void 0?void 0:_a.submitButtonColor)?{submitButtonTextColor:(_c=translatedActiveSurvey.survey.appearance.submitButtonTextColor)!==null&&_c!==void 0?_c:(0,_surveysUtils.getContrastingTextColor)(translatedActiveSurvey.survey.appearance.submitButtonColor)}:{});},[translatedActiveSurvey,defaultSurveyAppearance,overrideAppearanceWithDefault]);var activeSession=(0,_react.useMemo)(function(){var _a;return activeSurvey?{progress:(_a=progressStore.load(activeSurvey))!==null&&_a!==void 0?_a:(0,_surveyProgress.createSurveyProgress)(activeSurvey),completed:false,epoch:sessionEpochRef.current}:undefined;},[activeSurvey,progressStore]);var activeContext=(0,_react.useMemo)(function(){if(!activeSurvey||!translatedActiveSurvey||!activeSession){return undefined;}return{client:posthog,initialProgress:activeSession.progress,onProgressChange:function onProgressChange(progress,completed){var _a;if(activeSessionRef.current!==activeSession||!(0,_surveyProgress.canCaptureSurvey)(posthog)||((_a=progressStore.load(activeSurvey))===null||_a===void 0?void 0:_a.submissionId)!==activeSession.progress.submissionId)return false;activeSession.progress=progress;activeSession.completed=completed;if(completed){progressStore.remove(activeSurvey);setSeenSurvey(activeSurvey);}else{progressStore.save(activeSurvey,progress);}return true;},survey:translatedActiveSurvey.survey,surveyLanguage:translatedActiveSurvey.language,onShow:function onShow(){if(activeSession.epoch!==sessionEpochRef.current||!(0,_surveyProgress.canCaptureSurvey)(posthog))return;if(shownSurveyIdRef.current===activeSurvey.id){return;}activeSessionRef.current=activeSession;progressStore.save(activeSurvey,activeSession.progress);shownSurveyIdRef.current=activeSurvey.id;(0,_Surveys.sendSurveyShownEvent)(translatedActiveSurvey.survey,posthog,translatedActiveSurvey.language);setLastSeenSurveyDate(new Date());},onClose:function onClose(submitted,responses){if(activeSessionRef.current!==activeSession)return;activeSessionRef.current=undefined;progressStore.remove(activeSurvey);shownSurveyIdRef.current=undefined;setSeenSurvey(activeSurvey);setActiveSurvey(undefined);if(submitted||activeSession.completed)return;if((0,_surveyProgress.canCaptureSurvey)(posthog)){(0,_Surveys.dismissedSurveyEvent)(translatedActiveSurvey.survey,responses,posthog,Object.keys(activeSession.progress.responses).length>0?activeSession.progress.surveyLanguage:translatedActiveSurvey.language,activeSession.progress);}}};},[activeSurvey,activeSession,posthog,progressStore,setLastSeenSurveyDate,setSeenSurvey,translatedActiveSurvey]);var autoPresent=props.autoPresentSurveys!==false;var isAlreadyShown=!!activeSurvey&&shownSurveyIdRef.current===activeSurvey.id;var shouldShowModal=activeContext&&activeContext.survey.type===_core.SurveyType.Popover&&(autoPresent||isAlreadyShown);return(0,_jsxRuntime.jsx)(ActiveSurveyContext.Provider,{value:activeContext,children:(0,_jsxRuntime.jsxs)(FeedbackSurveyContext.Provider,{value:{surveys:surveys,activeSurvey:activeSurvey,setActiveSurvey:setActiveSurvey},children:[props.children,shouldShowModal&&(0,_jsxRuntime.jsx)(_SurveyModal.SurveyModal,_objectSpread({appearance:surveyAppearance,androidKeyboardBehavior:props.androidKeyboardBehavior},activeContext),activeSession===null||activeSession===void 0?void 0:activeSession.progress.submissionId)]})});}
2
2
  //# sourceMappingURL=PostHogSurveyProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PostHogSurveyProvider.js","names":["_react","_interopRequireWildcard","require","_Surveys","_getActiveMatchingSurveys","_useSurveyStorage2","_surveyProgress","_surveys","_useActivatedSurveys","_SurveyModal","_surveysUtils","_core","_usePostHog","_useFeatureFlags","_surveyTranslations","_jsxRuntime","_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","ActiveSurveyContext","React","createContext","undefined","FeedbackSurveyContext","PostHogSurveyProvider","props","posthogFromHook","usePostHog","posthog","_a","client","_useSurveyStorage","useSurveyStorage","seenSurveys","setSeenSurvey","lastSeenSurveyDate","setLastSeenSurveyDate","isReady","progressStore","useMemo","SurveyProgressStore","_useState","useState","_useState2","_slicedToArray2","surveys","setSurveys","_useState3","_useState4","activeSurvey","setActiveSurvey","shownSurveyIdRef","useRef","sessionEpochRef","activeSessionRef","activatedSurveys","useActivatedSurveys","invalidateSession","useCallback","current","flags","useFeatureFlags","_useState5","detectUserLanguage","_useState6","userLanguage","setUserLanguage","useEffect","updateLanguage","unsubscribe","on","mounted","ready","then","_onSurveysReady","getSurveys","loadedSurveys","Array","isArray","getPersistedProperty","PostHogPersistedProperty","Surveys","reconcile","canCaptureSurvey","isShown","id","activeSurveys","getActiveMatchingSurveys","Set","survey","load","map","getSurveyIterationKey","popoverSurveys","type","SurveyType","Popover","sort","a","b","Number","some","translatedActiveSurvey","applySurveyTranslationForUser","surveyAppearance","overrideAppearanceWithDefault","defaultSurveyAppearance","_b","_c","_d","appearance","submitButtonColor","submitButtonTextColor","_e","getContrastingTextColor","activeSession","progress","createSurveyProgress","completed","epoch","activeContext","initialProgress","onProgressChange","submissionId","remove","save","surveyLanguage","language","onShow","sendSurveyShownEvent","Date","onClose","submitted","responses","dismissedSurveyEvent","autoPresent","autoPresentSurveys","isAlreadyShown","shouldShowModal","jsx","Provider","value","children","jsxs","SurveyModal","androidKeyboardBehavior"],"sources":["../../src/surveys/PostHogSurveyProvider.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport { dismissedSurveyEvent, sendSurveyShownEvent } from './components/Surveys'\n\nimport { getActiveMatchingSurveys } from './getActiveMatchingSurveys'\nimport { useSurveyStorage } from './useSurveyStorage'\nimport { canCaptureSurvey, createSurveyProgress, SurveyProgress, SurveyProgressStore } from './survey-progress'\nimport { getSurveyIterationKey } from '@posthog/core/surveys'\nimport { useActivatedSurveys } from './useActivatedSurveys'\nimport { SurveyModal } from './components/SurveyModal'\nimport {\n defaultSurveyAppearance,\n getContrastingTextColor,\n SurveyAppearance,\n SurveyAppearanceTheme,\n} from './surveys-utils'\nimport { PostHogPersistedProperty, Survey, SurveyType, type SurveyResponses } from '@posthog/core'\nimport { usePostHog } from '../hooks/usePostHog'\nimport { useFeatureFlags } from '../hooks/useFeatureFlags'\nimport { PostHog } from '../posthog-rn'\nimport { applySurveyTranslationForUser, detectUserLanguage } from './survey-translations'\n\ntype ActiveSurveyContextType =\n | {\n survey: Survey\n surveyLanguage: string | null\n onShow: () => void\n onClose: (submitted: boolean, responses: SurveyResponses) => void\n }\n | undefined\nconst ActiveSurveyContext = React.createContext<ActiveSurveyContextType>(undefined)\n// export const useActiveSurvey = (): ActiveSurveyContextType => React.useContext(ActiveSurveyContext)\n\n// type FeedbackSurveyHook = {\n// survey: Survey\n// showSurveyModal: () => void\n// hideSurveyModal: () => void\n// }\nconst FeedbackSurveyContext = React.createContext<\n | {\n surveys: Survey[]\n activeSurvey: Survey | undefined\n setActiveSurvey: React.Dispatch<React.SetStateAction<Survey | undefined>>\n }\n | undefined\n>(undefined)\n// export const useFeedbackSurvey = (selector: string): FeedbackSurveyHook | undefined => {\n// const context = React.useContext(FeedbackSurveyContext)\n// const survey = context?.surveys.find(\n// (survey: Survey) => survey.type === SurveyType.Widget && survey.appearance?.widgetSelector === selector\n// )\n// if (!context || !survey) {\n// return undefined\n// }\n\n// return {\n// survey,\n// showSurveyModal: () => context.setActiveSurvey(survey),\n// hideSurveyModal: () => {\n// if (context.activeSurvey === survey) {\n// context.setActiveSurvey(undefined)\n// }\n// },\n// }\n// }\n\nexport type PostHogSurveyProviderProps = {\n /**\n * Whether eligible popover surveys are automatically presented. (Default: true)\n * Set to false to defer presentation — e.g. while a native-stack formSheet/modal is on top.\n * Deferral is display-only: the survey stays armed and presents once this is true again.\n * A survey already on screen is not interrupted when this becomes false.\n *\n * You own flipping this back to true (e.g. wire it to route/screen focus). While it stays\n * false the survey remains deferred and never shows — if the un-defer never happens\n * (sheet dismissed without re-focusing the provider, an unmount, an error boundary), the\n * survey stays armed indefinitely and no \"survey shown\" event fires.\n */\n autoPresentSurveys?: boolean\n\n /**\n * The default appearance for surveys when not specified in PostHog.\n *\n * Accepts the React Native-only appearance fields as well (e.g.\n * `maxFontSizeMultiplier`) — they are merged into the same theme object the\n * survey components read, and PostHog never sends them down.\n */\n defaultSurveyAppearance?: SurveyAppearance\n\n /**\n * If true, PosHog appearance will be ignored and defaultSurveyAppearance is always used.\n */\n overrideAppearanceWithDefault?: boolean\n\n /**\n * The keyboard avoiding behavior for the survey modal (KeyboardAvoidingView), applied only to Android devices.\n * - 'padding': Adds padding to avoid keyboard (recommended)\n * - 'height': Resizes the view height (default, for legacy - may cause flickering on some Android devices)\n * @default 'height'\n */\n androidKeyboardBehavior?: 'padding' | 'height'\n\n client?: PostHog\n\n children: React.ReactNode\n}\n\nexport function PostHogSurveyProvider(props: PostHogSurveyProviderProps): JSX.Element {\n const posthogFromHook = usePostHog()\n const posthog = props.client ?? posthogFromHook\n const { seenSurveys, setSeenSurvey, lastSeenSurveyDate, setLastSeenSurveyDate, isReady } = useSurveyStorage(posthog)\n const progressStore = useMemo(() => new SurveyProgressStore(posthog), [posthog])\n const [surveys, setSurveys] = useState<Survey[]>([])\n const [activeSurvey, setActiveSurvey] = useState<Survey | undefined>(undefined)\n // Latches the id of the survey once its modal has actually painted, so deferring presentation\n // (autoPresentSurveys=false) never tears down a survey the user is already interacting with.\n const shownSurveyIdRef = useRef<string | undefined>(undefined)\n const sessionEpochRef = useRef(0)\n const activeSessionRef = useRef<object | undefined>(undefined)\n const activatedSurveys = useActivatedSurveys(posthog, surveys)\n const invalidateSession = useCallback(() => {\n sessionEpochRef.current++\n activeSessionRef.current = undefined\n shownSurveyIdRef.current = undefined\n }, [])\n\n const flags = useFeatureFlags(posthog)\n const [userLanguage, setUserLanguage] = useState(() => detectUserLanguage(posthog))\n\n useEffect(() => {\n const updateLanguage = () => setUserLanguage(detectUserLanguage(posthog))\n const unsubscribe = posthog.on('personProperties', updateLanguage)\n updateLanguage()\n return unsubscribe\n }, [posthog])\n\n useEffect(\n () =>\n posthog.on('surveysReset', () => {\n invalidateSession()\n setActiveSurvey(undefined)\n }),\n [posthog, invalidateSession]\n )\n\n // Load surveys once\n useEffect(() => {\n let mounted = true\n setActiveSurvey(undefined)\n setSurveys([])\n activeSessionRef.current = undefined\n shownSurveyIdRef.current = undefined\n posthog\n .ready()\n .then(() => posthog._onSurveysReady())\n .then(() => {\n setUserLanguage(detectUserLanguage(posthog))\n return posthog.getSurveys()\n })\n .then((loadedSurveys) => {\n if (!mounted) return\n // An unavailable cache (failed load or disableSurveys) is not an empty project.\n if (Array.isArray(posthog.getPersistedProperty(PostHogPersistedProperty.Surveys))) {\n progressStore.reconcile(loadedSurveys)\n }\n setSurveys(loadedSurveys)\n })\n .catch(() => {})\n return () => {\n mounted = false\n invalidateSession()\n }\n }, [posthog, progressStore, invalidateSession])\n\n // Whenever state changes, re-select the popover survey to show. A survey that has already\n // painted is left alone; an armed-but-deferred one is re-validated so it can't be presented\n // after it stops matching (e.g. its targeting flag flips off during a long deferral).\n useEffect(() => {\n if (!isReady || !canCaptureSurvey(posthog)) return\n const isShown = !!activeSurvey && shownSurveyIdRef.current === activeSurvey.id\n if (isShown) {\n return\n }\n\n const activeSurveys = getActiveMatchingSurveys(\n surveys,\n flags ?? {},\n seenSurveys,\n activatedSurveys,\n new Set(surveys.filter((survey) => progressStore.load(survey)).map(getSurveyIterationKey)),\n lastSeenSurveyDate\n )\n\n const popoverSurveys = activeSurveys\n .filter((survey: Survey) => survey.type === SurveyType.Popover)\n .sort((a, b) => Number(!!progressStore.load(b)) - Number(!!progressStore.load(a)))\n // TODO: sort by appearance delay, implement delay\n // const popoverSurveyQueue = sortSurveysByAppearanceDelay(popoverSurveys)\n\n if (activeSurvey && popoverSurveys.some((survey) => survey.id === activeSurvey.id)) {\n return\n }\n\n setActiveSurvey(popoverSurveys.length > 0 ? popoverSurveys[0] : undefined)\n }, [activeSurvey, flags, surveys, seenSurveys, lastSeenSurveyDate, activatedSurveys, isReady, posthog, progressStore])\n\n const translatedActiveSurvey = useMemo(() => {\n return activeSurvey ? applySurveyTranslationForUser(activeSurvey, posthog, userLanguage) : undefined\n }, [activeSurvey, posthog, userLanguage])\n\n // Merge survey appearance so that components and hooks can use a consistent model\n const surveyAppearance = useMemo<SurveyAppearanceTheme>(() => {\n if (props.overrideAppearanceWithDefault || !translatedActiveSurvey) {\n return {\n ...defaultSurveyAppearance,\n ...(props.defaultSurveyAppearance ?? {}),\n }\n }\n return {\n ...defaultSurveyAppearance,\n ...(props.defaultSurveyAppearance ?? {}),\n ...(translatedActiveSurvey.survey.appearance ?? {}),\n // If submitButtonColor is set by PostHog, ensure submitButtonTextColor is also set to contrast\n ...(translatedActiveSurvey.survey.appearance?.submitButtonColor\n ? {\n submitButtonTextColor:\n translatedActiveSurvey.survey.appearance.submitButtonTextColor ??\n getContrastingTextColor(translatedActiveSurvey.survey.appearance.submitButtonColor),\n }\n : {}),\n }\n }, [translatedActiveSurvey, props.defaultSurveyAppearance, props.overrideAppearanceWithDefault])\n\n const activeSession = useMemo(\n () =>\n activeSurvey\n ? {\n progress: progressStore.load(activeSurvey) ?? createSurveyProgress(activeSurvey),\n completed: false,\n epoch: sessionEpochRef.current,\n }\n : undefined,\n [activeSurvey, progressStore]\n )\n\n const activeContext = useMemo(() => {\n if (!activeSurvey || !translatedActiveSurvey || !activeSession) {\n return undefined\n }\n return {\n client: posthog,\n initialProgress: activeSession.progress,\n onProgressChange: (progress: SurveyProgress, completed: boolean) => {\n if (\n activeSessionRef.current !== activeSession ||\n !canCaptureSurvey(posthog) ||\n progressStore.load(activeSurvey)?.submissionId !== activeSession.progress.submissionId\n )\n return false\n activeSession.progress = progress\n activeSession.completed = completed\n if (completed) {\n progressStore.remove(activeSurvey)\n setSeenSurvey(activeSurvey)\n } else {\n progressStore.save(activeSurvey, progress)\n }\n return true\n },\n survey: translatedActiveSurvey.survey,\n surveyLanguage: translatedActiveSurvey.language,\n onShow: () => {\n // Updating translated copy changes this callback, but does not show a new survey.\n if (activeSession.epoch !== sessionEpochRef.current || !canCaptureSurvey(posthog)) return\n if (shownSurveyIdRef.current === activeSurvey.id) {\n return\n }\n activeSessionRef.current = activeSession\n progressStore.save(activeSurvey, activeSession.progress)\n shownSurveyIdRef.current = activeSurvey.id\n sendSurveyShownEvent(translatedActiveSurvey.survey, posthog, translatedActiveSurvey.language)\n setLastSeenSurveyDate(new Date())\n },\n onClose: (submitted: boolean, responses: SurveyResponses) => {\n if (activeSessionRef.current !== activeSession) return\n activeSessionRef.current = undefined\n progressStore.remove(activeSurvey)\n shownSurveyIdRef.current = undefined\n setSeenSurvey(activeSurvey)\n setActiveSurvey(undefined)\n if (submitted || activeSession.completed) return\n if (canCaptureSurvey(posthog)) {\n dismissedSurveyEvent(\n translatedActiveSurvey.survey,\n responses,\n posthog,\n Object.keys(activeSession.progress.responses).length > 0\n ? activeSession.progress.surveyLanguage\n : translatedActiveSurvey.language,\n activeSession.progress\n )\n }\n },\n }\n }, [\n activeSurvey,\n activeSession,\n posthog,\n progressStore,\n setLastSeenSurveyDate,\n setSeenSurvey,\n translatedActiveSurvey,\n ])\n\n // Present a popover survey when autoPresentSurveys is on. Once it has painted (shownSurveyIdRef),\n // keep it mounted regardless of the gate so a mid-interaction survey is never yanked — the gate\n // defers not-yet-shown surveys, it does not interrupt a live one.\n const autoPresent = props.autoPresentSurveys !== false\n const isAlreadyShown = !!activeSurvey && shownSurveyIdRef.current === activeSurvey.id\n const shouldShowModal =\n activeContext && activeContext.survey.type === SurveyType.Popover && (autoPresent || isAlreadyShown)\n\n return (\n <ActiveSurveyContext.Provider value={activeContext}>\n <FeedbackSurveyContext.Provider value={{ surveys, activeSurvey, setActiveSurvey }}>\n {props.children}\n {shouldShowModal && (\n <SurveyModal\n key={activeSession?.progress.submissionId}\n appearance={surveyAppearance}\n androidKeyboardBehavior={props.androidKeyboardBehavior}\n {...activeContext}\n />\n )}\n </FeedbackSurveyContext.Provider>\n </ActiveSurveyContext.Provider>\n )\n}\n\n// function sortSurveysByAppearanceDelay(surveys: Survey[]): Survey[] {\n// return surveys.sort(\n// (a, b) => (a.appearance?.surveyPopupDelaySeconds ?? 0) - (b.appearance?.surveyPopupDelaySeconds ?? 0)\n// )\n// }\n"],"mappings":"4bAAA,IAAAA,MAAA,CAAAC,uBAAA,CAAAC,OAAA,WAEA,IAAAC,QAAA,CAAAD,OAAA,yBAEA,IAAAE,yBAAA,CAAAF,OAAA,+BACA,IAAAG,kBAAA,CAAAH,OAAA,uBACA,IAAAI,eAAA,CAAAJ,OAAA,sBACA,IAAAK,QAAA,CAAAL,OAAA,0BACA,IAAAM,oBAAA,CAAAN,OAAA,0BACA,IAAAO,YAAA,CAAAP,OAAA,6BACA,IAAAQ,aAAA,CAAAR,OAAA,oBAMA,IAAAS,KAAA,CAAAT,OAAA,kBACA,IAAAU,WAAA,CAAAV,OAAA,wBACA,IAAAW,gBAAA,CAAAX,OAAA,6BAEA,IAAAY,mBAAA,CAAAZ,OAAA,0BAAyF,IAAAa,WAAA,CAAAb,OAAA,0BAAAc,YAAA,gHAAAf,wBAAAgB,CAAA,CAAAC,CAAA,wBAAAC,OAAA,KAAAC,CAAA,KAAAD,OAAA,GAAAE,CAAA,KAAAF,OAAA,UAAAlB,uBAAA,UAAAA,wBAAAgB,CAAA,CAAAC,CAAA,MAAAA,CAAA,EAAAD,CAAA,EAAAA,CAAA,CAAAK,UAA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3J,WAAA,CAAA4J,GAAA,EAAClK,YAAA,CAAAuK,WAAW,CAAApI,aAAA,EAEVkG,UAAU,CAAEN,gBAAiB,CAC7ByC,uBAAuB,CAAExH,KAAK,CAACwH,uBAAwB,EACnDzB,aAAa,EAHZL,aAAa,SAAbA,aAAa,iBAAbA,aAAa,CAAEC,QAAQ,CAACO,YAGX,CAErB,EAC6B,CAClC,CAA8B,CAAC,CAEnC","ignoreList":[]}
1
+ {"version":3,"file":"PostHogSurveyProvider.js","names":["_react","_interopRequireWildcard","require","_Surveys","_getActiveMatchingSurveys","_useSurveyStorage2","_surveyProgress","_surveys","_useActivatedSurveys","_SurveyModal","_surveysUtils","_core","_usePostHog","_useFeatureFlags","_surveyTranslations","_jsxRuntime","_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","ActiveSurveyContext","React","createContext","undefined","FeedbackSurveyContext","PostHogSurveyProvider","props","posthogFromHook","usePostHog","posthog","_a","client","_useSurveyStorage","useSurveyStorage","seenSurveys","setSeenSurvey","lastSeenSurveyDate","setLastSeenSurveyDate","isReady","progressStore","useMemo","SurveyProgressStore","_useState","useState","_useState2","_slicedToArray2","surveys","setSurveys","_useState3","_useState4","activeSurvey","setActiveSurvey","shownSurveyIdRef","useRef","sessionEpochRef","activeSessionRef","pendingSurveyRef","activatedSurveys","useActivatedSurveys","invalidateSession","useCallback","current","flags","useFeatureFlags","_useState5","detectUserLanguage","_useState6","userLanguage","setUserLanguage","defaultSurveyAppearance","overrideAppearanceWithDefault","useEffect","updateLanguage","unsubscribe","on","mounted","ready","then","_onSurveysReady","getSurveys","loadedSurveys","Array","isArray","getPersistedProperty","PostHogPersistedProperty","Surveys","reconcile","canCaptureSurvey","isShown","id","inProgressSurveys","Set","survey","load","map","getSurveyIterationKey","activeSurveys","getActiveMatchingSurveys","defaultDelay","_b","surveyPopupDelaySeconds","getDelaySeconds","Math","max","appearance","popoverSurveys","type","SurveyType","Popover","sort","a","b","progressPriority","Number","some","nextSurvey","_c","find","surveyKey","startedAt","Date","now","elapsed","remainingDelay","surveyActivationTimeoutId","setTimeout","currentActiveSurveys","nextSurveyEligible","clearTimeout","translatedActiveSurvey","applySurveyTranslationForUser","surveyAppearance","builtInSurveyAppearance","submitButtonColor","submitButtonTextColor","getContrastingTextColor","activeSession","progress","createSurveyProgress","completed","epoch","activeContext","initialProgress","onProgressChange","submissionId","remove","save","surveyLanguage","language","onShow","sendSurveyShownEvent","onClose","submitted","responses","dismissedSurveyEvent","autoPresent","autoPresentSurveys","isAlreadyShown","shouldShowModal","jsx","Provider","value","children","jsxs","SurveyModal","androidKeyboardBehavior"],"sources":["../../src/surveys/PostHogSurveyProvider.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport { dismissedSurveyEvent, sendSurveyShownEvent } from './components/Surveys'\n\nimport { getActiveMatchingSurveys } from './getActiveMatchingSurveys'\nimport { useSurveyStorage } from './useSurveyStorage'\nimport { canCaptureSurvey, createSurveyProgress, SurveyProgress, SurveyProgressStore } from './survey-progress'\nimport { getSurveyIterationKey } from '@posthog/core/surveys'\nimport { useActivatedSurveys } from './useActivatedSurveys'\nimport { SurveyModal } from './components/SurveyModal'\nimport {\n defaultSurveyAppearance as builtInSurveyAppearance,\n getContrastingTextColor,\n SurveyAppearance,\n SurveyAppearanceTheme,\n} from './surveys-utils'\nimport { PostHogPersistedProperty, Survey, SurveyType, type SurveyResponses } from '@posthog/core'\nimport { usePostHog } from '../hooks/usePostHog'\nimport { useFeatureFlags } from '../hooks/useFeatureFlags'\nimport { PostHog } from '../posthog-rn'\nimport { applySurveyTranslationForUser, detectUserLanguage } from './survey-translations'\n\ntype ActiveSurveyContextType =\n | {\n survey: Survey\n surveyLanguage: string | null\n onShow: () => void\n onClose: (submitted: boolean, responses: SurveyResponses) => void\n }\n | undefined\nconst ActiveSurveyContext = React.createContext<ActiveSurveyContextType>(undefined)\n// export const useActiveSurvey = (): ActiveSurveyContextType => React.useContext(ActiveSurveyContext)\n\n// type FeedbackSurveyHook = {\n// survey: Survey\n// showSurveyModal: () => void\n// hideSurveyModal: () => void\n// }\nconst FeedbackSurveyContext = React.createContext<\n | {\n surveys: Survey[]\n activeSurvey: Survey | undefined\n setActiveSurvey: React.Dispatch<React.SetStateAction<Survey | undefined>>\n }\n | undefined\n>(undefined)\n// export const useFeedbackSurvey = (selector: string): FeedbackSurveyHook | undefined => {\n// const context = React.useContext(FeedbackSurveyContext)\n// const survey = context?.surveys.find(\n// (survey: Survey) => survey.type === SurveyType.Widget && survey.appearance?.widgetSelector === selector\n// )\n// if (!context || !survey) {\n// return undefined\n// }\n\n// return {\n// survey,\n// showSurveyModal: () => context.setActiveSurvey(survey),\n// hideSurveyModal: () => {\n// if (context.activeSurvey === survey) {\n// context.setActiveSurvey(undefined)\n// }\n// },\n// }\n// }\n\nexport type PostHogSurveyProviderProps = {\n /**\n * Whether eligible popover surveys are automatically presented. (Default: true)\n * Set to false to defer presentation — e.g. while a native-stack formSheet/modal is on top.\n * Deferral is display-only: the survey stays armed and presents once this is true again.\n * A survey already on screen is not interrupted when this becomes false.\n *\n * You own flipping this back to true (e.g. wire it to route/screen focus). While it stays\n * false the survey remains deferred and never shows — if the un-defer never happens\n * (sheet dismissed without re-focusing the provider, an unmount, an error boundary), the\n * survey stays armed indefinitely and no \"survey shown\" event fires.\n */\n autoPresentSurveys?: boolean\n\n /**\n * The default appearance for surveys when not specified in PostHog.\n *\n * Accepts the React Native-only appearance fields as well (e.g.\n * `maxFontSizeMultiplier`) — they are merged into the same theme object the\n * survey components read, and PostHog never sends them down.\n */\n defaultSurveyAppearance?: SurveyAppearance\n\n /**\n * If true, PosHog appearance will be ignored and defaultSurveyAppearance is always used.\n */\n overrideAppearanceWithDefault?: boolean\n\n /**\n * The keyboard avoiding behavior for the survey modal (KeyboardAvoidingView), applied only to Android devices.\n * - 'padding': Adds padding to avoid keyboard (recommended)\n * - 'height': Resizes the view height (default, for legacy - may cause flickering on some Android devices)\n * @default 'height'\n */\n androidKeyboardBehavior?: 'padding' | 'height'\n\n client?: PostHog\n\n children: React.ReactNode\n}\n\nexport function PostHogSurveyProvider(props: PostHogSurveyProviderProps): JSX.Element {\n const posthogFromHook = usePostHog()\n const posthog = props.client ?? posthogFromHook\n const { seenSurveys, setSeenSurvey, lastSeenSurveyDate, setLastSeenSurveyDate, isReady } = useSurveyStorage(posthog)\n const progressStore = useMemo(() => new SurveyProgressStore(posthog), [posthog])\n const [surveys, setSurveys] = useState<Survey[]>([])\n const [activeSurvey, setActiveSurvey] = useState<Survey | undefined>(undefined)\n // Latches the id of the survey once its modal has actually painted, so deferring presentation\n // (autoPresentSurveys=false) never tears down a survey the user is already interacting with.\n const shownSurveyIdRef = useRef<string | undefined>(undefined)\n const sessionEpochRef = useRef(0)\n const activeSessionRef = useRef<object | undefined>(undefined)\n const pendingSurveyRef = useRef<{ surveyKey: string; startedAt: number } | undefined>(undefined)\n const activatedSurveys = useActivatedSurveys(posthog, surveys)\n const invalidateSession = useCallback(() => {\n sessionEpochRef.current++\n activeSessionRef.current = undefined\n shownSurveyIdRef.current = undefined\n pendingSurveyRef.current = undefined\n }, [])\n\n const flags = useFeatureFlags(posthog)\n const [userLanguage, setUserLanguage] = useState(() => detectUserLanguage(posthog))\n const defaultSurveyAppearance = useMemo(() => props?.defaultSurveyAppearance ?? {}, [props?.defaultSurveyAppearance])\n\n const overrideAppearanceWithDefault = props?.overrideAppearanceWithDefault\n\n useEffect(() => {\n const updateLanguage = () => setUserLanguage(detectUserLanguage(posthog))\n const unsubscribe = posthog.on('personProperties', updateLanguage)\n updateLanguage()\n return unsubscribe\n }, [posthog])\n\n useEffect(\n () =>\n posthog.on('surveysReset', () => {\n invalidateSession()\n setActiveSurvey(undefined)\n }),\n [posthog, invalidateSession]\n )\n\n // Load surveys once\n useEffect(() => {\n let mounted = true\n setActiveSurvey(undefined)\n setSurveys([])\n activeSessionRef.current = undefined\n shownSurveyIdRef.current = undefined\n posthog\n .ready()\n .then(() => posthog._onSurveysReady())\n .then(() => {\n setUserLanguage(detectUserLanguage(posthog))\n return posthog.getSurveys()\n })\n .then((loadedSurveys) => {\n if (!mounted) return\n // An unavailable cache (failed load or disableSurveys) is not an empty project.\n if (Array.isArray(posthog.getPersistedProperty(PostHogPersistedProperty.Surveys))) {\n progressStore.reconcile(loadedSurveys)\n }\n setSurveys(loadedSurveys)\n })\n .catch(() => {})\n return () => {\n mounted = false\n invalidateSession()\n }\n }, [posthog, progressStore, invalidateSession])\n\n // Whenever state changes, re-select the popover survey to show. A survey that has already\n // painted is left alone; an armed-but-deferred one is re-validated so it can't be presented\n // after it stops matching (e.g. its targeting flag flips off during a long deferral).\n useEffect(() => {\n if (!isReady || !canCaptureSurvey(posthog)) {\n pendingSurveyRef.current = undefined\n return\n }\n const isShown = !!activeSurvey && shownSurveyIdRef.current === activeSurvey.id\n if (isShown) {\n return\n }\n const inProgressSurveys = new Set(surveys.filter((survey) => progressStore.load(survey)).map(getSurveyIterationKey))\n const activeSurveys = getActiveMatchingSurveys(\n surveys,\n flags ?? {},\n seenSurveys,\n activatedSurveys,\n inProgressSurveys,\n lastSeenSurveyDate\n )\n const defaultDelay = defaultSurveyAppearance.surveyPopupDelaySeconds ?? 0\n const getDelaySeconds = (survey: Survey) =>\n Math.max(\n 0,\n overrideAppearanceWithDefault ? defaultDelay : (survey.appearance?.surveyPopupDelaySeconds ?? defaultDelay)\n )\n const popoverSurveys = activeSurveys\n .filter((survey) => survey.type === SurveyType.Popover)\n .sort((a, b) => {\n // Resume an existing response before starting a new survey, then prefer the shortest delay.\n const progressPriority =\n Number(inProgressSurveys.has(getSurveyIterationKey(b))) -\n Number(inProgressSurveys.has(getSurveyIterationKey(a)))\n return progressPriority || getDelaySeconds(a) - getDelaySeconds(b)\n })\n\n // Keep an eligible armed survey, including one whose delay has already elapsed.\n if (activeSurvey && popoverSurveys.some((survey) => survey.id === activeSurvey.id)) {\n return\n }\n\n // An ineligible armed survey must not be presented while its replacement waits.\n setActiveSurvey(undefined)\n const nextSurvey =\n popoverSurveys.find((survey) => getSurveyIterationKey(survey) === pendingSurveyRef.current?.surveyKey) ??\n popoverSurveys[0]\n if (!nextSurvey) {\n pendingSurveyRef.current = undefined\n return\n }\n\n const surveyKey = getSurveyIterationKey(nextSurvey)\n if (pendingSurveyRef.current?.surveyKey !== surveyKey) {\n pendingSurveyRef.current = { surveyKey, startedAt: Date.now() }\n }\n const elapsed = Math.max(0, Date.now() - pendingSurveyRef.current.startedAt)\n const remainingDelay = Math.max(0, getDelaySeconds(nextSurvey) * 1000 - elapsed)\n\n if (remainingDelay === 0) {\n pendingSurveyRef.current = undefined\n setActiveSurvey(nextSurvey)\n return\n }\n\n const surveyActivationTimeoutId = setTimeout(() => {\n pendingSurveyRef.current = undefined\n if (!canCaptureSurvey(posthog)) return\n\n const currentActiveSurveys = getActiveMatchingSurveys(\n surveys,\n flags ?? {},\n seenSurveys,\n activatedSurveys,\n new Set(surveys.filter((survey) => progressStore.load(survey)).map(getSurveyIterationKey)),\n lastSeenSurveyDate\n )\n\n const nextSurveyEligible = currentActiveSurveys.some((survey: Survey) => survey.id === nextSurvey.id)\n\n if (nextSurveyEligible) {\n setActiveSurvey(nextSurvey)\n }\n }, remainingDelay)\n\n return () => clearTimeout(surveyActivationTimeoutId)\n }, [\n activeSurvey,\n flags,\n surveys,\n seenSurveys,\n lastSeenSurveyDate,\n defaultSurveyAppearance,\n overrideAppearanceWithDefault,\n activatedSurveys,\n isReady,\n posthog,\n progressStore,\n ])\n\n const translatedActiveSurvey = useMemo(() => {\n return activeSurvey ? applySurveyTranslationForUser(activeSurvey, posthog, userLanguage) : undefined\n }, [activeSurvey, posthog, userLanguage])\n\n // Merge survey appearance so that components and hooks can use a consistent model\n const surveyAppearance = useMemo<SurveyAppearanceTheme>(() => {\n if (overrideAppearanceWithDefault || !translatedActiveSurvey) {\n return {\n ...builtInSurveyAppearance,\n ...defaultSurveyAppearance,\n }\n }\n return {\n ...builtInSurveyAppearance,\n ...defaultSurveyAppearance,\n ...(translatedActiveSurvey.survey.appearance ?? {}),\n // If submitButtonColor is set by PostHog, ensure submitButtonTextColor is also set to contrast\n ...(translatedActiveSurvey.survey.appearance?.submitButtonColor\n ? {\n submitButtonTextColor:\n translatedActiveSurvey.survey.appearance.submitButtonTextColor ??\n getContrastingTextColor(translatedActiveSurvey.survey.appearance.submitButtonColor),\n }\n : {}),\n }\n }, [translatedActiveSurvey, defaultSurveyAppearance, overrideAppearanceWithDefault])\n\n const activeSession = useMemo(\n () =>\n activeSurvey\n ? {\n progress: progressStore.load(activeSurvey) ?? createSurveyProgress(activeSurvey),\n completed: false,\n epoch: sessionEpochRef.current,\n }\n : undefined,\n [activeSurvey, progressStore]\n )\n\n const activeContext = useMemo(() => {\n if (!activeSurvey || !translatedActiveSurvey || !activeSession) {\n return undefined\n }\n return {\n client: posthog,\n initialProgress: activeSession.progress,\n onProgressChange: (progress: SurveyProgress, completed: boolean) => {\n if (\n activeSessionRef.current !== activeSession ||\n !canCaptureSurvey(posthog) ||\n progressStore.load(activeSurvey)?.submissionId !== activeSession.progress.submissionId\n )\n return false\n activeSession.progress = progress\n activeSession.completed = completed\n if (completed) {\n progressStore.remove(activeSurvey)\n setSeenSurvey(activeSurvey)\n } else {\n progressStore.save(activeSurvey, progress)\n }\n return true\n },\n survey: translatedActiveSurvey.survey,\n surveyLanguage: translatedActiveSurvey.language,\n onShow: () => {\n // Updating translated copy changes this callback, but does not show a new survey.\n if (activeSession.epoch !== sessionEpochRef.current || !canCaptureSurvey(posthog)) return\n if (shownSurveyIdRef.current === activeSurvey.id) {\n return\n }\n activeSessionRef.current = activeSession\n progressStore.save(activeSurvey, activeSession.progress)\n shownSurveyIdRef.current = activeSurvey.id\n sendSurveyShownEvent(translatedActiveSurvey.survey, posthog, translatedActiveSurvey.language)\n setLastSeenSurveyDate(new Date())\n },\n onClose: (submitted: boolean, responses: SurveyResponses) => {\n if (activeSessionRef.current !== activeSession) return\n activeSessionRef.current = undefined\n progressStore.remove(activeSurvey)\n shownSurveyIdRef.current = undefined\n setSeenSurvey(activeSurvey)\n setActiveSurvey(undefined)\n if (submitted || activeSession.completed) return\n if (canCaptureSurvey(posthog)) {\n dismissedSurveyEvent(\n translatedActiveSurvey.survey,\n responses,\n posthog,\n Object.keys(activeSession.progress.responses).length > 0\n ? activeSession.progress.surveyLanguage\n : translatedActiveSurvey.language,\n activeSession.progress\n )\n }\n },\n }\n }, [\n activeSurvey,\n activeSession,\n posthog,\n progressStore,\n setLastSeenSurveyDate,\n setSeenSurvey,\n translatedActiveSurvey,\n ])\n\n // Present a popover survey when autoPresentSurveys is on. Once it has painted (shownSurveyIdRef),\n // keep it mounted regardless of the gate so a mid-interaction survey is never yanked — the gate\n // defers not-yet-shown surveys, it does not interrupt a live one.\n const autoPresent = props.autoPresentSurveys !== false\n const isAlreadyShown = !!activeSurvey && shownSurveyIdRef.current === activeSurvey.id\n const shouldShowModal =\n activeContext && activeContext.survey.type === SurveyType.Popover && (autoPresent || isAlreadyShown)\n\n return (\n <ActiveSurveyContext.Provider value={activeContext}>\n <FeedbackSurveyContext.Provider value={{ surveys, activeSurvey, setActiveSurvey }}>\n {props.children}\n {shouldShowModal && (\n <SurveyModal\n key={activeSession?.progress.submissionId}\n appearance={surveyAppearance}\n androidKeyboardBehavior={props.androidKeyboardBehavior}\n {...activeContext}\n />\n )}\n </FeedbackSurveyContext.Provider>\n </ActiveSurveyContext.Provider>\n )\n}\n"],"mappings":"4bAAA,IAAAA,MAAA,CAAAC,uBAAA,CAAAC,OAAA,WAEA,IAAAC,QAAA,CAAAD,OAAA,yBAEA,IAAAE,yBAAA,CAAAF,OAAA,+BACA,IAAAG,kBAAA,CAAAH,OAAA,uBACA,IAAAI,eAAA,CAAAJ,OA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1
+ export declare const version = "4.85.0";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.version=void 0;var version=exports.version="4.84.3";
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.version=void 0;var version=exports.version="4.85.0";
2
2
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":["version","exports"],"sources":["../src/version.ts"],"sourcesContent":["export const version = \"4.84.3\"\n"],"mappings":"6FAAO,GAAM,CAAAA,OAAO,CAAAC,OAAA,CAAAD,OAAA,CAAG,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"version.js","names":["version","exports"],"sources":["../src/version.ts"],"sourcesContent":["export const version = \"4.85.0\"\n"],"mappings":"6FAAO,GAAM,CAAAA,OAAO,CAAAC,OAAA,CAAAD,OAAA,CAAG,QAAQ","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-react-native",
3
- "version": "4.84.3",
3
+ "version": "4.85.0",
4
4
  "bugs": {
5
5
  "url": "https://github.com/PostHog/posthog-js/issues"
6
6
  },
@@ -34,7 +34,7 @@
34
34
  "directory": "packages/react-native"
35
35
  },
36
36
  "dependencies": {
37
- "@posthog/core": "^1.61.1",
37
+ "@posthog/core": "^1.61.2",
38
38
  "@posthog/types": "^1.418.0"
39
39
  },
40
40
  "devDependencies": {
@@ -73,9 +73,9 @@
73
73
  "typescript": "7.0.2",
74
74
  "@vitest/coverage-v8": "^1.6.1",
75
75
  "vitest": "^1.6.1",
76
+ "@posthog-tooling/rollup-utils": "1.1.1",
76
77
  "@posthog/react-native-plugin": "2.12.7",
77
- "@posthog-tooling/tsconfig-base": "1.1.1",
78
- "@posthog-tooling/rollup-utils": "1.1.1"
78
+ "@posthog-tooling/tsconfig-base": "1.1.1"
79
79
  },
80
80
  "peerDependencies": {
81
81
  "@react-native-async-storage/async-storage": ">=1.0.0",