posthog-react-native 4.84.2 → 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");Object.defineProperty(exports,"__esModule",{value:true});exports.maxAncestorsTraversed=exports.findOwningNode=exports.defaultPostHogLabelProp=exports.autocaptureFromTouchEvent=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof"));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 _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 isAnimatedValue=function isAnimatedValue(value){return(value===null||value===void 0?void 0:value._isReanimatedSharedValue)===true||(0,_typeof2["default"])(value)==='object'&&value!==null&&'_value'in value;};var _flattenStyles=function flattenStyles(styles){var flattened={};if(isAnimatedValue(styles)){return{};}if(Array.isArray(styles)){var _iterator=_createForOfIteratorHelper(styles),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var style=_step.value;(0,_extends2["default"])(flattened,_flattenStyles(style));}}catch(err){_iterator.e(err);}finally{_iterator.f();}}else if(styles&&(0,_typeof2["default"])(styles)==='object'){for(var key in styles){if(!isAnimatedValue(styles[key])){flattened[key]=styles[key];}}}return flattened;};var stringifyStyle=function stringifyStyle(styles){var flattened=_flattenStyles(styles);var str=Object.keys(flattened).map(function(x){return"".concat(x,":").concat(flattened[x]);}).join(';');return str;};var sanitiseLabel=function sanitiseLabel(label){return label.replace(/[^a-z0-9]+/gi,'-');};var defaultPostHogLabelProp=exports.defaultPostHogLabelProp='ph-label';var captureAttributePrefix='data-ph-capture-attribute-';var frameworkInternalLabels=['LocaleProvider'];var reactFiberKeyPattern=/^__react(Fiber|InternalInstance)\$/;var maxFallbackAncestors=100;var maxOwnerAncestors=100;var warnedCaptureFailure=false;var getFallbackTargetInstance=function getFallbackTargetInstance(e){var node=e.target;for(var depth=0;node&&(0,_typeof2["default"])(node)==='object'&&depth<maxFallbackAncestors;depth++){var key=Object.getOwnPropertyNames(node).find(function(name){return reactFiberKeyPattern.test(name);});if(key){return node[key];}node=node.parentNode;}return undefined;};var findOwningNode=exports.findOwningNode=function findOwningNode(e,owners){var current=e._targetInst||getFallbackTargetInstance(e);for(var depth=0;current&&depth<maxOwnerAncestors;depth++){if(current.stateNode&&owners.has(current.stateNode)){return current.stateNode;}current=current["return"];}return undefined;};var maxAncestorsTraversed=exports.maxAncestorsTraversed=1000;var defaultMaxElementsCaptured=20;var autocaptureFromTouchEvent=exports.autocaptureFromTouchEvent=function autocaptureFromTouchEvent(e,posthog){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var eventType=arguments.length>3&&arguments[3]!==undefined?arguments[3]:'touch';try{captureFromEvent(e,posthog,options,eventType);}catch(error){if(!warnedCaptureFailure){warnedCaptureFailure=true;console.warn('PostHog autocapture: capturing the interaction threw:',error);}}};var captureFromEvent=function captureFromEvent(e,posthog,options,eventType){var _a,_b,_c,_d;var _options$noCapturePro=options.noCaptureProp,noCaptureProp=_options$noCapturePro===void 0?'ph-no-capture':_options$noCapturePro,_options$customLabelP=options.customLabelProp,customLabelProp=_options$customLabelP===void 0?defaultPostHogLabelProp:_options$customLabelP,_options$maxElementsC=options.maxElementsCaptured,maxElementsCapturedOption=_options$maxElementsC===void 0?defaultMaxElementsCaptured:_options$maxElementsC,_options$ignoreLabels=options.ignoreLabels,ignoreLabels=_options$ignoreLabels===void 0?[]:_options$ignoreLabels,_options$propsToCaptu=options.propsToCapture,propsToCapture=_options$propsToCaptu===void 0?['style','testID','accessibilityLabel',customLabelProp,'children']:_options$propsToCaptu;var maxElementsCaptured=Number.isFinite(maxElementsCapturedOption)?maxElementsCapturedOption:defaultMaxElementsCaptured;var nativeInst=e._targetInst;var targetInst=nativeInst||getFallbackTargetInstance(e);if(!targetInst){return;}var elements=[];var autocaptureProperties={};var currentInst=targetInst;var ancestorsTraversed=0;var _loop=function _loop(){var props=currentInst.memoizedProps;if(ancestorsTraversed++>=maxAncestorsTraversed){return{v:void 0};}if(props===null||props===void 0?void 0:props[noCaptureProp]){return{v:void 0};}if(elements.length>=maxElementsCaptured){currentInst=currentInst["return"];return 0;}var el={tag_name:''};var elAutocaptureProperties={};if(props){Object.keys(props).forEach(function(key){var value=props[key];if(key.indexOf(captureAttributePrefix)===0){var propertyKey=key.slice(captureAttributePrefix.length);if(propertyKey&&['string','number','boolean'].includes((0,_typeof2["default"])(value))&&value!==''){elAutocaptureProperties[propertyKey]=value;}}if(!propsToCapture.includes(key)){return;}if(key==='style'){try{el.attr__style=stringifyStyle(value);}catch(error){}}else if(['string','number','boolean'].includes((0,_typeof2["default"])(value))){if(key==='children'){el.$el_text=typeof value==='string'?value:JSON.stringify(value);}else{el["attr__".concat(key)]=value;}}});}var hasCustomLabel=typeof(props===null||props===void 0?void 0:props[customLabelProp])!=='undefined';var label=hasCustomLabel?"".concat(props===null||props===void 0?void 0:props[customLabelProp]):((_a=currentInst.elementType)===null||_a===void 0?void 0:_a.displayName)||((_b=currentInst.elementType)===null||_b===void 0?void 0:_b.name);(0,_extends2["default"])(autocaptureProperties,elAutocaptureProperties);var isFrameworkWrapper=!nativeInst&&!hasCustomLabel&&elements.length===0&&frameworkInternalLabels.includes(label);if(label&&!isFrameworkWrapper&&!ignoreLabels.includes(label)){el.tag_name=sanitiseLabel(label);elements.push(el);}currentInst=currentInst["return"];},_ret;while(currentInst){_ret=_loop();if(_ret===0)continue;if(_ret)return _ret.v;}if(elements.length){var elAttrLabelKey="attr__".concat(customLabelProp);var lastLabel=undefined;for(var i=elements.length-1;i>=0;i--){var element=elements[i];if(element[elAttrLabelKey]){lastLabel=element[elAttrLabelKey];}if(lastLabel){element['tag_name']=lastLabel;}}posthog.autocapture(eventType,elements,_objectSpread(_objectSpread({},autocaptureProperties),{},{$touch_x:(_c=e.nativeEvent)===null||_c===void 0?void 0:_c.pageX,$touch_y:(_d=e.nativeEvent)===null||_d===void 0?void 0:_d.pageY}));}};
1
+ "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.maxAncestorsTraversed=exports.findOwningNode=exports.defaultPostHogLabelProp=exports.autocaptureFromTouchEvent=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof"));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 _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 isAnimatedValue=function isAnimatedValue(value){return(value===null||value===void 0?void 0:value._isReanimatedSharedValue)===true||(0,_typeof2["default"])(value)==='object'&&value!==null&&'_value'in value;};var _flattenStyles=function flattenStyles(styles){var flattened={};if(isAnimatedValue(styles)){return{};}if(Array.isArray(styles)){var _iterator=_createForOfIteratorHelper(styles),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var style=_step.value;(0,_extends2["default"])(flattened,_flattenStyles(style));}}catch(err){_iterator.e(err);}finally{_iterator.f();}}else if(styles&&(0,_typeof2["default"])(styles)==='object'){for(var key in styles){if(!isAnimatedValue(styles[key])){flattened[key]=styles[key];}}}return flattened;};var stringifyStyle=function stringifyStyle(styles){var flattened=_flattenStyles(styles);var str=Object.keys(flattened).map(function(x){return"".concat(x,":").concat(flattened[x]);}).join(';');return str;};var sanitiseLabel=function sanitiseLabel(label){return label.replace(/[^a-z0-9]+/gi,'-');};var defaultPostHogLabelProp=exports.defaultPostHogLabelProp='ph-label';var captureAttributePrefix='data-ph-capture-attribute-';var frameworkInternalLabels=['LocaleProvider'];var reactFiberKeyPattern=/^__react(Fiber|InternalInstance)\$/;var maxFallbackAncestors=100;var maxOwnerAncestors=100;var warnedCaptureFailure=false;var getFallbackTargetInstance=function getFallbackTargetInstance(e){var node=e.target;for(var depth=0;node&&(0,_typeof2["default"])(node)==='object'&&depth<maxFallbackAncestors;depth++){if(node.__internalInstanceHandle){return node.__internalInstanceHandle;}var key=Object.getOwnPropertyNames(node).find(function(name){return reactFiberKeyPattern.test(name);});if(key){return node[key];}node=node.parentNode;}return undefined;};var findOwningNode=exports.findOwningNode=function findOwningNode(e,owners){var current=e._targetInst||getFallbackTargetInstance(e);for(var depth=0;current&&depth<maxOwnerAncestors;depth++){if(current.stateNode&&owners.has(current.stateNode)){return current.stateNode;}current=current["return"];}return undefined;};var maxAncestorsTraversed=exports.maxAncestorsTraversed=1000;var defaultMaxElementsCaptured=20;var autocaptureFromTouchEvent=exports.autocaptureFromTouchEvent=function autocaptureFromTouchEvent(e,posthog){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var eventType=arguments.length>3&&arguments[3]!==undefined?arguments[3]:'touch';try{captureFromEvent(e,posthog,options,eventType);}catch(error){if(!warnedCaptureFailure){warnedCaptureFailure=true;console.warn('PostHog autocapture: capturing the interaction threw:',error);}}};var captureFromEvent=function captureFromEvent(e,posthog,options,eventType){var _a,_b,_c,_d;var _options$noCapturePro=options.noCaptureProp,noCaptureProp=_options$noCapturePro===void 0?'ph-no-capture':_options$noCapturePro,_options$customLabelP=options.customLabelProp,customLabelProp=_options$customLabelP===void 0?defaultPostHogLabelProp:_options$customLabelP,_options$maxElementsC=options.maxElementsCaptured,maxElementsCapturedOption=_options$maxElementsC===void 0?defaultMaxElementsCaptured:_options$maxElementsC,_options$ignoreLabels=options.ignoreLabels,ignoreLabels=_options$ignoreLabels===void 0?[]:_options$ignoreLabels,_options$propsToCaptu=options.propsToCapture,propsToCapture=_options$propsToCaptu===void 0?['style','testID','accessibilityLabel',customLabelProp,'children']:_options$propsToCaptu;var maxElementsCaptured=Number.isFinite(maxElementsCapturedOption)?maxElementsCapturedOption:defaultMaxElementsCaptured;var nativeInst=e._targetInst;var targetInst=nativeInst||getFallbackTargetInstance(e);if(!targetInst){return;}var elements=[];var autocaptureProperties={};var currentInst=targetInst;var ancestorsTraversed=0;var _loop=function _loop(){var props=currentInst.memoizedProps;if(ancestorsTraversed++>=maxAncestorsTraversed){return{v:void 0};}if(props===null||props===void 0?void 0:props[noCaptureProp]){return{v:void 0};}if(elements.length>=maxElementsCaptured){currentInst=currentInst["return"];return 0;}var el={tag_name:''};var elAutocaptureProperties={};if(props){Object.keys(props).forEach(function(key){var value=props[key];if(key.indexOf(captureAttributePrefix)===0){var propertyKey=key.slice(captureAttributePrefix.length);if(propertyKey&&['string','number','boolean'].includes((0,_typeof2["default"])(value))&&value!==''){elAutocaptureProperties[propertyKey]=value;}}if(!propsToCapture.includes(key)){return;}if(key==='style'){try{el.attr__style=stringifyStyle(value);}catch(error){}}else if(['string','number','boolean'].includes((0,_typeof2["default"])(value))){if(key==='children'){el.$el_text=typeof value==='string'?value:JSON.stringify(value);}else{el["attr__".concat(key)]=value;}}});}var hasCustomLabel=typeof(props===null||props===void 0?void 0:props[customLabelProp])!=='undefined';var label=hasCustomLabel?"".concat(props===null||props===void 0?void 0:props[customLabelProp]):((_a=currentInst.elementType)===null||_a===void 0?void 0:_a.displayName)||((_b=currentInst.elementType)===null||_b===void 0?void 0:_b.name);(0,_extends2["default"])(autocaptureProperties,elAutocaptureProperties);var isFrameworkWrapper=!nativeInst&&!hasCustomLabel&&elements.length===0&&frameworkInternalLabels.includes(label);if(label&&!isFrameworkWrapper&&!ignoreLabels.includes(label)){el.tag_name=sanitiseLabel(label);elements.push(el);}currentInst=currentInst["return"];},_ret;while(currentInst){_ret=_loop();if(_ret===0)continue;if(_ret)return _ret.v;}if(elements.length){var elAttrLabelKey="attr__".concat(customLabelProp);var lastLabel=undefined;for(var i=elements.length-1;i>=0;i--){var element=elements[i];if(element[elAttrLabelKey]){lastLabel=element[elAttrLabelKey];}if(lastLabel){element['tag_name']=lastLabel;}}posthog.autocapture(eventType,elements,_objectSpread(_objectSpread({},autocaptureProperties),{},{$touch_x:(_c=e.nativeEvent)===null||_c===void 0?void 0:_c.pageX,$touch_y:(_d=e.nativeEvent)===null||_d===void 0?void 0:_d.pageY}));}};
2
2
  //# sourceMappingURL=autocapture.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"autocapture.js","names":["isAnimatedValue","value","_isReanimatedSharedValue","_typeof2","flattenStyles","styles","flattened","Array","isArray","_iterator","_createForOfIteratorHelper","_step","s","n","done","style","_extends2","err","e","f","key","stringifyStyle","str","Object","keys","map","x","concat","join","sanitiseLabel","label","replace","defaultPostHogLabelProp","exports","captureAttributePrefix","frameworkInternalLabels","reactFiberKeyPattern","maxFallbackAncestors","maxOwnerAncestors","warnedCaptureFailure","getFallbackTargetInstance","node","target","depth","getOwnPropertyNames","find","name","test","parentNode","undefined","findOwningNode","owners","current","_targetInst","stateNode","has","maxAncestorsTraversed","defaultMaxElementsCaptured","autocaptureFromTouchEvent","posthog","options","arguments","length","eventType","captureFromEvent","error","console","warn","_options$noCapturePro","noCaptureProp","_options$customLabelP","customLabelProp","_options$maxElementsC","maxElementsCaptured","maxElementsCapturedOption","_options$ignoreLabels","ignoreLabels","_options$propsToCaptu","propsToCapture","Number","isFinite","nativeInst","targetInst","elements","autocaptureProperties","currentInst","ancestorsTraversed","_loop","props","memoizedProps","v","el","tag_name","elAutocaptureProperties","forEach","indexOf","propertyKey","slice","includes","attr__style","$el_text","JSON","stringify","hasCustomLabel","_a","elementType","displayName","_b","isFrameworkWrapper","push","_ret","elAttrLabelKey","lastLabel","i","element","autocapture","_objectSpread","$touch_x","_c","nativeEvent","pageX","$touch_y","_d","pageY"],"sources":["../src/autocapture.tsx"],"sourcesContent":["import { PostHog } from './posthog-rn'\nimport { PostHogAutocaptureElement, JsonType } from '@posthog/core'\nimport { PostHogAutocaptureOptions } from './types'\n\ninterface Element {\n elementType?: {\n displayName?: string\n name?: string\n }\n memoizedProps?: Record<string, unknown>\n return?: Element\n // Host fibers carry their DOM node here; used to scope web capture to a provider's subtree.\n stateNode?: unknown\n}\n\nconst isAnimatedValue = (value: any): boolean => {\n // Check if it's a Reanimated shared value or animated style\n // _isReanimatedSharedValue is the official internal marker for SharedValues\n // Also check for _value property which is present in SharedValues\n return value?._isReanimatedSharedValue === true || (typeof value === 'object' && value !== null && '_value' in value)\n}\n\nconst flattenStyles = (styles: any): any => {\n const flattened: any = {}\n\n // Skip if the entire style object is an animated value\n if (isAnimatedValue(styles)) {\n return {}\n }\n\n if (Array.isArray(styles)) {\n for (const style of styles) {\n Object.assign(flattened, flattenStyles(style))\n }\n } else if (styles && typeof styles === 'object') {\n // Filter out individual animated properties within a regular style object\n // This handles cases like { opacity: animatedValue, backgroundColor: 'red' }\n for (const key in styles) {\n if (!isAnimatedValue(styles[key])) {\n flattened[key] = styles[key]\n }\n }\n }\n\n return flattened\n}\n\nconst stringifyStyle = (styles: any): string => {\n const flattened = flattenStyles(styles)\n\n const str = Object.keys(flattened)\n .map((x) => `${x}:${flattened[x]}`)\n .join(';')\n\n return str\n}\n\nconst sanitiseLabel = (label: string): string => {\n return label.replace(/[^a-z0-9]+/gi, '-')\n}\n\nexport const defaultPostHogLabelProp = 'ph-label'\n\nconst captureAttributePrefix = 'data-ph-capture-attribute-'\n\n// react-native-web internals; skipped only where RNW puts them, so a same-named app component is kept.\n// Verified against RNW 0.20.0 and 0.21.2: createElement wraps in LocaleProvider only when\n// `domProps.dir` is set, so a nested element inside a text ancestor never gets one. Recheck on bump.\nconst frameworkInternalLabels = ['LocaleProvider']\n\nconst reactFiberKeyPattern = /^__react(Fiber|InternalInstance)\\$/\n\n// Cycle guard, not a depth policy: real DOM chains null-terminate, a malformed parentNode may not.\nconst maxFallbackAncestors = 100\n\n// Separate bound for the fiber walk: unrelated to the DOM guard above, so tuning one never\n// silently retunes the other.\nconst maxOwnerAncestors = 100\n\n// Fires per interaction, so warn once: a persistent failure here silently disables autocapture.\nlet warnedCaptureFailure = false\n\n// react-dom (RN Web) events have no _targetInst; the fiber sits on e.target under a randomised\n// __reactFiber$ key. The clicked node may be a non-React node inside a React subtree, so walk up.\nconst getFallbackTargetInstance = (e: any): Element | undefined => {\n let node = e.target\n\n for (let depth = 0; node && typeof node === 'object' && depth < maxFallbackAncestors; depth++) {\n const key = Object.getOwnPropertyNames(node).find((name) => reactFiberKeyPattern.test(name))\n if (key) {\n return node[key]\n }\n node = node.parentNode\n }\n\n return undefined\n}\n\n// Returns the owner node this event happened under, or undefined if none owns it. Walks the fiber\n// tree, not the DOM: RNW's Modal portals to document.body, so the DOM parent chain leaves the\n// subtree but fiber `.return` does not. Kept separate from the element walk in captureFromEvent,\n// which stops at maxElementsCaptured and would falsely reject a deep target.\nexport const findOwningNode = (e: any, owners: { has(node: unknown): boolean }): unknown => {\n let current: Element | undefined = e._targetInst || getFallbackTargetInstance(e)\n for (let depth = 0; current && depth < maxOwnerAncestors; depth++) {\n if (current.stateNode && owners.has(current.stateNode)) {\n return current.stateNode\n }\n current = current.return\n }\n\n return undefined\n}\n\n// Fail-closed bound on the walk; unrelated to maxElementsCaptured, which caps the emitted payload.\nexport const maxAncestorsTraversed = 1000\n\nconst defaultMaxElementsCaptured = 20\n\n// Autocapture must never break the host app: a throw would escape into RN's touch dispatch on\n// native, or the DOM click handler on web. Matches the browser SDK, which guards its equivalent\n// document-level handler (packages/browser/src/autocapture.ts).\nexport const autocaptureFromTouchEvent = (\n e: any,\n posthog: PostHog,\n options: PostHogAutocaptureOptions = {},\n eventType: 'touch' | 'click' = 'touch'\n): void => {\n try {\n captureFromEvent(e, posthog, options, eventType)\n } catch (error) {\n if (!warnedCaptureFailure) {\n warnedCaptureFailure = true\n console.warn('PostHog autocapture: capturing the interaction threw:', error)\n }\n }\n}\n\nconst captureFromEvent = (\n e: any,\n posthog: PostHog,\n options: PostHogAutocaptureOptions,\n eventType: 'touch' | 'click'\n): void => {\n const {\n noCaptureProp = 'ph-no-capture',\n customLabelProp = defaultPostHogLabelProp,\n maxElementsCaptured: maxElementsCapturedOption = defaultMaxElementsCaptured,\n ignoreLabels = [],\n propsToCapture = ['style', 'testID', 'accessibilityLabel', customLabelProp, 'children'],\n } = options\n\n // The destructure default only covers `undefined`; a NaN would make every comparison against it\n // false, silently uncapping the payload instead of capping it.\n const maxElementsCaptured = Number.isFinite(maxElementsCapturedOption)\n ? maxElementsCapturedOption\n : defaultMaxElementsCaptured\n\n const nativeInst = e._targetInst\n const targetInst: Element | undefined = nativeInst || getFallbackTargetInstance(e)\n if (!targetInst) {\n return\n }\n const elements: PostHogAutocaptureElement[] = []\n const autocaptureProperties: Record<string, JsonType> = {}\n\n let currentInst: Element | undefined = targetInst\n let ancestorsTraversed = 0\n\n while (currentInst) {\n const props = currentInst.memoizedProps\n\n if (ancestorsTraversed++ >= maxAncestorsTraversed) {\n return\n }\n\n if (props?.[noCaptureProp]) {\n // Immediately ignore events if a no capture is in the chain\n return\n }\n\n if (elements.length >= maxElementsCaptured) {\n // keep walking so a no capture ancestor above the cap is still seen\n currentInst = currentInst.return\n continue\n }\n\n const el: PostHogAutocaptureElement = {\n tag_name: '',\n }\n const elAutocaptureProperties: Record<string, JsonType> = {}\n\n if (props) {\n // Capture data-ph-capture-attribute props as event properties.\n // Element props are only captured from propsToCapture.\n Object.keys(props).forEach((key) => {\n const value = props[key]\n\n if (key.indexOf(captureAttributePrefix) === 0) {\n const propertyKey = key.slice(captureAttributePrefix.length)\n if (propertyKey && ['string', 'number', 'boolean'].includes(typeof value) && value !== '') {\n elAutocaptureProperties[propertyKey] = value as JsonType\n }\n }\n\n if (!propsToCapture.includes(key)) {\n return\n }\n\n if (key === 'style') {\n // Safely handle style prop, especially for animated styles\n try {\n el.attr__style = stringifyStyle(value)\n } catch (error) {\n // Skip style capturing if it fails (e.g., animated styles)\n }\n } else if (['string', 'number', 'boolean'].includes(typeof value)) {\n if (key === 'children') {\n el.$el_text = typeof value === 'string' ? value : JSON.stringify(value)\n } else {\n el[`attr__${key}`] = value as JsonType\n }\n }\n })\n }\n\n // Try and find a sensible label\n const hasCustomLabel = typeof props?.[customLabelProp] !== 'undefined'\n const label = hasCustomLabel\n ? `${props?.[customLabelProp]}`\n : currentInst.elementType?.displayName || currentInst.elementType?.name\n\n Object.assign(autocaptureProperties, elAutocaptureProperties)\n\n // RNW wraps the touched host node directly, so its internals only ever head the chain; a match\n // further up is the app's own component. A user-set label is never a framework internal.\n const isFrameworkWrapper =\n !nativeInst && !hasCustomLabel && elements.length === 0 && frameworkInternalLabels.includes(label as string)\n\n if (label && !isFrameworkWrapper && !ignoreLabels.includes(label)) {\n el.tag_name = sanitiseLabel(label)\n elements.push(el)\n }\n\n currentInst = currentInst.return\n }\n\n if (elements.length) {\n // The element that was tapped, may be a child (or grandchild of an element with a customLabelProp (default: ph-label))\n // In this case, the current labels applied obscure the customLabelProp (default: ph-label)\n // To correct this, loop over the elements in reverse, and promote the customLabelProp (default: ph-label)\n const elAttrLabelKey = `attr__${customLabelProp}`\n let lastLabel: string | undefined = undefined\n\n for (let i = elements.length - 1; i >= 0; i--) {\n const element = elements[i]\n if (element[elAttrLabelKey]) {\n // this element had a customLabelProp (default: ph-label) set, promote it to the lastLabel\n lastLabel = element[elAttrLabelKey] as string\n }\n\n // if lastLabel is set, update this elements tag_name\n if (lastLabel) {\n element['tag_name'] = lastLabel\n }\n }\n posthog.autocapture(eventType, elements, {\n ...autocaptureProperties,\n $touch_x: e.nativeEvent?.pageX,\n $touch_y: e.nativeEvent?.pageY,\n })\n }\n}\n"],"mappings":"uyEAeA,GAAM,CAAAA,eAAe,CAAG,QAAlB,CAAAA,eAAeA,CAAIC,KAAU,CAAa,CAI9C,MAAO,CAAAA,KAAK,SAALA,KAAK,iBAALA,KAAK,CAAEC,wBAAwB,IAAK,IAAI,EAAK,GAAAC,QAAA,aAAOF,KAAK,IAAK,QAAQ,EAAIA,KAAK,GAAK,IAAI,EAAI,QAAQ,EAAI,CAAAA,KAAM,CACvH,CAAC,CAED,GAAM,CAAAG,cAAa,CAAG,QAAhB,CAAAA,aAAaA,CAAIC,MAAW,CAAS,CACzC,GAAM,CAAAC,SAAS,CAAQ,EAAE,CAGzB,GAAIN,eAAe,CAACK,MAAM,CAAC,CAAE,CAC3B,MAAO,EAAE,CACX,CAEA,GAAIE,KAAK,CAACC,OAAO,CAACH,MAAM,CAAC,CAAE,KAAAI,SAAA,CAAAC,0BAAA,CACLL,MAAM,EAAAM,KAAA,KAA1B,IAAAF,SAAA,CAAAG,CAAA,KAAAD,KAAA,CAAAF,SAAA,CAAAI,CAAA,IAAAC,IAAA,EAA4B,IAAjB,CAAAC,KAAK,CAAAJ,KAAA,CAAAV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Ac,CAAW,CAC/C,CAGA,GAAIC,SAAS,CAAE,CACbE,OAAO,CAAC,UAAU,CAAC,CAAGF,SAAS,CACjC,CACF,CACArD,OAAO,CAACwD,WAAW,CAACpD,SAAS,CAAEoB,QAAQ,CAAAiC,aAAA,CAAAA,aAAA,IAClChC,qBAAqB,MACxBiC,QAAQ,CAAE,CAAAC,EAAA,CAAApG,CAAC,CAACqG,WAAW,UAAAD,EAAA,iBAAAA,EAAA,CAAEE,KAAK,CAC9BC,QAAQ,CAAE,CAAAC,EAAA,CAAAxG,CAAC,CAACqG,WAAW,UAAAG,EAAA,iBAAAA,EAAA,CAAEC,KAAK,EAC/B,CAAC,CACJ,CACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"autocapture.js","names":["isAnimatedValue","value","_isReanimatedSharedValue","_typeof2","flattenStyles","styles","flattened","Array","isArray","_iterator","_createForOfIteratorHelper","_step","s","n","done","style","_extends2","err","e","f","key","stringifyStyle","str","Object","keys","map","x","concat","join","sanitiseLabel","label","replace","defaultPostHogLabelProp","exports","captureAttributePrefix","frameworkInternalLabels","reactFiberKeyPattern","maxFallbackAncestors","maxOwnerAncestors","warnedCaptureFailure","getFallbackTargetInstance","node","target","depth","__internalInstanceHandle","getOwnPropertyNames","find","name","test","parentNode","undefined","findOwningNode","owners","current","_targetInst","stateNode","has","maxAncestorsTraversed","defaultMaxElementsCaptured","autocaptureFromTouchEvent","posthog","options","arguments","length","eventType","captureFromEvent","error","console","warn","_options$noCapturePro","noCaptureProp","_options$customLabelP","customLabelProp","_options$maxElementsC","maxElementsCaptured","maxElementsCapturedOption","_options$ignoreLabels","ignoreLabels","_options$propsToCaptu","propsToCapture","Number","isFinite","nativeInst","targetInst","elements","autocaptureProperties","currentInst","ancestorsTraversed","_loop","props","memoizedProps","v","el","tag_name","elAutocaptureProperties","forEach","indexOf","propertyKey","slice","includes","attr__style","$el_text","JSON","stringify","hasCustomLabel","_a","elementType","displayName","_b","isFrameworkWrapper","push","_ret","elAttrLabelKey","lastLabel","i","element","autocapture","_objectSpread","$touch_x","_c","nativeEvent","pageX","$touch_y","_d","pageY"],"sources":["../src/autocapture.tsx"],"sourcesContent":["import { PostHog } from './posthog-rn'\nimport { PostHogAutocaptureElement, JsonType } from '@posthog/core'\nimport { PostHogAutocaptureOptions } from './types'\n\ninterface Element {\n elementType?: {\n displayName?: string\n name?: string\n }\n memoizedProps?: Record<string, unknown>\n return?: Element\n // Host fibers carry their DOM node here; used to scope web capture to a provider's subtree.\n stateNode?: unknown\n}\n\nconst isAnimatedValue = (value: any): boolean => {\n // Check if it's a Reanimated shared value or animated style\n // _isReanimatedSharedValue is the official internal marker for SharedValues\n // Also check for _value property which is present in SharedValues\n return value?._isReanimatedSharedValue === true || (typeof value === 'object' && value !== null && '_value' in value)\n}\n\nconst flattenStyles = (styles: any): any => {\n const flattened: any = {}\n\n // Skip if the entire style object is an animated value\n if (isAnimatedValue(styles)) {\n return {}\n }\n\n if (Array.isArray(styles)) {\n for (const style of styles) {\n Object.assign(flattened, flattenStyles(style))\n }\n } else if (styles && typeof styles === 'object') {\n // Filter out individual animated properties within a regular style object\n // This handles cases like { opacity: animatedValue, backgroundColor: 'red' }\n for (const key in styles) {\n if (!isAnimatedValue(styles[key])) {\n flattened[key] = styles[key]\n }\n }\n }\n\n return flattened\n}\n\nconst stringifyStyle = (styles: any): string => {\n const flattened = flattenStyles(styles)\n\n const str = Object.keys(flattened)\n .map((x) => `${x}:${flattened[x]}`)\n .join(';')\n\n return str\n}\n\nconst sanitiseLabel = (label: string): string => {\n return label.replace(/[^a-z0-9]+/gi, '-')\n}\n\nexport const defaultPostHogLabelProp = 'ph-label'\n\nconst captureAttributePrefix = 'data-ph-capture-attribute-'\n\n// react-native-web internals; skipped only where RNW puts them, so a same-named app component is kept.\n// Verified against RNW 0.20.0 and 0.21.2: createElement wraps in LocaleProvider only when\n// `domProps.dir` is set, so a nested element inside a text ancestor never gets one. Recheck on bump.\nconst frameworkInternalLabels = ['LocaleProvider']\n\nconst reactFiberKeyPattern = /^__react(Fiber|InternalInstance)\\$/\n\n// Cycle guard, not a depth policy: real DOM chains null-terminate, a malformed parentNode may not.\nconst maxFallbackAncestors = 100\n\n// Separate bound for the fiber walk: unrelated to the DOM guard above, so tuning one never\n// silently retunes the other.\nconst maxOwnerAncestors = 100\n\n// Fires per interaction, so warn once: a persistent failure here silently disables autocapture.\nlet warnedCaptureFailure = false\n\n// react-dom (RN Web) events have no _targetInst; the fiber sits on e.target under a randomised\n// __reactFiber$ key. Fabric host instances (RN new architecture) have no such key either, but expose\n// the fiber as __internalInstanceHandle. The clicked node may be a non-React node inside a React\n// subtree, so walk up.\nconst getFallbackTargetInstance = (e: any): Element | undefined => {\n let node = e.target\n\n for (let depth = 0; node && typeof node === 'object' && depth < maxFallbackAncestors; depth++) {\n if (node.__internalInstanceHandle) {\n return node.__internalInstanceHandle\n }\n const key = Object.getOwnPropertyNames(node).find((name) => reactFiberKeyPattern.test(name))\n if (key) {\n return node[key]\n }\n node = node.parentNode\n }\n\n return undefined\n}\n\n// Returns the owner node this event happened under, or undefined if none owns it. Walks the fiber\n// tree, not the DOM: RNW's Modal portals to document.body, so the DOM parent chain leaves the\n// subtree but fiber `.return` does not. Kept separate from the element walk in captureFromEvent,\n// which stops at maxElementsCaptured and would falsely reject a deep target.\nexport const findOwningNode = (e: any, owners: { has(node: unknown): boolean }): unknown => {\n let current: Element | undefined = e._targetInst || getFallbackTargetInstance(e)\n for (let depth = 0; current && depth < maxOwnerAncestors; depth++) {\n if (current.stateNode && owners.has(current.stateNode)) {\n return current.stateNode\n }\n current = current.return\n }\n\n return undefined\n}\n\n// Fail-closed bound on the walk; unrelated to maxElementsCaptured, which caps the emitted payload.\nexport const maxAncestorsTraversed = 1000\n\nconst defaultMaxElementsCaptured = 20\n\n// Autocapture must never break the host app: a throw would escape into RN's touch dispatch on\n// native, or the DOM click handler on web. Matches the browser SDK, which guards its equivalent\n// document-level handler (packages/browser/src/autocapture.ts).\nexport const autocaptureFromTouchEvent = (\n e: any,\n posthog: PostHog,\n options: PostHogAutocaptureOptions = {},\n eventType: 'touch' | 'click' = 'touch'\n): void => {\n try {\n captureFromEvent(e, posthog, options, eventType)\n } catch (error) {\n if (!warnedCaptureFailure) {\n warnedCaptureFailure = true\n console.warn('PostHog autocapture: capturing the interaction threw:', error)\n }\n }\n}\n\nconst captureFromEvent = (\n e: any,\n posthog: PostHog,\n options: PostHogAutocaptureOptions,\n eventType: 'touch' | 'click'\n): void => {\n const {\n noCaptureProp = 'ph-no-capture',\n customLabelProp = defaultPostHogLabelProp,\n maxElementsCaptured: maxElementsCapturedOption = defaultMaxElementsCaptured,\n ignoreLabels = [],\n propsToCapture = ['style', 'testID', 'accessibilityLabel', customLabelProp, 'children'],\n } = options\n\n // The destructure default only covers `undefined`; a NaN would make every comparison against it\n // false, silently uncapping the payload instead of capping it.\n const maxElementsCaptured = Number.isFinite(maxElementsCapturedOption)\n ? maxElementsCapturedOption\n : defaultMaxElementsCaptured\n\n const nativeInst = e._targetInst\n const targetInst: Element | undefined = nativeInst || getFallbackTargetInstance(e)\n if (!targetInst) {\n return\n }\n const elements: PostHogAutocaptureElement[] = []\n const autocaptureProperties: Record<string, JsonType> = {}\n\n let currentInst: Element | undefined = targetInst\n let ancestorsTraversed = 0\n\n while (currentInst) {\n const props = currentInst.memoizedProps\n\n if (ancestorsTraversed++ >= maxAncestorsTraversed) {\n return\n }\n\n if (props?.[noCaptureProp]) {\n // Immediately ignore events if a no capture is in the chain\n return\n }\n\n if (elements.length >= maxElementsCaptured) {\n // keep walking so a no capture ancestor above the cap is still seen\n currentInst = currentInst.return\n continue\n }\n\n const el: PostHogAutocaptureElement = {\n tag_name: '',\n }\n const elAutocaptureProperties: Record<string, JsonType> = {}\n\n if (props) {\n // Capture data-ph-capture-attribute props as event properties.\n // Element props are only captured from propsToCapture.\n Object.keys(props).forEach((key) => {\n const value = props[key]\n\n if (key.indexOf(captureAttributePrefix) === 0) {\n const propertyKey = key.slice(captureAttributePrefix.length)\n if (propertyKey && ['string', 'number', 'boolean'].includes(typeof value) && value !== '') {\n elAutocaptureProperties[propertyKey] = value as JsonType\n }\n }\n\n if (!propsToCapture.includes(key)) {\n return\n }\n\n if (key === 'style') {\n // Safely handle style prop, especially for animated styles\n try {\n el.attr__style = stringifyStyle(value)\n } catch (error) {\n // Skip style capturing if it fails (e.g., animated styles)\n }\n } else if (['string', 'number', 'boolean'].includes(typeof value)) {\n if (key === 'children') {\n el.$el_text = typeof value === 'string' ? value : JSON.stringify(value)\n } else {\n el[`attr__${key}`] = value as JsonType\n }\n }\n })\n }\n\n // Try and find a sensible label\n const hasCustomLabel = typeof props?.[customLabelProp] !== 'undefined'\n const label = hasCustomLabel\n ? `${props?.[customLabelProp]}`\n : currentInst.elementType?.displayName || currentInst.elementType?.name\n\n Object.assign(autocaptureProperties, elAutocaptureProperties)\n\n // RNW wraps the touched host node directly, so its internals only ever head the chain; a match\n // further up is the app's own component. A user-set label is never a framework internal.\n const isFrameworkWrapper =\n !nativeInst && !hasCustomLabel && elements.length === 0 && frameworkInternalLabels.includes(label as string)\n\n if (label && !isFrameworkWrapper && !ignoreLabels.includes(label)) {\n el.tag_name = sanitiseLabel(label)\n elements.push(el)\n }\n\n currentInst = currentInst.return\n }\n\n if (elements.length) {\n // The element that was tapped, may be a child (or grandchild of an element with a customLabelProp (default: ph-label))\n // In this case, the current labels applied obscure the customLabelProp (default: ph-label)\n // To correct this, loop over the elements in reverse, and promote the customLabelProp (default: ph-label)\n const elAttrLabelKey = `attr__${customLabelProp}`\n let lastLabel: string | undefined = undefined\n\n for (let i = elements.length - 1; i >= 0; i--) {\n const element = elements[i]\n if (element[elAttrLabelKey]) {\n // this element had a customLabelProp (default: ph-label) set, promote it to the lastLabel\n lastLabel = element[elAttrLabelKey] as string\n }\n\n // if lastLabel is set, update this elements tag_name\n if (lastLabel) {\n element['tag_name'] = lastLabel\n }\n }\n posthog.autocapture(eventType, elements, {\n ...autocaptureProperties,\n $touch_x: e.native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,EAC/B,CAAC,CACJ,CACF,CAAC","ignoreList":[]}
