posthog-react-native 4.14.0 → 4.14.2

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 +1 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports.getAppProperties=exports.currentDeviceType=exports.buildOptimisiticAsyncStorage=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _reactNative=require("react-native");var _OptionalAsyncStorage=require("./optional/OptionalAsyncStorage");var _OptionalExpoApplication=require("./optional/OptionalExpoApplication");var _OptionalExpoDevice=require("./optional/OptionalExpoDevice");var _OptionalExpoFileSystem=require("./optional/OptionalExpoFileSystem");var _OptionalExpoLocalization=require("./optional/OptionalExpoLocalization");var _OptionalReactNativeDeviceInfo=require("./optional/OptionalReactNativeDeviceInfo");var _OptionalReactNativeLocalize=require("./optional/OptionalReactNativeLocalize");var _OptionalExpoFileSystemLegacy=require("./optional/OptionalExpoFileSystemLegacy");function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function _regeneratorRuntime(){return r;};var t,r={},e=Object.prototype,n=e.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(t,r,e,n){return Object.defineProperty(t,r,{value:e,enumerable:!n,configurable:!n,writable:!n});}try{c({},"");}catch(t){c=function c(t,r,e){return t[r]=e;};}function h(r,e,n,o){var i=e&&e.prototype instanceof Generator?e:Generator,a=Object.create(i.prototype);return c(a,"_invoke",function(r,e,n){var o=1;return function(i,a){if(3===o)throw Error("Generator is already running");if(4===o){if("throw"===i)throw a;return{value:t,done:!0};}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var c=d(u,n);if(c){if(c===f)continue;return c;}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(1===o)throw o=4,n.arg;n.dispatchException(n.arg);}else"return"===n.method&&n.abrupt("return",n.arg);o=3;var h=s(r,e,n);if("normal"===h.type){if(o=n.done?4:2,h.arg===f)continue;return{value:h.arg,done:n.done};}"throw"===h.type&&(o=4,n.method="throw",n.arg=h.arg);}};}(r,n,new Context(o||[])),!0),a;}function s(t,r,e){try{return{type:"normal",arg:t.call(r,e)};}catch(t){return{type:"throw",arg:t};}}r.wrap=h;var f={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var l={};c(l,i,function(){return this;});var p=Object.getPrototypeOf,y=p&&p(p(x([])));y&&y!==e&&n.call(y,i)&&(l=y);var v=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(l);function g(t){["next","throw","return"].forEach(function(r){c(t,r,function(t){return this._invoke(r,t);});});}function AsyncIterator(t,r){function e(o,i,a,u){var c=s(t[o],t,i);if("throw"!==c.type){var h=c.arg,f=h.value;return f&&"object"==_typeof(f)&&n.call(f,"__await")?r.resolve(f.__await).then(function(t){e("next",t,a,u);},function(t){e("throw",t,a,u);}):r.resolve(f).then(function(t){h.value=t,a(h);},function(t){return e("throw",t,a,u);});}u(c.arg);}var o;c(this,"_invoke",function(t,n){function i(){return new r(function(r,o){e(t,n,r,o);});}return o=o?o.then(i,i):i();},!0);}function d(r,e){var n=e.method,o=r.i[n];if(o===t)return e.delegate=null,"throw"===n&&r.i["return"]&&(e.method="return",e.arg=t,d(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var i=s(o,r.i,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,f;var a=i.arg;return a?a.done?(e[r.r]=a.value,e.next=r.n,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,f):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f);}function w(t){this.tryEntries.push(t);}function m(r){var e=r[4]||{};e.type="normal",e.arg=t,r[4]=e;}function Context(t){this.tryEntries=[[-1]],t.forEach(w,this),this.reset(!0);}function x(r){if(null!=r){var e=r[i];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function e(){for(;++o<r.length;)if(n.call(r,o))return e.value=r[o],e.done=!1,e;return e.value=t,e.done=!0,e;};return a.next=a;}}throw new TypeError(_typeof(r)+" is not iterable");}return GeneratorFunction.prototype=GeneratorFunctionPrototype,c(v,"constructor",GeneratorFunctionPrototype),c(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName=c(GeneratorFunctionPrototype,u,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===GeneratorFunction||"GeneratorFunction"===(r.displayName||r.name));},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,GeneratorFunctionPrototype):(t.__proto__=GeneratorFunctionPrototype,c(t,u,"GeneratorFunction")),t.prototype=Object.create(v),t;},r.awrap=function(t){return{__await:t};},g(AsyncIterator.prototype),c(AsyncIterator.prototype,a,function(){return this;}),r.AsyncIterator=AsyncIterator,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new AsyncIterator(h(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then(function(t){return t.done?t.value:a.next();});},g(v),c(v,u,"Generator"),c(v,i,function(){return this;}),c(v,"toString",function(){return"[object Generator]";}),r.keys=function(t){var r=Object(t),e=[];for(var n in r)e.unshift(n);return function t(){for(;e.length;)if((n=e.pop())in r)return t.value=n,t.done=!1,t;return t.done=!0,t;};},r.values=x,Context.prototype={constructor:Context,reset:function reset(r){if(this.prev=this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(m),!r)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t);},stop:function stop(){this.done=!0;var t=this.tryEntries[0][4];if("throw"===t.type)throw t.arg;return this.rval;},dispatchException:function dispatchException(r){if(this.done)throw r;var e=this;function n(t){a.type="throw",a.arg=r,e.next=t;}for(var o=e.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i[4],u=this.prev,c=i[1],h=i[2];if(-1===i[0])return n("end"),!1;if(!c&&!h)throw Error("try statement without catch or finally");if(null!=i[0]&&i[0]<=u){if(u<c)return this.method="next",this.arg=t,n(c),!0;if(u<h)return n(h),!1;}}},abrupt:function abrupt(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n[0]>-1&&n[0]<=this.prev&&this.prev<n[2]){var o=n;break;}}o&&("break"===t||"continue"===t)&&o[0]<=r&&r<=o[2]&&(o=null);var i=o?o[4]:{};return i.type=t,i.arg=r,o?(this.method="next",this.next=o[2],f):this.complete(i);},complete:function complete(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),f;},finish:function finish(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e[2]===t)return this.complete(e[4],e[3]),m(e),f;}},"catch":function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e[0]===t){var n=e[4];if("throw"===n.type){var o=n.arg;m(e);}return o;}}throw Error("illegal catch attempt");},delegateYield:function delegateYield(r,e,n){return this.delegate={i:x(r),r:e,n:n},"next"===this.method&&(this.arg=t),f;}},r;}var getDeviceType=function getDeviceType(){var deviceType='Mobile';if(_reactNative.Platform.OS==='macos'||_reactNative.Platform.OS==='windows'){deviceType='Desktop';}else if(_reactNative.Platform.OS==='web'){deviceType='Web';}return deviceType;};var currentDeviceType=exports.currentDeviceType=getDeviceType();var getAppProperties=exports.getAppProperties=function getAppProperties(){var properties={$device_type:currentDeviceType};if(_OptionalExpoApplication.OptionalExpoApplication){properties.$app_build=_OptionalExpoApplication.OptionalExpoApplication.nativeBuildVersion;properties.$app_name=_OptionalExpoApplication.OptionalExpoApplication.applicationName;properties.$app_namespace=_OptionalExpoApplication.OptionalExpoApplication.applicationId;properties.$app_version=_OptionalExpoApplication.OptionalExpoApplication.nativeApplicationVersion;}else if(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo){properties.$app_build=returnPropertyIfNotUnknown(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo.getBuildNumber());properties.$app_name=returnPropertyIfNotUnknown(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo.getApplicationName());properties.$app_namespace=returnPropertyIfNotUnknown(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo.getBundleId());properties.$app_version=returnPropertyIfNotUnknown(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo.getVersion());}if(_OptionalExpoDevice.OptionalExpoDevice){properties.$device_manufacturer=_OptionalExpoDevice.OptionalExpoDevice.manufacturer;properties.$device_name=_OptionalExpoDevice.OptionalExpoDevice.modelName;if(_reactNative.Platform.OS==='android'){properties.$os_name='Android';}else{properties.$os_name=_OptionalExpoDevice.OptionalExpoDevice.osName;}properties.$os_version=_OptionalExpoDevice.OptionalExpoDevice.osVersion;}else if(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo){properties.$device_manufacturer=returnPropertyIfNotUnknown(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo.getManufacturerSync());properties.$device_name=returnPropertyIfNotUnknown(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo.getModel());properties.$os_name=returnPropertyIfNotUnknown(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo.getSystemName());properties.$os_version=returnPropertyIfNotUnknown(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo.getSystemVersion());}if(_OptionalExpoLocalization.OptionalExpoLocalization){properties.$locale=_OptionalExpoLocalization.OptionalExpoLocalization.locale;properties.$timezone=_OptionalExpoLocalization.OptionalExpoLocalization.timezone;}else if(_OptionalReactNativeLocalize.OptionalReactNativeLocalize){var localesFn=_OptionalReactNativeLocalize.OptionalReactNativeLocalize.getLocales;if(localesFn){var locales=localesFn();if(locales&&locales.length>0){var languageTag=locales[0].languageTag;if(languageTag){properties.$locale=languageTag;}}}var timezoneFn=_OptionalReactNativeLocalize.OptionalReactNativeLocalize.getTimeZone;if(timezoneFn){var timezone=timezoneFn();if(timezone){properties.$timezone=timezone;}}}return properties;};var returnPropertyIfNotUnknown=function returnPropertyIfNotUnknown(value){if(value!=='unknown'){return value;}return null;};var buildLegacyStorage=function buildLegacyStorage(filesystem){return{getItem:function getItem(key){return(0,_asyncToGenerator2["default"])(_regeneratorRuntime().mark(function _callee(){var uri,stringContent;return _regeneratorRuntime().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.prev=0;uri=(filesystem.documentDirectory||'')+key;_context.next=4;return filesystem.readAsStringAsync(uri);case 4:stringContent=_context.sent;return _context.abrupt("return",stringContent);case 8:_context.prev=8;_context.t0=_context["catch"](0);return _context.abrupt("return",null);case 11:case"end":return _context.stop();}},_callee,null,[[0,8]]);}))();},setItem:function setItem(key,value){return(0,_asyncToGenerator2["default"])(_regeneratorRuntime().mark(function _callee2(){var uri;return _regeneratorRuntime().wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:uri=(filesystem.documentDirectory||'')+key;_context2.next=3;return filesystem.writeAsStringAsync(uri,value);case 3:case"end":return _context2.stop();}},_callee2);}))();}};};var buildOptimisiticAsyncStorage=exports.buildOptimisiticAsyncStorage=function buildOptimisiticAsyncStorage(){var supportedPlatform=_reactNative.Platform.OS!=='web'&&_reactNative.Platform.OS!=='macos';if(_OptionalExpoFileSystemLegacy.OptionalExpoFileSystemLegacy&&supportedPlatform){var filesystem=_OptionalExpoFileSystemLegacy.OptionalExpoFileSystemLegacy;return buildLegacyStorage(filesystem);}if(_OptionalExpoFileSystem.OptionalExpoFileSystem&&supportedPlatform){var _filesystem=_OptionalExpoFileSystem.OptionalExpoFileSystem;try{var expoFileSystemLegacy=_filesystem;if(expoFileSystemLegacy.readAsStringAsync){return buildLegacyStorage(_filesystem);}}catch(e){}return{getItem:function getItem(key){return(0,_asyncToGenerator2["default"])(_regeneratorRuntime().mark(function _callee3(){var _a,uri,file,stringContent;return _regeneratorRuntime().wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.prev=0;uri=(((_a=_filesystem.Paths)===null||_a===void 0?void 0:_a.document.info().uri)||'')+key;file=new _filesystem.File(uri);_context3.next=5;return file.text();case 5:stringContent=_context3.sent;return _context3.abrupt("return",stringContent);case 9:_context3.prev=9;_context3.t0=_context3["catch"](0);return _context3.abrupt("return",null);case 12:case"end":return _context3.stop();}},_callee3,null,[[0,9]]);}))();},setItem:function setItem(key,value){return(0,_asyncToGenerator2["default"])(_regeneratorRuntime().mark(function _callee4(){var _a,uri,file;return _regeneratorRuntime().wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:uri=(((_a=_filesystem.Paths)===null||_a===void 0?void 0:_a.document.info().uri)||'')+key;file=new _filesystem.File(uri);file.write(value);case 3:case"end":return _context4.stop();}},_callee4);}))();}};}if(_OptionalAsyncStorage.OptionalAsyncStorage){return _OptionalAsyncStorage.OptionalAsyncStorage;}throw new Error('PostHog: No storage available. Please install expo-file-system or react-native-async-storage OR implement a custom storage provider.');};
1
+ "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.getAppProperties=exports.currentDeviceType=exports.buildOptimisiticAsyncStorage=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _reactNative=require("react-native");var _OptionalAsyncStorage=require("./optional/OptionalAsyncStorage");var _OptionalExpoApplication=require("./optional/OptionalExpoApplication");var _OptionalExpoDevice=require("./optional/OptionalExpoDevice");var _OptionalExpoFileSystem=require("./optional/OptionalExpoFileSystem");var _OptionalExpoLocalization=require("./optional/OptionalExpoLocalization");var _OptionalReactNativeDeviceInfo=require("./optional/OptionalReactNativeDeviceInfo");var _OptionalReactNativeLocalize=require("./optional/OptionalReactNativeLocalize");var _OptionalExpoFileSystemLegacy=require("./optional/OptionalExpoFileSystemLegacy");var getDeviceType=function getDeviceType(){var deviceType='Mobile';if(_reactNative.Platform.OS==='macos'||_reactNative.Platform.OS==='windows'){deviceType='Desktop';}else if(_reactNative.Platform.OS==='web'){deviceType='Web';}return deviceType;};var currentDeviceType=exports.currentDeviceType=getDeviceType();var getAppProperties=exports.getAppProperties=function getAppProperties(){var properties={$device_type:currentDeviceType};if(_OptionalExpoApplication.OptionalExpoApplication){properties.$app_build=_OptionalExpoApplication.OptionalExpoApplication.nativeBuildVersion;properties.$app_name=_OptionalExpoApplication.OptionalExpoApplication.applicationName;properties.$app_namespace=_OptionalExpoApplication.OptionalExpoApplication.applicationId;properties.$app_version=_OptionalExpoApplication.OptionalExpoApplication.nativeApplicationVersion;}else if(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo){properties.$app_build=returnPropertyIfNotUnknown(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo.getBuildNumber());properties.$app_name=returnPropertyIfNotUnknown(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo.getApplicationName());properties.$app_namespace=returnPropertyIfNotUnknown(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo.getBundleId());properties.$app_version=returnPropertyIfNotUnknown(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo.getVersion());}if(_OptionalExpoDevice.OptionalExpoDevice){properties.$device_manufacturer=_OptionalExpoDevice.OptionalExpoDevice.manufacturer;properties.$device_name=_OptionalExpoDevice.OptionalExpoDevice.modelName;if(_reactNative.Platform.OS==='android'){properties.$os_name='Android';}else{properties.$os_name=_OptionalExpoDevice.OptionalExpoDevice.osName;}properties.$os_version=_OptionalExpoDevice.OptionalExpoDevice.osVersion;}else if(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo){properties.$device_manufacturer=returnPropertyIfNotUnknown(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo.getManufacturerSync());properties.$device_name=returnPropertyIfNotUnknown(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo.getModel());properties.$os_name=returnPropertyIfNotUnknown(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo.getSystemName());properties.$os_version=returnPropertyIfNotUnknown(_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo.getSystemVersion());}if(_OptionalExpoLocalization.OptionalExpoLocalization){properties.$locale=_OptionalExpoLocalization.OptionalExpoLocalization.locale;properties.$timezone=_OptionalExpoLocalization.OptionalExpoLocalization.timezone;}else if(_OptionalReactNativeLocalize.OptionalReactNativeLocalize){var localesFn=_OptionalReactNativeLocalize.OptionalReactNativeLocalize.getLocales;if(localesFn){var locales=localesFn();if(locales&&locales.length>0){var languageTag=locales[0].languageTag;if(languageTag){properties.$locale=languageTag;}}}var timezoneFn=_OptionalReactNativeLocalize.OptionalReactNativeLocalize.getTimeZone;if(timezoneFn){var timezone=timezoneFn();if(timezone){properties.$timezone=timezone;}}}return properties;};var returnPropertyIfNotUnknown=function returnPropertyIfNotUnknown(value){if(value!=='unknown'){return value;}return null;};var buildLegacyStorage=function buildLegacyStorage(filesystem){return{getItem:function getItem(key){return(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(){var uri,stringContent;return _regenerator["default"].wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.prev=0;uri=(filesystem.documentDirectory||'')+key;_context.next=4;return filesystem.readAsStringAsync(uri);case 4:stringContent=_context.sent;return _context.abrupt("return",stringContent);case 8:_context.prev=8;_context.t0=_context["catch"](0);return _context.abrupt("return",null);case 11:case"end":return _context.stop();}},_callee,null,[[0,8]]);}))();},setItem:function setItem(key,value){return(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(){var uri;return _regenerator["default"].wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:uri=(filesystem.documentDirectory||'')+key;_context2.next=3;return filesystem.writeAsStringAsync(uri,value);case 3:case"end":return _context2.stop();}},_callee2);}))();}};};var buildOptimisiticAsyncStorage=exports.buildOptimisiticAsyncStorage=function buildOptimisiticAsyncStorage(){var supportedPlatform=_reactNative.Platform.OS!=='web'&&_reactNative.Platform.OS!=='macos';if(_OptionalExpoFileSystemLegacy.OptionalExpoFileSystemLegacy&&supportedPlatform){var filesystem=_OptionalExpoFileSystemLegacy.OptionalExpoFileSystemLegacy;return buildLegacyStorage(filesystem);}if(_OptionalExpoFileSystem.OptionalExpoFileSystem&&supportedPlatform){var _filesystem=_OptionalExpoFileSystem.OptionalExpoFileSystem;try{var expoFileSystemLegacy=_filesystem;if(expoFileSystemLegacy.readAsStringAsync){return buildLegacyStorage(_filesystem);}}catch(e){}return{getItem:function getItem(key){return(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(){var _a,uri,file,stringContent;return _regenerator["default"].wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.prev=0;uri=(((_a=_filesystem.Paths)===null||_a===void 0?void 0:_a.document.info().uri)||'')+key;file=new _filesystem.File(uri);_context3.next=5;return file.text();case 5:stringContent=_context3.sent;return _context3.abrupt("return",stringContent);case 9:_context3.prev=9;_context3.t0=_context3["catch"](0);return _context3.abrupt("return",null);case 12:case"end":return _context3.stop();}},_callee3,null,[[0,9]]);}))();},setItem:function setItem(key,value){return(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4(){var _a,uri,file;return _regenerator["default"].wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:uri=(((_a=_filesystem.Paths)===null||_a===void 0?void 0:_a.document.info().uri)||'')+key;file=new _filesystem.File(uri);file.write(value);case 3:case"end":return _context4.stop();}},_callee4);}))();}};}if(_OptionalAsyncStorage.OptionalAsyncStorage){return _OptionalAsyncStorage.OptionalAsyncStorage;}throw new Error('PostHog: No storage available. Please install expo-file-system or react-native-async-storage OR implement a custom storage provider.');};
@@ -1 +1 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof3=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports.PostHog=void 0;Object.defineProperty(exports,"PostHogPersistedProperty",{enumerable:true,get:function get(){return _core.PostHogPersistedProperty;}});var _typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _get2=_interopRequireDefault(require("@babel/runtime/helpers/get"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _reactNative=require("react-native");var _core=require("@posthog/core");var _storage=require("./storage");var _version=require("./version");var _nativeDeps=require("./native-deps");var _wixNavigation=require("./frameworks/wix-navigation");var _OptionalSessionReplay=require("./optional/OptionalSessionReplay");var _errorTracking=require("./error-tracking");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 _regeneratorRuntime(){"use strict";_regeneratorRuntime=function _regeneratorRuntime(){return r;};var t,r={},e=Object.prototype,n=e.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(t,r,e,n){return Object.defineProperty(t,r,{value:e,enumerable:!n,configurable:!n,writable:!n});}try{c({},"");}catch(t){c=function c(t,r,e){return t[r]=e;};}function h(r,e,n,o){var i=e&&e.prototype instanceof Generator?e:Generator,a=Object.create(i.prototype);return c(a,"_invoke",function(r,e,n){var o=1;return function(i,a){if(3===o)throw Error("Generator is already running");if(4===o){if("throw"===i)throw a;return{value:t,done:!0};}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var c=d(u,n);if(c){if(c===f)continue;return c;}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(1===o)throw o=4,n.arg;n.dispatchException(n.arg);}else"return"===n.method&&n.abrupt("return",n.arg);o=3;var h=s(r,e,n);if("normal"===h.type){if(o=n.done?4:2,h.arg===f)continue;return{value:h.arg,done:n.done};}"throw"===h.type&&(o=4,n.method="throw",n.arg=h.arg);}};}(r,n,new Context(o||[])),!0),a;}function s(t,r,e){try{return{type:"normal",arg:t.call(r,e)};}catch(t){return{type:"throw",arg:t};}}r.wrap=h;var f={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var l={};c(l,i,function(){return this;});var p=Object.getPrototypeOf,y=p&&p(p(x([])));y&&y!==e&&n.call(y,i)&&(l=y);var v=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(l);function g(t){["next","throw","return"].forEach(function(r){c(t,r,function(t){return this._invoke(r,t);});});}function AsyncIterator(t,r){function e(o,i,a,u){var c=s(t[o],t,i);if("throw"!==c.type){var h=c.arg,f=h.value;return f&&"object"==_typeof3(f)&&n.call(f,"__await")?r.resolve(f.__await).then(function(t){e("next",t,a,u);},function(t){e("throw",t,a,u);}):r.resolve(f).then(function(t){h.value=t,a(h);},function(t){return e("throw",t,a,u);});}u(c.arg);}var o;c(this,"_invoke",function(t,n){function i(){return new r(function(r,o){e(t,n,r,o);});}return o=o?o.then(i,i):i();},!0);}function d(r,e){var n=e.method,o=r.i[n];if(o===t)return e.delegate=null,"throw"===n&&r.i["return"]&&(e.method="return",e.arg=t,d(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var i=s(o,r.i,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,f;var a=i.arg;return a?a.done?(e[r.r]=a.value,e.next=r.n,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,f):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f);}function w(t){this.tryEntries.push(t);}function m(r){var e=r[4]||{};e.type="normal",e.arg=t,r[4]=e;}function Context(t){this.tryEntries=[[-1]],t.forEach(w,this),this.reset(!0);}function x(r){if(null!=r){var e=r[i];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function e(){for(;++o<r.length;)if(n.call(r,o))return e.value=r[o],e.done=!1,e;return e.value=t,e.done=!0,e;};return a.next=a;}}throw new TypeError(_typeof3(r)+" is not iterable");}return GeneratorFunction.prototype=GeneratorFunctionPrototype,c(v,"constructor",GeneratorFunctionPrototype),c(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName=c(GeneratorFunctionPrototype,u,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===GeneratorFunction||"GeneratorFunction"===(r.displayName||r.name));},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,GeneratorFunctionPrototype):(t.__proto__=GeneratorFunctionPrototype,c(t,u,"GeneratorFunction")),t.prototype=Object.create(v),t;},r.awrap=function(t){return{__await:t};},g(AsyncIterator.prototype),c(AsyncIterator.prototype,a,function(){return this;}),r.AsyncIterator=AsyncIterator,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new AsyncIterator(h(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then(function(t){return t.done?t.value:a.next();});},g(v),c(v,u,"Generator"),c(v,i,function(){return this;}),c(v,"toString",function(){return"[object Generator]";}),r.keys=function(t){var r=Object(t),e=[];for(var n in r)e.unshift(n);return function t(){for(;e.length;)if((n=e.pop())in r)return t.value=n,t.done=!1,t;return t.done=!0,t;};},r.values=x,Context.prototype={constructor:Context,reset:function reset(r){if(this.prev=this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(m),!r)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t);},stop:function stop(){this.done=!0;var t=this.tryEntries[0][4];if("throw"===t.type)throw t.arg;return this.rval;},dispatchException:function dispatchException(r){if(this.done)throw r;var e=this;function n(t){a.type="throw",a.arg=r,e.next=t;}for(var o=e.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i[4],u=this.prev,c=i[1],h=i[2];if(-1===i[0])return n("end"),!1;if(!c&&!h)throw Error("try statement without catch or finally");if(null!=i[0]&&i[0]<=u){if(u<c)return this.method="next",this.arg=t,n(c),!0;if(u<h)return n(h),!1;}}},abrupt:function abrupt(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n[0]>-1&&n[0]<=this.prev&&this.prev<n[2]){var o=n;break;}}o&&("break"===t||"continue"===t)&&o[0]<=r&&r<=o[2]&&(o=null);var i=o?o[4]:{};return i.type=t,i.arg=r,o?(this.method="next",this.next=o[2],f):this.complete(i);},complete:function complete(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),f;},finish:function finish(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e[2]===t)return this.complete(e[4],e[3]),m(e),f;}},"catch":function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e[0]===t){var n=e[4];if("throw"===n.type){var o=n.arg;m(e);}return o;}}throw Error("illegal catch attempt");},delegateYield:function delegateYield(r,e,n){return this.delegate={i:x(r),r:e,n:n},"next"===this.method&&(this.arg=t),f;}},r;}function _callSuper(t,o,e){return o=(0,_getPrototypeOf2["default"])(o),(0,_possibleConstructorReturn2["default"])(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],(0,_getPrototypeOf2["default"])(t).constructor):o.apply(t,e));}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _superPropGet(t,o,e,r){var p=(0,_get2["default"])((0,_getPrototypeOf2["default"])(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t);}:p;}var PostHog=exports.PostHog=function(_PostHogCore){function PostHog(apiKey,options){var _this;(0,_classCallCheck2["default"])(this,PostHog);var _a,_b,_c,_d,_e;_this=_callSuper(this,PostHog,[apiKey,options]);_this._appProperties={};_this._surveysReadyPromise=null;_this._surveysReady=false;_this._surveysReadyResolve=null;_this._isInitialized=false;_this._persistence=(_a=options===null||options===void 0?void 0:options.persistence)!==null&&_a!==void 0?_a:'file';_this._disableSurveys=(_b=options===null||options===void 0?void 0:options.disableSurveys)!==null&&_b!==void 0?_b:false;_this._disableRemoteConfig=(_c=options===null||options===void 0?void 0:options.disableRemoteConfig)!==null&&_c!==void 0?_c:false;_this._errorTracking=new _errorTracking.ErrorTracking(_this,options===null||options===void 0?void 0:options.errorTracking,_this._logger);_this._setDefaultPersonProperties=(_d=options===null||options===void 0?void 0:options.setDefaultPersonProperties)!==null&&_d!==void 0?_d:true;_this._appProperties=typeof(options===null||options===void 0?void 0:options.customAppProperties)==='function'?options.customAppProperties((0,_nativeDeps.getAppProperties)()):(options===null||options===void 0?void 0:options.customAppProperties)||(0,_nativeDeps.getAppProperties)();_reactNative.AppState.addEventListener('change',function(state){if(state==='unknown'){return;}void _this.flush()["catch"](function(){var _ref=(0,_asyncToGenerator2["default"])(_regeneratorRuntime().mark(function _callee(err){return _regeneratorRuntime().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.next=2;return(0,_core.logFlushError)(err);case 2:case"end":return _context.stop();}},_callee);}));return function(_x3){return _ref.apply(this,arguments);};}());if(state==='active'){_this.getSessionId();}});var storagePromise;if(_this._persistence==='file'){_this._storage=new _storage.PostHogRNStorage((_e=options===null||options===void 0?void 0:options.customStorage)!==null&&_e!==void 0?_e:(0,_nativeDeps.buildOptimisiticAsyncStorage)());storagePromise=_this._storage.preloadPromise;}else{_this._storage=new _storage.PostHogRNSyncMemoryStorage();}if(storagePromise){storagePromise["catch"](function(error){console.error('PostHog storage initialization failed:',error);});}var initAfterStorage=function initAfterStorage(){var enablePersistSessionIdAcrossRestart=options===null||options===void 0?void 0:options.enablePersistSessionIdAcrossRestart;if(!enablePersistSessionIdAcrossRestart){_this.setPersistedProperty(_core.PostHogPersistedProperty.SessionId,null);_this.setPersistedProperty(_core.PostHogPersistedProperty.SessionLastTimestamp,null);_this.setPersistedProperty(_core.PostHogPersistedProperty.SessionStartTimestamp,null);}_this.setupBootstrap(options);if(_this._setDefaultPersonProperties){_this._setDefaultPersonPropertiesForFlags(false);}_this._isInitialized=true;if(_this._disableRemoteConfig===false){_this.reloadRemoteConfigAsync().then(function(response){if(response){_this._handleSurveysFromRemoteConfig(response);}})["catch"](function(error){_this._logger.error('Error loading remote config:',error);})["finally"](function(){_this._notifySurveysReady();});}else{_this._logger.info('Remote config is disabled.');if((options===null||options===void 0?void 0:options.preloadFeatureFlags)!==false){_this._logger.info('Feature flags will be preloaded from Flags API.');_this._flagsAsyncWithSurveys()["catch"](function(error){_this._logger.error('Error loading flags with surveys:',error);})["finally"](function(){_this._notifySurveysReady();});}else{_this._logger.info('preloadFeatureFlags is disabled, loading surveys from API.');_this._loadSurveysFromAPI()["catch"](function(error){_this._logger.error('Error loading surveys from API:',error);})["finally"](function(){_this._notifySurveysReady();});}}if(options===null||options===void 0?void 0:options.captureAppLifecycleEvents){void _this.captureAppLifecycleEvents();}void _this.persistAppVersion();void _this.startSessionReplay(options);};if(storagePromise){_this._initPromise=storagePromise.then(initAfterStorage);}else{_this._initPromise=Promise.resolve();initAfterStorage();}return _this;}(0,_inherits2["default"])(PostHog,_PostHogCore);return(0,_createClass2["default"])(PostHog,[{key:"ready",value:(function(){var _ready=(0,_asyncToGenerator2["default"])(_regeneratorRuntime().mark(function _callee2(){return _regeneratorRuntime().wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_context2.next=2;return this._initPromise;case 2:case"end":return _context2.stop();}},_callee2,this);}));function ready(){return _ready.apply(this,arguments);}return ready;}())},{key:"getPersistedProperty",value:function getPersistedProperty(key){return this._storage.getItem(key);}},{key:"setPersistedProperty",value:function setPersistedProperty(key,value){return value!==null?this._storage.setItem(key,value):this._storage.removeItem(key);}},{key:"fetch",value:function(_fetch){function fetch(_x,_x2){return _fetch.apply(this,arguments);}fetch.toString=function(){return _fetch.toString();};return fetch;}(function(url,options){return fetch(url,options);})},{key:"getLibraryId",value:function getLibraryId(){return'posthog-react-native';}},{key:"getLibraryVersion",value:function getLibraryVersion(){return _version.version;}},{key:"getCustomUserAgent",value:function getCustomUserAgent(){if(_reactNative.Platform.OS==='web'){return'';}return"".concat(this.getLibraryId(),"/").concat(this.getLibraryVersion());}},{key:"getCommonEventProperties",value:function getCommonEventProperties(){return _objectSpread(_objectSpread(_objectSpread({},_superPropGet(PostHog,"getCommonEventProperties",this,3)([])),this._appProperties),{},{$screen_height:_reactNative.Dimensions.get('screen').height,$screen_width:_reactNative.Dimensions.get('screen').width});}},{key:"register",value:function register(properties){return _superPropGet(PostHog,"register",this,3)([properties]);}},{key:"unregister",value:function unregister(property){return _superPropGet(PostHog,"unregister",this,3)([property]);}},{key:"reset",value:function reset(){_superPropGet(PostHog,"reset",this,3)([]);if(this._setDefaultPersonProperties){this._setDefaultPersonPropertiesForFlags(false);}}},{key:"_setDefaultPersonPropertiesForFlags",value:function _setDefaultPersonPropertiesForFlags(){var _this2=this;var reloadFeatureFlags=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var defaultProps={};var relevantKeys=['$app_version','$app_build','$app_namespace','$os_name','$os_version','$device_type'];relevantKeys.forEach(function(key){var value=_this2._appProperties[key];if(value!==null&&value!==undefined){defaultProps[key]=String(value);}});var commonProps=this.getCommonEventProperties();if(commonProps.$lib){defaultProps.$lib=String(commonProps.$lib);}if(commonProps.$lib_version){defaultProps.$lib_version=String(commonProps.$lib_version);}if(Object.keys(defaultProps).length>0){this.setPersonPropertiesForFlags(defaultProps,reloadFeatureFlags);}}},{key:"flush",value:function flush(){return _superPropGet(PostHog,"flush",this,3)([]);}},{key:"optIn",value:function optIn(){return _superPropGet(PostHog,"optIn",this,3)([]);}},{key:"optOut",value:function optOut(){return _superPropGet(PostHog,"optOut",this,3)([]);}},{key:"isFeatureEnabled",value:function isFeatureEnabled(key){return _superPropGet(PostHog,"isFeatureEnabled",this,3)([key]);}},{key:"getFeatureFlag",value:function getFeatureFlag(key){return _superPropGet(PostHog,"getFeatureFlag",this,3)([key]);}},{key:"getFeatureFlagPayload",value:function getFeatureFlagPayload(key){return _superPropGet(PostHog,"getFeatureFlagPayload",this,3)([key]);}},{key:"reloadFeatureFlags",value:function reloadFeatureFlags(){_superPropGet(PostHog,"reloadFeatureFlags",this,3)([]);}},{key:"reloadFeatureFlagsAsync",value:function reloadFeatureFlagsAsync(){return _superPropGet(PostHog,"reloadFeatureFlagsAsync",this,3)([]);}},{key:"group",value:function group(groupType,groupKey,properties){_superPropGet(PostHog,"group",this,3)([groupType,groupKey,properties]);if(properties&&Object.keys(properties).length>0){var propsToCache={};Object.keys(properties).forEach(function(key){var value=properties[key];if(value!==null&&value!==undefined){propsToCache[key]=String(value);}});if(Object.keys(propsToCache).length>0){this.setGroupPropertiesForFlags((0,_defineProperty2["default"])({},groupType,propsToCache));}}}},{key:"alias",value:function alias(_alias){_superPropGet(PostHog,"alias",this,3)([_alias]);}},{key:"getDistinctId",value:function getDistinctId(){return _superPropGet(PostHog,"getDistinctId",this,3)([]);}},{key:"setPersonPropertiesForFlags",value:function setPersonPropertiesForFlags(properties){var reloadFeatureFlags=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;_superPropGet(PostHog,"setPersonPropertiesForFlags",this,3)([properties]);if(reloadFeatureFlags){this.reloadFeatureFlags();}}},{key:"resetPersonPropertiesForFlags",value:function resetPersonPropertiesForFlags(){var reloadFeatureFlags=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;_superPropGet(PostHog,"resetPersonPropertiesForFlags",this,3)([]);if(reloadFeatureFlags){this.reloadFeatureFlags();}}},{key:"setGroupPropertiesForFlags",value:function setGroupPropertiesForFlags(properties){var reloadFeatureFlags=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;_superPropGet(PostHog,"setGroupPropertiesForFlags",this,3)([properties]);if(reloadFeatureFlags){this.reloadFeatureFlags();}}},{key:"resetGroupPropertiesForFlags",value:function resetGroupPropertiesForFlags(){var reloadFeatureFlags=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;_superPropGet(PostHog,"resetGroupPropertiesForFlags",this,3)([]);if(reloadFeatureFlags){this.reloadFeatureFlags();}}},{key:"screen",value:(function(){var _screen=(0,_asyncToGenerator2["default"])(_regeneratorRuntime().mark(function _callee3(name,properties,options){return _regeneratorRuntime().wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.next=2;return this._initPromise;case 2:this.registerForSession({$screen_name:name});return _context3.abrupt("return",this.capture('$screen',_objectSpread(_objectSpread({},properties),{},{$screen_name:name}),options));case 4:case"end":return _context3.stop();}},_callee3,this);}));function screen(_x4,_x5,_x6){return _screen.apply(this,arguments);}return screen;}())},{key:"_isEnableSessionReplay",value:function _isEnableSessionReplay(){var _a;return!this.isDisabled&&((_a=this._enableSessionReplay)!==null&&_a!==void 0?_a:false);}},{key:"_resetSessionId",value:function _resetSessionId(reactNativeSessionReplay,sessionId){if(reactNativeSessionReplay){reactNativeSessionReplay.endSession();reactNativeSessionReplay.startSession(sessionId);}}},{key:"getSessionId",value:function getSessionId(){var sessionId=_superPropGet(PostHog,"getSessionId",this,3)([]);if(!this._isEnableSessionReplay()){return sessionId;}if(sessionId.length>0&&this._currentSessionId&&sessionId!==this._currentSessionId){if(_OptionalSessionReplay.OptionalReactNativeSessionReplay){try{this._resetSessionId(_OptionalSessionReplay.OptionalReactNativeSessionReplay,String(sessionId));this._logger.info("sessionId rotated from ".concat(this._currentSessionId," to ").concat(sessionId,"."));}catch(e){this._logger.error("Failed to rotate sessionId: ".concat(e,"."));}}this._currentSessionId=sessionId;}else{this._logger.info("sessionId not rotated, sessionId ".concat(sessionId," and currentSessionId ").concat(this._currentSessionId,"."));}return sessionId;}},{key:"resetSessionId",value:function resetSessionId(){_superPropGet(PostHog,"resetSessionId",this,3)([]);if(this._isEnableSessionReplay()&&_OptionalSessionReplay.OptionalReactNativeSessionReplay){try{_OptionalSessionReplay.OptionalReactNativeSessionReplay.endSession();this._logger.info("Session replay ended.");}catch(e){this._logger.error("Session replay failed to end: ".concat(e,"."));}}}},{key:"identify",value:function identify(distinctId,properties,options){var previousDistinctId=this.getDistinctId();_superPropGet(PostHog,"identify",this,3)([distinctId,properties,options]);var userProps=(properties===null||properties===void 0?void 0:properties.$set)||properties;if(userProps&&Object.keys(userProps).length>0){var propsToCache={};Object.entries(userProps).forEach(function(_ref2){var _ref3=(0,_slicedToArray2["default"])(_ref2,2),key=_ref3[0],value=_ref3[1];if(value!==null&&value!==undefined){propsToCache[key]=String(value);}});if(Object.keys(propsToCache).length>0){var shouldReloadFlags=distinctId===previousDistinctId;this.setPersonPropertiesForFlags(propsToCache,shouldReloadFlags);}}if(this._isEnableSessionReplay()&&_OptionalSessionReplay.OptionalReactNativeSessionReplay){try{distinctId=distinctId||previousDistinctId;var anonymousId=this.getAnonymousId();_OptionalSessionReplay.OptionalReactNativeSessionReplay.identify(String(distinctId),String(anonymousId));this._logger.info("Session replay identified with distinctId ".concat(distinctId," and anonymousId ").concat(anonymousId,"."));}catch(e){this._logger.error("Session replay failed to identify: ".concat(e,"."));}}}},{key:"captureException",value:function captureException(error){var additionalProperties=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var syntheticException=new Error('Synthetic Error');this._errorTracking.captureException(error,additionalProperties,{mechanism:{handled:true,type:'generic'},syntheticException:syntheticException});}},{key:"initReactNativeNavigation",value:function initReactNativeNavigation(options){return(0,_wixNavigation.withReactNativeNavigation)(this,options);}},{key:"getSurveys",value:function(){var _getSurveys=(0,_asyncToGenerator2["default"])(_regeneratorRuntime().mark(function _callee4(){var surveys;return _regeneratorRuntime().wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:if(!(this._disableSurveys===true)){_context4.next=4;break;}this._logger.info('Loading surveys is disabled.');this._cacheSurveys(null,'disabled in config');return _context4.abrupt("return",[]);case 4:surveys=this.getPersistedProperty(_core.PostHogPersistedProperty.Surveys);if(!(surveys&&surveys.length>0)){_context4.next=8;break;}this._logger.info('Surveys fetched from storage: ',JSON.stringify(surveys));return _context4.abrupt("return",surveys);case 8:this._logger.info('No surveys found in storage');return _context4.abrupt("return",[]);case 10:case"end":return _context4.stop();}},_callee4,this);}));function getSurveys(){return _getSurveys.apply(this,arguments);}return getSurveys;}()},{key:"_onSurveysReady",value:function _onSurveysReady(){var _this3=this;if(this._surveysReady){return Promise.resolve();}if(!this._surveysReadyPromise){this._surveysReadyPromise=new Promise(function(resolve){_this3._surveysReadyResolve=resolve;});}return this._surveysReadyPromise;}},{key:"_cacheSurveys",value:function _cacheSurveys(surveys,source){this.setPersistedProperty(_core.PostHogPersistedProperty.Surveys,surveys);if(surveys&&surveys.length>0){this._logger.info("Surveys cached from ".concat(source,":"),JSON.stringify(surveys));}else if(surveys===null){this._logger.info("Surveys cleared (".concat(source,")"));}else{this._logger.info("No surveys to cache from ".concat(source,")"));}}},{key:"_notifySurveysReady",value:function _notifySurveysReady(){this._surveysReady=true;if(this._surveysReadyResolve){this._surveysReadyResolve();this._surveysReadyResolve=null;this._surveysReadyPromise=null;}}},{key:"_handleSurveysFromRemoteConfig",value:function _handleSurveysFromRemoteConfig(response){if(this._disableSurveys===true){this._logger.info('Loading surveys skipped, disabled.');this._cacheSurveys(null,'remote config (disabled)');return;}var surveys=response.surveys;if(Array.isArray(surveys)&&surveys.length>0){this._cacheSurveys(surveys,'remote config');}else{this._cacheSurveys(null,'remote config');}}},{key:"_flagsAsyncWithSurveys",value:(function(){var _flagsAsyncWithSurveys2=(0,_asyncToGenerator2["default"])(_regeneratorRuntime().mark(function _callee5(){var flagsResponse,surveys;return _regeneratorRuntime().wrap(function _callee5$(_context5){while(1)switch(_context5.prev=_context5.next){case 0:_context5.prev=0;_context5.next=3;return this.flagsAsync(true,true);case 3:flagsResponse=_context5.sent;if(!(this._disableRemoteConfig===true)){_context5.next=11;break;}if(!(this._disableSurveys===true)){_context5.next=9;break;}this._logger.info('Loading surveys skipped, disabled.');this._cacheSurveys(null,'flags (disabled)');return _context5.abrupt("return");case 9:surveys=flagsResponse===null||flagsResponse===void 0?void 0:flagsResponse.surveys;if(Array.isArray(surveys)&&surveys.length>0){this._cacheSurveys(surveys,'flags endpoint');}else{this._logger.info('No surveys in flags response');this._cacheSurveys(null,'flags endpoint');}case 11:_context5.next=16;break;case 13:_context5.prev=13;_context5.t0=_context5["catch"](0);this._logger.error('Error in _flagsAsyncWithSurveys:',_context5.t0);case 16:case"end":return _context5.stop();}},_callee5,this,[[0,13]]);}));function _flagsAsyncWithSurveys(){return _flagsAsyncWithSurveys2.apply(this,arguments);}return _flagsAsyncWithSurveys;}())},{key:"_loadSurveysFromAPI",value:(function(){var _loadSurveysFromAPI2=(0,_asyncToGenerator2["default"])(_regeneratorRuntime().mark(function _callee6(){var surveysFromApi;return _regeneratorRuntime().wrap(function _callee6$(_context6){while(1)switch(_context6.prev=_context6.next){case 0:if(!(this._disableSurveys===true)){_context6.next=4;break;}this._logger.info('Loading surveys skipped, disabled.');this._cacheSurveys(null,'API (disabled)');return _context6.abrupt("return");case 4:_context6.prev=4;_context6.next=7;return _superPropGet(PostHog,"getSurveysStateless",this,3)([]);case 7:surveysFromApi=_context6.sent;if(surveysFromApi&&surveysFromApi.length>0){this._cacheSurveys(surveysFromApi,'API');}else{this._cacheSurveys(null,'API');}_context6.next=14;break;case 11:_context6.prev=11;_context6.t0=_context6["catch"](4);this._logger.error('Error loading surveys from API:',_context6.t0);case 14:case"end":return _context6.stop();}},_callee6,this,[[4,11]]);}));function _loadSurveysFromAPI(){return _loadSurveysFromAPI2.apply(this,arguments);}return _loadSurveysFromAPI;}())},{key:"startSessionReplay",value:function(){var _startSessionReplay=(0,_asyncToGenerator2["default"])(_regeneratorRuntime().mark(function _callee7(options){var _a,_b,_c,_d,_e,_f,_g,defaultThrottleDelayMs,_ref4,_ref4$maskAllTextInpu,maskAllTextInputs,_ref4$maskAllImages,maskAllImages,_ref4$maskAllSandboxe,maskAllSandboxedViews,_ref4$captureLog,captureLog,_ref4$captureNetworkT,captureNetworkTelemetry,_ref4$iOSdebouncerDel,iOSdebouncerDelayMs,_ref4$androidDebounce,androidDebouncerDelayMs,throttleDelayMs,sdkReplayConfig,sessionReplay,featureFlags,cachedFeatureFlags,cachedSessionReplayConfig,recordingActive,linkedFlag,value,flag,variant,_value,sessionId,sdkOptions;return _regeneratorRuntime().wrap(function _callee7$(_context7){while(1)switch(_context7.prev=_context7.next){case 0:this._enableSessionReplay=options===null||options===void 0?void 0:options.enableSessionReplay;if(this._isEnableSessionReplay()){_context7.next=4;break;}this._logger.info('Session replay is not enabled.');return _context7.abrupt("return");case 4:defaultThrottleDelayMs=1000;_ref4=(_a=options===null||options===void 0?void 0:options.sessionReplayConfig)!==null&&_a!==void 0?_a:{},_ref4$maskAllTextInpu=_ref4.maskAllTextInputs,maskAllTextInputs=_ref4$maskAllTextInpu===void 0?true:_ref4$maskAllTextInpu,_ref4$maskAllImages=_ref4.maskAllImages,maskAllImages=_ref4$maskAllImages===void 0?true:_ref4$maskAllImages,_ref4$maskAllSandboxe=_ref4.maskAllSandboxedViews,maskAllSandboxedViews=_ref4$maskAllSandboxe===void 0?true:_ref4$maskAllSandboxe,_ref4$captureLog=_ref4.captureLog,captureLog=_ref4$captureLog===void 0?true:_ref4$captureLog,_ref4$captureNetworkT=_ref4.captureNetworkTelemetry,captureNetworkTelemetry=_ref4$captureNetworkT===void 0?true:_ref4$captureNetworkT,_ref4$iOSdebouncerDel=_ref4.iOSdebouncerDelayMs,iOSdebouncerDelayMs=_ref4$iOSdebouncerDel===void 0?defaultThrottleDelayMs:_ref4$iOSdebouncerDel,_ref4$androidDebounce=_ref4.androidDebouncerDelayMs,androidDebouncerDelayMs=_ref4$androidDebounce===void 0?defaultThrottleDelayMs:_ref4$androidDebounce;throttleDelayMs=(_c=(_b=options===null||options===void 0?void 0:options.sessionReplayConfig)===null||_b===void 0?void 0:_b.throttleDelayMs)!==null&&_c!==void 0?_c:defaultThrottleDelayMs;if(throttleDelayMs===defaultThrottleDelayMs&&(iOSdebouncerDelayMs!==defaultThrottleDelayMs||androidDebouncerDelayMs!==defaultThrottleDelayMs)){throttleDelayMs=Math.max(iOSdebouncerDelayMs,androidDebouncerDelayMs);}sdkReplayConfig={maskAllTextInputs:maskAllTextInputs,maskAllImages:maskAllImages,maskAllSandboxedViews:maskAllSandboxedViews,captureLog:captureLog,captureNetworkTelemetry:captureNetworkTelemetry,iOSdebouncerDelayMs:iOSdebouncerDelayMs,androidDebouncerDelayMs:androidDebouncerDelayMs,throttleDelayMs:throttleDelayMs};this._logger.info("Session replay SDK config: ".concat(JSON.stringify(sdkReplayConfig)));sessionReplay=(_d=this.getPersistedProperty(_core.PostHogPersistedProperty.SessionReplay))!==null&&_d!==void 0?_d:{};featureFlags=(_e=this.getKnownFeatureFlags())!==null&&_e!==void 0?_e:{};cachedFeatureFlags=(_f=featureFlags)!==null&&_f!==void 0?_f:{};cachedSessionReplayConfig=(_g=sessionReplay)!==null&&_g!==void 0?_g:{};this._logger.info('Session replay feature flags from flags cached config:',JSON.stringify(cachedFeatureFlags));this._logger.info("Session replay session recording from flags cached config: ".concat(JSON.stringify(cachedSessionReplayConfig)));recordingActive=true;linkedFlag=cachedSessionReplayConfig['linkedFlag'];if(typeof linkedFlag==='string'){value=cachedFeatureFlags[linkedFlag];if(typeof value==='boolean'){recordingActive=value;}else if(typeof value==='string'){recordingActive=true;}else{recordingActive=false;}this._logger.info("Session replay '".concat(linkedFlag,"' linked flag value: '").concat(value,"'"));}else if(linkedFlag&&(0,_typeof2["default"])(linkedFlag)==='object'){flag=linkedFlag['flag'];variant=linkedFlag['variant'];if(flag&&variant){_value=cachedFeatureFlags[flag];recordingActive=_value===variant;this._logger.info("Session replay '".concat(flag,"' linked flag variant '").concat(variant,"' and value '").concat(_value,"'"));}else{this._logger.info("Session replay '".concat(flag,"' linked flag variant: '").concat(variant,"' does not exist/quota limited."));recordingActive=false;}}else{this._logger.info("Session replay has no cached linkedFlag.");}if(!recordingActive){_context7.next=49;break;}if(!_OptionalSessionReplay.OptionalReactNativeSessionReplay){_context7.next=46;break;}sessionId=this.getSessionId();if(!(sessionId.length===0)){_context7.next=25;break;}this._logger.warn("Session replay enabled but no sessionId found.");return _context7.abrupt("return");case 25:sdkOptions={apiKey:this.apiKey,host:this.host,debug:this.isDebug,distinctId:this.getDistinctId(),anonymousId:this.getAnonymousId(),sdkVersion:this.getLibraryVersion(),flushAt:this.flushAt};this._logger.info("Session replay sdk options: ".concat(JSON.stringify(sdkOptions)));_context7.prev=27;_context7.next=30;return _OptionalSessionReplay.OptionalReactNativeSessionReplay.isEnabled();case 30:if(_context7.sent){_context7.next=36;break;}_context7.next=33;return _OptionalSessionReplay.OptionalReactNativeSessionReplay.start(String(sessionId),sdkOptions,sdkReplayConfig,cachedSessionReplayConfig);case 33:this._logger.info("Session replay started with sessionId ".concat(sessionId,"."));_context7.next=38;break;case 36:this._resetSessionId(_OptionalSessionReplay.OptionalReactNativeSessionReplay,String(sessionId));this._logger.info("Session replay already started with sessionId ".concat(sessionId,"."));case 38:this._currentSessionId=sessionId;_context7.next=44;break;case 41:_context7.prev=41;_context7.t0=_context7["catch"](27);this._logger.error("Session replay failed to start: ".concat(_context7.t0,"."));case 44:_context7.next=47;break;case 46:this._logger.warn('Session replay enabled but not installed.');case 47:_context7.next=50;break;case 49:this._logger.info('Session replay disabled.');case 50:case"end":return _context7.stop();}},_callee7,this,[[27,41]]);}));function startSessionReplay(_x7){return _startSessionReplay.apply(this,arguments);}return startSessionReplay;}()},{key:"captureAppLifecycleEvents",value:function(){var _captureAppLifecycleEvents=(0,_asyncToGenerator2["default"])(_regeneratorRuntime().mark(function _callee8(){var _this4=this;var _a,appBuild,appVersion,isMemoryPersistence,properties,prevAppBuild,prevAppVersion,initialUrl;return _regeneratorRuntime().wrap(function _callee8$(_context8){while(1)switch(_context8.prev=_context8.next){case 0:appBuild=this._appProperties.$app_build;appVersion=this._appProperties.$app_version;isMemoryPersistence=this._persistence==='memory';properties={};if(!isMemoryPersistence){prevAppBuild=this.getPersistedProperty(_core.PostHogPersistedProperty.InstalledAppBuild);prevAppVersion=this.getPersistedProperty(_core.PostHogPersistedProperty.InstalledAppVersion);if(!appBuild||!appVersion){this._logger.warn('PostHog could not track installation/update/open, as the build and version were not set. '+'This can happen if some dependencies are not installed correctly, or if you have provided'+'customAppProperties but not included $app_build or $app_version.');}if(appBuild){if(!prevAppBuild){this.capture('Application Installed',properties);}else if(prevAppBuild!==appBuild){this.capture('Application Updated',_objectSpread(_objectSpread(_objectSpread({},(0,_core.maybeAdd)('previous_version',prevAppVersion)),(0,_core.maybeAdd)('previous_build',prevAppBuild)),properties));}}}else{this._logger.warn('PostHog was initialised with persistence set to "memory", capturing native app events (Application Installed and Application Updated) is not supported.');}_context8.next=7;return _reactNative.Linking.getInitialURL();case 7:_context8.t1=_a=_context8.sent;_context8.t0=_context8.t1!==null;if(!_context8.t0){_context8.next=11;break;}_context8.t0=_a!==void 0;case 11:if(!_context8.t0){_context8.next=15;break;}_context8.t2=_a;_context8.next=16;break;case 15:_context8.t2=undefined;case 16:initialUrl=_context8.t2;this.capture('Application Opened',_objectSpread(_objectSpread({},properties),(0,_core.maybeAdd)('url',initialUrl)));_reactNative.AppState.addEventListener('change',function(state){if(state==='active'){_this4.capture('Application Became Active');}else if(state==='background'){_this4.capture('Application Backgrounded');}});case 19:case"end":return _context8.stop();}},_callee8,this);}));function captureAppLifecycleEvents(){return _captureAppLifecycleEvents.apply(this,arguments);}return captureAppLifecycleEvents;}()},{key:"persistAppVersion",value:function(){var _persistAppVersion=(0,_asyncToGenerator2["default"])(_regeneratorRuntime().mark(function _callee9(){var appBuild,appVersion;return _regeneratorRuntime().wrap(function _callee9$(_context9){while(1)switch(_context9.prev=_context9.next){case 0:appBuild=this._appProperties.$app_build;appVersion=this._appProperties.$app_version;this.setPersistedProperty(_core.PostHogPersistedProperty.InstalledAppBuild,appBuild);this.setPersistedProperty(_core.PostHogPersistedProperty.InstalledAppVersion,appVersion);case 4:case"end":return _context9.stop();}},_callee9,this);}));function persistAppVersion(){return _persistAppVersion.apply(this,arguments);}return persistAppVersion;}()}]);}(_core.PostHogCore);
1
+ "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.PostHog=void 0;Object.defineProperty(exports,"PostHogPersistedProperty",{enumerable:true,get:function get(){return _core.PostHogPersistedProperty;}});var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _get2=_interopRequireDefault(require("@babel/runtime/helpers/get"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _reactNative=require("react-native");var _core=require("@posthog/core");var _storage=require("./storage");var _version=require("./version");var _nativeDeps=require("./native-deps");var _wixNavigation=require("./frameworks/wix-navigation");var _OptionalSessionReplay=require("./optional/OptionalSessionReplay");var _errorTracking=require("./error-tracking");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 _callSuper(t,o,e){return o=(0,_getPrototypeOf2["default"])(o),(0,_possibleConstructorReturn2["default"])(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],(0,_getPrototypeOf2["default"])(t).constructor):o.apply(t,e));}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _superPropGet(t,o,e,r){var p=(0,_get2["default"])((0,_getPrototypeOf2["default"])(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t);}:p;}var PostHog=exports.PostHog=function(_PostHogCore){function PostHog(apiKey,options){var _this;(0,_classCallCheck2["default"])(this,PostHog);var _a,_b,_c,_d,_e;_this=_callSuper(this,PostHog,[apiKey,options]);_this._appProperties={};_this._surveysReadyPromise=null;_this._surveysReady=false;_this._surveysReadyResolve=null;_this._isInitialized=false;_this._persistence=(_a=options===null||options===void 0?void 0:options.persistence)!==null&&_a!==void 0?_a:'file';_this._disableSurveys=(_b=options===null||options===void 0?void 0:options.disableSurveys)!==null&&_b!==void 0?_b:false;_this._disableRemoteConfig=(_c=options===null||options===void 0?void 0:options.disableRemoteConfig)!==null&&_c!==void 0?_c:false;_this._errorTracking=new _errorTracking.ErrorTracking(_this,options===null||options===void 0?void 0:options.errorTracking,_this._logger);_this._setDefaultPersonProperties=(_d=options===null||options===void 0?void 0:options.setDefaultPersonProperties)!==null&&_d!==void 0?_d:true;_this._appProperties=typeof(options===null||options===void 0?void 0:options.customAppProperties)==='function'?options.customAppProperties((0,_nativeDeps.getAppProperties)()):(options===null||options===void 0?void 0:options.customAppProperties)||(0,_nativeDeps.getAppProperties)();_reactNative.AppState.addEventListener('change',function(state){if(state==='unknown'){return;}void _this.flush()["catch"](function(){var _ref=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(err){return _regenerator["default"].wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.next=2;return(0,_core.logFlushError)(err);case 2:case"end":return _context.stop();}},_callee);}));return function(_x3){return _ref.apply(this,arguments);};}());if(state==='active'){_this.getSessionId();}});var storagePromise;if(_this._persistence==='file'){_this._storage=new _storage.PostHogRNStorage((_e=options===null||options===void 0?void 0:options.customStorage)!==null&&_e!==void 0?_e:(0,_nativeDeps.buildOptimisiticAsyncStorage)());storagePromise=_this._storage.preloadPromise;}else{_this._storage=new _storage.PostHogRNSyncMemoryStorage();}if(storagePromise){storagePromise["catch"](function(error){console.error('PostHog storage initialization failed:',error);});}var initAfterStorage=function initAfterStorage(){var enablePersistSessionIdAcrossRestart=options===null||options===void 0?void 0:options.enablePersistSessionIdAcrossRestart;if(!enablePersistSessionIdAcrossRestart){_this.setPersistedProperty(_core.PostHogPersistedProperty.SessionId,null);_this.setPersistedProperty(_core.PostHogPersistedProperty.SessionLastTimestamp,null);_this.setPersistedProperty(_core.PostHogPersistedProperty.SessionStartTimestamp,null);}_this.setupBootstrap(options);if(_this._setDefaultPersonProperties){_this._setDefaultPersonPropertiesForFlags(false);}_this._isInitialized=true;if(_this._disableRemoteConfig===false){_this.reloadRemoteConfigAsync().then(function(response){if(response){_this._handleSurveysFromRemoteConfig(response);}})["catch"](function(error){_this._logger.error('Error loading remote config:',error);})["finally"](function(){_this._notifySurveysReady();});}else{_this._logger.info('Remote config is disabled.');if((options===null||options===void 0?void 0:options.preloadFeatureFlags)!==false){_this._logger.info('Feature flags will be preloaded from Flags API.');_this._flagsAsyncWithSurveys()["catch"](function(error){_this._logger.error('Error loading flags with surveys:',error);})["finally"](function(){_this._notifySurveysReady();});}else{_this._logger.info('preloadFeatureFlags is disabled, loading surveys from API.');_this._loadSurveysFromAPI()["catch"](function(error){_this._logger.error('Error loading surveys from API:',error);})["finally"](function(){_this._notifySurveysReady();});}}if(options===null||options===void 0?void 0:options.captureAppLifecycleEvents){void _this.captureAppLifecycleEvents();}void _this.persistAppVersion();void _this.startSessionReplay(options);};if(storagePromise){_this._initPromise=storagePromise.then(initAfterStorage);}else{_this._initPromise=Promise.resolve();initAfterStorage();}return _this;}(0,_inherits2["default"])(PostHog,_PostHogCore);return(0,_createClass2["default"])(PostHog,[{key:"ready",value:(function(){var _ready=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(){return _regenerator["default"].wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_context2.next=2;return this._initPromise;case 2:case"end":return _context2.stop();}},_callee2,this);}));function ready(){return _ready.apply(this,arguments);}return ready;}())},{key:"getPersistedProperty",value:function getPersistedProperty(key){return this._storage.getItem(key);}},{key:"setPersistedProperty",value:function setPersistedProperty(key,value){return value!==null?this._storage.setItem(key,value):this._storage.removeItem(key);}},{key:"fetch",value:function(_fetch){function fetch(_x,_x2){return _fetch.apply(this,arguments);}fetch.toString=function(){return _fetch.toString();};return fetch;}(function(url,options){return fetch(url,options);})},{key:"getLibraryId",value:function getLibraryId(){return'posthog-react-native';}},{key:"getLibraryVersion",value:function getLibraryVersion(){return _version.version;}},{key:"getCustomUserAgent",value:function getCustomUserAgent(){if(_reactNative.Platform.OS==='web'){return'';}return"".concat(this.getLibraryId(),"/").concat(this.getLibraryVersion());}},{key:"getCommonEventProperties",value:function getCommonEventProperties(){return _objectSpread(_objectSpread(_objectSpread({},_superPropGet(PostHog,"getCommonEventProperties",this,3)([])),this._appProperties),{},{$screen_height:_reactNative.Dimensions.get('screen').height,$screen_width:_reactNative.Dimensions.get('screen').width});}},{key:"register",value:function register(properties){return _superPropGet(PostHog,"register",this,3)([properties]);}},{key:"unregister",value:function unregister(property){return _superPropGet(PostHog,"unregister",this,3)([property]);}},{key:"reset",value:function reset(){_superPropGet(PostHog,"reset",this,3)([]);if(this._setDefaultPersonProperties){this._setDefaultPersonPropertiesForFlags(false);}}},{key:"_setDefaultPersonPropertiesForFlags",value:function _setDefaultPersonPropertiesForFlags(){var _this2=this;var reloadFeatureFlags=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var defaultProps={};var relevantKeys=['$app_version','$app_build','$app_namespace','$os_name','$os_version','$device_type'];relevantKeys.forEach(function(key){var value=_this2._appProperties[key];if(value!==null&&value!==undefined){defaultProps[key]=String(value);}});var commonProps=this.getCommonEventProperties();if(commonProps.$lib){defaultProps.$lib=String(commonProps.$lib);}if(commonProps.$lib_version){defaultProps.$lib_version=String(commonProps.$lib_version);}if(Object.keys(defaultProps).length>0){this.setPersonPropertiesForFlags(defaultProps,reloadFeatureFlags);}}},{key:"flush",value:function flush(){return _superPropGet(PostHog,"flush",this,3)([]);}},{key:"optIn",value:function optIn(){return _superPropGet(PostHog,"optIn",this,3)([]);}},{key:"optOut",value:function optOut(){return _superPropGet(PostHog,"optOut",this,3)([]);}},{key:"isFeatureEnabled",value:function isFeatureEnabled(key){return _superPropGet(PostHog,"isFeatureEnabled",this,3)([key]);}},{key:"getFeatureFlag",value:function getFeatureFlag(key){return _superPropGet(PostHog,"getFeatureFlag",this,3)([key]);}},{key:"getFeatureFlagPayload",value:function getFeatureFlagPayload(key){return _superPropGet(PostHog,"getFeatureFlagPayload",this,3)([key]);}},{key:"reloadFeatureFlags",value:function reloadFeatureFlags(){_superPropGet(PostHog,"reloadFeatureFlags",this,3)([]);}},{key:"reloadFeatureFlagsAsync",value:function reloadFeatureFlagsAsync(){return _superPropGet(PostHog,"reloadFeatureFlagsAsync",this,3)([]);}},{key:"group",value:function group(groupType,groupKey,properties){_superPropGet(PostHog,"group",this,3)([groupType,groupKey,properties]);if(properties&&Object.keys(properties).length>0){var propsToCache={};Object.keys(properties).forEach(function(key){var value=properties[key];if(value!==null&&value!==undefined){propsToCache[key]=String(value);}});if(Object.keys(propsToCache).length>0){this.setGroupPropertiesForFlags((0,_defineProperty2["default"])({},groupType,propsToCache));}}}},{key:"alias",value:function alias(_alias){_superPropGet(PostHog,"alias",this,3)([_alias]);}},{key:"getDistinctId",value:function getDistinctId(){return _superPropGet(PostHog,"getDistinctId",this,3)([]);}},{key:"setPersonPropertiesForFlags",value:function setPersonPropertiesForFlags(properties){var reloadFeatureFlags=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;_superPropGet(PostHog,"setPersonPropertiesForFlags",this,3)([properties]);if(reloadFeatureFlags){this.reloadFeatureFlags();}}},{key:"resetPersonPropertiesForFlags",value:function resetPersonPropertiesForFlags(){var reloadFeatureFlags=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;_superPropGet(PostHog,"resetPersonPropertiesForFlags",this,3)([]);if(reloadFeatureFlags){this.reloadFeatureFlags();}}},{key:"setGroupPropertiesForFlags",value:function setGroupPropertiesForFlags(properties){var reloadFeatureFlags=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;_superPropGet(PostHog,"setGroupPropertiesForFlags",this,3)([properties]);if(reloadFeatureFlags){this.reloadFeatureFlags();}}},{key:"resetGroupPropertiesForFlags",value:function resetGroupPropertiesForFlags(){var reloadFeatureFlags=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;_superPropGet(PostHog,"resetGroupPropertiesForFlags",this,3)([]);if(reloadFeatureFlags){this.reloadFeatureFlags();}}},{key:"screen",value:(function(){var _screen=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(name,properties,options){return _regenerator["default"].wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.next=2;return this._initPromise;case 2:this.registerForSession({$screen_name:name});return _context3.abrupt("return",this.capture('$screen',_objectSpread(_objectSpread({},properties),{},{$screen_name:name}),options));case 4:case"end":return _context3.stop();}},_callee3,this);}));function screen(_x4,_x5,_x6){return _screen.apply(this,arguments);}return screen;}())},{key:"_isEnableSessionReplay",value:function _isEnableSessionReplay(){var _a;return!this.isDisabled&&((_a=this._enableSessionReplay)!==null&&_a!==void 0?_a:false);}},{key:"_resetSessionId",value:function _resetSessionId(reactNativeSessionReplay,sessionId){if(reactNativeSessionReplay){reactNativeSessionReplay.endSession();reactNativeSessionReplay.startSession(sessionId);}}},{key:"getSessionId",value:function getSessionId(){var sessionId=_superPropGet(PostHog,"getSessionId",this,3)([]);if(!this._isEnableSessionReplay()){return sessionId;}if(sessionId.length>0&&this._currentSessionId&&sessionId!==this._currentSessionId){if(_OptionalSessionReplay.OptionalReactNativeSessionReplay){try{this._resetSessionId(_OptionalSessionReplay.OptionalReactNativeSessionReplay,String(sessionId));this._logger.info("sessionId rotated from ".concat(this._currentSessionId," to ").concat(sessionId,"."));}catch(e){this._logger.error("Failed to rotate sessionId: ".concat(e,"."));}}this._currentSessionId=sessionId;}else{this._logger.info("sessionId not rotated, sessionId ".concat(sessionId," and currentSessionId ").concat(this._currentSessionId,"."));}return sessionId;}},{key:"resetSessionId",value:function resetSessionId(){_superPropGet(PostHog,"resetSessionId",this,3)([]);if(this._isEnableSessionReplay()&&_OptionalSessionReplay.OptionalReactNativeSessionReplay){try{_OptionalSessionReplay.OptionalReactNativeSessionReplay.endSession();this._logger.info("Session replay ended.");}catch(e){this._logger.error("Session replay failed to end: ".concat(e,"."));}}}},{key:"identify",value:function identify(distinctId,properties,options){var previousDistinctId=this.getDistinctId();_superPropGet(PostHog,"identify",this,3)([distinctId,properties,options]);var userProps=(properties===null||properties===void 0?void 0:properties.$set)||properties;if(userProps&&Object.keys(userProps).length>0){var propsToCache={};Object.entries(userProps).forEach(function(_ref2){var _ref3=(0,_slicedToArray2["default"])(_ref2,2),key=_ref3[0],value=_ref3[1];if(value!==null&&value!==undefined){propsToCache[key]=String(value);}});if(Object.keys(propsToCache).length>0){var shouldReloadFlags=distinctId===previousDistinctId;this.setPersonPropertiesForFlags(propsToCache,shouldReloadFlags);}}if(this._isEnableSessionReplay()&&_OptionalSessionReplay.OptionalReactNativeSessionReplay){try{distinctId=distinctId||previousDistinctId;var anonymousId=this.getAnonymousId();_OptionalSessionReplay.OptionalReactNativeSessionReplay.identify(String(distinctId),String(anonymousId));this._logger.info("Session replay identified with distinctId ".concat(distinctId," and anonymousId ").concat(anonymousId,"."));}catch(e){this._logger.error("Session replay failed to identify: ".concat(e,"."));}}}},{key:"captureException",value:function captureException(error){var additionalProperties=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var syntheticException=new Error('Synthetic Error');this._errorTracking.captureException(error,additionalProperties,{mechanism:{handled:true,type:'generic'},syntheticException:syntheticException});}},{key:"initReactNativeNavigation",value:function initReactNativeNavigation(options){return(0,_wixNavigation.withReactNativeNavigation)(this,options);}},{key:"getSurveys",value:function(){var _getSurveys=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4(){var surveys;return _regenerator["default"].wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:if(!(this._disableSurveys===true)){_context4.next=4;break;}this._logger.info('Loading surveys is disabled.');this._cacheSurveys(null,'disabled in config');return _context4.abrupt("return",[]);case 4:surveys=this.getPersistedProperty(_core.PostHogPersistedProperty.Surveys);if(!(surveys&&surveys.length>0)){_context4.next=8;break;}this._logger.info('Surveys fetched from storage: ',JSON.stringify(surveys));return _context4.abrupt("return",surveys);case 8:this._logger.info('No surveys found in storage');return _context4.abrupt("return",[]);case 10:case"end":return _context4.stop();}},_callee4,this);}));function getSurveys(){return _getSurveys.apply(this,arguments);}return getSurveys;}()},{key:"_onSurveysReady",value:function _onSurveysReady(){var _this3=this;if(this._surveysReady){return Promise.resolve();}if(!this._surveysReadyPromise){this._surveysReadyPromise=new Promise(function(resolve){_this3._surveysReadyResolve=resolve;});}return this._surveysReadyPromise;}},{key:"_cacheSurveys",value:function _cacheSurveys(surveys,source){this.setPersistedProperty(_core.PostHogPersistedProperty.Surveys,surveys);if(surveys&&surveys.length>0){this._logger.info("Surveys cached from ".concat(source,":"),JSON.stringify(surveys));}else if(surveys===null){this._logger.info("Surveys cleared (".concat(source,")"));}else{this._logger.info("No surveys to cache from ".concat(source,")"));}}},{key:"_notifySurveysReady",value:function _notifySurveysReady(){this._surveysReady=true;if(this._surveysReadyResolve){this._surveysReadyResolve();this._surveysReadyResolve=null;this._surveysReadyPromise=null;}}},{key:"_handleSurveysFromRemoteConfig",value:function _handleSurveysFromRemoteConfig(response){if(this._disableSurveys===true){this._logger.info('Loading surveys skipped, disabled.');this._cacheSurveys(null,'remote config (disabled)');return;}var surveys=response.surveys;if(Array.isArray(surveys)&&surveys.length>0){this._cacheSurveys(surveys,'remote config');}else{this._cacheSurveys(null,'remote config');}}},{key:"_flagsAsyncWithSurveys",value:(function(){var _flagsAsyncWithSurveys2=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee5(){var flagsResponse,surveys;return _regenerator["default"].wrap(function _callee5$(_context5){while(1)switch(_context5.prev=_context5.next){case 0:_context5.prev=0;_context5.next=3;return this.flagsAsync(true,true);case 3:flagsResponse=_context5.sent;if(!(this._disableRemoteConfig===true)){_context5.next=11;break;}if(!(this._disableSurveys===true)){_context5.next=9;break;}this._logger.info('Loading surveys skipped, disabled.');this._cacheSurveys(null,'flags (disabled)');return _context5.abrupt("return");case 9:surveys=flagsResponse===null||flagsResponse===void 0?void 0:flagsResponse.surveys;if(Array.isArray(surveys)&&surveys.length>0){this._cacheSurveys(surveys,'flags endpoint');}else{this._logger.info('No surveys in flags response');this._cacheSurveys(null,'flags endpoint');}case 11:_context5.next=16;break;case 13:_context5.prev=13;_context5.t0=_context5["catch"](0);this._logger.error('Error in _flagsAsyncWithSurveys:',_context5.t0);case 16:case"end":return _context5.stop();}},_callee5,this,[[0,13]]);}));function _flagsAsyncWithSurveys(){return _flagsAsyncWithSurveys2.apply(this,arguments);}return _flagsAsyncWithSurveys;}())},{key:"_loadSurveysFromAPI",value:(function(){var _loadSurveysFromAPI2=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee6(){var surveysFromApi;return _regenerator["default"].wrap(function _callee6$(_context6){while(1)switch(_context6.prev=_context6.next){case 0:if(!(this._disableSurveys===true)){_context6.next=4;break;}this._logger.info('Loading surveys skipped, disabled.');this._cacheSurveys(null,'API (disabled)');return _context6.abrupt("return");case 4:_context6.prev=4;_context6.next=7;return _superPropGet(PostHog,"getSurveysStateless",this,3)([]);case 7:surveysFromApi=_context6.sent;if(surveysFromApi&&surveysFromApi.length>0){this._cacheSurveys(surveysFromApi,'API');}else{this._cacheSurveys(null,'API');}_context6.next=14;break;case 11:_context6.prev=11;_context6.t0=_context6["catch"](4);this._logger.error('Error loading surveys from API:',_context6.t0);case 14:case"end":return _context6.stop();}},_callee6,this,[[4,11]]);}));function _loadSurveysFromAPI(){return _loadSurveysFromAPI2.apply(this,arguments);}return _loadSurveysFromAPI;}())},{key:"startSessionReplay",value:function(){var _startSessionReplay=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee7(options){var _a,_b,_c,_d,_e,_f,_g,defaultThrottleDelayMs,_ref4,_ref4$maskAllTextInpu,maskAllTextInputs,_ref4$maskAllImages,maskAllImages,_ref4$maskAllSandboxe,maskAllSandboxedViews,_ref4$captureLog,captureLog,_ref4$captureNetworkT,captureNetworkTelemetry,_ref4$iOSdebouncerDel,iOSdebouncerDelayMs,_ref4$androidDebounce,androidDebouncerDelayMs,throttleDelayMs,sdkReplayConfig,sessionReplay,featureFlags,cachedFeatureFlags,cachedSessionReplayConfig,recordingActive,linkedFlag,value,flag,variant,_value,sessionId,sdkOptions;return _regenerator["default"].wrap(function _callee7$(_context7){while(1)switch(_context7.prev=_context7.next){case 0:this._enableSessionReplay=options===null||options===void 0?void 0:options.enableSessionReplay;if(this._isEnableSessionReplay()){_context7.next=4;break;}this._logger.info('Session replay is not enabled.');return _context7.abrupt("return");case 4:defaultThrottleDelayMs=1000;_ref4=(_a=options===null||options===void 0?void 0:options.sessionReplayConfig)!==null&&_a!==void 0?_a:{},_ref4$maskAllTextInpu=_ref4.maskAllTextInputs,maskAllTextInputs=_ref4$maskAllTextInpu===void 0?true:_ref4$maskAllTextInpu,_ref4$maskAllImages=_ref4.maskAllImages,maskAllImages=_ref4$maskAllImages===void 0?true:_ref4$maskAllImages,_ref4$maskAllSandboxe=_ref4.maskAllSandboxedViews,maskAllSandboxedViews=_ref4$maskAllSandboxe===void 0?true:_ref4$maskAllSandboxe,_ref4$captureLog=_ref4.captureLog,captureLog=_ref4$captureLog===void 0?true:_ref4$captureLog,_ref4$captureNetworkT=_ref4.captureNetworkTelemetry,captureNetworkTelemetry=_ref4$captureNetworkT===void 0?true:_ref4$captureNetworkT,_ref4$iOSdebouncerDel=_ref4.iOSdebouncerDelayMs,iOSdebouncerDelayMs=_ref4$iOSdebouncerDel===void 0?defaultThrottleDelayMs:_ref4$iOSdebouncerDel,_ref4$androidDebounce=_ref4.androidDebouncerDelayMs,androidDebouncerDelayMs=_ref4$androidDebounce===void 0?defaultThrottleDelayMs:_ref4$androidDebounce;throttleDelayMs=(_c=(_b=options===null||options===void 0?void 0:options.sessionReplayConfig)===null||_b===void 0?void 0:_b.throttleDelayMs)!==null&&_c!==void 0?_c:defaultThrottleDelayMs;if(throttleDelayMs===defaultThrottleDelayMs&&(iOSdebouncerDelayMs!==defaultThrottleDelayMs||androidDebouncerDelayMs!==defaultThrottleDelayMs)){throttleDelayMs=Math.max(iOSdebouncerDelayMs,androidDebouncerDelayMs);}sdkReplayConfig={maskAllTextInputs:maskAllTextInputs,maskAllImages:maskAllImages,maskAllSandboxedViews:maskAllSandboxedViews,captureLog:captureLog,captureNetworkTelemetry:captureNetworkTelemetry,iOSdebouncerDelayMs:iOSdebouncerDelayMs,androidDebouncerDelayMs:androidDebouncerDelayMs,throttleDelayMs:throttleDelayMs};this._logger.info("Session replay SDK config: ".concat(JSON.stringify(sdkReplayConfig)));sessionReplay=(_d=this.getPersistedProperty(_core.PostHogPersistedProperty.SessionReplay))!==null&&_d!==void 0?_d:{};featureFlags=(_e=this.getKnownFeatureFlags())!==null&&_e!==void 0?_e:{};cachedFeatureFlags=(_f=featureFlags)!==null&&_f!==void 0?_f:{};cachedSessionReplayConfig=(_g=sessionReplay)!==null&&_g!==void 0?_g:{};this._logger.info('Session replay feature flags from flags cached config:',JSON.stringify(cachedFeatureFlags));this._logger.info("Session replay session recording from flags cached config: ".concat(JSON.stringify(cachedSessionReplayConfig)));recordingActive=true;linkedFlag=cachedSessionReplayConfig['linkedFlag'];if(typeof linkedFlag==='string'){value=cachedFeatureFlags[linkedFlag];if(typeof value==='boolean'){recordingActive=value;}else if(typeof value==='string'){recordingActive=true;}else{recordingActive=false;}this._logger.info("Session replay '".concat(linkedFlag,"' linked flag value: '").concat(value,"'"));}else if(linkedFlag&&(0,_typeof2["default"])(linkedFlag)==='object'){flag=linkedFlag['flag'];variant=linkedFlag['variant'];if(flag&&variant){_value=cachedFeatureFlags[flag];recordingActive=_value===variant;this._logger.info("Session replay '".concat(flag,"' linked flag variant '").concat(variant,"' and value '").concat(_value,"'"));}else{this._logger.info("Session replay '".concat(flag,"' linked flag variant: '").concat(variant,"' does not exist/quota limited."));recordingActive=false;}}else{this._logger.info("Session replay has no cached linkedFlag.");}if(!recordingActive){_context7.next=49;break;}if(!_OptionalSessionReplay.OptionalReactNativeSessionReplay){_context7.next=46;break;}sessionId=this.getSessionId();if(!(sessionId.length===0)){_context7.next=25;break;}this._logger.warn("Session replay enabled but no sessionId found.");return _context7.abrupt("return");case 25:sdkOptions={apiKey:this.apiKey,host:this.host,debug:this.isDebug,distinctId:this.getDistinctId(),anonymousId:this.getAnonymousId(),sdkVersion:this.getLibraryVersion(),flushAt:this.flushAt};this._logger.info("Session replay sdk options: ".concat(JSON.stringify(sdkOptions)));_context7.prev=27;_context7.next=30;return _OptionalSessionReplay.OptionalReactNativeSessionReplay.isEnabled();case 30:if(_context7.sent){_context7.next=36;break;}_context7.next=33;return _OptionalSessionReplay.OptionalReactNativeSessionReplay.start(String(sessionId),sdkOptions,sdkReplayConfig,cachedSessionReplayConfig);case 33:this._logger.info("Session replay started with sessionId ".concat(sessionId,"."));_context7.next=38;break;case 36:this._resetSessionId(_OptionalSessionReplay.OptionalReactNativeSessionReplay,String(sessionId));this._logger.info("Session replay already started with sessionId ".concat(sessionId,"."));case 38:this._currentSessionId=sessionId;_context7.next=44;break;case 41:_context7.prev=41;_context7.t0=_context7["catch"](27);this._logger.error("Session replay failed to start: ".concat(_context7.t0,"."));case 44:_context7.next=47;break;case 46:this._logger.warn('Session replay enabled but not installed.');case 47:_context7.next=50;break;case 49:this._logger.info('Session replay disabled.');case 50:case"end":return _context7.stop();}},_callee7,this,[[27,41]]);}));function startSessionReplay(_x7){return _startSessionReplay.apply(this,arguments);}return startSessionReplay;}()},{key:"captureAppLifecycleEvents",value:function(){var _captureAppLifecycleEvents=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee8(){var _this4=this;var _a,appBuild,appVersion,isMemoryPersistence,properties,prevAppBuild,prevAppVersion,initialUrl;return _regenerator["default"].wrap(function _callee8$(_context8){while(1)switch(_context8.prev=_context8.next){case 0:appBuild=this._appProperties.$app_build;appVersion=this._appProperties.$app_version;isMemoryPersistence=this._persistence==='memory';properties={};if(!isMemoryPersistence){prevAppBuild=this.getPersistedProperty(_core.PostHogPersistedProperty.InstalledAppBuild);prevAppVersion=this.getPersistedProperty(_core.PostHogPersistedProperty.InstalledAppVersion);if(!appBuild||!appVersion){this._logger.warn('PostHog could not track installation/update/open, as the build and version were not set. '+'This can happen if some dependencies are not installed correctly, or if you have provided'+'customAppProperties but not included $app_build or $app_version.');}if(appBuild){if(!prevAppBuild){this.capture('Application Installed',properties);}else if(prevAppBuild!==appBuild){this.capture('Application Updated',_objectSpread(_objectSpread(_objectSpread({},(0,_core.maybeAdd)('previous_version',prevAppVersion)),(0,_core.maybeAdd)('previous_build',prevAppBuild)),properties));}}}else{this._logger.warn('PostHog was initialised with persistence set to "memory", capturing native app events (Application Installed and Application Updated) is not supported.');}_context8.next=7;return _reactNative.Linking.getInitialURL();case 7:_context8.t1=_a=_context8.sent;_context8.t0=_context8.t1!==null;if(!_context8.t0){_context8.next=11;break;}_context8.t0=_a!==void 0;case 11:if(!_context8.t0){_context8.next=15;break;}_context8.t2=_a;_context8.next=16;break;case 15:_context8.t2=undefined;case 16:initialUrl=_context8.t2;this.capture('Application Opened',_objectSpread(_objectSpread({},properties),(0,_core.maybeAdd)('url',initialUrl)));_reactNative.AppState.addEventListener('change',function(state){if(state==='active'){_this4.capture('Application Became Active');}else if(state==='background'){_this4.capture('Application Backgrounded');}});case 19:case"end":return _context8.stop();}},_callee8,this);}));function captureAppLifecycleEvents(){return _captureAppLifecycleEvents.apply(this,arguments);}return captureAppLifecycleEvents;}()},{key:"persistAppVersion",value:function(){var _persistAppVersion=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee9(){var appBuild,appVersion;return _regenerator["default"].wrap(function _callee9$(_context9){while(1)switch(_context9.prev=_context9.next){case 0:appBuild=this._appProperties.$app_build;appVersion=this._appProperties.$app_version;this.setPersistedProperty(_core.PostHogPersistedProperty.InstalledAppBuild,appBuild);this.setPersistedProperty(_core.PostHogPersistedProperty.InstalledAppVersion,appVersion);case 4:case"end":return _context9.stop();}},_callee9,this);}));function persistAppVersion(){return _persistAppVersion.apply(this,arguments);}return persistAppVersion;}()}]);}(_core.PostHogCore);
@@ -1 +1 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports.createPostHogMetroSerializer=void 0;exports.unstableBeforeAssetSerializationDebugIdPlugin=unstableBeforeAssetSerializationDebugIdPlugin;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _utils=require("./utils");var _utils2=require("./vendor/metro/utils");function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function _regeneratorRuntime(){return r;};var t,r={},e=Object.prototype,n=e.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(t,r,e,n){return Object.defineProperty(t,r,{value:e,enumerable:!n,configurable:!n,writable:!n});}try{c({},"");}catch(t){c=function c(t,r,e){return t[r]=e;};}function h(r,e,n,o){var i=e&&e.prototype instanceof Generator?e:Generator,a=Object.create(i.prototype);return c(a,"_invoke",function(r,e,n){var o=1;return function(i,a){if(3===o)throw Error("Generator is already running");if(4===o){if("throw"===i)throw a;return{value:t,done:!0};}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var c=d(u,n);if(c){if(c===f)continue;return c;}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(1===o)throw o=4,n.arg;n.dispatchException(n.arg);}else"return"===n.method&&n.abrupt("return",n.arg);o=3;var h=s(r,e,n);if("normal"===h.type){if(o=n.done?4:2,h.arg===f)continue;return{value:h.arg,done:n.done};}"throw"===h.type&&(o=4,n.method="throw",n.arg=h.arg);}};}(r,n,new Context(o||[])),!0),a;}function s(t,r,e){try{return{type:"normal",arg:t.call(r,e)};}catch(t){return{type:"throw",arg:t};}}r.wrap=h;var f={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var l={};c(l,i,function(){return this;});var p=Object.getPrototypeOf,y=p&&p(p(x([])));y&&y!==e&&n.call(y,i)&&(l=y);var v=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(l);function g(t){["next","throw","return"].forEach(function(r){c(t,r,function(t){return this._invoke(r,t);});});}function AsyncIterator(t,r){function e(o,i,a,u){var c=s(t[o],t,i);if("throw"!==c.type){var h=c.arg,f=h.value;return f&&"object"==_typeof(f)&&n.call(f,"__await")?r.resolve(f.__await).then(function(t){e("next",t,a,u);},function(t){e("throw",t,a,u);}):r.resolve(f).then(function(t){h.value=t,a(h);},function(t){return e("throw",t,a,u);});}u(c.arg);}var o;c(this,"_invoke",function(t,n){function i(){return new r(function(r,o){e(t,n,r,o);});}return o=o?o.then(i,i):i();},!0);}function d(r,e){var n=e.method,o=r.i[n];if(o===t)return e.delegate=null,"throw"===n&&r.i["return"]&&(e.method="return",e.arg=t,d(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var i=s(o,r.i,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,f;var a=i.arg;return a?a.done?(e[r.r]=a.value,e.next=r.n,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,f):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f);}function w(t){this.tryEntries.push(t);}function m(r){var e=r[4]||{};e.type="normal",e.arg=t,r[4]=e;}function Context(t){this.tryEntries=[[-1]],t.forEach(w,this),this.reset(!0);}function x(r){if(null!=r){var e=r[i];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function e(){for(;++o<r.length;)if(n.call(r,o))return e.value=r[o],e.done=!1,e;return e.value=t,e.done=!0,e;};return a.next=a;}}throw new TypeError(_typeof(r)+" is not iterable");}return GeneratorFunction.prototype=GeneratorFunctionPrototype,c(v,"constructor",GeneratorFunctionPrototype),c(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName=c(GeneratorFunctionPrototype,u,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===GeneratorFunction||"GeneratorFunction"===(r.displayName||r.name));},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,GeneratorFunctionPrototype):(t.__proto__=GeneratorFunctionPrototype,c(t,u,"GeneratorFunction")),t.prototype=Object.create(v),t;},r.awrap=function(t){return{__await:t};},g(AsyncIterator.prototype),c(AsyncIterator.prototype,a,function(){return this;}),r.AsyncIterator=AsyncIterator,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new AsyncIterator(h(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then(function(t){return t.done?t.value:a.next();});},g(v),c(v,u,"Generator"),c(v,i,function(){return this;}),c(v,"toString",function(){return"[object Generator]";}),r.keys=function(t){var r=Object(t),e=[];for(var n in r)e.unshift(n);return function t(){for(;e.length;)if((n=e.pop())in r)return t.value=n,t.done=!1,t;return t.done=!0,t;};},r.values=x,Context.prototype={constructor:Context,reset:function reset(r){if(this.prev=this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(m),!r)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t);},stop:function stop(){this.done=!0;var t=this.tryEntries[0][4];if("throw"===t.type)throw t.arg;return this.rval;},dispatchException:function dispatchException(r){if(this.done)throw r;var e=this;function n(t){a.type="throw",a.arg=r,e.next=t;}for(var o=e.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i[4],u=this.prev,c=i[1],h=i[2];if(-1===i[0])return n("end"),!1;if(!c&&!h)throw Error("try statement without catch or finally");if(null!=i[0]&&i[0]<=u){if(u<c)return this.method="next",this.arg=t,n(c),!0;if(u<h)return n(h),!1;}}},abrupt:function abrupt(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n[0]>-1&&n[0]<=this.prev&&this.prev<n[2]){var o=n;break;}}o&&("break"===t||"continue"===t)&&o[0]<=r&&r<=o[2]&&(o=null);var i=o?o[4]:{};return i.type=t,i.arg=r,o?(this.method="next",this.next=o[2],f):this.complete(i);},complete:function complete(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),f;},finish:function finish(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e[2]===t)return this.complete(e[4],e[3]),m(e),f;}},"catch":function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e[0]===t){var n=e[4];if("throw"===n.type){var o=n.arg;m(e);}return o;}}throw Error("illegal catch attempt");},delegateYield:function delegateYield(r,e,n){return this.delegate={i:x(r),r:e,n:n},"next"===this.method&&(this.arg=t),f;}},r;}var DEBUG_ID_PLACE_HOLDER='__POSTHOG_CHUNK_ID__';var DEBUG_ID_MODULE_PATH='__chunkid__';var SOURCE_MAP_COMMENT='//# sourceMappingURL=';var DEBUG_ID_COMMENT='//# chunkId=';function unstableBeforeAssetSerializationDebugIdPlugin(_ref){var premodules=_ref.premodules,debugId=_ref.debugId;if(!debugId){return premodules;}var debugIdModuleExists=premodules.some(function(module){return module.path===DEBUG_ID_MODULE_PATH;});if(debugIdModuleExists){console.warn('\n\nChunk ID module found. Skipping PostHog Chunk ID module...\n\n');return premodules;}var debugIdModule=createDebugIdModule(debugId);return(0,_utils.prependModule)(premodules,debugIdModule);}var createPostHogMetroSerializer=exports.createPostHogMetroSerializer=function createPostHogMetroSerializer(customSerializer){var serializer=customSerializer||(0,_utils2.createDefaultMetroSerializer)();return function(){var _ref2=(0,_asyncToGenerator2["default"])(_regeneratorRuntime().mark(function _callee(entryPoint,premodules,graph,options){var debugIdModuleExists,debugIdModule,modifiedPremodules,serializerResult,_yield$extractSeriali,bundleCode,bundleMapString,debugId,debugIdComment,indexOfSourceMapComment,bundleCodeWithDebugId,bundleMap;return _regeneratorRuntime().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(!graph.transformOptions.hot){_context.next=2;break;}return _context.abrupt("return",serializer(entryPoint,premodules,graph,options));case 2:debugIdModuleExists=premodules.some(function(module){return module.path===DEBUG_ID_MODULE_PATH;});if(!debugIdModuleExists){_context.next=6;break;}console.warn('Chunk ID module found. Skipping PostHog Chunk ID module...');return _context.abrupt("return",serializer(entryPoint,premodules,graph,options));case 6:debugIdModule=createDebugIdModule(DEBUG_ID_PLACE_HOLDER);modifiedPremodules=(0,_utils.prependModule)(premodules,debugIdModule);serializerResult=serializer(entryPoint,modifiedPremodules,graph,options);_context.next=11;return extractSerializerResult(serializerResult);case 11:_yield$extractSeriali=_context.sent;bundleCode=_yield$extractSeriali.code;bundleMapString=_yield$extractSeriali.map;debugId=(0,_utils.determineDebugIdFromBundleSource)(bundleCode);if(debugId){_context.next=17;break;}throw new Error('Chunk ID was not found in the bundle.');case 17:console.log('info '+"Bundle Chunk ID: ".concat(debugId));debugIdComment="".concat(DEBUG_ID_COMMENT).concat(debugId);indexOfSourceMapComment=bundleCode.lastIndexOf(SOURCE_MAP_COMMENT);bundleCodeWithDebugId=indexOfSourceMapComment===-1?"".concat(bundleCode,"\n").concat(debugIdComment):"".concat(bundleCode.substring(0,indexOfSourceMapComment)+debugIdComment,"\n").concat(bundleCode.substring(indexOfSourceMapComment));bundleMap=JSON.parse(bundleMapString);bundleMap['chunkId']=debugId;return _context.abrupt("return",{code:bundleCodeWithDebugId,map:JSON.stringify(bundleMap)});case 24:case"end":return _context.stop();}},_callee);}));return function(_x,_x2,_x3,_x4){return _ref2.apply(this,arguments);};}();};function extractSerializerResult(_x5){return _extractSerializerResult.apply(this,arguments);}function _extractSerializerResult(){_extractSerializerResult=(0,_asyncToGenerator2["default"])(_regeneratorRuntime().mark(function _callee2(serializerResult){var awaitedResult;return _regeneratorRuntime().wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:if(!(typeof serializerResult==='string')){_context2.next=2;break;}return _context2.abrupt("return",{code:serializerResult,map:'{}'});case 2:if(!('map'in serializerResult)){_context2.next=4;break;}return _context2.abrupt("return",{code:serializerResult.code,map:serializerResult.map});case 4:_context2.next=6;return serializerResult;case 6:awaitedResult=_context2.sent;if(!(typeof awaitedResult==='string')){_context2.next=9;break;}return _context2.abrupt("return",{code:awaitedResult,map:'{}'});case 9:return _context2.abrupt("return",{code:awaitedResult.code,map:awaitedResult.map});case 10:case"end":return _context2.stop();}},_callee2);}));return _extractSerializerResult.apply(this,arguments);}function createDebugIdModule(debugId){return(0,_utils.createVirtualJSModule)(DEBUG_ID_MODULE_PATH,(0,_utils.createDebugIdSnippet)(debugId));}
1
+ "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.createPostHogMetroSerializer=void 0;exports.unstableBeforeAssetSerializationDebugIdPlugin=unstableBeforeAssetSerializationDebugIdPlugin;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _utils=require("./utils");var _utils2=require("./vendor/metro/utils");var DEBUG_ID_PLACE_HOLDER='__POSTHOG_CHUNK_ID__';var DEBUG_ID_MODULE_PATH='__chunkid__';var SOURCE_MAP_COMMENT='//# sourceMappingURL=';var DEBUG_ID_COMMENT='//# chunkId=';function unstableBeforeAssetSerializationDebugIdPlugin(_ref){var premodules=_ref.premodules,debugId=_ref.debugId;if(!debugId){return premodules;}var debugIdModuleExists=premodules.some(function(module){return module.path===DEBUG_ID_MODULE_PATH;});if(debugIdModuleExists){console.warn('\n\nChunk ID module found. Skipping PostHog Chunk ID module...\n\n');return premodules;}var debugIdModule=createDebugIdModule(debugId);return(0,_utils.prependModule)(premodules,debugIdModule);}var createPostHogMetroSerializer=exports.createPostHogMetroSerializer=function createPostHogMetroSerializer(customSerializer){var serializer=customSerializer||(0,_utils2.createDefaultMetroSerializer)();return function(){var _ref2=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(entryPoint,premodules,graph,options){var debugIdModuleExists,debugIdModule,modifiedPremodules,serializerResult,_yield$extractSeriali,bundleCode,bundleMapString,debugId,debugIdComment,indexOfSourceMapComment,bundleCodeWithDebugId,bundleMap;return _regenerator["default"].wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(!graph.transformOptions.hot){_context.next=2;break;}return _context.abrupt("return",serializer(entryPoint,premodules,graph,options));case 2:debugIdModuleExists=premodules.some(function(module){return module.path===DEBUG_ID_MODULE_PATH;});if(!debugIdModuleExists){_context.next=6;break;}console.warn('Chunk ID module found. Skipping PostHog Chunk ID module...');return _context.abrupt("return",serializer(entryPoint,premodules,graph,options));case 6:debugIdModule=createDebugIdModule(DEBUG_ID_PLACE_HOLDER);modifiedPremodules=(0,_utils.prependModule)(premodules,debugIdModule);serializerResult=serializer(entryPoint,modifiedPremodules,graph,options);_context.next=11;return extractSerializerResult(serializerResult);case 11:_yield$extractSeriali=_context.sent;bundleCode=_yield$extractSeriali.code;bundleMapString=_yield$extractSeriali.map;debugId=(0,_utils.determineDebugIdFromBundleSource)(bundleCode);if(debugId){_context.next=17;break;}throw new Error('Chunk ID was not found in the bundle.');case 17:console.log('info '+"Bundle Chunk ID: ".concat(debugId));debugIdComment="".concat(DEBUG_ID_COMMENT).concat(debugId);indexOfSourceMapComment=bundleCode.lastIndexOf(SOURCE_MAP_COMMENT);bundleCodeWithDebugId=indexOfSourceMapComment===-1?"".concat(bundleCode,"\n").concat(debugIdComment):"".concat(bundleCode.substring(0,indexOfSourceMapComment)+debugIdComment,"\n").concat(bundleCode.substring(indexOfSourceMapComment));bundleMap=JSON.parse(bundleMapString);bundleMap['chunkId']=debugId;return _context.abrupt("return",{code:bundleCodeWithDebugId,map:JSON.stringify(bundleMap)});case 24:case"end":return _context.stop();}},_callee);}));return function(_x,_x2,_x3,_x4){return _ref2.apply(this,arguments);};}();};function extractSerializerResult(_x5){return _extractSerializerResult.apply(this,arguments);}function _extractSerializerResult(){_extractSerializerResult=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(serializerResult){var awaitedResult;return _regenerator["default"].wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:if(!(typeof serializerResult==='string')){_context2.next=2;break;}return _context2.abrupt("return",{code:serializerResult,map:'{}'});case 2:if(!('map'in serializerResult)){_context2.next=4;break;}return _context2.abrupt("return",{code:serializerResult.code,map:serializerResult.map});case 4:_context2.next=6;return serializerResult;case 6:awaitedResult=_context2.sent;if(!(typeof awaitedResult==='string')){_context2.next=9;break;}return _context2.abrupt("return",{code:awaitedResult,map:'{}'});case 9:return _context2.abrupt("return",{code:awaitedResult.code,map:awaitedResult.map});case 10:case"end":return _context2.stop();}},_callee2);}));return _extractSerializerResult.apply(this,arguments);}function createDebugIdModule(debugId){return(0,_utils.createVirtualJSModule)(DEBUG_ID_MODULE_PATH,(0,_utils.createDebugIdSnippet)(debugId));}
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "4.14.0";
1
+ export declare const version = "4.14.2";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.version=void 0;var version=exports.version="4.14.0";
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.version=void 0;var version=exports.version="4.14.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-react-native",
3
- "version": "4.14.0",
3
+ "version": "4.14.2",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "directory": "packages/react-native"
29
29
  },
30
30
  "dependencies": {
31
- "@posthog/core": "1.6.0"
31
+ "@posthog/core": "1.7.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/cli": "^7.19.3",
@@ -59,8 +59,8 @@
59
59
  "react-native-svg": "^15.0.0",
60
60
  "ts-jest": "29.4.0",
61
61
  "typescript": "5.8.2",
62
- "@posthog-tooling/rollup-utils": "1.1.0",
63
- "@posthog-tooling/tsconfig-base": "1.1.0"
62
+ "@posthog-tooling/tsconfig-base": "1.1.1",
63
+ "@posthog-tooling/rollup-utils": "1.1.1"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "@react-native-async-storage/async-storage": ">=1.0.0",