posthog-react-native 4.83.0 → 4.84.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PostHogProvider.d.ts +9 -3
- package/dist/PostHogProvider.js +1 -1
- package/dist/PostHogProvider.js.map +1 -1
- package/dist/posthog-rn.d.ts +9 -3
- package/dist/posthog-rn.js +1 -1
- package/dist/posthog-rn.js.map +1 -1
- package/dist/surveys/survey-progress.js +1 -1
- package/dist/surveys/survey-progress.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 +5 -5
|
@@ -16,6 +16,12 @@ export interface PostHogProviderProps {
|
|
|
16
16
|
* Your PostHog project token, which starts with `phc_`. Find it in your project settings:
|
|
17
17
|
* https://us.posthog.com/settings/project-details#variables
|
|
18
18
|
*/
|
|
19
|
+
projectToken?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Your PostHog project token. Ignored when `projectToken` is set.
|
|
22
|
+
*
|
|
23
|
+
* @deprecated Use `projectToken` instead. This will be removed in the next major version.
|
|
24
|
+
*/
|
|
19
25
|
apiKey?: string;
|
|
20
26
|
/** An existing PostHog client instance */
|
|
21
27
|
client?: PostHog;
|
|
@@ -57,7 +63,7 @@ export interface PostHogProviderProps {
|
|
|
57
63
|
*
|
|
58
64
|
* export function MyApp() {
|
|
59
65
|
* return (
|
|
60
|
-
* <PostHogProvider
|
|
66
|
+
* <PostHogProvider projectToken="<ph_project_token>" options={{
|
|
61
67
|
* host: '<ph_client_api_host>',
|
|
62
68
|
* }}>
|
|
63
69
|
* <MyComponent />
|
|
@@ -83,7 +89,7 @@ export interface PostHogProviderProps {
|
|
|
83
89
|
* // Using with existing client
|
|
84
90
|
* import { PostHog } from 'posthog-react-native'
|
|
85
91
|
*
|
|
86
|
-
* const posthog = new PostHog('<
|
|
92
|
+
* const posthog = new PostHog('<ph_project_token>', {
|
|
87
93
|
* host: '<ph_client_api_host>'
|
|
88
94
|
* })
|
|
89
95
|
*
|
|
@@ -100,4 +106,4 @@ export interface PostHogProviderProps {
|
|
|
100
106
|
*
|
|
101
107
|
* @param props - The PostHogProvider props
|
|
102
108
|
*/
|
|
103
|
-
export declare const PostHogProvider: ({ children, client, options, apiKey, autocapture, style, debug, }: PostHogProviderProps) => JSX.Element | null;
|
|
109
|
+
export declare const PostHogProvider: ({ children, client, options, projectToken, apiKey, autocapture, style, debug, }: PostHogProviderProps) => JSX.Element | null;
|
package/dist/PostHogProvider.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports.PostHogProvider=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _posthogRn=require("./posthog-rn");var _autocapture=require("./autocapture");var _useNavigationTracker=require("./hooks/useNavigationTracker");var _PostHogContext=require("./PostHogContext");var _utils=require("./utils");var _jsxRuntime=require("react/jsx-runtime");var _this=void 0,_jsxFileName="/home/runner/work/posthog-js/posthog-js/packages/react-native/dist/PostHogProvider.js";function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap(),n=new WeakMap();return(_interopRequireWildcard=function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,"default":e};if(null===e||"object"!=_typeof(e)&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f);}for(var _t2 in e)"default"!==_t2&&{}.hasOwnProperty.call(e,_t2)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,_t2))&&(i.get||i.set)?o(f,_t2,i):f[_t2]=e[_t2]);return f;})(e,t);}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){(0,_defineProperty2["default"])(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}var webClickListeners=new WeakMap();function PostHogNavigationHook(_ref){var options=_ref.options,client=_ref.client;(0,_useNavigationTracker.useNavigationTracker)(options===null||options===void 0?void 0:options.navigation,options===null||options===void 0?void 0:options.navigationRef,client);return null;}var PostHogProvider=exports.PostHogProvider=function PostHogProvider(_ref2){var children=_ref2.children,client=_ref2.client,options=_ref2.options,apiKey=_ref2.apiKey,autocapture=_ref2.autocapture,style=_ref2.style,_ref2$debug=_ref2.debug,debug=_ref2$debug===void 0?false:_ref2$debug;var _a;var captureAll=autocapture===true;var captureNone=autocapture===false;var posthog=(0,_react.useMemo)(function(){if(client&&
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports.PostHogProvider=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _posthogRn=require("./posthog-rn");var _autocapture=require("./autocapture");var _useNavigationTracker=require("./hooks/useNavigationTracker");var _PostHogContext=require("./PostHogContext");var _utils=require("./utils");var _jsxRuntime=require("react/jsx-runtime");var _this=void 0,_jsxFileName="/home/runner/work/posthog-js/posthog-js/packages/react-native/dist/PostHogProvider.js";function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap(),n=new WeakMap();return(_interopRequireWildcard=function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,"default":e};if(null===e||"object"!=_typeof(e)&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f);}for(var _t2 in e)"default"!==_t2&&{}.hasOwnProperty.call(e,_t2)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,_t2))&&(i.get||i.set)?o(f,_t2,i):f[_t2]=e[_t2]);return f;})(e,t);}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){(0,_defineProperty2["default"])(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}var webClickListeners=new WeakMap();function PostHogNavigationHook(_ref){var options=_ref.options,client=_ref.client;(0,_useNavigationTracker.useNavigationTracker)(options===null||options===void 0?void 0:options.navigation,options===null||options===void 0?void 0:options.navigationRef,client);return null;}var PostHogProvider=exports.PostHogProvider=function PostHogProvider(_ref2){var children=_ref2.children,client=_ref2.client,options=_ref2.options,projectToken=_ref2.projectToken,apiKey=_ref2.apiKey,autocapture=_ref2.autocapture,style=_ref2.style,_ref2$debug=_ref2.debug,debug=_ref2$debug===void 0?false:_ref2$debug;var _a;var captureAll=autocapture===true;var captureNone=autocapture===false;var token=projectToken!==null&&projectToken!==void 0?projectToken:apiKey;var posthog=(0,_react.useMemo)(function(){if(client&&token){console.warn('You have provided both a client and a projectToken to PostHogProvider. The projectToken will be ignored in favour of the client.');}if(client){return client;}var parsedOptions=_objectSpread(_objectSpread({},options),{},{captureAppLifecycleEvents:(options===null||options===void 0?void 0:options.captureAppLifecycleEvents)!==undefined?options.captureAppLifecycleEvents:!captureNone});return new _posthogRn.PostHog(token!==null&&token!==void 0?token:'',parsedOptions);},[client,token]);var autocaptureOptions=(0,_react.useMemo)(function(){return autocapture&&typeof autocapture!=='boolean'?autocapture:{};},[autocapture]);var captureTouches=!captureNone&&posthog&&(captureAll||(autocaptureOptions===null||autocaptureOptions===void 0?void 0:autocaptureOptions.captureTouches));var captureScreens=!captureNone&&posthog&&(captureAll||((_a=autocaptureOptions===null||autocaptureOptions===void 0?void 0:autocaptureOptions.captureScreens)!==null&&_a!==void 0?_a:true));var phLabelProp=(autocaptureOptions===null||autocaptureOptions===void 0?void 0:autocaptureOptions.customLabelProp)||_autocapture.defaultPostHogLabelProp;(0,_react.useEffect)(function(){posthog.debug(debug);},[debug,posthog]);var onTouch=(0,_react.useCallback)(function(type,e){if(!captureTouches){return;}if(type==='end'){(0,_autocapture.autocaptureFromTouchEvent)(e,posthog,autocaptureOptions);}},[captureTouches,posthog,autocaptureOptions]);var hostRef=(0,_react.useRef)(null);var optionsRef=(0,_react.useRef)(autocaptureOptions);(0,_react.useEffect)(function(){optionsRef.current=autocaptureOptions;},[autocaptureOptions]);(0,_react.useEffect)(function(){var doc=globalThis===null||globalThis===void 0?void 0:globalThis.document;if(!(0,_utils.isWeb)()||!captureTouches||!(doc===null||doc===void 0?void 0:doc.addEventListener)){return;}var ownerNode=hostRef.current;if(!ownerNode){return;}var existing=webClickListeners.get(posthog);if(existing){existing.owners.set(ownerNode,optionsRef);}else{var owners=new Map([[ownerNode,optionsRef]]);var handler=function handler(e){var _a;var owner=(0,_autocapture.findOwningNode)(e,owners);if(!owner){return;}var options=(_a=owners.get(owner))===null||_a===void 0?void 0:_a.current;if(!options){return;}(0,_autocapture.autocaptureFromTouchEvent)({target:e.target,nativeEvent:e},posthog,options,'click');};doc.addEventListener('click',handler,true);webClickListeners.set(posthog,{owners:owners,remove:function remove(){return doc.removeEventListener('click',handler,true);}});}return function(){var entry=webClickListeners.get(posthog);if(!entry){return;}entry.owners["delete"](ownerNode);if(entry.owners.size===0){entry.remove();webClickListeners["delete"](posthog);}};},[captureTouches,posthog]);var captureProps=(0,_utils.isWeb)()?{}:{onTouchEndCapture:captureTouches?function(e){return onTouch('end',e);}:undefined};return(0,_jsxRuntime.jsx)(_reactNative.View,_objectSpread(_objectSpread(_objectSpread({ref:hostRef},(0,_defineProperty2["default"])({},phLabelProp,'PostHogProvider')),{},{style:style||{flex:1}},captureProps),{},{children:(0,_jsxRuntime.jsxs)(_PostHogContext.PostHogContext.Provider,{value:{client:posthog},children:[captureScreens&&(0,_jsxRuntime.jsx)(PostHogNavigationHook,{options:autocaptureOptions,client:posthog}),children]})}));};
|
|
2
2
|
//# sourceMappingURL=PostHogProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostHogProvider.js","names":["_react","_interopRequireWildcard","require","_reactNative","_posthogRn","_autocapture","_useNavigationTracker","_PostHogContext","_utils","_jsxRuntime","_this","_jsxFileName","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t2","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","webClickListeners","PostHogNavigationHook","_ref","options","client","useNavigationTracker","navigation","navigationRef","PostHogProvider","exports","_ref2","children","apiKey","autocapture","style","_ref2$debug","debug","captureAll","captureNone","posthog","useMemo","console","warn","parsedOptions","captureAppLifecycleEvents","undefined","PostHog","autocaptureOptions","captureTouches","captureScreens","_a","phLabelProp","customLabelProp","defaultPostHogLabelProp","useEffect","onTouch","useCallback","type","autocaptureFromTouchEvent","hostRef","useRef","optionsRef","current","doc","globalThis","document","isWeb","addEventListener","ownerNode","existing","owners","Map","handler","owner","findOwningNode","target","nativeEvent","remove","removeEventListener","entry","size","captureProps","onTouchEndCapture","jsx","View","ref","flex","jsxs","PostHogContext","Provider","value"],"sources":["../src/PostHogProvider.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef } from 'react'\nimport { GestureResponderEvent, StyleProp, View, ViewStyle } from 'react-native'\nimport { PostHog, PostHogOptions } from './posthog-rn'\nimport { autocaptureFromTouchEvent, findOwningNode } from './autocapture'\nimport { useNavigationTracker } from './hooks/useNavigationTracker'\nimport { PostHogContext } from './PostHogContext'\nimport { PostHogAutocaptureOptions } from './types'\nimport { isWeb } from './utils'\nimport { defaultPostHogLabelProp } from './autocapture'\n\n/**\n * Props for the PostHogProvider component.\n *\n * @public\n */\nexport interface PostHogProviderProps {\n /** The child components to render within the PostHog context */\n children: React.ReactNode\n /** PostHog configuration options */\n options?: PostHogOptions\n /**\n * Your PostHog project token, which starts with `phc_`. Find it in your project settings:\n * https://us.posthog.com/settings/project-details#variables\n */\n apiKey?: string\n /** An existing PostHog client instance */\n client?: PostHog\n /**\n * Autocapture configuration - can be a boolean or detailed options.\n *\n * When not set, the default behavior is:\n * - `captureScreens`: true\n * - `captureTouches`: false\n * - `captureAppLifecycleEvents`: true\n *\n * Set to `true` to enable all autocapture features (including touches).\n * Set to `false` to disable all autocapture features.\n */\n autocapture?: boolean | PostHogAutocaptureOptions\n /**\n * Enable debug mode for additional logging\n *\n * @default false\n */\n debug?: boolean\n /** Custom styles for the provider wrapper View */\n style?: StyleProp<ViewStyle>\n}\n\n// One document click listener per client, shared across sibling providers, so one interaction\n// enqueues exactly one $autocapture event (sdk-specs autocapture). `owners` maps each mounted\n// provider's host node to its own options, so a click is scoped to the owning subtree AND\n// captured with that provider's config; its size doubles as the refcount.\ntype WebClickOwners = Map<unknown, React.MutableRefObject<PostHogAutocaptureOptions>>\nconst webClickListeners = new WeakMap<PostHog, { owners: WebClickOwners; remove: () => void }>()\n\nfunction PostHogNavigationHook({\n options,\n client,\n}: {\n options?: PostHogAutocaptureOptions\n client?: PostHog\n}): JSX.Element | null {\n useNavigationTracker(options?.navigation, options?.navigationRef, client)\n return null\n}\n\n/**\n * PostHogProvider is a React component that provides PostHog functionality to your React Native app. You can find all configuration options in the [React Native SDK docs](https://posthog.com/docs/libraries/react-native#configuration-options).\n *\n * Autocapturing navigation requires further configuration. See the [React Native SDK navigation docs](https://posthog.com/docs/libraries/react-native#capturing-screen-views)\n * for more information about autocapturing navigation.\n *\n * This is the recommended way to set up PostHog for React Native. This utilizes the Context API to pass the PostHog client around, enable autocapture.\n *\n * {@label Initialization}\n *\n * @example\n * ```jsx\n * // Add to App.(js|ts)\n * import { usePostHog, PostHogProvider } from 'posthog-react-native'\n *\n * export function MyApp() {\n * return (\n * <PostHogProvider apiKey=\"<ph_project_api_key>\" options={{\n * host: '<ph_client_api_host>',\n * }}>\n * <MyComponent />\n * </PostHogProvider>\n * )\n * }\n *\n * // And access the PostHog client via the usePostHog hook\n * import { usePostHog } from 'posthog-react-native'\n *\n * const MyComponent = () => {\n * const posthog = usePostHog()\n *\n * useEffect(() => {\n * posthog.capture(\"event_name\")\n * }, [posthog])\n * }\n *\n * ```\n *\n * @example\n * ```jsx\n * // Using with existing client\n * import { PostHog } from 'posthog-react-native'\n *\n * const posthog = new PostHog('<ph_project_api_key>', {\n * host: '<ph_client_api_host>'\n * })\n *\n * export function MyApp() {\n * return (\n * <PostHogProvider client={posthog}>\n * <MyComponent />\n * </PostHogProvider>\n * )\n * }\n * ```\n *\n * @public\n *\n * @param props - The PostHogProvider props\n */\nexport const PostHogProvider = ({\n children,\n client,\n options,\n apiKey,\n autocapture,\n style,\n debug = false,\n}: PostHogProviderProps): JSX.Element | null => {\n const captureAll = autocapture === true\n const captureNone = autocapture === false\n\n const posthog = useMemo(() => {\n if (client && apiKey) {\n console.warn(\n 'You have provided both a client and an apiKey to PostHogProvider. The apiKey will be ignored in favour of the client.'\n )\n }\n\n if (client) {\n return client\n }\n\n const parsedOptions = {\n ...options,\n captureAppLifecycleEvents:\n options?.captureAppLifecycleEvents !== undefined ? options.captureAppLifecycleEvents : !captureNone,\n }\n\n return new PostHog(apiKey ?? '', parsedOptions)\n }, [client, apiKey]) // oxlint-disable-line react/exhaustive-deps\n\n const autocaptureOptions = useMemo(\n () => (autocapture && typeof autocapture !== 'boolean' ? autocapture : {}),\n [autocapture]\n )\n\n const captureTouches = !captureNone && posthog && (captureAll || autocaptureOptions?.captureTouches)\n const captureScreens = !captureNone && posthog && (captureAll || (autocaptureOptions?.captureScreens ?? true)) // Default to true if not set\n const phLabelProp = autocaptureOptions?.customLabelProp || defaultPostHogLabelProp\n\n useEffect(() => {\n posthog.debug(debug)\n }, [debug, posthog])\n\n const onTouch = useCallback(\n (type: 'start' | 'move' | 'end', e: GestureResponderEvent) => {\n // TODO: Improve this to ensure we only capture presses and not just ends of a drag for example\n if (!captureTouches) {\n return\n }\n\n if (type === 'end') {\n autocaptureFromTouchEvent(e, posthog, autocaptureOptions)\n }\n },\n [captureTouches, posthog, autocaptureOptions]\n )\n\n // Browsers fire touchend only for touch input, so a mouse never reaches onTouchEndCapture.\n // Listen on the document in the CAPTURE phase: RNW forwards `onClick` but not `onClickCapture`,\n // and its Pressable stops propagation before any bubble-phase handler runs. Document-wide so it\n // still sees Modal; subtree scoping happens in autocapture.tsx. Read options through a ref so an\n // inline `autocapture` prop doesn't re-attach every render.\n const hostRef = useRef<unknown>(null)\n const optionsRef = useRef(autocaptureOptions)\n useEffect(() => {\n optionsRef.current = autocaptureOptions\n }, [autocaptureOptions])\n\n useEffect(() => {\n // The package targets ESNext without the DOM lib, so reach the document off the global.\n const doc = (globalThis as any)?.document\n if (!isWeb() || !captureTouches || !doc?.addEventListener) {\n return\n }\n\n const ownerNode = hostRef.current\n if (!ownerNode) {\n // Without a host node nothing can be scoped to this provider, and a null key would collide\n // with any sibling in the same state.\n return\n }\n\n const existing = webClickListeners.get(posthog)\n if (existing) {\n existing.owners.set(ownerNode, optionsRef)\n } else {\n const owners: WebClickOwners = new Map([[ownerNode, optionsRef]])\n const handler = (e: any): void => {\n const owner = findOwningNode(e, owners)\n if (!owner) {\n return\n }\n const options = owners.get(owner)?.current\n if (!options) {\n return\n }\n autocaptureFromTouchEvent({ target: e.target, nativeEvent: e }, posthog, options, 'click')\n }\n doc.addEventListener('click', handler, true)\n webClickListeners.set(posthog, {\n owners,\n remove: () => doc.removeEventListener('click', handler, true),\n })\n }\n\n return () => {\n const entry = webClickListeners.get(posthog)\n if (!entry) {\n return\n }\n entry.owners.delete(ownerNode)\n if (entry.owners.size === 0) {\n entry.remove()\n webClickListeners.delete(posthog)\n }\n }\n }, [captureTouches, posthog])\n\n const captureProps = isWeb()\n ? {}\n : { onTouchEndCapture: captureTouches ? (e: GestureResponderEvent) => onTouch('end', e) : undefined }\n\n return (\n <View\n ref={hostRef as any}\n {...{ [phLabelProp]: 'PostHogProvider' }} // Dynamically setting customLabelProp (default: ph-label)\n style={style || { flex: 1 }}\n {...captureProps}\n >\n <PostHogContext.Provider value={{ client: posthog }}>\n {captureScreens && <PostHogNavigationHook options={autocaptureOptions} client={posthog} />}\n {children}\n </PostHogContext.Provider>\n </View>\n )\n}\n"],"mappings":"2UAAA,IAAAA,MAAA,CAAAC,uBAAA,CAAAC,OAAA,WACA,IAAAC,YAAA,CAAAD,OAAA,iBACA,IAAAE,UAAA,CAAAF,OAAA,iBACA,IAAAG,YAAA,CAAAH,OAAA,kBACA,IAAAI,qBAAA,CAAAJ,OAAA,iCACA,IAAAK,eAAA,CAAAL,OAAA,qBAEA,IAAAM,MAAA,CAAAN,OAAA,YAA+B,IAAAO,WAAA,CAAAP,OAAA,0BAAAQ,KAAA,QAAAC,YAAA,kGAAAV,wBAAAW,CAAA,CAAAC,CAAA,wBAAAC,OAAA,KAAAC,CAAA,KAAAD,OAAA,GAAAE,CAAA,KAAAF,OAAA,UAAAb,uBAAA,UAAAA,wBAAAW,CAAA,CAAAC,CAAA,MAAAA,CAAA,EAAAD,CAAA,EAAAA,CAAA,CAAAK,UAAA,QAAAL,CAAA,KAAAM,CAAA,CAAAC,CAAA,CAAAC,CAAA,EAA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,GAAIW,KAAK,CAACT,MAAM,CAACU,IAAI,GAAK,CAAC,CAAE,CAC3BD,KAAK,CAACF,MAAM,EAAE,CACdzD,iBAAiB,UAAO,CAACmB,OAAO,CAAC,CACnC,CACF,CAAC,CACH,CAAC,CAAE,CAACS,cAAc,CAAET,OAAO,CAAC,CAAC,CAE7B,GAAM,CAAA0C,YAAY,CAAG,GAAAf,YAAK,GAAE,CACxB,EAAE,CACF,CAAEgB,iBAAiB,CAAElC,cAAc,CAAG,SAAC9D,CAAwB,QAAK,CAAAqE,OAAO,CAAC,KAAK,CAAErE,CAAC,CAAC,GAAG2D,SAAS,CAAE,CAEvG,MACE,GAAA9D,WAAA,CAAAoG,GAAA,EAAC1G,YAAA,CAAA2G,IAAI,CAAAvE,aAAA,CAAAA,aAAA,CAAAA,aAAA,EACHwE,GAAG,CAAE1B,OAAe,KAAA1C,gBAAA,gBACbkC,WAAW,CAAG,iBAAiB,OACtCjB,KAAK,CAAEA,KAAK,EAAI,CAAEoD,IAAI,CAAE,CAAC,CAAG,EACxBL,YAAY,MAAAlD,QAAA,CAEhB,GAAAhD,WAAA,CAAAwG,IAAA,EAAC1G,eAAA,CAAA2G,cAAc,CAACC,QAAQ,EAACC,KAAK,CAAE,CAAElE,MAAM,CAAEe,OAAO,CAAG,CAAAR,QAAA,EACjDkB,cAAc,EAAI,GAAAlE,WAAA,CAAAoG,GAAA,EAAC9D,qBAAqB,EAACE,OAAO,CAAEwB,kBAAmB,CAACvB,MAAM,CAAEe,OAAQ,EAAG,CACzFR,QAAQ,EACc,CAC3B,EAAM,CAAC,CAEX,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"PostHogProvider.js","names":["_react","_interopRequireWildcard","require","_reactNative","_posthogRn","_autocapture","_useNavigationTracker","_PostHogContext","_utils","_jsxRuntime","_this","_jsxFileName","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t2","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","webClickListeners","PostHogNavigationHook","_ref","options","client","useNavigationTracker","navigation","navigationRef","PostHogProvider","exports","_ref2","children","projectToken","apiKey","autocapture","style","_ref2$debug","debug","captureAll","captureNone","token","posthog","useMemo","console","warn","parsedOptions","captureAppLifecycleEvents","undefined","PostHog","autocaptureOptions","captureTouches","captureScreens","_a","phLabelProp","customLabelProp","defaultPostHogLabelProp","useEffect","onTouch","useCallback","type","autocaptureFromTouchEvent","hostRef","useRef","optionsRef","current","doc","globalThis","document","isWeb","addEventListener","ownerNode","existing","owners","Map","handler","owner","findOwningNode","target","nativeEvent","remove","removeEventListener","entry","size","captureProps","onTouchEndCapture","jsx","View","ref","flex","jsxs","PostHogContext","Provider","value"],"sources":["../src/PostHogProvider.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef } from 'react'\nimport { GestureResponderEvent, StyleProp, View, ViewStyle } from 'react-native'\nimport { PostHog, PostHogOptions } from './posthog-rn'\nimport { autocaptureFromTouchEvent, findOwningNode } from './autocapture'\nimport { useNavigationTracker } from './hooks/useNavigationTracker'\nimport { PostHogContext } from './PostHogContext'\nimport { PostHogAutocaptureOptions } from './types'\nimport { isWeb } from './utils'\nimport { defaultPostHogLabelProp } from './autocapture'\n\n/**\n * Props for the PostHogProvider component.\n *\n * @public\n */\nexport interface PostHogProviderProps {\n /** The child components to render within the PostHog context */\n children: React.ReactNode\n /** PostHog configuration options */\n options?: PostHogOptions\n /**\n * Your PostHog project token, which starts with `phc_`. Find it in your project settings:\n * https://us.posthog.com/settings/project-details#variables\n */\n projectToken?: string\n /**\n * Your PostHog project token. Ignored when `projectToken` is set.\n *\n * @deprecated Use `projectToken` instead. This will be removed in the next major version.\n */\n apiKey?: string\n /** An existing PostHog client instance */\n client?: PostHog\n /**\n * Autocapture configuration - can be a boolean or detailed options.\n *\n * When not set, the default behavior is:\n * - `captureScreens`: true\n * - `captureTouches`: false\n * - `captureAppLifecycleEvents`: true\n *\n * Set to `true` to enable all autocapture features (including touches).\n * Set to `false` to disable all autocapture features.\n */\n autocapture?: boolean | PostHogAutocaptureOptions\n /**\n * Enable debug mode for additional logging\n *\n * @default false\n */\n debug?: boolean\n /** Custom styles for the provider wrapper View */\n style?: StyleProp<ViewStyle>\n}\n\n// One document click listener per client, shared across sibling providers, so one interaction\n// enqueues exactly one $autocapture event (sdk-specs autocapture). `owners` maps each mounted\n// provider's host node to its own options, so a click is scoped to the owning subtree AND\n// captured with that provider's config; its size doubles as the refcount.\ntype WebClickOwners = Map<unknown, React.MutableRefObject<PostHogAutocaptureOptions>>\nconst webClickListeners = new WeakMap<PostHog, { owners: WebClickOwners; remove: () => void }>()\n\nfunction PostHogNavigationHook({\n options,\n client,\n}: {\n options?: PostHogAutocaptureOptions\n client?: PostHog\n}): JSX.Element | null {\n useNavigationTracker(options?.navigation, options?.navigationRef, client)\n return null\n}\n\n/**\n * PostHogProvider is a React component that provides PostHog functionality to your React Native app. You can find all configuration options in the [React Native SDK docs](https://posthog.com/docs/libraries/react-native#configuration-options).\n *\n * Autocapturing navigation requires further configuration. See the [React Native SDK navigation docs](https://posthog.com/docs/libraries/react-native#capturing-screen-views)\n * for more information about autocapturing navigation.\n *\n * This is the recommended way to set up PostHog for React Native. This utilizes the Context API to pass the PostHog client around, enable autocapture.\n *\n * {@label Initialization}\n *\n * @example\n * ```jsx\n * // Add to App.(js|ts)\n * import { usePostHog, PostHogProvider } from 'posthog-react-native'\n *\n * export function MyApp() {\n * return (\n * <PostHogProvider projectToken=\"<ph_project_token>\" options={{\n * host: '<ph_client_api_host>',\n * }}>\n * <MyComponent />\n * </PostHogProvider>\n * )\n * }\n *\n * // And access the PostHog client via the usePostHog hook\n * import { usePostHog } from 'posthog-react-native'\n *\n * const MyComponent = () => {\n * const posthog = usePostHog()\n *\n * useEffect(() => {\n * posthog.capture(\"event_name\")\n * }, [posthog])\n * }\n *\n * ```\n *\n * @example\n * ```jsx\n * // Using with existing client\n * import { PostHog } from 'posthog-react-native'\n *\n * const posthog = new PostHog('<ph_project_token>', {\n * host: '<ph_client_api_host>'\n * })\n *\n * export function MyApp() {\n * return (\n * <PostHogProvider client={posthog}>\n * <MyComponent />\n * </PostHogProvider>\n * )\n * }\n * ```\n *\n * @public\n *\n * @param props - The PostHogProvider props\n */\nexport const PostHogProvider = ({\n children,\n client,\n options,\n projectToken,\n apiKey,\n autocapture,\n style,\n debug = false,\n}: PostHogProviderProps): JSX.Element | null => {\n const captureAll = autocapture === true\n const captureNone = autocapture === false\n\n const token = projectToken ?? apiKey\n\n const posthog = useMemo(() => {\n if (client && token) {\n console.warn(\n 'You have provided both a client and a projectToken to PostHogProvider. The projectToken will be ignored in favour of the client.'\n )\n }\n\n if (client) {\n return client\n }\n\n const parsedOptions = {\n ...options,\n captureAppLifecycleEvents:\n options?.captureAppLifecycleEvents !== undefined ? options.captureAppLifecycleEvents : !captureNone,\n }\n\n return new PostHog(token ?? '', parsedOptions)\n }, [client, token]) // oxlint-disable-line react/exhaustive-deps\n\n const autocaptureOptions = useMemo(\n () => (autocapture && typeof autocapture !== 'boolean' ? autocapture : {}),\n [autocapture]\n )\n\n const captureTouches = !captureNone && posthog && (captureAll || autocaptureOptions?.captureTouches)\n const captureScreens = !captureNone && posthog && (captureAll || (autocaptureOptions?.captureScreens ?? true)) // Default to true if not set\n const phLabelProp = autocaptureOptions?.customLabelProp || defaultPostHogLabelProp\n\n useEffect(() => {\n posthog.debug(debug)\n }, [debug, posthog])\n\n const onTouch = useCallback(\n (type: 'start' | 'move' | 'end', e: GestureResponderEvent) => {\n // TODO: Improve this to ensure we only capture presses and not just ends of a drag for example\n if (!captureTouches) {\n return\n }\n\n if (type === 'end') {\n autocaptureFromTouchEvent(e, posthog, autocaptureOptions)\n }\n },\n [captureTouches, posthog, autocaptureOptions]\n )\n\n // Browsers fire touchend only for touch input, so a mouse never reaches onTouchEndCapture.\n // Listen on the document in the CAPTURE phase: RNW forwards `onClick` but not `onClickCapture`,\n // and its Pressable stops propagation before any bubble-phase handler runs. Document-wide so it\n // still sees Modal; subtree scoping happens in autocapture.tsx. Read options through a ref so an\n // inline `autocapture` prop doesn't re-attach every render.\n const hostRef = useRef<unknown>(null)\n const optionsRef = useRef(autocaptureOptions)\n useEffect(() => {\n optionsRef.current = autocaptureOptions\n }, [autocaptureOptions])\n\n useEffect(() => {\n // The package targets ESNext without the DOM lib, so reach the document off the global.\n const doc = (globalThis as any)?.document\n if (!isWeb() || !captureTouches || !doc?.addEventListener) {\n return\n }\n\n const ownerNode = hostRef.current\n if (!ownerNode) {\n // Without a host node nothing can be scoped to this provider, and a null key would collide\n // with any sibling in the same state.\n return\n }\n\n const existing = webClickListeners.get(posthog)\n if (existing) {\n existing.owners.set(ownerNode, optionsRef)\n } else {\n const owners: WebClickOwners = new Map([[ownerNode, optionsRef]])\n const handler = (e: any): void => {\n const owner = findOwningNode(e, owners)\n if (!owner) {\n return\n }\n const options = owners.get(owner)?.current\n if (!options) {\n return\n }\n autocaptureFromTouchEvent({ target: e.target, nativeEvent: e }, posthog, options, 'click')\n }\n doc.addEventListener('click', handler, true)\n webClickListeners.set(posthog, {\n owners,\n remove: () => doc.removeEventListener('click', handler, true),\n })\n }\n\n return () => {\n const entry = webClickListeners.get(posthog)\n if (!entry) {\n return\n }\n entry.owners.delete(ownerNode)\n if (entry.owners.size === 0) {\n entry.remove()\n webClickListeners.delete(posthog)\n }\n }\n }, [captureTouches, posthog])\n\n const captureProps = isWeb()\n ? {}\n : { onTouchEndCapture: captureTouches ? (e: GestureResponderEvent) => onTouch('end', e) : undefined }\n\n return (\n <View\n ref={hostRef as any}\n {...{ [phLabelProp]: 'PostHogProvider' }} // Dynamically setting customLabelProp (default: ph-label)\n style={style || { flex: 1 }}\n {...captureProps}\n >\n <PostHogContext.Provider value={{ client: posthog }}>\n {captureScreens && <PostHogNavigationHook options={autocaptureOptions} client={posthog} />}\n {children}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AAAA,aAAA,EACH0E,GAAG,CAAE1B,OAAe,KAAA5C,gBAAA,gBACboC,WAAW,CAAG,iBAAiB,OACtClB,KAAK,CAAEA,KAAK,EAAI,CAAEqD,IAAI,CAAE,CAAC,CAAG,EACxBL,YAAY,MAAApD,QAAA,CAEhB,GAAAhD,WAAA,CAAA0G,IAAA,EAAC5G,eAAA,CAAA6G,cAAc,CAACC,QAAQ,EAACC,KAAK,CAAE,CAAEpE,MAAM,CAAEiB,OAAO,CAAG,CAAAV,QAAA,EACjDoB,cAAc,EAAI,GAAApE,WAAA,CAAAsG,GAAA,EAAChE,qBAAqB,EAACE,OAAO,CAAE0B,kBAAmB,CAACzB,MAAM,CAAEiB,OAAQ,EAAG,CACzFV,QAAQ,EACc,CAC3B,EAAM,CAAC,CAEX,CAAC","ignoreList":[]}
|
package/dist/posthog-rn.d.ts
CHANGED
|
@@ -229,6 +229,12 @@ export declare class PostHog extends PostHogCore {
|
|
|
229
229
|
private _setDefaultPersonProperties;
|
|
230
230
|
private _overrideDisplayLanguage;
|
|
231
231
|
private _requestHeaders;
|
|
232
|
+
/**
|
|
233
|
+
* The project token the client was created with.
|
|
234
|
+
*
|
|
235
|
+
* @deprecated Use `projectToken` instead. This will be removed in the next major version.
|
|
236
|
+
*/
|
|
237
|
+
get apiKey(): string;
|
|
232
238
|
/**
|
|
233
239
|
* Creates a new PostHog instance for React Native. You can find all configuration options in the [React Native SDK docs](https://posthog.com/docs/libraries/react-native#configuration-options).
|
|
234
240
|
*
|
|
@@ -241,7 +247,7 @@ export declare class PostHog extends PostHogCore {
|
|
|
241
247
|
* // posthog.ts
|
|
242
248
|
* import PostHog from 'posthog-react-native'
|
|
243
249
|
*
|
|
244
|
-
* export const posthog = new PostHog('<
|
|
250
|
+
* export const posthog = new PostHog('<ph_project_token>', {
|
|
245
251
|
* host: '<ph_client_api_host>'
|
|
246
252
|
* })
|
|
247
253
|
*
|
|
@@ -260,11 +266,11 @@ export declare class PostHog extends PostHogCore {
|
|
|
260
266
|
*
|
|
261
267
|
* @public
|
|
262
268
|
*
|
|
263
|
-
* @param
|
|
269
|
+
* @param projectToken - Your PostHog project token, which starts with `phc_`. Find it in your project
|
|
264
270
|
* settings: https://us.posthog.com/settings/project-details#variables
|
|
265
271
|
* @param options - PostHog configuration options
|
|
266
272
|
*/
|
|
267
|
-
constructor(
|
|
273
|
+
constructor(projectToken: string, options?: PostHogOptions);
|
|
268
274
|
/**
|
|
269
275
|
*
|
|
270
276
|
* @internal
|