@@ -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,UAAA,QAAAL,CAAA,KAAAM,CAAA,CAAAC,CAAA,CAAAC,CAAA,EAAAC,SAA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AEVkG,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,OAAA,sBACA,IAAAK,QAAA,CAAAL,OAAA,0BACA,IAAAM,oBAAA,CAAAN,OA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a,CAACC,QAAQ,CACvB,CACH,CACF,C,CACD,CACH,CAAC,CAAE,CACDvF,YAAY,CACZsF,aAAa,CACb3G,OAAO,CACPU,aAAa,CACbF,qBAAqB,CACrBF,aAAa,CACb8F,sBAAsB,CACvB,CAAC,CAKF,GAAM,CAAA0B,WAAW,CAAGjI,KAAK,CAACkI,kBAAkB,GAAK,KAAK,CACtD,GAAM,CAAAC,cAAc,CAAG,CAAC,CAAC3G,YAAY,EAAIE,gBAAgB,CAACS,OAAO,GAAKX,YAAY,CAACuC,EAAE,CACrF,GAAM,CAAAqE,eAAe,CACnBjB,aAAa,EAAIA,aAAa,CAACjD,MAAM,CAACc,IAAI,GAAKC,gBAAU,CAACC,OAAO,GAAK+C,WAAW,EAAIE,cAAc,CAAC,CAEtG,MACE,GAAA7K,WAAA,CAAA+K,GAAA,EAAC3I,mBAAmB,CAAC4I,QAAQ,EAACC,KAAK,CAAEpB,aAAc,CAAAqB,QAAA,CACjD,GAAAlL,WAAA,CAAAmL,IAAA,EAAC3I,qBAAqB,CAACwI,QAAQ,EAACC,KAAK,CAAE,CAAEnH,OAAO,CAAPA,OAAO,CAAEI,YAAY,CAAZA,YAAY,CAAEC,eAAe,CAAfA,eAAe,CAAG,CAAA+G,QAAA,EAC/ExI,KAAK,CAACwI,QAAQ,CACdJ,eAAe,EACd,GAAA9K,WAAA,CAAA+K,GAAA,EAACrL,YAAA,CAAA0L,WAAW,CAAAvJ,aAAA,EAEV2F,UAAU,CAAE2B,gBAAiB,CAC7BkC,uBAAuB,CAAE3I,KAAK,CAAC2I,uBAAwB,EACnDxB,aAAa,EAHZL,aAAa,SAAbA,aAAa,iBAAbA,aAAa,CAAEC,QAAQ,CAACO,YAGX,CAErB,EAC6B,CAClC,CAA8B,CAAC,CAEnC","ignoreList":[]}
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "4.84.2";
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.2";
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.2\"\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.2",
3
+ "version": "4.85.0",
4
4
  "bugs": {
5
5
  "url": "https://github.com/PostHog/posthog-js/issues"
6
6
  },
@@ -34,8 +34,8 @@
34
34
  "directory": "packages/react-native"
35
35
  },
36
36
  "dependencies": {
37
- "@posthog/core": "^1.61.1",
38
- "@posthog/types": "^1.417.0"
37
+ "@posthog/core": "^1.61.2",
38
+ "@posthog/types": "^1.418.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@babel/cli": "^7.19.3",
@@ -74,8 +74,8 @@
74
74
  "@vitest/coverage-v8": "^1.6.1",
75
75
  "vitest": "^1.6.1",
76
76
  "@posthog-tooling/rollup-utils": "1.1.1",
77
- "@posthog-tooling/tsconfig-base": "1.1.1",
78
- "@posthog/react-native-plugin": "2.12.7"
77
+ "@posthog/react-native-plugin": "2.12.7",
78
+ "@posthog-tooling/tsconfig-base": "1.1.1"
79
79
  },
80
80
  "peerDependencies": {
81
81
  "@react-native-async-storage/async-storage": ">=1.0.0",