posthog-react-native 4.81.7 → 4.81.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/error-tracking/utils.js +1 -1
- package/dist/error-tracking/utils.js.map +1 -1
- package/dist/native-deps.js +1 -1
- package/dist/native-deps.js.map +1 -1
- package/dist/optional/OptionalReactNativeExceptionsManager.d.ts +4 -0
- package/dist/optional/OptionalReactNativeExceptionsManager.js +2 -0
- package/dist/optional/OptionalReactNativeExceptionsManager.js.map +1 -0
- package/dist/optional/OptionalReactNativeExceptionsManager.web.d.ts +2 -0
- package/dist/optional/OptionalReactNativeExceptionsManager.web.js +2 -0
- package/dist/optional/OptionalReactNativeExceptionsManager.web.js.map +1 -0
- package/dist/posthog-rn.d.ts +3 -0
- package/dist/posthog-rn.js +1 -1
- package/dist/posthog-rn.js.map +1 -1
- package/dist/surveys/components/ConfirmationMessage.js +1 -1
- package/dist/surveys/components/ConfirmationMessage.js.map +1 -1
- package/dist/surveys/components/SurveyModal.js +1 -1
- package/dist/surveys/components/SurveyModal.js.map +1 -1
- package/dist/surveys/surveys-utils.d.ts +1 -0
- package/dist/surveys/surveys-utils.js +1 -1
- package/dist/surveys/surveys-utils.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.trackConsole=trackConsole;exports.trackUncaughtExceptions=trackUncaughtExceptions;exports.trackUnhandledRejections=trackUnhandledRejections;var _core=require("@posthog/core");var _utils=require("../utils");var FATAL_PERSISTENCE_TIMEOUT_MS=2000;function trackUnhandledRejections(tracker){var _a,_b,_c;if((0,_utils.isHermes)()&&((_a=_utils.GLOBAL_OBJ===null||_utils.GLOBAL_OBJ===void 0?void 0:_utils.GLOBAL_OBJ.HermesInternal)===null||_a===void 0?void 0:_a.enablePromiseRejectionTracker)&&((_c=(_b=_utils.GLOBAL_OBJ===null||_utils.GLOBAL_OBJ===void 0?void 0:_utils.GLOBAL_OBJ.HermesInternal)===null||_b===void 0?void 0:_b.hasPromise)===null||_c===void 0?void 0:_c.call(_b))){_utils.GLOBAL_OBJ.HermesInternal.enablePromiseRejectionTracker({allRejections:true,onUnhandled:function onUnhandled(_,error){return tracker(error,false);},onHandled:function onHandled(){}});}else if((0,_utils.isWeb)()){addWebUnhandledRejectionListener(tracker);}else{throw new Error('Promise rejection tracking is only supported on Web and Hermes runtime');}}var uncaughtExceptionSubscriptions=new WeakMap();function trackUncaughtExceptions(tracker){var errorUtils=_utils.GLOBAL_OBJ===null||_utils.GLOBAL_OBJ===void 0?void 0:_utils.GLOBAL_OBJ.ErrorUtils;if(!(errorUtils===null||errorUtils===void 0?void 0:errorUtils.setGlobalHandler)||!errorUtils.getGlobalHandler){throw new Error('ErrorUtils globalHandlers are not defined');}var subscription=uncaughtExceptionSubscriptions.get(errorUtils);if(!subscription){var previousHandler=errorUtils.getGlobalHandler();var _trackers=new Set();var
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.trackConsole=trackConsole;exports.trackUncaughtExceptions=trackUncaughtExceptions;exports.trackUnhandledRejections=trackUnhandledRejections;var _typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof"));var _core=require("@posthog/core");var _utils=require("../utils");var _OptionalReactNativeExceptionsManager=require("../optional/OptionalReactNativeExceptionsManager");var FATAL_PERSISTENCE_TIMEOUT_MS=2000;function trackUnhandledRejections(tracker){var _a,_b,_c;if((0,_utils.isHermes)()&&((_a=_utils.GLOBAL_OBJ===null||_utils.GLOBAL_OBJ===void 0?void 0:_utils.GLOBAL_OBJ.HermesInternal)===null||_a===void 0?void 0:_a.enablePromiseRejectionTracker)&&((_c=(_b=_utils.GLOBAL_OBJ===null||_utils.GLOBAL_OBJ===void 0?void 0:_utils.GLOBAL_OBJ.HermesInternal)===null||_b===void 0?void 0:_b.hasPromise)===null||_c===void 0?void 0:_c.call(_b))){_utils.GLOBAL_OBJ.HermesInternal.enablePromiseRejectionTracker({allRejections:true,onUnhandled:function onUnhandled(_,error){return tracker(error,false);},onHandled:function onHandled(){}});}else if((0,_utils.isWeb)()){addWebUnhandledRejectionListener(tracker);}else{throw new Error('Promise rejection tracking is only supported on Web and Hermes runtime');}}var uncaughtExceptionSubscriptions=new WeakMap();function trackUncaughtExceptions(tracker){var errorUtils=_utils.GLOBAL_OBJ===null||_utils.GLOBAL_OBJ===void 0?void 0:_utils.GLOBAL_OBJ.ErrorUtils;if(!(errorUtils===null||errorUtils===void 0?void 0:errorUtils.setGlobalHandler)||!errorUtils.getGlobalHandler){throw new Error('ErrorUtils globalHandlers are not defined');}var subscription=uncaughtExceptionSubscriptions.get(errorUtils);if(!subscription){var previousHandler=errorUtils.getGlobalHandler();var _trackers=new Set();var fatalsInFlight=new Map();var forwardedFatals=new WeakSet();var dispatch=function dispatch(error,isFatal,forward){if(isFatal&&(0,_typeof2["default"])(error)==='object'&&error!==null&&forwardedFatals.has(error)){forward();return;}var inFlight=isFatal?fatalsInFlight.get(error):undefined;if(inFlight){if(inFlight.forwarding){forward();}else{void inFlight.forwarded.then(function(){return(0,_core.safeSetTimeout)(forward,0);});}return;}var forwardFatal=forward;if(isFatal){var markForwarded;var fatal={forwarding:false,forwarded:new Promise(function(resolve){return markForwarded=resolve;})};fatalsInFlight.set(error,fatal);forwardFatal=function forwardFatal(){fatal.forwarding=true;if((0,_typeof2["default"])(error)==='object'&&error!==null){forwardedFatals.add(error);}markForwarded();try{forward();}finally{fatalsInFlight["delete"](error);}};}var pending=[];try{for(var _i=0,_Array$from=Array.from(_trackers);_i<_Array$from.length;_i++){var callback=_Array$from[_i];try{var result=callback(error,isFatal);if((0,_core.isPromise)(result)){pending.push(Promise.resolve(result)["catch"](function(){}));}}catch(_a){}}}finally{if(isFatal&&pending.length>0){var forwarded=false;var forwardOnce=function forwardOnce(){if(!forwarded){forwarded=true;forwardFatal();}};var deadline=(0,_core.safeSetTimeout)(forwardOnce,FATAL_PERSISTENCE_TIMEOUT_MS);void Promise.all(pending).then(function(){if(!forwarded){clearTimeout(deadline);(0,_core.safeSetTimeout)(forwardOnce,0);}});}else{forwardFatal();}}};var handler=function handler(error,isFatal){dispatch(error,isFatal!==null&&isFatal!==void 0?isFatal:false,function(){return previousHandler===null||previousHandler===void 0?void 0:previousHandler(error,isFatal);});};var restoreExceptionsManager=wrapExceptionsManager(function(error,forward){return dispatch(error,true,forward);});subscription={trackers:_trackers,restore:function restore(){var _a,_b;if(((_a=errorUtils.getGlobalHandler)===null||_a===void 0?void 0:_a.call(errorUtils))===handler){(_b=errorUtils.setGlobalHandler)===null||_b===void 0?void 0:_b.call(errorUtils,previousHandler);}restoreExceptionsManager();uncaughtExceptionSubscriptions["delete"](errorUtils);}};errorUtils.setGlobalHandler(handler);uncaughtExceptionSubscriptions.set(errorUtils,subscription);}var _subscription=subscription,trackers=_subscription.trackers,restore=_subscription.restore;trackers.add(tracker);return function(){if(trackers["delete"](tracker)&&trackers.size===0){restore();}};}function wrapExceptionsManager(onFatal){try{var exceptionsManager=_OptionalReactNativeExceptionsManager.OptionalReactNativeExceptionsManager;var original=exceptionsManager===null||exceptionsManager===void 0?void 0:exceptionsManager.handleException;if(!exceptionsManager||typeof original!=='function'){return function(){};}var wrapped=function wrapped(error,isFatal){if(!isFatal){return original.call(exceptionsManager,error,isFatal);}onFatal(error,function(){return original.call(exceptionsManager,error,isFatal);});};exceptionsManager.handleException=wrapped;return function(){try{if(exceptionsManager.handleException===wrapped){exceptionsManager.handleException=original;}}catch(_a){}};}catch(_a){return function(){};}}function trackConsole(level,tracker){var con=console;if(!con){throw new Error('console not available, cannot wrap console.error');}var originalMethod=con[level];con[level]=function(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}var message=args.join(' ');var error=args.find(function(arg){return arg instanceof Error;});var syntheticException=new Error('Synthetic PostHog Error');tracker(error!==null&&error!==void 0?error:message,false,syntheticException);return originalMethod===null||originalMethod===void 0?void 0:originalMethod.apply(void 0,args);};}function addWebUnhandledRejectionListener(tracker){var _oldUnhandledRejectionHandler=_utils.GLOBAL_OBJ.onunhandledrejection;_utils.GLOBAL_OBJ.onunhandledrejection=function(event){tracker(event,false);if(_oldUnhandledRejectionHandler){_oldUnhandledRejectionHandler.apply(_utils.GLOBAL_OBJ,[event]);}};}
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["_core","require","_utils","FATAL_PERSISTENCE_TIMEOUT_MS","trackUnhandledRejections","tracker","isHermes","_a","GLOBAL_OBJ","HermesInternal","enablePromiseRejectionTracker","_c","_b","hasPromise","call","allRejections","onUnhandled","_","error","onHandled","isWeb","addWebUnhandledRejectionListener","Error","uncaughtExceptionSubscriptions","WeakMap","trackUncaughtExceptions","errorUtils","ErrorUtils","setGlobalHandler","getGlobalHandler","subscription","get","previousHandler","trackers","Set","handler","isFatal","pending","_i","_Array$from","Array","from","length","callback","result","isPromise","push","Promise","resolve","forwarded","forward","deadline","safeSetTimeout","all","then","clearTimeout","restore","set","_subscription","add","size","trackConsole","level","con","console","originalMethod","_len","arguments","args","_key","message","join","find","arg","syntheticException","apply","_oldUnhandledRejectionHandler","onunhandledrejection","event"],"sources":["../../src/error-tracking/utils.ts"],"sourcesContent":["import { isPromise, safeSetTimeout } from '@posthog/core'\nimport { GLOBAL_OBJ, isHermes, isWeb } from '../utils'\n\ntype ExceptionHook = (error: unknown, isFatal: boolean, syntheticException?: Error) => void\ntype UncaughtExceptionHook = (error: unknown, isFatal: boolean) => void | Promise<void>\n\nconst FATAL_PERSISTENCE_TIMEOUT_MS = 2000\n\nexport function trackUnhandledRejections(tracker: ExceptionHook): void {\n if (\n isHermes() &&\n GLOBAL_OBJ?.HermesInternal?.enablePromiseRejectionTracker &&\n GLOBAL_OBJ?.HermesInternal?.hasPromise?.()\n ) {\n GLOBAL_OBJ.HermesInternal.enablePromiseRejectionTracker({\n allRejections: true,\n onUnhandled: (_, error: unknown) => tracker(error as Error, false),\n onHandled: () => {},\n })\n } else if (isWeb()) {\n addWebUnhandledRejectionListener(tracker)\n } else {\n throw new Error('Promise rejection tracking is only supported on Web and Hermes runtime')\n }\n}\n\nconst uncaughtExceptionSubscriptions = new WeakMap<\n NonNullable<typeof GLOBAL_OBJ.ErrorUtils>,\n { trackers: Set<UncaughtExceptionHook>; restore: () => void }\n>()\n\nexport function trackUncaughtExceptions(tracker: UncaughtExceptionHook): () => void {\n const errorUtils = GLOBAL_OBJ?.ErrorUtils\n if (!errorUtils?.setGlobalHandler || !errorUtils.getGlobalHandler) {\n throw new Error('ErrorUtils globalHandlers are not defined')\n }\n\n let subscription = uncaughtExceptionSubscriptions.get(errorUtils)\n if (!subscription) {\n const previousHandler = errorUtils.getGlobalHandler()\n const trackers = new Set<UncaughtExceptionHook>()\n const handler = (error: Error, isFatal: boolean): void => {\n const pending: Promise<void>[] = []\n try {\n for (const callback of Array.from(trackers)) {\n try {\n const result = callback(error, isFatal ?? false)\n if (isPromise(result)) {\n pending.push(Promise.resolve(result).catch(() => {}))\n }\n } catch {\n // One reporter must not prevent other reporters or React Native from handling the error.\n }\n }\n } finally {\n if (isFatal && pending.length > 0) {\n let forwarded = false\n const forward = () => {\n if (!forwarded) {\n forwarded = true\n previousHandler?.(error, isFatal)\n }\n }\n const deadline = safeSetTimeout(forward, FATAL_PERSISTENCE_TIMEOUT_MS)\n void Promise.all(pending).then(() => {\n if (!forwarded) {\n clearTimeout(deadline)\n // Keep errors thrown by the previous handler outside Promise rejection handling.\n safeSetTimeout(forward, 0)\n }\n })\n } else {\n previousHandler?.(error, isFatal)\n }\n }\n }\n subscription = {\n trackers,\n restore: () => {\n // Leave another SDK's chain intact, but retire this empty subscription in case it is later detached.\n if (errorUtils.getGlobalHandler?.() === handler) {\n errorUtils.setGlobalHandler?.(previousHandler)\n }\n uncaughtExceptionSubscriptions.delete(errorUtils)\n },\n }\n errorUtils.setGlobalHandler(handler)\n uncaughtExceptionSubscriptions.set(errorUtils, subscription)\n }\n\n const { trackers, restore } = subscription\n trackers.add(tracker)\n return () => {\n if (trackers.delete(tracker) && trackers.size === 0) {\n restore()\n }\n }\n}\n\nexport function trackConsole(level: string, tracker: ExceptionHook): void {\n const con = console as any\n if (!con) {\n throw new Error('console not available, cannot wrap console.error')\n }\n\n const originalMethod = con[level]\n con[level] = function (...args: any[]): void {\n const message = args.join(' ')\n const error = args.find((arg) => arg instanceof Error)\n const syntheticException = new Error('Synthetic PostHog Error')\n tracker(error ?? message, false, syntheticException)\n return originalMethod?.(...args)\n }\n}\n\nfunction addWebUnhandledRejectionListener(tracker: ExceptionHook): void {\n const _oldUnhandledRejectionHandler = GLOBAL_OBJ.onunhandledrejection\n GLOBAL_OBJ.onunhandledrejection = (event) => {\n tracker(event, false)\n if (_oldUnhandledRejectionHandler) {\n _oldUnhandledRejectionHandler.apply(GLOBAL_OBJ, [event])\n }\n }\n}\n"],"mappings":"0NAAA,IAAAA,KAAA,CAAAC,OAAA,kBACA,IAAAC,MAAA,CAAAD,OAAA,aAKA,GAAM,CAAAE,4BAA4B,CAAG,IAAI,CAEnC,QAAU,CAAAC,wBAAwBA,CAACC,OAAsB,E,aAC7D,GACE,GAAAC,eAAQ,GAAE,GACV,CAAAC,EAAA,CAAAC,iBAAU,SAAVA,iBAAU,iBAAVA,iBAAU,CAAEC,cAAc,UAAAF,EAAA,iBAAAA,EAAA,CAAEG,6BAA6B,IACzD,CAAAC,EAAA,EAAAC,EAAA,CAAAJ,iBAAU,SAAVA,iBAAU,iBAAVA,iBAAU,CAAEC,cAAc,UAAAG,EAAA,iBAAAA,EAAA,CAAEC,UAAU,UAAAF,EAAA,iBAAAA,EAAA,CAAAG,IAAA,CAAAF,EAAA,CAAI,EAC1C,CACAJ,iBAAU,CAACC,cAAc,CAACC,6BAA6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AAM,CAAAC,OAAO,CAAGF,IAAI,CAACG,IAAI,CAAC,GAAG,CAAC,CAC9B,GAAM,CAAArD,KAAK,CAAGkD,IAAI,CAACI,IAAI,CAAC,SAACC,GAAG,QAAK,CAAAA,GAAG,WAAY,CAAAnD,KAAK,GAAC,CACtD,GAAM,CAAAoD,kBAAkB,CAAG,GAAI,CAAApD,KAAK,CAAC,yBAAyB,CAAC,CAC/DjB,OAAO,CAACa,KAAK,SAALA,KAAK,UAALA,KAAK,CAAIoD,OAAO,CAAE,KAAK,CAAEI,kBAAkB,CAAC,CACpD,MAAO,CAAAT,cAAc,SAAdA,cAAc,iBAAdA,cAAc,CAAAU,KAAA,QAAMP,IAAI,CAAC,CAClC,CAAC,CACH,CAEA,QAAS,CAAA/C,gCAAgCA,CAAChB,OAAsB,EAC9D,GAAM,CAAAuE,6BAA6B,CAAGpE,iBAAU,CAACqE,oBAAoB,CACrErE,iBAAU,CAACqE,oBAAoB,CAAG,SAACC,KAAK,CAAI,CAC1CzE,OAAO,CAACyE,KAAK,CAAE,KAAK,CAAC,CACrB,GAAIF,6BAA6B,CAAE,CACjCA,6BAA6B,CAACD,KAAK,CAACnE,iBAAU,CAAE,CAACsE,KAAK,CAAC,CAAC,CAC1D,CACF,CAAC,CACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"utils.js","names":["_core","require","_utils","_OptionalReactNativeExceptionsManager","FATAL_PERSISTENCE_TIMEOUT_MS","trackUnhandledRejections","tracker","isHermes","_a","GLOBAL_OBJ","HermesInternal","enablePromiseRejectionTracker","_c","_b","hasPromise","call","allRejections","onUnhandled","_","error","onHandled","isWeb","addWebUnhandledRejectionListener","Error","uncaughtExceptionSubscriptions","WeakMap","trackUncaughtExceptions","errorUtils","ErrorUtils","setGlobalHandler","getGlobalHandler","subscription","get","previousHandler","trackers","Set","fatalsInFlight","Map","forwardedFatals","WeakSet","dispatch","isFatal","forward","_typeof2","has","inFlight","undefined","forwarding","forwarded","then","safeSetTimeout","forwardFatal","markForwarded","fatal","Promise","resolve","set","add","pending","_i","_Array$from","Array","from","length","callback","result","isPromise","push","forwardOnce","deadline","all","clearTimeout","handler","restoreExceptionsManager","wrapExceptionsManager","restore","_subscription","size","onFatal","exceptionsManager","OptionalReactNativeExceptionsManager","original","handleException","wrapped","trackConsole","level","con","console","originalMethod","_len","arguments","args","_key","message","join","find","arg","syntheticException","apply","_oldUnhandledRejectionHandler","onunhandledrejection","event"],"sources":["../../src/error-tracking/utils.ts"],"sourcesContent":["import { isPromise, safeSetTimeout } from '@posthog/core'\nimport { GLOBAL_OBJ, isHermes, isWeb } from '../utils'\nimport { OptionalReactNativeExceptionsManager } from '../optional/OptionalReactNativeExceptionsManager'\n\ntype ExceptionHook = (error: unknown, isFatal: boolean, syntheticException?: Error) => void\ntype UncaughtExceptionHook = (error: unknown, isFatal: boolean) => void | Promise<void>\n\nconst FATAL_PERSISTENCE_TIMEOUT_MS = 2000\n\nexport function trackUnhandledRejections(tracker: ExceptionHook): void {\n if (\n isHermes() &&\n GLOBAL_OBJ?.HermesInternal?.enablePromiseRejectionTracker &&\n GLOBAL_OBJ?.HermesInternal?.hasPromise?.()\n ) {\n GLOBAL_OBJ.HermesInternal.enablePromiseRejectionTracker({\n allRejections: true,\n onUnhandled: (_, error: unknown) => tracker(error as Error, false),\n onHandled: () => {},\n })\n } else if (isWeb()) {\n addWebUnhandledRejectionListener(tracker)\n } else {\n throw new Error('Promise rejection tracking is only supported on Web and Hermes runtime')\n }\n}\n\nconst uncaughtExceptionSubscriptions = new WeakMap<\n NonNullable<typeof GLOBAL_OBJ.ErrorUtils>,\n { trackers: Set<UncaughtExceptionHook>; restore: () => void }\n>()\n\nexport function trackUncaughtExceptions(tracker: UncaughtExceptionHook): () => void {\n const errorUtils = GLOBAL_OBJ?.ErrorUtils\n if (!errorUtils?.setGlobalHandler || !errorUtils.getGlobalHandler) {\n throw new Error('ErrorUtils globalHandlers are not defined')\n }\n\n let subscription = uncaughtExceptionSubscriptions.get(errorUtils)\n if (!subscription) {\n const previousHandler = errorUtils.getGlobalHandler()\n const trackers = new Set<UncaughtExceptionHook>()\n // The same fatal can arrive through both hooks: the ErrorUtils handler forwards to React\n // Native's default handler, which calls ExceptionsManager.handleException. Each fatal is\n // captured once while it is in flight; a repeated report is only forwarded, once the first\n // report has been forwarded. A previous handler can report the fatal to React Native after it\n // returns (Sentry flushes first), so forwarded Error objects are also only forwarded again.\n const fatalsInFlight = new Map<unknown, { forwarding: boolean; forwarded: Promise<void> }>()\n const forwardedFatals = new WeakSet<object>()\n const dispatch = (error: unknown, isFatal: boolean, forward: () => void): void => {\n if (isFatal && typeof error === 'object' && error !== null && forwardedFatals.has(error)) {\n forward()\n return\n }\n const inFlight = isFatal ? fatalsInFlight.get(error) : undefined\n if (inFlight) {\n if (inFlight.forwarding) {\n forward()\n } else {\n // Keep errors thrown by the previous handler outside Promise rejection handling.\n void inFlight.forwarded.then(() => safeSetTimeout(forward, 0))\n }\n return\n }\n let forwardFatal = forward\n if (isFatal) {\n let markForwarded!: () => void\n const fatal = { forwarding: false, forwarded: new Promise<void>((resolve) => (markForwarded = resolve)) }\n fatalsInFlight.set(error, fatal)\n forwardFatal = () => {\n fatal.forwarding = true\n if (typeof error === 'object' && error !== null) {\n forwardedFatals.add(error)\n }\n markForwarded()\n try {\n forward()\n } finally {\n fatalsInFlight.delete(error)\n }\n }\n }\n const pending: Promise<void>[] = []\n try {\n for (const callback of Array.from(trackers)) {\n try {\n const result = callback(error, isFatal)\n if (isPromise(result)) {\n pending.push(Promise.resolve(result).catch(() => {}))\n }\n } catch {\n // One reporter must not prevent other reporters or React Native from handling the error.\n }\n }\n } finally {\n if (isFatal && pending.length > 0) {\n let forwarded = false\n const forwardOnce = () => {\n if (!forwarded) {\n forwarded = true\n forwardFatal()\n }\n }\n const deadline = safeSetTimeout(forwardOnce, FATAL_PERSISTENCE_TIMEOUT_MS)\n void Promise.all(pending).then(() => {\n if (!forwarded) {\n clearTimeout(deadline)\n // Keep errors thrown by the previous handler outside Promise rejection handling.\n safeSetTimeout(forwardOnce, 0)\n }\n })\n } else {\n forwardFatal()\n }\n }\n }\n const handler = (error: Error, isFatal: boolean): void => {\n dispatch(error, isFatal ?? false, () => previousHandler?.(error, isFatal))\n }\n const restoreExceptionsManager = wrapExceptionsManager((error, forward) => dispatch(error, true, forward))\n subscription = {\n trackers,\n restore: () => {\n // Leave another SDK's chain intact, but retire this empty subscription in case it is later detached.\n if (errorUtils.getGlobalHandler?.() === handler) {\n errorUtils.setGlobalHandler?.(previousHandler)\n }\n restoreExceptionsManager()\n uncaughtExceptionSubscriptions.delete(errorUtils)\n },\n }\n errorUtils.setGlobalHandler(handler)\n uncaughtExceptionSubscriptions.set(errorUtils, subscription)\n }\n\n const { trackers, restore } = subscription\n trackers.add(tracker)\n return () => {\n if (trackers.delete(tracker) && trackers.size === 0) {\n restore()\n }\n }\n}\n\n// React 19 reports uncaught render errors from the root `onUncaughtError` straight to\n// ExceptionsManager.handleException(error, true), which never reaches ErrorUtils. Only fatal\n// calls are intercepted; errors caught by an error boundary arrive with isFatal false.\nfunction wrapExceptionsManager(onFatal: (error: unknown, forward: () => void) => void): () => void {\n try {\n const exceptionsManager = OptionalReactNativeExceptionsManager\n const original = exceptionsManager?.handleException\n if (!exceptionsManager || typeof original !== 'function') {\n return () => {}\n }\n const wrapped = (error: unknown, isFatal: boolean): void => {\n if (!isFatal) {\n return original.call(exceptionsManager, error, isFatal)\n }\n onFatal(error, () => original.call(exceptionsManager, error, isFatal))\n }\n exceptionsManager.handleException = wrapped\n return () => {\n try {\n if (exceptionsManager.handleException === wrapped) {\n exceptionsManager.handleException = original\n }\n } catch {}\n }\n } catch {\n return () => {}\n }\n}\n\nexport function trackConsole(level: string, tracker: ExceptionHook): void {\n const con = console as any\n if (!con) {\n throw new Error('console not available, cannot wrap console.error')\n }\n\n const originalMethod = con[level]\n con[level] = function (...args: any[]): void {\n const message = args.join(' ')\n const error = args.find((arg) => arg instanceof Error)\n const syntheticException = new Error('Synthetic PostHog Error')\n tracker(error ?? message, false, syntheticException)\n return originalMethod?.(...args)\n }\n}\n\nfunction addWebUnhandledRejectionListener(tracker: ExceptionHook): void {\n const _oldUnhandledRejectionHandler = GLOBAL_OBJ.onunhandledrejection\n GLOBAL_OBJ.onunhandledrejection = (event) => {\n tracker(event, false)\n if (_oldUnhandledRejectionHandler) {\n _oldUnhandledRejectionHandler.apply(GLOBAL_OBJ, [event])\n }\n }\n}\n"],"mappings":"2XAAA,IAAAA,KAAA,CAAAC,OAAA,kBACA,IAAAC,MAAA,CAAAD,OAAA,aACA,IAAAE,qCAAA,CAAAF,OAAA,qDAKA,GAAM,CAAAG,4BAA4B,CAAG,IAAI,CAEnC,QAAU,CAAAC,wBAAwBA,CAACC,OAAsB,E,aAC7D,GACE,GAAAC,eAAQ,GAAE,GACV,CAAAC,EAAA,CAAAC,iBAAU,SAAVA,iBAAU,iBAAVA,iBAAU,CAAEC,cAAc,UAAAF,EAAA,iBAAAA,EAAA,CAAEG,6BAA6B,IACzD,CAAAC,EAAA,EAAAC,EAAA,CAAAJ,iBAAU,SAAVA,iBAAU,iBAAVA,iBAAU,CAAEC,cAAc,UAAAG,EAAA,iBAAAA,EAAA,CAAEC,UAAU,UAAAF,EAAA,iBAAAA,EAAA,CAAAG,IAAA,CAAAF,EAAA,CAAI,EAC1C,CACAJ,iBAAU,CAACC,cAAc,CAACC,6BAA6B,CAAC,CACtDK,aAAa,CAAE,IAAI,CACnBC,WAAW,CAAE,QAAb,CAAAA,WAAWA,CAAGC,CAAC,CAAEC,KAAc,QAAK,CAAAb,OAAO,CAACa,KAAc,CAAE,KAAK,CAAC,GAClEC,SAAS,CAAE,QAAX,CAAAA,SAASA,CAAA,CAAO,CAAE,C,CACnB,CAAC,CACJ,CAAC,IAAM,IAAI,GAAAC,YAAK,GAAE,CAAE,CAClBC,gCAAgC,CAAChB,OAAO,CAAC,CAC3C,CAAC,IAAM,CACL,KAAM,IAAI,CAAAiB,KAAK,CAAC,wEAAw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AAK,CAAI0E,OAAO,CAAE,KAAK,CAAEI,kBAAkB,CAAC,CACpD,MAAO,CAAAT,cAAc,SAAdA,cAAc,iBAAdA,cAAc,CAAAU,KAAA,QAAMP,IAAI,CAAC,CAClC,CAAC,CACH,CAEA,QAAS,CAAArE,gCAAgCA,CAAChB,OAAsB,EAC9D,GAAM,CAAA6F,6BAA6B,CAAG1F,iBAAU,CAAC2F,oBAAoB,CACrE3F,iBAAU,CAAC2F,oBAAoB,CAAG,SAACC,KAAK,CAAI,CAC1C/F,OAAO,CAAC+F,KAAK,CAAE,KAAK,CAAC,CACrB,GAAIF,6BAA6B,CAAE,CACjCA,6BAA6B,CAACD,KAAK,CAACzF,iBAAU,CAAE,CAAC4F,KAAK,CAAC,CAAC,CAC1D,CACF,CAAC,CACH","ignoreList":[]}
|
package/dist/native-deps.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.getAppProperties=exports.currentDeviceType=exports.buildOptimisticAsyncStorage=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _OptionalAsyncStorage=require("./optional/OptionalAsyncStorage");var _utils=require("./utils");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 _core=require("@posthog/core");var getDeviceType=function getDeviceType(){var _a,_b,_c;var deviceType='Mobile';if((0,_utils.isMacOS)()||(0,_utils.isWindows)()){deviceType='Desktop';}else if((0,_utils.isWeb)()){var ua=typeof navigator!=='undefined'&&navigator.userAgent?navigator.userAgent:'';var nav=typeof navigator!=='undefined'?navigator:undefined;var win=typeof globalThis.window!=='undefined'?globalThis.window:undefined;deviceType=(0,_core.detectDeviceType)(ua,{userAgentDataPlatform:(_a=nav===null||nav===void 0?void 0:nav.userAgentData)===null||_a===void 0?void 0:_a.platform,maxTouchPoints:nav===null||nav===void 0?void 0:nav.maxTouchPoints,screenWidth:(_b=win===null||win===void 0?void 0:win.screen)===null||_b===void 0?void 0:_b.width,screenHeight:(_c=win===null||win===void 0?void 0:win.screen)===null||_c===void 0?void 0:_c.height,devicePixelRatio:win===null||win===void 0?void 0:win.devicePixelRatio});}return deviceType;};var currentDeviceType=exports.currentDeviceType=getDeviceType();var getAppProperties=exports.getAppProperties=function getAppProperties(){var _a,_b;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((0,_utils.getPlatformOS)()==='android'){properties.$os_name='Android';}else{properties.$os_name=_OptionalExpoDevice.OptionalExpoDevice.osName;}properties.$os_version=_OptionalExpoDevice.OptionalExpoDevice.osVersion;properties.$is_emulator=!_OptionalExpoDevice.OptionalExpoDevice.isDevice;}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());properties.$is_emulator=_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo.isEmulatorSync();}if(_OptionalExpoLocalization.OptionalExpoLocalization){var optionalExpoLocalization=_OptionalExpoLocalization.OptionalExpoLocalization;var locale=optionalExpoLocalization.locale;if(!locale&&optionalExpoLocalization.getLocales){locale=(_a=optionalExpoLocalization.getLocales()[0])===null||_a===void 0?void 0:_a.languageTag;}if(locale){properties.$locale=locale;}var timezone=optionalExpoLocalization.timezone;if(!timezone&&optionalExpoLocalization.getCalendars){timezone=(_b=optionalExpoLocalization.getCalendars()[0])===null||_b===void 0?void 0:_b.timeZone;}if(timezone){properties.$timezone=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,_t;return _regenerator["default"].wrap(function(_context){while(1)switch(_context.prev=_context.next){case 0:_context.prev=0;uri=(filesystem.documentDirectory||'')+key;_context.next=1;return filesystem.readAsStringAsync(uri);case 1:stringContent=_context.sent;return _context.abrupt("return",stringContent);case 2:_context.prev=2;_t=_context["catch"](0);return _context.abrupt("return",null);case 3:case"end":return _context.stop();}},_callee,null,[[0,2]]);}))();},setItem:function setItem(key,value){return(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(){var uri;return _regenerator["default"].wrap(function(_context2){while(1)switch(_context2.prev=_context2.next){case 0:uri=(filesystem.documentDirectory||'')+key;_context2.next=1;return filesystem.writeAsStringAsync(uri,value);case 1:case"end":return _context2.stop();}},_callee2);}))();}};};var buildOptimisticAsyncStorage=exports.buildOptimisticAsyncStorage=function buildOptimisticAsyncStorage(){if((0,_utils.isWeb)()&&typeof(_utils.GLOBAL_OBJ===null||_utils.GLOBAL_OBJ===void 0?void 0:_utils.GLOBAL_OBJ.window)==='undefined'){return undefined;}var supportedPlatform=!(0,_utils.isWeb)()&&!(0,_utils.isMacOS)();if(supportedPlatform){if(_OptionalExpoFileSystem.OptionalExpoFileSystem){var filesystem=_OptionalExpoFileSystem.OptionalExpoFileSystem;if(filesystem.Paths&&filesystem.File){return{getItem:function getItem(key){return(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(){var file,stringContent,_t2;return _regenerator["default"].wrap(function(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.prev=0;file=new filesystem.File(filesystem.Paths.document,key);_context3.next=1;return file.text();case 1:stringContent=_context3.sent;return _context3.abrupt("return",stringContent);case 2:_context3.prev=2;_t2=_context3["catch"](0);return _context3.abrupt("return",null);case 3:case"end":return _context3.stop();}},_callee3,null,[[0,2]]);}))();},setItem:function setItem(key,value){return(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4(){var file;return _regenerator["default"].wrap(function(_context4){while(1)switch(_context4.prev=_context4.next){case 0:file=new filesystem.File(filesystem.Paths.document,key);_context4.next=1;return file.write(value);case 1:case"end":return _context4.stop();}},_callee4);}))();}};}}var legacyModule=_OptionalExpoFileSystemLegacy.OptionalExpoFileSystemLegacy||_OptionalExpoFileSystem.OptionalExpoFileSystem;try{if(legacyModule&&typeof legacyModule.readAsStringAsync==='function'){return buildLegacyStorage(legacyModule);}}catch(e){}}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.buildOptimisticAsyncStorage=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _OptionalAsyncStorage=require("./optional/OptionalAsyncStorage");var _utils=require("./utils");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 _core=require("@posthog/core");var _reactNative=require("react-native");var getDeviceType=function getDeviceType(){var _a,_b,_c;var deviceType='Mobile';if((0,_utils.isMacOS)()||(0,_utils.isWindows)()){deviceType='Desktop';}else if((0,_utils.isWeb)()){var ua=typeof navigator!=='undefined'&&navigator.userAgent?navigator.userAgent:'';var nav=typeof navigator!=='undefined'?navigator:undefined;var win=typeof globalThis.window!=='undefined'?globalThis.window:undefined;deviceType=(0,_core.detectDeviceType)(ua,{userAgentDataPlatform:(_a=nav===null||nav===void 0?void 0:nav.userAgentData)===null||_a===void 0?void 0:_a.platform,maxTouchPoints:nav===null||nav===void 0?void 0:nav.maxTouchPoints,screenWidth:(_b=win===null||win===void 0?void 0:win.screen)===null||_b===void 0?void 0:_b.width,screenHeight:(_c=win===null||win===void 0?void 0:win.screen)===null||_c===void 0?void 0:_c.height,devicePixelRatio:win===null||win===void 0?void 0:win.devicePixelRatio});}return deviceType;};var currentDeviceType=exports.currentDeviceType=getDeviceType();var getAppProperties=exports.getAppProperties=function getAppProperties(){var _a,_b;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((0,_utils.getPlatformOS)()==='android'){properties.$os_name='Android';}else{properties.$os_name=_OptionalExpoDevice.OptionalExpoDevice.osName;}properties.$os_version=_OptionalExpoDevice.OptionalExpoDevice.osVersion;properties.$is_emulator=!_OptionalExpoDevice.OptionalExpoDevice.isDevice;}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());properties.$is_emulator=_OptionalReactNativeDeviceInfo.OptionalReactNativeDeviceInfo.isEmulatorSync();}if(!properties.$os_name){(0,_extends2["default"])(properties,getPlatformOSProperties());}if(_OptionalExpoLocalization.OptionalExpoLocalization){var optionalExpoLocalization=_OptionalExpoLocalization.OptionalExpoLocalization;var locale=optionalExpoLocalization.locale;if(!locale&&optionalExpoLocalization.getLocales){locale=(_a=optionalExpoLocalization.getLocales()[0])===null||_a===void 0?void 0:_a.languageTag;}if(locale){properties.$locale=locale;}var timezone=optionalExpoLocalization.timezone;if(!timezone&&optionalExpoLocalization.getCalendars){timezone=(_b=optionalExpoLocalization.getCalendars()[0])===null||_b===void 0?void 0:_b.timeZone;}if(timezone){properties.$timezone=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 getPlatformOSProperties=function getPlatformOSProperties(){var _a,_b;try{var os=(0,_utils.getPlatformOS)();var constants=_reactNative.Platform.constants;var version=_reactNative.Platform.Version!==undefined?String(_reactNative.Platform.Version):undefined;if(os==='android'){return{$os_name:'Android',$os_version:(_a=constants===null||constants===void 0?void 0:constants.Release)!==null&&_a!==void 0?_a:version};}if(os==='ios'){return{$os_name:(_b=constants===null||constants===void 0?void 0:constants.systemName)!==null&&_b!==void 0?_b:'iOS',$os_version:version};}}catch(_c){}return{};};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,_t;return _regenerator["default"].wrap(function(_context){while(1)switch(_context.prev=_context.next){case 0:_context.prev=0;uri=(filesystem.documentDirectory||'')+key;_context.next=1;return filesystem.readAsStringAsync(uri);case 1:stringContent=_context.sent;return _context.abrupt("return",stringContent);case 2:_context.prev=2;_t=_context["catch"](0);return _context.abrupt("return",null);case 3:case"end":return _context.stop();}},_callee,null,[[0,2]]);}))();},setItem:function setItem(key,value){return(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(){var uri;return _regenerator["default"].wrap(function(_context2){while(1)switch(_context2.prev=_context2.next){case 0:uri=(filesystem.documentDirectory||'')+key;_context2.next=1;return filesystem.writeAsStringAsync(uri,value);case 1:case"end":return _context2.stop();}},_callee2);}))();}};};var buildOptimisticAsyncStorage=exports.buildOptimisticAsyncStorage=function buildOptimisticAsyncStorage(){if((0,_utils.isWeb)()&&typeof(_utils.GLOBAL_OBJ===null||_utils.GLOBAL_OBJ===void 0?void 0:_utils.GLOBAL_OBJ.window)==='undefined'){return undefined;}var supportedPlatform=!(0,_utils.isWeb)()&&!(0,_utils.isMacOS)();if(supportedPlatform){if(_OptionalExpoFileSystem.OptionalExpoFileSystem){var filesystem=_OptionalExpoFileSystem.OptionalExpoFileSystem;if(filesystem.Paths&&filesystem.File){return{getItem:function getItem(key){return(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(){var file,stringContent,_t2;return _regenerator["default"].wrap(function(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.prev=0;file=new filesystem.File(filesystem.Paths.document,key);_context3.next=1;return file.text();case 1:stringContent=_context3.sent;return _context3.abrupt("return",stringContent);case 2:_context3.prev=2;_t2=_context3["catch"](0);return _context3.abrupt("return",null);case 3:case"end":return _context3.stop();}},_callee3,null,[[0,2]]);}))();},setItem:function setItem(key,value){return(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4(){var file;return _regenerator["default"].wrap(function(_context4){while(1)switch(_context4.prev=_context4.next){case 0:file=new filesystem.File(filesystem.Paths.document,key);_context4.next=1;return file.write(value);case 1:case"end":return _context4.stop();}},_callee4);}))();}};}}var legacyModule=_OptionalExpoFileSystemLegacy.OptionalExpoFileSystemLegacy||_OptionalExpoFileSystem.OptionalExpoFileSystem;try{if(legacyModule&&typeof legacyModule.readAsStringAsync==='function'){return buildLegacyStorage(legacyModule);}}catch(e){}}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.');};
|
|
2
2
|
//# sourceMappingURL=native-deps.js.map
|
package/dist/native-deps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-deps.js","names":["_OptionalAsyncStorage","require","_utils","_OptionalExpoApplication","_OptionalExpoDevice","_OptionalExpoFileSystem","_OptionalExpoLocalization","_OptionalReactNativeDeviceInfo","_OptionalReactNativeLocalize","_OptionalExpoFileSystemLegacy","_core","getDeviceType","deviceType","isMacOS","isWindows","isWeb","ua","navigator","userAgent","nav","undefined","win","globalThis","window","detectDeviceType","userAgentDataPlatform","_a","userAgentData","platform","maxTouchPoints","screenWidth","_b","screen","width","screenHeight","_c","height","devicePixelRatio","currentDeviceType","exports","getAppProperties","properties","$device_type","OptionalExpoApplication","$app_build","nativeBuildVersion","$app_name","applicationName","$app_namespace","applicationId","$app_version","nativeApplicationVersion","OptionalReactNativeDeviceInfo","returnPropertyIfNotUnknown","getBuildNumber","getApplicationName","getBundleId","getVersion","OptionalExpoDevice","$device_manufacturer","manufacturer","$device_name","modelName","getPlatformOS","$os_name","osName","$os_version","osVersion","$is_emulator","isDevice","getManufacturerSync","getModel","getSystemName","getSystemVersion","isEmulatorSync","OptionalExpoLocalization","optionalExpoLocalization","locale","getLocales","languageTag","$locale","timezone","getCalendars","timeZone","$timezone","OptionalReactNativeLocalize","localesFn","locales","length","timezoneFn","getTimeZone","value","buildLegacyStorage","filesystem","getItem","key","_asyncToGenerator2","_regenerator","mark","_callee","uri","stringContent","_t","wrap","_context","prev","next","documentDirectory","readAsStringAsync","sent","abrupt","stop","setItem","_callee2","_context2","writeAsStringAsync","buildOptimisticAsyncStorage","GLOBAL_OBJ","supportedPlatform","OptionalExpoFileSystem","Paths","File","_callee3","file","_t2","_context3","document","text","_callee4","_context4","write","legacyModule","OptionalExpoFileSystemLegacy","e","OptionalAsyncStorage","Error"],"sources":["../src/native-deps.tsx"],"sourcesContent":["import { OptionalAsyncStorage } from './optional/OptionalAsyncStorage'\nimport { GLOBAL_OBJ, getPlatformOS, isMacOS, isWeb, isWindows } from './utils'\nimport { OptionalExpoApplication } from './optional/OptionalExpoApplication'\nimport { OptionalExpoDevice } from './optional/OptionalExpoDevice'\nimport { OptionalExpoFileSystem } from './optional/OptionalExpoFileSystem'\nimport { OptionalExpoLocalization } from './optional/OptionalExpoLocalization'\nimport { OptionalReactNativeDeviceInfo } from './optional/OptionalReactNativeDeviceInfo'\nimport { PostHogCustomAppProperties, PostHogCustomStorage } from './types'\nimport { OptionalReactNativeLocalize } from './optional/OptionalReactNativeLocalize'\nimport { OptionalExpoFileSystemLegacy } from './optional/OptionalExpoFileSystemLegacy'\nimport { detectDeviceType } from '@posthog/core'\n\nconst getDeviceType = (): string => {\n let deviceType = 'Mobile'\n\n if (isMacOS() || isWindows()) {\n deviceType = 'Desktop'\n } else if (isWeb()) {\n // Check user agent to determine if it's desktop or mobile\n const ua = typeof navigator !== 'undefined' && navigator.userAgent ? navigator.userAgent : ''\n\n const nav = typeof navigator !== 'undefined' ? (navigator as any) : undefined\n const win = typeof (globalThis as any).window !== 'undefined' ? (globalThis as any).window : undefined\n deviceType = detectDeviceType(ua, {\n userAgentDataPlatform: nav?.userAgentData?.platform,\n maxTouchPoints: nav?.maxTouchPoints,\n screenWidth: win?.screen?.width,\n screenHeight: win?.screen?.height,\n devicePixelRatio: win?.devicePixelRatio,\n })\n }\n return deviceType\n}\n\nexport const currentDeviceType = getDeviceType()\n\nexport const getAppProperties = (): PostHogCustomAppProperties => {\n const properties: PostHogCustomAppProperties = {\n $device_type: currentDeviceType,\n }\n\n if (OptionalExpoApplication) {\n properties.$app_build = OptionalExpoApplication.nativeBuildVersion\n properties.$app_name = OptionalExpoApplication.applicationName\n properties.$app_namespace = OptionalExpoApplication.applicationId\n properties.$app_version = OptionalExpoApplication.nativeApplicationVersion\n } else if (OptionalReactNativeDeviceInfo) {\n properties.$app_build = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getBuildNumber())\n properties.$app_name = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getApplicationName())\n properties.$app_namespace = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getBundleId())\n properties.$app_version = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getVersion())\n }\n\n if (OptionalExpoDevice) {\n properties.$device_manufacturer = OptionalExpoDevice.manufacturer\n // expo-device already maps the device model identifier to a human readable name\n properties.$device_name = OptionalExpoDevice.modelName\n\n // https://github.com/expo/expo/issues/6990\n // some devices return a value similar to:\n // HUAWEI/SNE-LX1/HWSNE:8.1.0/HUAWEISNE-LX1/131(C432):user/release-keys\n if (getPlatformOS() === 'android') {\n properties.$os_name = 'Android'\n } else {\n properties.$os_name = OptionalExpoDevice.osName\n }\n\n properties.$os_version = OptionalExpoDevice.osVersion\n properties.$is_emulator = !OptionalExpoDevice.isDevice\n } else if (OptionalReactNativeDeviceInfo) {\n properties.$device_manufacturer = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getManufacturerSync())\n // react-native-device-info already maps the device model identifier to a human readable name\n properties.$device_name = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getModel())\n properties.$os_name = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getSystemName())\n properties.$os_version = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getSystemVersion())\n properties.$is_emulator = OptionalReactNativeDeviceInfo.isEmulatorSync()\n }\n\n if (OptionalExpoLocalization) {\n // expo-localization >= 14 use functions to get these results, older versions use JS getters\n // https://github.com/expo/expo/blob/sdk-54/packages/expo-localization/CHANGELOG.md#1400--2022-10-25\n // this type below supports both variants, and type-checks with older and newer versions of expo-localization\n const optionalExpoLocalization: {\n locale?: string\n getLocales?: () => {\n languageTag: string\n }[]\n timezone?: string\n getCalendars?: () => {\n timeZone: string | null\n }[]\n } = OptionalExpoLocalization\n\n let locale = optionalExpoLocalization.locale\n if (!locale && optionalExpoLocalization.getLocales) {\n locale = optionalExpoLocalization.getLocales()[0]?.languageTag\n }\n if (locale) {\n properties.$locale = locale\n }\n let timezone: string | undefined | null = optionalExpoLocalization.timezone\n if (!timezone && optionalExpoLocalization.getCalendars) {\n timezone = optionalExpoLocalization.getCalendars()[0]?.timeZone\n }\n if (timezone) {\n properties.$timezone = timezone\n }\n } else if (OptionalReactNativeLocalize) {\n const localesFn = OptionalReactNativeLocalize.getLocales\n if (localesFn) {\n const locales = localesFn()\n\n if (locales && locales.length > 0) {\n const languageTag = locales[0].languageTag\n if (languageTag) {\n properties.$locale = languageTag\n }\n }\n }\n\n const timezoneFn = OptionalReactNativeLocalize.getTimeZone\n if (timezoneFn) {\n const timezone = timezoneFn()\n\n if (timezone) {\n properties.$timezone = timezone\n }\n }\n }\n\n return properties\n}\n\n// react-native-device-info returns 'unknown' if the property is not available (Web target)\nconst returnPropertyIfNotUnknown = (value: string | null): string | null => {\n if (value !== 'unknown') {\n return value\n }\n return null\n}\n\nconst buildLegacyStorage = (filesystem: any): PostHogCustomStorage => {\n return {\n async getItem(key: string) {\n try {\n const uri = (filesystem.documentDirectory || '') + key\n const stringContent = await filesystem.readAsStringAsync(uri)\n return stringContent\n } catch (e) {\n return null\n }\n },\n\n async setItem(key: string, value: string) {\n const uri = (filesystem.documentDirectory || '') + key\n await filesystem.writeAsStringAsync(uri, value)\n },\n }\n}\n\nexport const buildOptimisticAsyncStorage = (): PostHogCustomStorage | undefined => {\n // On web platform during SSR (no window), skip file storage\n // The caller will fall back to memory storage\n if (isWeb() && typeof (GLOBAL_OBJ as any)?.window === 'undefined') {\n return undefined\n }\n\n // expo-file-system is not supported on web and macos, so we need to use the react-native-async-storage package instead\n // see https://github.com/PostHog/posthog-js-lite/blob/5fb7bee96f739b243dfea5589e2027f16629e8cd/posthog-react-native/src/optional/OptionalExpoFileSystem.ts#L7-L11\n const supportedPlatform = !isWeb() && !isMacOS()\n\n // expo-file-system is only supported on native platforms (not web/macOS).\n // See https://github.com/PostHog/posthog-js-lite/issues/140\n if (supportedPlatform) {\n // expo >= 54 and expo-file-system >= 19: prefer the new File/Paths API.\n // We always check for the new API first because:\n // - SDK 54 stable exports legacy methods (readAsStringAsync, writeAsStringAsync) that throw\n // a deprecation error when called, so existence checks alone are unreliable.\n // - SDK 55+ has a working legacy subpath, but the new API is the recommended approach.\n // See https://github.com/PostHog/posthog-js/issues/3151\n if (OptionalExpoFileSystem) {\n const filesystem = OptionalExpoFileSystem as any\n\n if (filesystem.Paths && filesystem.File) {\n return {\n async getItem(key: string) {\n try {\n // File constructor accepts Directory instances and joins path segments\n // See https://docs.expo.dev/versions/latest/sdk/filesystem/\n const file = new filesystem.File(filesystem.Paths.document, key)\n const stringContent = await file.text()\n return stringContent\n } catch (e) {\n return null\n }\n },\n\n async setItem(key: string, value: string) {\n const file = new filesystem.File(filesystem.Paths.document, key)\n await file.write(value)\n },\n }\n }\n }\n\n // Fallback to legacy APIs for older Expo versions (expo <= 53, expo-file-system <= 18).\n // Try the legacy subpath first (available in SDK 55+), then the main module.\n // We validate that readAsStringAsync is a real function before using it,\n // to avoid calling deprecated stubs that throw at runtime (SDK 54 stable).\n const legacyModule = (OptionalExpoFileSystemLegacy || OptionalExpoFileSystem) as any\n try {\n if (legacyModule && typeof legacyModule.readAsStringAsync === 'function') {\n return buildLegacyStorage(legacyModule)\n }\n } catch (e) {}\n }\n\n if (OptionalAsyncStorage) {\n return OptionalAsyncStorage\n }\n\n throw new Error(\n 'PostHog: No storage available. Please install expo-file-system or react-native-async-storage OR implement a custom storage provider.'\n )\n}\n"],"mappings":"waAAA,IAAAA,qBAAA,CAAAC,OAAA,oCACA,IAAAC,MAAA,CAAAD,OAAA,YACA,IAAAE,wBAAA,CAAAF,OAAA,uCACA,IAAAG,mBAAA,CAAAH,OAAA,kCACA,IAAAI,uBAAA,CAAAJ,OAAA,sCACA,IAAAK,yBAAA,CAAAL,OAAA,wCACA,IAAAM,8BAAA,CAAAN,OAAA,6CAEA,IAAAO,4BAAA,CAAAP,OAAA,2CACA,IAAAQ,6BAAA,CAAAR,OAAA,4CACA,IAAAS,KAAA,CAAAT,OAAA,kBAEA,GAAM,CAAAU,aAAa,CAAG,QAAhB,CAAAA,aAAaA,CAAA,CAAgB,C,aACjC,GAAI,CAAAC,UAAU,CAAG,QAAQ,CAEzB,GAAI,GAAAC,cAAO,GAAE,EAAI,GAAAC,gBAAS,GAAE,CAAE,CAC5BF,UAAU,CAAG,SAAS,CACxB,CAAC,IAAM,IAAI,GAAAG,YAAK,GAAE,CAAE,CAElB,GAAM,CA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AEA,KAAM,IAAI,CAAAC,KAAK,CACb,sIAAsI,CACvI,CACH,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"native-deps.js","names":["_OptionalAsyncStorage","require","_utils","_OptionalExpoApplication","_OptionalExpoDevice","_OptionalExpoFileSystem","_OptionalExpoLocalization","_OptionalReactNativeDeviceInfo","_OptionalReactNativeLocalize","_OptionalExpoFileSystemLegacy","_core","_reactNative","getDeviceType","deviceType","isMacOS","isWindows","isWeb","ua","navigator","userAgent","nav","undefined","win","globalThis","window","detectDeviceType","userAgentDataPlatform","_a","userAgentData","platform","maxTouchPoints","screenWidth","_b","screen","width","screenHeight","_c","height","devicePixelRatio","currentDeviceType","exports","getAppProperties","properties","$device_type","OptionalExpoApplication","$app_build","nativeBuildVersion","$app_name","applicationName","$app_namespace","applicationId","$app_version","nativeApplicationVersion","OptionalReactNativeDeviceInfo","returnPropertyIfNotUnknown","getBuildNumber","getApplicationName","getBundleId","getVersion","OptionalExpoDevice","$device_manufacturer","manufacturer","$device_name","modelName","getPlatformOS","$os_name","osName","$os_version","osVersion","$is_emulator","isDevice","getManufacturerSync","getModel","getSystemName","getSystemVersion","isEmulatorSync","_extends2","getPlatformOSProperties","OptionalExpoLocalization","optionalExpoLocalization","locale","getLocales","languageTag","$locale","timezone","getCalendars","timeZone","$timezone","OptionalReactNativeLocalize","localesFn","locales","length","timezoneFn","getTimeZone","os","constants","Platform","version","Version","String","Release","systemName","value","buildLegacyStorage","filesystem","getItem","key","_asyncToGenerator2","_regenerator","mark","_callee","uri","stringContent","_t","wrap","_context","prev","next","documentDirectory","readAsStringAsync","sent","abrupt","stop","setItem","_callee2","_context2","writeAsStringAsync","buildOptimisticAsyncStorage","GLOBAL_OBJ","supportedPlatform","OptionalExpoFileSystem","Paths","File","_callee3","file","_t2","_context3","document","text","_callee4","_context4","write","legacyModule","OptionalExpoFileSystemLegacy","e","OptionalAsyncStorage","Error"],"sources":["../src/native-deps.tsx"],"sourcesContent":["import { OptionalAsyncStorage } from './optional/OptionalAsyncStorage'\nimport { GLOBAL_OBJ, getPlatformOS, isMacOS, isWeb, isWindows } from './utils'\nimport { OptionalExpoApplication } from './optional/OptionalExpoApplication'\nimport { OptionalExpoDevice } from './optional/OptionalExpoDevice'\nimport { OptionalExpoFileSystem } from './optional/OptionalExpoFileSystem'\nimport { OptionalExpoLocalization } from './optional/OptionalExpoLocalization'\nimport { OptionalReactNativeDeviceInfo } from './optional/OptionalReactNativeDeviceInfo'\nimport { PostHogCustomAppProperties, PostHogCustomStorage } from './types'\nimport { OptionalReactNativeLocalize } from './optional/OptionalReactNativeLocalize'\nimport { OptionalExpoFileSystemLegacy } from './optional/OptionalExpoFileSystemLegacy'\nimport { detectDeviceType } from '@posthog/core'\nimport { Platform } from 'react-native'\n\nconst getDeviceType = (): string => {\n let deviceType = 'Mobile'\n\n if (isMacOS() || isWindows()) {\n deviceType = 'Desktop'\n } else if (isWeb()) {\n // Check user agent to determine if it's desktop or mobile\n const ua = typeof navigator !== 'undefined' && navigator.userAgent ? navigator.userAgent : ''\n\n const nav = typeof navigator !== 'undefined' ? (navigator as any) : undefined\n const win = typeof (globalThis as any).window !== 'undefined' ? (globalThis as any).window : undefined\n deviceType = detectDeviceType(ua, {\n userAgentDataPlatform: nav?.userAgentData?.platform,\n maxTouchPoints: nav?.maxTouchPoints,\n screenWidth: win?.screen?.width,\n screenHeight: win?.screen?.height,\n devicePixelRatio: win?.devicePixelRatio,\n })\n }\n return deviceType\n}\n\nexport const currentDeviceType = getDeviceType()\n\nexport const getAppProperties = (): PostHogCustomAppProperties => {\n const properties: PostHogCustomAppProperties = {\n $device_type: currentDeviceType,\n }\n\n if (OptionalExpoApplication) {\n properties.$app_build = OptionalExpoApplication.nativeBuildVersion\n properties.$app_name = OptionalExpoApplication.applicationName\n properties.$app_namespace = OptionalExpoApplication.applicationId\n properties.$app_version = OptionalExpoApplication.nativeApplicationVersion\n } else if (OptionalReactNativeDeviceInfo) {\n properties.$app_build = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getBuildNumber())\n properties.$app_name = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getApplicationName())\n properties.$app_namespace = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getBundleId())\n properties.$app_version = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getVersion())\n }\n\n if (OptionalExpoDevice) {\n properties.$device_manufacturer = OptionalExpoDevice.manufacturer\n // expo-device already maps the device model identifier to a human readable name\n properties.$device_name = OptionalExpoDevice.modelName\n\n // https://github.com/expo/expo/issues/6990\n // some devices return a value similar to:\n // HUAWEI/SNE-LX1/HWSNE:8.1.0/HUAWEISNE-LX1/131(C432):user/release-keys\n if (getPlatformOS() === 'android') {\n properties.$os_name = 'Android'\n } else {\n properties.$os_name = OptionalExpoDevice.osName\n }\n\n properties.$os_version = OptionalExpoDevice.osVersion\n properties.$is_emulator = !OptionalExpoDevice.isDevice\n } else if (OptionalReactNativeDeviceInfo) {\n properties.$device_manufacturer = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getManufacturerSync())\n // react-native-device-info already maps the device model identifier to a human readable name\n properties.$device_name = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getModel())\n properties.$os_name = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getSystemName())\n properties.$os_version = returnPropertyIfNotUnknown(OptionalReactNativeDeviceInfo.getSystemVersion())\n properties.$is_emulator = OptionalReactNativeDeviceInfo.isEmulatorSync()\n }\n\n if (!properties.$os_name) {\n Object.assign(properties, getPlatformOSProperties())\n }\n\n if (OptionalExpoLocalization) {\n // expo-localization >= 14 use functions to get these results, older versions use JS getters\n // https://github.com/expo/expo/blob/sdk-54/packages/expo-localization/CHANGELOG.md#1400--2022-10-25\n // this type below supports both variants, and type-checks with older and newer versions of expo-localization\n const optionalExpoLocalization: {\n locale?: string\n getLocales?: () => {\n languageTag: string\n }[]\n timezone?: string\n getCalendars?: () => {\n timeZone: string | null\n }[]\n } = OptionalExpoLocalization\n\n let locale = optionalExpoLocalization.locale\n if (!locale && optionalExpoLocalization.getLocales) {\n locale = optionalExpoLocalization.getLocales()[0]?.languageTag\n }\n if (locale) {\n properties.$locale = locale\n }\n let timezone: string | undefined | null = optionalExpoLocalization.timezone\n if (!timezone && optionalExpoLocalization.getCalendars) {\n timezone = optionalExpoLocalization.getCalendars()[0]?.timeZone\n }\n if (timezone) {\n properties.$timezone = timezone\n }\n } else if (OptionalReactNativeLocalize) {\n const localesFn = OptionalReactNativeLocalize.getLocales\n if (localesFn) {\n const locales = localesFn()\n\n if (locales && locales.length > 0) {\n const languageTag = locales[0].languageTag\n if (languageTag) {\n properties.$locale = languageTag\n }\n }\n }\n\n const timezoneFn = OptionalReactNativeLocalize.getTimeZone\n if (timezoneFn) {\n const timezone = timezoneFn()\n\n if (timezone) {\n properties.$timezone = timezone\n }\n }\n }\n\n return properties\n}\n\ntype PlatformConstants = { Release?: string; systemName?: string }\n\n// Reads the OS from React Native's own Platform module, matching what posthog-android and posthog-ios report.\nconst getPlatformOSProperties = (): Pick<PostHogCustomAppProperties, '$os_name' | '$os_version'> => {\n try {\n const os = getPlatformOS()\n const constants = (Platform as { constants?: PlatformConstants }).constants\n const version = Platform.Version !== undefined ? String(Platform.Version) : undefined\n if (os === 'android') {\n // Platform.Version is the API level on Android; Release is the user-facing OS version\n return { $os_name: 'Android', $os_version: constants?.Release ?? version }\n }\n if (os === 'ios') {\n return { $os_name: constants?.systemName ?? 'iOS', $os_version: version }\n }\n } catch {}\n return {}\n}\n\n// react-native-device-info returns 'unknown' if the property is not available (Web target)\nconst returnPropertyIfNotUnknown = (value: string | null): string | null => {\n if (value !== 'unknown') {\n return value\n }\n return null\n}\n\nconst buildLegacyStorage = (filesystem: any): PostHogCustomStorage => {\n return {\n async getItem(key: string) {\n try {\n const uri = (filesystem.documentDirectory || '') + key\n const stringContent = await filesystem.readAsStringAsync(uri)\n return stringContent\n } catch (e) {\n return null\n }\n },\n\n async setItem(key: string, value: string) {\n const uri = (filesystem.documentDirectory || '') + key\n await filesystem.writeAsStringAsync(uri, value)\n },\n }\n}\n\nexport const buildOptimisticAsyncStorage = (): PostHogCustomStorage | undefined => {\n // On web platform during SSR (no window), skip file storage\n // The caller will fall back to memory storage\n if (isWeb() && typeof (GLOBAL_OBJ as any)?.window === 'undefined') {\n return undefined\n }\n\n // expo-file-system is not supported on web and macos, so we need to use the react-native-async-storage package instead\n // see https://github.com/PostHog/posthog-js-lite/blob/5fb7bee96f739b243dfea5589e2027f16629e8cd/posthog-react-native/src/optional/OptionalExpoFileSystem.ts#L7-L11\n const supportedPlatform = !isWeb() && !isMacOS()\n\n // expo-file-system is only supported on native platforms (not web/macOS).\n // See https://github.com/PostHog/posthog-js-lite/issues/140\n if (supportedPlatform) {\n // expo >= 54 and expo-file-system >= 19: prefer the new File/Paths API.\n // We always check for the new API first because:\n // - SDK 54 stable exports legacy methods (readAsStringAsync, writeAsStringAsync) that throw\n // a deprecation error when called, so existence checks alone are unreliable.\n // - SDK 55+ has a working legacy subpath, but the new API is the recommended approach.\n // See https://github.com/PostHog/posthog-js/issues/3151\n if (OptionalExpoFileSystem) {\n const filesystem = OptionalExpoFileSystem as any\n\n if (filesystem.Paths && filesystem.File) {\n return {\n async getItem(key: string) {\n try {\n // File constructor accepts Directory instances and joins path segments\n // See https://docs.expo.dev/versions/latest/sdk/filesystem/\n const file = new filesystem.File(filesystem.Paths.document, key)\n const stringContent = await file.text()\n return stringContent\n } catch (e) {\n return null\n }\n },\n\n async setItem(key: string, value: string) {\n const file = new filesystem.File(filesystem.Paths.document, key)\n await file.write(value)\n },\n }\n }\n }\n\n // Fallback to legacy APIs for older Expo versions (expo <= 53, expo-file-system <= 18).\n // Try the legacy subpath first (available in SDK 55+), then the main module.\n // We validate that readAsStringAsync is a real function before using it,\n // to avoid calling deprecated stubs that throw at runtime (SDK 54 stable).\n const legacyModule = (OptionalExpoFileSystemLegacy || OptionalExpoFileSystem) as any\n try {\n if (legacyModule && typeof legacyModule.readAsStringAsync === 'function') {\n return buildLegacyStorage(legacyModule)\n }\n } catch (e) {}\n }\n\n if (OptionalAsyncStorage) {\n return OptionalAsyncStorage\n }\n\n throw new Error(\n 'PostHog: No storage available. Please install expo-file-system or react-native-async-storage OR implement a custom storage provider.'\n )\n}\n"],"mappings":"wfAAA,IAAAA,qBAAA,CAAAC,OAAA,oCACA,IAAAC,MAAA,CAAAD,OAAA,YACA,IAAAE,wBAAA,CAAAF,OAAA,uCACA,IAAAG,mBAAA,CAAAH,OAAA,kCACA,IAAAI,uBAAA,CAAAJ,OAAA,sCACA,IAAAK,yBAAA,CAAAL,OAAA,wCACA,IAAAM,8BAAA,CAAAN,OAAA,6CAEA,IAAAO,4BAAA,CAAAP,OAAA,2CACA,IAAAQ,6BAAA,CAAAR,OAAA,4CACA,IAAAS,KAAA,CAAAT,OAAA,kBACA,IAAAU,YAAA,CAAAV,OAAA,iBAEA,GAAM,CAAAW,aAAa,CAAG,QAAhB,CAAAA,aAAaA,CAAA,CAAgB,C,aACjC,GAAI,CAAAC,UAAU,CAAG,QAAQ,CAEzB,GAAI,GAAAC,cAAO,GAAE,EAAI,GAAAC,gBAAS,GAAE,CAAE,CAC5BF,UAAU,CAAG,SAAS,CACxB,CAAC,IAAM,IAAI,GAAAG,YAAK,GAAE,CAAE,CAElB,GAAM,CAAAC,EAAE,CAAG,MAAO,CAAAC,SAAS,GAAK,WAAW,EAAIA,SAAS,CAACC,SAAS,CAAGD,SAAS,CAACC,SAAS,CAAG,EAAE,CAE7F,GAAM,CAAAC,GAAG,CAAG,MAAO,CAAAF,SAAS,GAAK,WAAW,CAAIA,SAAiB,CAAGG,SAAS,CAC7E,GAAM,CAAAC,GAAG,CAAG,MAAQ,CAAAC,UAAkB,CAACC,MAAM,GAAK,WAAW,CAAID,UAAkB,CAACC,MAAM,CAAGH,SAAS,CACtGR,UAAU,CAAG,GAAAY,sBAAgB,EAACR,EAAE,CAAE,CAChCS,qBAAqB,CAAE,CAA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4B,IAAI,CAAC5B,UAAU,CAAC2B,KAAK,CAACM,QAAQ,CAAE/B,GAAG,CAACkC,CAAA,UAAAvB,IAAA,SAC1D,CAAAiB,IAAI,CAACO,KAAK,CAACvC,KAAK,CAAC,yBAAAsC,SAAA,CAAAlB,IAAA,MAAAiB,QAAA,QACzB,C,CACD,CACH,CACF,CAMA,GAAM,CAAAG,YAAY,CAAIC,0DAA4B,EAAIb,8CAA8B,CACpF,GAAI,CACF,GAAIY,YAAY,EAAI,MAAO,CAAAA,YAAY,CAACvB,iBAAiB,GAAK,UAAU,CAAE,CACxE,MAAO,CAAAhB,kBAAkB,CAACuC,YAAY,CAAC,CACzC,CACF,CAAE,MAAOE,CAAC,CAAE,CAAC,CACf,CAEA,GAAIC,0CAAoB,CAAE,CACxB,MAAO,CAAAA,0CAAoB,CAC7B,CAEA,KAAM,IAAI,CAAAC,KAAK,CACb,sIAAsI,CACvI,CACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.OptionalReactNativeExceptionsManager=void 0;var _reactNative=require("react-native");var _a;var OptionalReactNativeExceptionsManager;if(_reactNative.Platform.OS!=='web'){try{var exceptionsManager=require('react-native/Libraries/Core/ExceptionsManager');exports.OptionalReactNativeExceptionsManager=OptionalReactNativeExceptionsManager=(_a=exceptionsManager===null||exceptionsManager===void 0?void 0:exceptionsManager["default"])!==null&&_a!==void 0?_a:exceptionsManager;}catch(_b){}}
|
|
2
|
+
//# sourceMappingURL=OptionalReactNativeExceptionsManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OptionalReactNativeExceptionsManager.js","names":["_reactNative","require","OptionalReactNativeExceptionsManager","Platform","OS","exceptionsManager","exports","_a"],"sources":["../../src/optional/OptionalReactNativeExceptionsManager.ts"],"sourcesContent":["import { Platform } from 'react-native'\n\n// React Native's internal exception reporter. React 19's root `onUncaughtError` and\n// `onCaughtError` callbacks report through `handleException` without going through ErrorUtils.\n// Callers read `handleException` off this object at call time, so it can be wrapped in place.\nexport type ReactNativeExceptionsManager = {\n handleException?: (error: unknown, isFatal: boolean) => void\n}\n\nexport let OptionalReactNativeExceptionsManager: ReactNativeExceptionsManager | undefined\n\nif (Platform.OS !== 'web') {\n try {\n // Metro recognizes optional dependencies only when require is directly inside the try block.\n const exceptionsManager = require('react-native/Libraries/Core/ExceptionsManager')\n // CommonJS `module.exports` up to RN 0.78, an ES default export from 0.79.\n OptionalReactNativeExceptionsManager = exceptionsManager?.default ?? exceptionsManager\n } catch {}\n}\n"],"mappings":"0HAAA,IAAAA,YAAA,CAAAC,OAAA,iB,OASO,GAAI,CAAAC,oCAA8E,CAEzF,GAAIC,qBAAQ,CAACC,EAAE,GAAK,KAAK,CAAE,CACzB,GAAI,CAEF,GAAM,CAAAC,iBAAiB,CAAGJ,OAAO,CAAC,+CAA+C,CAAC,CAElFK,OAAA,CAAAJ,oCAAA,CAAAA,oCAAoC,EAAAK,EAAA,CAAGF,iBAAiB,SAAjBA,iBAAiB,iBAAjBA,iBAAiB,WAAS,UAAAE,EAAA,UAAAA,EAAA,CAAIF,iBAAiB,CACxF,C,SAAQ,CAAC,CACX","ignoreList":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.OptionalReactNativeExceptionsManager=void 0;var OptionalReactNativeExceptionsManager=exports.OptionalReactNativeExceptionsManager=undefined;
|
|
2
|
+
//# sourceMappingURL=OptionalReactNativeExceptionsManager.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OptionalReactNativeExceptionsManager.web.js","names":["OptionalReactNativeExceptionsManager","exports","undefined"],"sources":["../../src/optional/OptionalReactNativeExceptionsManager.web.ts"],"sourcesContent":["import type { ReactNativeExceptionsManager } from './OptionalReactNativeExceptionsManager'\n\n// Web bundles resolve this file instead, so React Native's ExceptionsManager and its native-only\n// imports stay out of the web dependency graph.\nexport const OptionalReactNativeExceptionsManager: ReactNativeExceptionsManager | undefined = undefined\n"],"mappings":"0HAIO,GAAM,CAAAA,oCAAoC,CAAAC,OAAA,CAAAD,oCAAA,CAA6CE,SAAS","ignoreList":[]}
|
package/dist/posthog-rn.d.ts
CHANGED
|
@@ -911,6 +911,9 @@ export declare class PostHog extends PostHogCore {
|
|
|
911
911
|
*/
|
|
912
912
|
screen(name: string, properties?: PostHogEventProperties, options?: PostHogCaptureOptions): Promise<void>;
|
|
913
913
|
_isEnableSessionReplay(): boolean;
|
|
914
|
+
private _isNativeSessionOwner;
|
|
915
|
+
private _isSameProjectAs;
|
|
916
|
+
private _canTakeOverNativeSession;
|
|
914
917
|
_resetSessionId(reactNativeSessionReplay: typeof OptionalReactNativePlugin | undefined, sessionId: string): void;
|
|
915
918
|
getSessionId(): string;
|
|
916
919
|
resetSessionId(): void;
|