txlemetry-react-native 4.55.1 → 5.0.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/LICENSE +353 -353
- package/dist/TxlemetryContext.d.ts +5 -0
- package/dist/TxlemetryContext.js +1 -0
- package/dist/TxlemetryErrorBoundary.d.ts +27 -0
- package/dist/TxlemetryErrorBoundary.js +1 -0
- package/dist/{PostHogMaskView.d.ts → TxlemetryMaskView.d.ts} +39 -39
- package/dist/TxlemetryMaskView.js +1 -0
- package/dist/TxlemetryProvider.d.ts +100 -0
- package/dist/TxlemetryProvider.js +1 -0
- package/dist/autocapture.d.ts +4 -4
- package/dist/autocapture.js +1 -1
- package/dist/error-tracking/index.d.ts +98 -98
- package/dist/error-tracking/index.js +1 -1
- package/dist/error-tracking/utils.d.ts +5 -5
- package/dist/frameworks/wix-navigation.d.ts +3 -3
- package/dist/frameworks/wix-navigation.js +1 -1
- package/dist/hooks/useFeatureFlag.d.ts +5 -5
- package/dist/hooks/useFeatureFlag.js +1 -1
- package/dist/hooks/useFeatureFlagResult.d.ts +3 -3
- package/dist/hooks/useFeatureFlagResult.js +1 -1
- package/dist/hooks/useFeatureFlags.d.ts +3 -3
- package/dist/hooks/useFeatureFlags.js +1 -1
- package/dist/hooks/useNavigationTracker.d.ts +6 -6
- package/dist/hooks/useNavigationTracker.js +1 -1
- package/dist/hooks/useTxlemetry.d.ts +2 -0
- package/dist/hooks/useTxlemetry.js +1 -0
- package/dist/hooks/utils.d.ts +14 -14
- package/dist/hooks/utils.js +1 -1
- package/dist/index.d.ts +14 -14
- package/dist/index.js +1 -1
- package/dist/index.txlemetry.d.ts +36 -36
- package/dist/index.txlemetry.js +21 -21
- package/dist/logs-defaults.d.ts +9 -9
- package/dist/native-deps.d.ts +4 -4
- package/dist/native-deps.js +1 -1
- package/dist/optional/OptionalAsyncStorage.d.ts +2 -2
- package/dist/optional/OptionalExpoApplication.d.ts +2 -2
- package/dist/optional/OptionalExpoDevice.d.ts +2 -2
- package/dist/optional/OptionalExpoFileSystem.d.ts +2 -2
- package/dist/optional/OptionalExpoFileSystemLegacy.d.ts +2 -2
- package/dist/optional/OptionalExpoLocalization.d.ts +2 -2
- package/dist/optional/OptionalPlugin.d.ts +20 -20
- package/dist/optional/OptionalReactNativeDeviceInfo.d.ts +2 -2
- package/dist/optional/OptionalReactNativeLocalize.d.ts +13 -13
- package/dist/optional/OptionalReactNativeNavigation.d.ts +2 -2
- package/dist/optional/OptionalReactNativeNavigationWix.d.ts +2 -2
- package/dist/optional/OptionalReactNativeSafeArea.d.ts +2 -2
- package/dist/optional/OptionalReactNativeSvg.d.ts +2 -2
- package/dist/storage.d.ts +41 -41
- package/dist/storage.js +1 -1
- package/dist/surveys/{PostHogSurveyProvider.d.ts → TxlemetrySurveyProvider.d.ts} +23 -23
- package/dist/surveys/TxlemetrySurveyProvider.js +1 -0
- package/dist/surveys/components/BottomSection.d.ts +9 -9
- package/dist/surveys/components/BottomSection.js +1 -1
- package/dist/surveys/components/Cancel.d.ts +5 -5
- package/dist/surveys/components/Cancel.js +1 -1
- package/dist/surveys/components/ConfirmationMessage.d.ts +12 -12
- package/dist/surveys/components/ConfirmationMessage.js +1 -1
- package/dist/surveys/components/QuestionHeader.d.ts +8 -8
- package/dist/surveys/components/QuestionHeader.js +1 -1
- package/dist/surveys/components/QuestionTypes.d.ts +26 -26
- package/dist/surveys/components/QuestionTypes.js +1 -1
- package/dist/surveys/components/SurveyModal.d.ts +11 -11
- package/dist/surveys/components/SurveyModal.js +1 -1
- package/dist/surveys/components/Surveys.d.ts +16 -16
- package/dist/surveys/components/Surveys.js +1 -1
- package/dist/surveys/getActiveMatchingSurveys.d.ts +2 -2
- package/dist/surveys/icons.d.ts +11 -11
- package/dist/surveys/icons.js +1 -1
- package/dist/surveys/index.d.ts +6 -6
- package/dist/surveys/index.js +1 -1
- package/dist/surveys/safeStyleSheet.d.ts +8 -8
- package/dist/surveys/survey-translations.d.ts +7 -7
- package/dist/surveys/survey-translations.js +1 -1
- package/dist/surveys/surveys-utils.d.ts +54 -54
- package/dist/surveys/surveys-utils.js +1 -1
- package/dist/surveys/useActivatedSurveys.d.ts +3 -3
- package/dist/surveys/useActivatedSurveys.js +1 -1
- package/dist/surveys/useSurveyStorage.d.ts +8 -8
- package/dist/surveys/useSurveyStorage.js +1 -1
- package/dist/tooling/expoconfig.d.ts +64 -64
- package/dist/tooling/expoconfig.js +1 -1
- package/dist/tooling/metroconfig.d.ts +21 -21
- package/dist/tooling/metroconfig.js +1 -1
- package/dist/tooling/{posthogMetroSerializer.d.ts → txlemetryMetroSerializer.d.ts} +17 -17
- package/dist/tooling/txlemetryMetroSerializer.js +1 -0
- package/dist/tooling/utils.d.ts +58 -58
- package/dist/tooling/vendor/expo/expoconfig.d.ts +23 -23
- package/dist/tooling/vendor/metro/countLines.d.ts +2 -2
- package/dist/tooling/vendor/metro/utils.d.ts +22 -22
- package/dist/{posthog-rn.d.ts → txlemetry-rn.d.ts} +1096 -1096
- package/dist/txlemetry-rn.js +1 -0
- package/dist/types.d.ts +205 -205
- package/dist/utils.d.ts +25 -25
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +149 -149
- package/tooling/txlemetry-xcode.sh +2 -2
- package/dist/PostHogContext.d.ts +0 -5
- package/dist/PostHogContext.js +0 -1
- package/dist/PostHogErrorBoundary.d.ts +0 -27
- package/dist/PostHogErrorBoundary.js +0 -1
- package/dist/PostHogMaskView.js +0 -1
- package/dist/PostHogProvider.d.ts +0 -100
- package/dist/PostHogProvider.js +0 -1
- package/dist/hooks/usePostHog.d.ts +0 -2
- package/dist/hooks/usePostHog.js +0 -1
- package/dist/posthog-rn.js +0 -1
- package/dist/surveys/PostHogSurveyProvider.js +0 -1
- package/dist/tooling/posthogMetroSerializer.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.TxlemetryContext=void 0;var _react=_interopRequireDefault(require("react"));var TxlemetryContext=exports.TxlemetryContext=_react["default"].createContext({client:undefined});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { FunctionComponent } from 'react';
|
|
2
|
+
import { TxlemetryContext } from './TxlemetryContext';
|
|
3
|
+
export type Properties = Record<string, any>;
|
|
4
|
+
export type TxlemetryErrorBoundaryFallbackProps = {
|
|
5
|
+
error: unknown;
|
|
6
|
+
componentStack: string;
|
|
7
|
+
};
|
|
8
|
+
export type TxlemetryErrorBoundaryProps = {
|
|
9
|
+
children?: React.ReactNode | (() => React.ReactNode);
|
|
10
|
+
fallback?: React.ReactNode | FunctionComponent<TxlemetryErrorBoundaryFallbackProps>;
|
|
11
|
+
additionalProperties?: Properties | ((error: unknown) => Properties);
|
|
12
|
+
};
|
|
13
|
+
type TxlemetryErrorBoundaryState = {
|
|
14
|
+
componentStack: string | null;
|
|
15
|
+
error: unknown;
|
|
16
|
+
};
|
|
17
|
+
export declare class TxlemetryErrorBoundary extends React.Component<TxlemetryErrorBoundaryProps, TxlemetryErrorBoundaryState> {
|
|
18
|
+
static contextType: React.Context<{
|
|
19
|
+
client: import("./txlemetry-rn").Txlemetry;
|
|
20
|
+
}>;
|
|
21
|
+
context: React.ContextType<typeof TxlemetryContext>;
|
|
22
|
+
constructor(props: TxlemetryErrorBoundaryProps);
|
|
23
|
+
static getDerivedStateFromError(error: unknown): Partial<TxlemetryErrorBoundaryState>;
|
|
24
|
+
componentDidCatch(error: unknown, errorInfo: React.ErrorInfo): void;
|
|
25
|
+
render(): React.ReactNode;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.TxlemetryErrorBoundary=void 0;var _typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _react=_interopRequireDefault(require("react"));var _TxlemetryContext=require("./TxlemetryContext");var _jsxRuntime=require("react/jsx-runtime");function _callSuper(t,o,e){return o=(0,_getPrototypeOf2["default"])(o),(0,_possibleConstructorReturn2["default"])(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],(0,_getPrototypeOf2["default"])(t).constructor):o.apply(t,e));}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}var INITIAL_STATE={componentStack:null,error:null};var isFunction=function isFunction(f){return typeof f==='function';};var TxlemetryErrorBoundary=exports.TxlemetryErrorBoundary=function(_React$Component){function TxlemetryErrorBoundary(props){var _this;(0,_classCallCheck2["default"])(this,TxlemetryErrorBoundary);_this=_callSuper(this,TxlemetryErrorBoundary,[props]);_this.state=INITIAL_STATE;return _this;}(0,_inherits2["default"])(TxlemetryErrorBoundary,_React$Component);return(0,_createClass2["default"])(TxlemetryErrorBoundary,[{key:"componentDidCatch",value:function componentDidCatch(error,errorInfo){var additionalProperties=this.props.additionalProperties;var currentProperties;if(isFunction(additionalProperties)){currentProperties=additionalProperties(error);}else if((0,_typeof2["default"])(additionalProperties)==='object'){currentProperties=additionalProperties;}var client=this.context.client;client===null||client===void 0?void 0:client.captureException(error,currentProperties);var componentStack=errorInfo.componentStack;this.setState({error:error,componentStack:componentStack!==null&&componentStack!==void 0?componentStack:null});}},{key:"render",value:function render(){var _a;var _this$props=this.props,children=_this$props.children,fallback=_this$props.fallback;var state=this.state;if(state.error==null){return isFunction(children)?children():children;}var element=isFunction(fallback)?_react["default"].createElement(fallback,{error:state.error,componentStack:(_a=state.componentStack)!==null&&_a!==void 0?_a:''}):fallback;if(_react["default"].isValidElement(element)){return element;}return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{});}}],[{key:"getDerivedStateFromError",value:function getDerivedStateFromError(error){return{error:error};}}]);}(_react["default"].Component);TxlemetryErrorBoundary.contextType=_TxlemetryContext.TxlemetryContext;
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ViewProps } from 'react-native';
|
|
3
|
-
/**
|
|
4
|
-
* Props for the
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
export interface
|
|
9
|
-
/** The child components to mask from
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* session recordings without compromising accessibility.
|
|
15
|
-
*
|
|
16
|
-
* It works by:
|
|
17
|
-
* - Setting `accessibilityLabel` to `"ph-no-capture"` to hide the content from session recordings
|
|
18
|
-
* - Setting `importantForAccessibility` to `"no"` to prevent the wrapper View from hiding
|
|
19
|
-
* accessible content on Android (since `accessibilityLabel` would otherwise interfere)
|
|
20
|
-
* - Setting `collapsable={false}` so React Native keeps this wrapper in the native view hierarchy
|
|
21
|
-
* (otherwise layout-only view flattening can remove it and masking is not detected on iOS/Android)
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```jsx
|
|
25
|
-
* import {
|
|
26
|
-
*
|
|
27
|
-
* function SensitiveForm() {
|
|
28
|
-
* return (
|
|
29
|
-
* <
|
|
30
|
-
* <TextInput placeholder="Credit card number" />
|
|
31
|
-
* <TextInput placeholder="CVV" />
|
|
32
|
-
* </
|
|
33
|
-
* )
|
|
34
|
-
* }
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* @public
|
|
38
|
-
*/
|
|
39
|
-
export declare const
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewProps } from 'react-native';
|
|
3
|
+
/**
|
|
4
|
+
* Props for the TxlemetryMaskView component.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface TxlemetryMaskViewProps extends ViewProps {
|
|
9
|
+
/** The child components to mask from Txlemetry capture */
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* TxlemetryMaskView is a wrapper component that hides its children from Txlemetry
|
|
14
|
+
* session recordings without compromising accessibility.
|
|
15
|
+
*
|
|
16
|
+
* It works by:
|
|
17
|
+
* - Setting `accessibilityLabel` to `"ph-no-capture"` to hide the content from session recordings
|
|
18
|
+
* - Setting `importantForAccessibility` to `"no"` to prevent the wrapper View from hiding
|
|
19
|
+
* accessible content on Android (since `accessibilityLabel` would otherwise interfere)
|
|
20
|
+
* - Setting `collapsable={false}` so React Native keeps this wrapper in the native view hierarchy
|
|
21
|
+
* (otherwise layout-only view flattening can remove it and masking is not detected on iOS/Android)
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```jsx
|
|
25
|
+
* import { TxlemetryMaskView } from 'txlemetry-react-native'
|
|
26
|
+
*
|
|
27
|
+
* function SensitiveForm() {
|
|
28
|
+
* return (
|
|
29
|
+
* <TxlemetryMaskView>
|
|
30
|
+
* <TextInput placeholder="Credit card number" />
|
|
31
|
+
* <TextInput placeholder="CVV" />
|
|
32
|
+
* </TxlemetryMaskView>
|
|
33
|
+
* )
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export declare const TxlemetryMaskView: ({ children, ...viewProps }: TxlemetryMaskViewProps) => JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.TxlemetryMaskView=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _jsxRuntime=require("react/jsx-runtime");var _excluded=["children"];var _this=void 0,_jsxFileName="txlemetry-react-native/dist/TxlemetryMaskView.js";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 TxlemetryMaskView=exports.TxlemetryMaskView=function TxlemetryMaskView(_ref){var children=_ref.children,viewProps=(0,_objectWithoutProperties2["default"])(_ref,_excluded);return(0,_jsxRuntime.jsx)(_reactNative.View,_objectSpread(_objectSpread({},viewProps),{},{accessibilityLabel:"ph-no-capture",importantForAccessibility:"no",collapsable:false,children:children}));};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { Txlemetry, TxlemetryOptions } from './txlemetry-rn';
|
|
4
|
+
import { TxlemetryAutocaptureOptions } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Props for the TxlemetryProvider component.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export interface TxlemetryProviderProps {
|
|
11
|
+
/** The child components to render within the Txlemetry context */
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
/** Txlemetry configuration options */
|
|
14
|
+
options?: TxlemetryOptions;
|
|
15
|
+
/** Your Txlemetry API key */
|
|
16
|
+
apiKey?: string;
|
|
17
|
+
/** An existing Txlemetry client instance */
|
|
18
|
+
client?: Txlemetry;
|
|
19
|
+
/**
|
|
20
|
+
* Autocapture configuration - can be a boolean or detailed options.
|
|
21
|
+
*
|
|
22
|
+
* When not set, the default behavior is:
|
|
23
|
+
* - `captureScreens`: true
|
|
24
|
+
* - `captureTouches`: false
|
|
25
|
+
* - `captureAppLifecycleEvents`: true
|
|
26
|
+
*
|
|
27
|
+
* Set to `true` to enable all autocapture features (including touches).
|
|
28
|
+
* Set to `false` to disable all autocapture features.
|
|
29
|
+
*/
|
|
30
|
+
autocapture?: boolean | TxlemetryAutocaptureOptions;
|
|
31
|
+
/**
|
|
32
|
+
* Enable debug mode for additional logging
|
|
33
|
+
*
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
debug?: boolean;
|
|
37
|
+
/** Custom styles for the provider wrapper View */
|
|
38
|
+
style?: StyleProp<ViewStyle>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* TxlemetryProvider is a React component that provides Txlemetry functionality to your React Native app. You can find all configuration options in the [React Native SDK docs](https://txlemetry.com/docs/libraries/react-native#configuration-options).
|
|
42
|
+
*
|
|
43
|
+
* Autocapturing navigation requires further configuration. See the [React Native SDK navigation docs](https://txlemetry.com/docs/libraries/react-native#capturing-screen-views)
|
|
44
|
+
* for more information about autocapturing navigation.
|
|
45
|
+
*
|
|
46
|
+
* This is the recommended way to set up Txlemetry for React Native. This utilizes the Context API to pass the Txlemetry client around, enable autocapture.
|
|
47
|
+
*
|
|
48
|
+
* {@label Initialization}
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```jsx
|
|
52
|
+
* // Add to App.(js|ts)
|
|
53
|
+
* import { useTxlemetry, TxlemetryProvider } from 'txlemetry-react-native'
|
|
54
|
+
*
|
|
55
|
+
* export function MyApp() {
|
|
56
|
+
* return (
|
|
57
|
+
* <TxlemetryProvider apiKey="<ph_project_api_key>" options={{
|
|
58
|
+
* host: '<ph_client_api_host>',
|
|
59
|
+
* }}>
|
|
60
|
+
* <MyComponent />
|
|
61
|
+
* </TxlemetryProvider>
|
|
62
|
+
* )
|
|
63
|
+
* }
|
|
64
|
+
*
|
|
65
|
+
* // And access the Txlemetry client via the useTxlemetry hook
|
|
66
|
+
* import { useTxlemetry } from 'txlemetry-react-native'
|
|
67
|
+
*
|
|
68
|
+
* const MyComponent = () => {
|
|
69
|
+
* const txlemetry = useTxlemetry()
|
|
70
|
+
*
|
|
71
|
+
* useEffect(() => {
|
|
72
|
+
* txlemetry.capture("event_name")
|
|
73
|
+
* }, [txlemetry])
|
|
74
|
+
* }
|
|
75
|
+
*
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```jsx
|
|
80
|
+
* // Using with existing client
|
|
81
|
+
* import { Txlemetry } from 'txlemetry-react-native'
|
|
82
|
+
*
|
|
83
|
+
* const txlemetry = new Txlemetry('<ph_project_api_key>', {
|
|
84
|
+
* host: '<ph_client_api_host>'
|
|
85
|
+
* })
|
|
86
|
+
*
|
|
87
|
+
* export function MyApp() {
|
|
88
|
+
* return (
|
|
89
|
+
* <TxlemetryProvider client={txlemetry}>
|
|
90
|
+
* <MyComponent />
|
|
91
|
+
* </TxlemetryProvider>
|
|
92
|
+
* )
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @public
|
|
97
|
+
*
|
|
98
|
+
* @param props - The TxlemetryProvider props
|
|
99
|
+
*/
|
|
100
|
+
export declare const TxlemetryProvider: ({ children, client, options, apiKey, autocapture, style, debug, }: TxlemetryProviderProps) => JSX.Element | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:true});exports.TxlemetryProvider=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _txlemetryRn=require("./txlemetry-rn");var _autocapture=require("./autocapture");var _useNavigationTracker=require("./hooks/useNavigationTracker");var _TxlemetryContext=require("./TxlemetryContext");var _jsxRuntime=require("react/jsx-runtime");var _this=void 0,_jsxFileName="txlemetry-react-native/dist/TxlemetryProvider.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;}function TxlemetryNavigationHook(_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 TxlemetryProvider=exports.TxlemetryProvider=function TxlemetryProvider(_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 txlemetry=(0,_react.useMemo)(function(){if(client&&apiKey){console.warn('You have provided both a client and an apiKey to TxlemetryProvider. The apiKey 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 _txlemetryRn.Txlemetry(apiKey!==null&&apiKey!==void 0?apiKey:'',parsedOptions);},[client,apiKey]);var autocaptureOptions=(0,_react.useMemo)(function(){return autocapture&&typeof autocapture!=='boolean'?autocapture:{};},[autocapture]);var captureTouches=!captureNone&&txlemetry&&(captureAll||(autocaptureOptions===null||autocaptureOptions===void 0?void 0:autocaptureOptions.captureTouches));var captureScreens=!captureNone&&txlemetry&&(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.defaultTxlemetryLabelProp;(0,_react.useEffect)(function(){txlemetry.debug(debug);},[debug,txlemetry]);var onTouch=(0,_react.useCallback)(function(type,e){if(!captureTouches){return;}if(type==='end'){(0,_autocapture.autocaptureFromTouchEvent)(e,txlemetry,autocaptureOptions);}},[captureTouches,txlemetry,autocaptureOptions]);return(0,_jsxRuntime.jsx)(_reactNative.View,_objectSpread(_objectSpread({},(0,_defineProperty2["default"])({},phLabelProp,'TxlemetryProvider')),{},{style:style||{flex:1},onTouchEndCapture:captureTouches?function(e){return onTouch('end',e);}:undefined,children:(0,_jsxRuntime.jsxs)(_TxlemetryContext.TxlemetryContext.Provider,{value:{client:txlemetry},children:[captureScreens&&(0,_jsxRuntime.jsx)(TxlemetryNavigationHook,{options:autocaptureOptions,client:txlemetry}),children]})}));};
|
package/dist/autocapture.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const autocaptureFromTouchEvent: (e: any,
|
|
1
|
+
import { Txlemetry } from './txlemetry-rn';
|
|
2
|
+
import { TxlemetryAutocaptureOptions } from './types';
|
|
3
|
+
export declare const defaultTxlemetryLabelProp = "ph-label";
|
|
4
|
+
export declare const autocaptureFromTouchEvent: (e: any, txlemetry: Txlemetry, options?: TxlemetryAutocaptureOptions) => void;
|
package/dist/autocapture.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.defaultTxlemetryLabelProp=exports.autocaptureFromTouchEvent=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof"));function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){(0,_defineProperty2["default"])(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var _n=0,F=function F(){};return{s:F,n:function n(){return _n>=r.length?{done:!0}:{done:!1,value:r[_n++]};},e:function e(r){throw r;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}var isAnimatedValue=function isAnimatedValue(value){return(value===null||value===void 0?void 0:value._isReanimatedSharedValue)===true||(0,_typeof2["default"])(value)==='object'&&value!==null&&'_value'in value;};var _flattenStyles=function flattenStyles(styles){var flattened={};if(isAnimatedValue(styles)){return{};}if(Array.isArray(styles)){var _iterator=_createForOfIteratorHelper(styles),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var style=_step.value;(0,_extends2["default"])(flattened,_flattenStyles(style));}}catch(err){_iterator.e(err);}finally{_iterator.f();}}else if(styles&&(0,_typeof2["default"])(styles)==='object'){for(var key in styles){if(!isAnimatedValue(styles[key])){flattened[key]=styles[key];}}}return flattened;};var stringifyStyle=function stringifyStyle(styles){var flattened=_flattenStyles(styles);var str=Object.keys(flattened).map(function(x){return"".concat(x,":").concat(flattened[x]);}).join(';');return str;};var sanitiseLabel=function sanitiseLabel(label){return label.replace(/[^a-z0-9]+/gi,'-');};var defaultTxlemetryLabelProp=exports.defaultTxlemetryLabelProp='ph-label';var captureAttributePrefix='data-ph-capture-attribute-';var autocaptureFromTouchEvent=exports.autocaptureFromTouchEvent=function autocaptureFromTouchEvent(e,txlemetry){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var _a,_b;var _options$noCapturePro=options.noCaptureProp,noCaptureProp=_options$noCapturePro===void 0?'ph-no-capture':_options$noCapturePro,_options$customLabelP=options.customLabelProp,customLabelProp=_options$customLabelP===void 0?defaultTxlemetryLabelProp:_options$customLabelP,_options$maxElementsC=options.maxElementsCaptured,maxElementsCaptured=_options$maxElementsC===void 0?20:_options$maxElementsC,_options$ignoreLabels=options.ignoreLabels,ignoreLabels=_options$ignoreLabels===void 0?[]:_options$ignoreLabels,_options$propsToCaptu=options.propsToCapture,propsToCapture=_options$propsToCaptu===void 0?['style','testID','accessibilityLabel',customLabelProp,'children']:_options$propsToCaptu;if(!e._targetInst){return;}var elements=[];var autocaptureProperties={};var currentInst=e._targetInst;var _loop=function _loop(){var el={tag_name:''};var elAutocaptureProperties={};var props=currentInst.memoizedProps;if(props===null||props===void 0?void 0:props[noCaptureProp]){return{v:void 0};}if(props){Object.keys(props).forEach(function(key){var value=props[key];if(key.indexOf(captureAttributePrefix)===0){var propertyKey=key.slice(captureAttributePrefix.length);if(propertyKey&&['string','number','boolean'].includes((0,_typeof2["default"])(value))&&value!==''){elAutocaptureProperties[propertyKey]=value;}}if(!propsToCapture.includes(key)){return;}if(key==='style'){try{el.attr__style=stringifyStyle(value);}catch(error){}}else if(['string','number','boolean'].includes((0,_typeof2["default"])(value))){if(key==='children'){el.$el_text=typeof value==='string'?value:JSON.stringify(value);}else{el["attr__".concat(key)]=value;}}});}var label=typeof(props===null||props===void 0?void 0:props[customLabelProp])!=='undefined'?"".concat(props[customLabelProp]):((_a=currentInst.elementType)===null||_a===void 0?void 0:_a.displayName)||((_b=currentInst.elementType)===null||_b===void 0?void 0:_b.name);(0,_extends2["default"])(autocaptureProperties,elAutocaptureProperties);if(label&&!ignoreLabels.includes(label)){el.tag_name=sanitiseLabel(label);elements.push(el);}currentInst=currentInst["return"];},_ret;while(currentInst&&elements.length<maxElementsCaptured){_ret=_loop();if(_ret)return _ret.v;}if(elements.length){var elAttrLabelKey="attr__".concat(customLabelProp);var lastLabel=undefined;for(var i=elements.length-1;i>=0;i--){var element=elements[i];if(element[elAttrLabelKey]){lastLabel=element[elAttrLabelKey];}if(lastLabel){element['tag_name']=lastLabel;}}txlemetry.autocapture('touch',elements,_objectSpread(_objectSpread({},autocaptureProperties),{},{$touch_x:e.nativeEvent.pageX,$touch_y:e.nativeEvent.pageY}));}};
|
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { JsonType, Logger, ErrorTracking as CoreErrorTracking,
|
|
3
|
-
import { Properties } from '@txlemetry/types';
|
|
4
|
-
type LogLevel = 'debug' | 'log' | 'info' | 'warn' | 'error';
|
|
5
|
-
interface AutocaptureOptions {
|
|
6
|
-
uncaughtExceptions?: boolean;
|
|
7
|
-
unhandledRejections?: boolean;
|
|
8
|
-
console?: boolean | LogLevel[];
|
|
9
|
-
/**
|
|
10
|
-
* Enables native iOS/Android crash autocapture through the optional native plugin.
|
|
11
|
-
* Disabled by default. Requires `@txlemetry/react-native-plugin` installed.
|
|
12
|
-
*/
|
|
13
|
-
nativeCrashes?: boolean;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Controls the breadcrumb-style exception steps recorded via `addExceptionStep` and attached
|
|
17
|
-
* to captured exceptions as `$exception_steps`.
|
|
18
|
-
*/
|
|
19
|
-
export interface ExceptionStepsOptions {
|
|
20
|
-
/**
|
|
21
|
-
* Whether exception steps are recorded and attached.
|
|
22
|
-
* @default true
|
|
23
|
-
*/
|
|
24
|
-
enabled?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Total UTF-8 byte budget (~32KB) for the in-memory buffer. Oldest steps are evicted first when exceeded.
|
|
27
|
-
* @default 32768
|
|
28
|
-
*/
|
|
29
|
-
maxBytes?: number;
|
|
30
|
-
}
|
|
31
|
-
export interface ErrorTrackingOptions {
|
|
32
|
-
autocapture?: AutocaptureOptions | boolean;
|
|
33
|
-
exceptionSteps?: ExceptionStepsOptions;
|
|
34
|
-
}
|
|
35
|
-
export declare class ErrorTracking {
|
|
36
|
-
private instance;
|
|
37
|
-
private logger;
|
|
38
|
-
private options;
|
|
39
|
-
private _exceptionStepsConfig;
|
|
40
|
-
private _exceptionStepsBuffer;
|
|
41
|
-
private _nativeForwardingEnabled;
|
|
42
|
-
/**
|
|
43
|
-
* Controls whether autocaptured exceptions are actually sent.
|
|
44
|
-
* When remote config disables error tracking, this is set to false
|
|
45
|
-
* so that installed handlers become no-ops.
|
|
46
|
-
* Defaults to true (don't block locally enabled capture before remote config loads).
|
|
47
|
-
*/
|
|
48
|
-
private _autocaptureEnabled;
|
|
49
|
-
constructor(instance:
|
|
50
|
-
/**
|
|
51
|
-
* Exception-steps config in the native plugin's shape, so the embedded native SDK keeps one
|
|
52
|
-
* logical buffer with the same byte budget and enabled state.
|
|
53
|
-
*/
|
|
54
|
-
getNativePluginExceptionStepsConfig(): ExceptionStepsOptions;
|
|
55
|
-
/**
|
|
56
|
-
* Records a breadcrumb-style exception step in the instance buffer and mirrors it to the embedded
|
|
57
|
-
* native SDK. The `$timestamp` is captured at call time. Invalid messages are ignored with a
|
|
58
|
-
* warning and never throw. The step only reaches native when it was actually buffered.
|
|
59
|
-
*/
|
|
60
|
-
addExceptionStep(message: string, properties?: Properties): void;
|
|
61
|
-
/**
|
|
62
|
-
* Native error tracking initializes asynchronously, so steps recorded before then are buffered
|
|
63
|
-
* only in JS. The host calls this once native is ready to enable forwarding and replay the buffer,
|
|
64
|
-
* so a native crash shortly after startup carries the steps recorded before native was ready.
|
|
65
|
-
*/
|
|
66
|
-
onNativeErrorTrackingReady(): void;
|
|
67
|
-
private forwardExceptionStepToNative;
|
|
68
|
-
/**
|
|
69
|
-
* Returns `properties` with a snapshot of the buffered steps attached as `$exception_steps`,
|
|
70
|
-
* unless the feature is disabled, the caller already provided that key, or the buffer is empty.
|
|
71
|
-
* The buffer is left intact so subsequent exceptions read the same steps.
|
|
72
|
-
*/
|
|
73
|
-
attachExceptionSteps(properties:
|
|
74
|
-
/**
|
|
75
|
-
* Snapshot of the buffered steps (oldest first), or an empty array when disabled or empty.
|
|
76
|
-
*/
|
|
77
|
-
getAttachableExceptionSteps(): CoreErrorTracking.ExceptionStep[];
|
|
78
|
-
/**
|
|
79
|
-
* Clears the buffer. Called on SDK close, not on capture or identity changes.
|
|
80
|
-
*/
|
|
81
|
-
clearExceptionSteps(): void;
|
|
82
|
-
/**
|
|
83
|
-
* Called when remote config is loaded.
|
|
84
|
-
* If errorTracking.autocaptureExceptions is explicitly false, autocapture is disabled.
|
|
85
|
-
* If it's true or undefined (not yet loaded / not present), autocapture follows local config.
|
|
86
|
-
*/
|
|
87
|
-
onRemoteConfig(errorTracking: boolean | {
|
|
88
|
-
[key: string]: JsonType;
|
|
89
|
-
} | undefined): void;
|
|
90
|
-
private resolveOptions;
|
|
91
|
-
private resolveAutocaptureOptions;
|
|
92
|
-
private resolveConsoleOptions;
|
|
93
|
-
private autocaptureUncaughtErrors;
|
|
94
|
-
private autocaptureUnhandledRejections;
|
|
95
|
-
private autocaptureConsole;
|
|
96
|
-
private autocapture;
|
|
97
|
-
}
|
|
98
|
-
export {};
|
|
1
|
+
import type { Txlemetry } from '../txlemetry-rn';
|
|
2
|
+
import { JsonType, Logger, ErrorTracking as CoreErrorTracking, TxlemetryEventProperties } from '@txlemetry/core';
|
|
3
|
+
import { Properties } from '@txlemetry/types';
|
|
4
|
+
type LogLevel = 'debug' | 'log' | 'info' | 'warn' | 'error';
|
|
5
|
+
interface AutocaptureOptions {
|
|
6
|
+
uncaughtExceptions?: boolean;
|
|
7
|
+
unhandledRejections?: boolean;
|
|
8
|
+
console?: boolean | LogLevel[];
|
|
9
|
+
/**
|
|
10
|
+
* Enables native iOS/Android crash autocapture through the optional native plugin.
|
|
11
|
+
* Disabled by default. Requires `@txlemetry/react-native-plugin` installed.
|
|
12
|
+
*/
|
|
13
|
+
nativeCrashes?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Controls the breadcrumb-style exception steps recorded via `addExceptionStep` and attached
|
|
17
|
+
* to captured exceptions as `$exception_steps`.
|
|
18
|
+
*/
|
|
19
|
+
export interface ExceptionStepsOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Whether exception steps are recorded and attached.
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
enabled?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Total UTF-8 byte budget (~32KB) for the in-memory buffer. Oldest steps are evicted first when exceeded.
|
|
27
|
+
* @default 32768
|
|
28
|
+
*/
|
|
29
|
+
maxBytes?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface ErrorTrackingOptions {
|
|
32
|
+
autocapture?: AutocaptureOptions | boolean;
|
|
33
|
+
exceptionSteps?: ExceptionStepsOptions;
|
|
34
|
+
}
|
|
35
|
+
export declare class ErrorTracking {
|
|
36
|
+
private instance;
|
|
37
|
+
private logger;
|
|
38
|
+
private options;
|
|
39
|
+
private _exceptionStepsConfig;
|
|
40
|
+
private _exceptionStepsBuffer;
|
|
41
|
+
private _nativeForwardingEnabled;
|
|
42
|
+
/**
|
|
43
|
+
* Controls whether autocaptured exceptions are actually sent.
|
|
44
|
+
* When remote config disables error tracking, this is set to false
|
|
45
|
+
* so that installed handlers become no-ops.
|
|
46
|
+
* Defaults to true (don't block locally enabled capture before remote config loads).
|
|
47
|
+
*/
|
|
48
|
+
private _autocaptureEnabled;
|
|
49
|
+
constructor(instance: Txlemetry, options: ErrorTrackingOptions | undefined, logger: Logger);
|
|
50
|
+
/**
|
|
51
|
+
* Exception-steps config in the native plugin's shape, so the embedded native SDK keeps one
|
|
52
|
+
* logical buffer with the same byte budget and enabled state.
|
|
53
|
+
*/
|
|
54
|
+
getNativePluginExceptionStepsConfig(): ExceptionStepsOptions;
|
|
55
|
+
/**
|
|
56
|
+
* Records a breadcrumb-style exception step in the instance buffer and mirrors it to the embedded
|
|
57
|
+
* native SDK. The `$timestamp` is captured at call time. Invalid messages are ignored with a
|
|
58
|
+
* warning and never throw. The step only reaches native when it was actually buffered.
|
|
59
|
+
*/
|
|
60
|
+
addExceptionStep(message: string, properties?: Properties): void;
|
|
61
|
+
/**
|
|
62
|
+
* Native error tracking initializes asynchronously, so steps recorded before then are buffered
|
|
63
|
+
* only in JS. The host calls this once native is ready to enable forwarding and replay the buffer,
|
|
64
|
+
* so a native crash shortly after startup carries the steps recorded before native was ready.
|
|
65
|
+
*/
|
|
66
|
+
onNativeErrorTrackingReady(): void;
|
|
67
|
+
private forwardExceptionStepToNative;
|
|
68
|
+
/**
|
|
69
|
+
* Returns `properties` with a snapshot of the buffered steps attached as `$exception_steps`,
|
|
70
|
+
* unless the feature is disabled, the caller already provided that key, or the buffer is empty.
|
|
71
|
+
* The buffer is left intact so subsequent exceptions read the same steps.
|
|
72
|
+
*/
|
|
73
|
+
attachExceptionSteps(properties: TxlemetryEventProperties): TxlemetryEventProperties;
|
|
74
|
+
/**
|
|
75
|
+
* Snapshot of the buffered steps (oldest first), or an empty array when disabled or empty.
|
|
76
|
+
*/
|
|
77
|
+
getAttachableExceptionSteps(): CoreErrorTracking.ExceptionStep[];
|
|
78
|
+
/**
|
|
79
|
+
* Clears the buffer. Called on SDK close, not on capture or identity changes.
|
|
80
|
+
*/
|
|
81
|
+
clearExceptionSteps(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Called when remote config is loaded.
|
|
84
|
+
* If errorTracking.autocaptureExceptions is explicitly false, autocapture is disabled.
|
|
85
|
+
* If it's true or undefined (not yet loaded / not present), autocapture follows local config.
|
|
86
|
+
*/
|
|
87
|
+
onRemoteConfig(errorTracking: boolean | {
|
|
88
|
+
[key: string]: JsonType;
|
|
89
|
+
} | undefined): void;
|
|
90
|
+
private resolveOptions;
|
|
91
|
+
private resolveAutocaptureOptions;
|
|
92
|
+
private resolveConsoleOptions;
|
|
93
|
+
private autocaptureUncaughtErrors;
|
|
94
|
+
private autocaptureUnhandledRejections;
|
|
95
|
+
private autocaptureConsole;
|
|
96
|
+
private autocapture;
|
|
97
|
+
}
|
|
98
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ErrorTracking=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _core=require("@txlemetry/core");var _utils=require("./utils");var _utils2=require("../utils");var _OptionalPlugin=require("../optional/OptionalPlugin");function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var _n=0,F=function F(){};return{s:F,n:function n(){return _n>=r.length?{done:!0}:{done:!1,value:r[_n++]};},e:function e(r){throw r;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}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 LogLevelList=['debug','log','info','warn','error'];var ErrorTracking=exports.ErrorTracking=function(){function ErrorTracking(instance){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var logger=arguments.length>2?arguments[2]:undefined;(0,_classCallCheck2["default"])(this,ErrorTracking);this.instance=instance;this._nativeForwardingEnabled=false;this._autocaptureEnabled=true;this.logger=logger.createLogger('[ErrorTracking]');this.options=this.resolveOptions(options);var exceptionSteps=options.exceptionSteps;this._exceptionStepsConfig=_core.ErrorTracking.resolveExceptionStepsConfig(exceptionSteps?{enabled:exceptionSteps.enabled,max_bytes:exceptionSteps.maxBytes}:undefined);this._exceptionStepsBuffer=new _core.ErrorTracking.ExceptionStepsBuffer(this._exceptionStepsConfig);this.autocapture(this.options.autocapture);}return(0,_createClass2["default"])(ErrorTracking,[{key:"getNativePluginExceptionStepsConfig",value:function getNativePluginExceptionStepsConfig(){return{enabled:this._exceptionStepsConfig.enabled,maxBytes:this._exceptionStepsConfig.max_bytes};}},{key:"addExceptionStep",value:function addExceptionStep(message,properties){if(!this._exceptionStepsConfig.enabled){return;}try{if(!(0,_core.isString)(message)||message.trim().length===0){this.logger.warn('Ignoring exception step because message must be a non-empty string');return;}var userProperties=(0,_core.isObject)(properties)?_objectSpread({},properties):{};var _CoreErrorTracking$st=_core.ErrorTracking.stripReservedExceptionStepFields(userProperties),sanitizedProperties=_CoreErrorTracking$st.sanitizedProperties,droppedKeys=_CoreErrorTracking$st.droppedKeys;if(droppedKeys.length>0){this.logger.warn('Ignoring reserved exception step fields',{droppedKeys:droppedKeys});}this._exceptionStepsBuffer.add(_objectSpread((0,_defineProperty2["default"])((0,_defineProperty2["default"])({},_core.ErrorTracking.EXCEPTION_STEP_INTERNAL_FIELDS.MESSAGE,message),_core.ErrorTracking.EXCEPTION_STEP_INTERNAL_FIELDS.TIMESTAMP,new Date().toISOString()),sanitizedProperties));this.forwardExceptionStepToNative(message,properties);}catch(error){this.logger.error('Failed to add exception step. Ignoring breadcrumb.',error);}}},{key:"onNativeErrorTrackingReady",value:function onNativeErrorTrackingReady(){this._nativeForwardingEnabled=true;var _iterator=_createForOfIteratorHelper(this.getAttachableExceptionSteps()),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var step=_step.value;this.forwardExceptionStepToNative(step.$message,step);}}catch(err){_iterator.e(err);}finally{_iterator.f();}}},{key:"forwardExceptionStepToNative",value:function forwardExceptionStepToNative(message,properties){var _this=this;if(!this._nativeForwardingEnabled||!(_OptionalPlugin.OptionalReactNativePlugin===null||_OptionalPlugin.OptionalReactNativePlugin===void 0?void 0:_OptionalPlugin.OptionalReactNativePlugin.addExceptionStep)){return;}try{void Promise.resolve(_OptionalPlugin.OptionalReactNativePlugin.addExceptionStep(message,properties))["catch"](function(e){_this.logger.warn("Failed to forward exception step to native: ".concat(e));});}catch(e){this.logger.warn("Failed to forward exception step to native: ".concat(e));}}},{key:"attachExceptionSteps",value:function attachExceptionSteps(properties){if(!this._exceptionStepsConfig.enabled||!(0,_core.isNullish)(properties.$exception_steps)){return properties;}var steps=this.getAttachableExceptionSteps();if(steps.length===0){return properties;}return _objectSpread(_objectSpread({},properties),{},{$exception_steps:steps});}},{key:"getAttachableExceptionSteps",value:function getAttachableExceptionSteps(){if(!this._exceptionStepsConfig.enabled){return[];}try{return this._exceptionStepsBuffer.getAttachable();}catch(error){this.logger.error('Failed to read buffered exception steps.',error);return[];}}},{key:"clearExceptionSteps",value:function clearExceptionSteps(){this._exceptionStepsBuffer.clear();}},{key:"onRemoteConfig",value:function onRemoteConfig(errorTracking){if(errorTracking==null){return;}this._autocaptureEnabled=(0,_utils2.getRemoteConfigBool)(errorTracking,'autocaptureExceptions',false);this.logger.info("Error tracking autocapture ".concat(this._autocaptureEnabled?'enabled':'disabled'," by remote config."));}},{key:"resolveOptions",value:function resolveOptions(options){var autocaptureOptions=this.resolveAutocaptureOptions(options.autocapture);return{autocapture:autocaptureOptions};}},{key:"resolveAutocaptureOptions",value:function resolveAutocaptureOptions(){var autocapture=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(typeof autocapture==='boolean'){return{uncaughtExceptions:autocapture,unhandledRejections:autocapture,console:[]};}return{uncaughtExceptions:!!autocapture.uncaughtExceptions,unhandledRejections:!!autocapture.unhandledRejections,console:this.resolveConsoleOptions(autocapture.console)};}},{key:"resolveConsoleOptions",value:function resolveConsoleOptions(){var console=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(typeof console==='boolean'){return console?['error']:[];}return Array.isArray(console)?console.filter(function(level){return LogLevelList.includes(level);}):[];}},{key:"autocaptureUncaughtErrors",value:function autocaptureUncaughtErrors(){var _this2=this;var onUncaughtException=function onUncaughtException(error,isFatal){if(!_this2._autocaptureEnabled){return;}if((0,_core.
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ErrorTracking=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _core=require("@txlemetry/core");var _utils=require("./utils");var _utils2=require("../utils");var _OptionalPlugin=require("../optional/OptionalPlugin");function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var _n=0,F=function F(){};return{s:F,n:function n(){return _n>=r.length?{done:!0}:{done:!1,value:r[_n++]};},e:function e(r){throw r;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}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 LogLevelList=['debug','log','info','warn','error'];var ErrorTracking=exports.ErrorTracking=function(){function ErrorTracking(instance){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var logger=arguments.length>2?arguments[2]:undefined;(0,_classCallCheck2["default"])(this,ErrorTracking);this.instance=instance;this._nativeForwardingEnabled=false;this._autocaptureEnabled=true;this.logger=logger.createLogger('[ErrorTracking]');this.options=this.resolveOptions(options);var exceptionSteps=options.exceptionSteps;this._exceptionStepsConfig=_core.ErrorTracking.resolveExceptionStepsConfig(exceptionSteps?{enabled:exceptionSteps.enabled,max_bytes:exceptionSteps.maxBytes}:undefined);this._exceptionStepsBuffer=new _core.ErrorTracking.ExceptionStepsBuffer(this._exceptionStepsConfig);this.autocapture(this.options.autocapture);}return(0,_createClass2["default"])(ErrorTracking,[{key:"getNativePluginExceptionStepsConfig",value:function getNativePluginExceptionStepsConfig(){return{enabled:this._exceptionStepsConfig.enabled,maxBytes:this._exceptionStepsConfig.max_bytes};}},{key:"addExceptionStep",value:function addExceptionStep(message,properties){if(!this._exceptionStepsConfig.enabled){return;}try{if(!(0,_core.isString)(message)||message.trim().length===0){this.logger.warn('Ignoring exception step because message must be a non-empty string');return;}var userProperties=(0,_core.isObject)(properties)?_objectSpread({},properties):{};var _CoreErrorTracking$st=_core.ErrorTracking.stripReservedExceptionStepFields(userProperties),sanitizedProperties=_CoreErrorTracking$st.sanitizedProperties,droppedKeys=_CoreErrorTracking$st.droppedKeys;if(droppedKeys.length>0){this.logger.warn('Ignoring reserved exception step fields',{droppedKeys:droppedKeys});}this._exceptionStepsBuffer.add(_objectSpread((0,_defineProperty2["default"])((0,_defineProperty2["default"])({},_core.ErrorTracking.EXCEPTION_STEP_INTERNAL_FIELDS.MESSAGE,message),_core.ErrorTracking.EXCEPTION_STEP_INTERNAL_FIELDS.TIMESTAMP,new Date().toISOString()),sanitizedProperties));this.forwardExceptionStepToNative(message,properties);}catch(error){this.logger.error('Failed to add exception step. Ignoring breadcrumb.',error);}}},{key:"onNativeErrorTrackingReady",value:function onNativeErrorTrackingReady(){this._nativeForwardingEnabled=true;var _iterator=_createForOfIteratorHelper(this.getAttachableExceptionSteps()),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var step=_step.value;this.forwardExceptionStepToNative(step.$message,step);}}catch(err){_iterator.e(err);}finally{_iterator.f();}}},{key:"forwardExceptionStepToNative",value:function forwardExceptionStepToNative(message,properties){var _this=this;if(!this._nativeForwardingEnabled||!(_OptionalPlugin.OptionalReactNativePlugin===null||_OptionalPlugin.OptionalReactNativePlugin===void 0?void 0:_OptionalPlugin.OptionalReactNativePlugin.addExceptionStep)){return;}try{void Promise.resolve(_OptionalPlugin.OptionalReactNativePlugin.addExceptionStep(message,properties))["catch"](function(e){_this.logger.warn("Failed to forward exception step to native: ".concat(e));});}catch(e){this.logger.warn("Failed to forward exception step to native: ".concat(e));}}},{key:"attachExceptionSteps",value:function attachExceptionSteps(properties){if(!this._exceptionStepsConfig.enabled||!(0,_core.isNullish)(properties.$exception_steps)){return properties;}var steps=this.getAttachableExceptionSteps();if(steps.length===0){return properties;}return _objectSpread(_objectSpread({},properties),{},{$exception_steps:steps});}},{key:"getAttachableExceptionSteps",value:function getAttachableExceptionSteps(){if(!this._exceptionStepsConfig.enabled){return[];}try{return this._exceptionStepsBuffer.getAttachable();}catch(error){this.logger.error('Failed to read buffered exception steps.',error);return[];}}},{key:"clearExceptionSteps",value:function clearExceptionSteps(){this._exceptionStepsBuffer.clear();}},{key:"onRemoteConfig",value:function onRemoteConfig(errorTracking){if(errorTracking==null){return;}this._autocaptureEnabled=(0,_utils2.getRemoteConfigBool)(errorTracking,'autocaptureExceptions',false);this.logger.info("Error tracking autocapture ".concat(this._autocaptureEnabled?'enabled':'disabled'," by remote config."));}},{key:"resolveOptions",value:function resolveOptions(options){var autocaptureOptions=this.resolveAutocaptureOptions(options.autocapture);return{autocapture:autocaptureOptions};}},{key:"resolveAutocaptureOptions",value:function resolveAutocaptureOptions(){var autocapture=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(typeof autocapture==='boolean'){return{uncaughtExceptions:autocapture,unhandledRejections:autocapture,console:[]};}return{uncaughtExceptions:!!autocapture.uncaughtExceptions,unhandledRejections:!!autocapture.unhandledRejections,console:this.resolveConsoleOptions(autocapture.console)};}},{key:"resolveConsoleOptions",value:function resolveConsoleOptions(){var console=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(typeof console==='boolean'){return console?['error']:[];}return Array.isArray(console)?console.filter(function(level){return LogLevelList.includes(level);}):[];}},{key:"autocaptureUncaughtErrors",value:function autocaptureUncaughtErrors(){var _this2=this;var onUncaughtException=function onUncaughtException(error,isFatal){if(!_this2._autocaptureEnabled){return;}if((0,_core.isTxlemetryFetchNetworkError)(error)){return;}var hint={mechanism:{type:'onuncaughtexception',handled:false}};var additionalProperties={};if(isFatal){additionalProperties['$exception_level']='fatal';}_this2.instance.captureException(error,additionalProperties,hint);if(isFatal){void _this2.instance.flush()["catch"](function(){_this2.logger.critical('Failed to flush events');});}};try{(0,_utils.trackUncaughtExceptions)(onUncaughtException);}catch(err){this.logger.warn('Failed to track uncaught exceptions: ',err);}}},{key:"autocaptureUnhandledRejections",value:function autocaptureUnhandledRejections(){var _this3=this;var onUnhandledRejection=function onUnhandledRejection(error){if(!_this3._autocaptureEnabled){return;}if((0,_core.isTxlemetryFetchNetworkError)(error)){return;}var hint={mechanism:{type:'onunhandledrejection',handled:false}};_this3.instance.captureException(error,{},hint);};try{(0,_utils.trackUnhandledRejections)(onUnhandledRejection);}catch(err){this.logger.warn('Failed to track unhandled rejections: ',err);}}},{key:"autocaptureConsole",value:function autocaptureConsole(levels){var _this4=this;var onConsole=function onConsole(level){return function(error,isFatal,syntheticException){if(!_this4._autocaptureEnabled){return;}var hint={mechanism:{type:'onconsole',handled:true},syntheticException:syntheticException};var additionalProperties={$exception_level:level};_this4.instance.captureException(error,additionalProperties,hint);};};try{var _iterator2=_createForOfIteratorHelper(levels),_step2;try{for(_iterator2.s();!(_step2=_iterator2.n()).done;){var level=_step2.value;(0,_utils.trackConsole)(level,onConsole(level));}}catch(err){_iterator2.e(err);}finally{_iterator2.f();}}catch(err){this.logger.warn('Failed to track console errors: ',err);}}},{key:"autocapture",value:function autocapture(autocaptureOptions){if(autocaptureOptions.uncaughtExceptions===true){this.autocaptureUncaughtErrors();}if(autocaptureOptions.unhandledRejections===true){this.autocaptureUnhandledRejections();}if(autocaptureOptions.console.length>0){this.autocaptureConsole(autocaptureOptions.console);}}}]);}();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
type ExceptionHook = (error: unknown, isFatal: boolean, syntheticException?: Error) => void;
|
|
2
|
-
export declare function trackUnhandledRejections(tracker: ExceptionHook): void;
|
|
3
|
-
export declare function trackUncaughtExceptions(tracker: ExceptionHook): void;
|
|
4
|
-
export declare function trackConsole(level: string, tracker: ExceptionHook): void;
|
|
5
|
-
export {};
|
|
1
|
+
type ExceptionHook = (error: unknown, isFatal: boolean, syntheticException?: Error) => void;
|
|
2
|
+
export declare function trackUnhandledRejections(tracker: ExceptionHook): void;
|
|
3
|
+
export declare function trackUncaughtExceptions(tracker: ExceptionHook): void;
|
|
4
|
+
export declare function trackConsole(level: string, tracker: ExceptionHook): void;
|
|
5
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare const withReactNativeNavigation: (
|
|
1
|
+
import { Txlemetry } from '../txlemetry-rn';
|
|
2
|
+
import { TxlemetryAutocaptureOptions } from '../types';
|
|
3
|
+
export declare const withReactNativeNavigation: (txlemetry: Txlemetry, options?: TxlemetryAutocaptureOptions) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.withReactNativeNavigation=void 0;var _OptionalReactNativeNavigationWix=require("../optional/OptionalReactNativeNavigationWix");var withReactNativeNavigation=exports.withReactNativeNavigation=function withReactNativeNavigation(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.withReactNativeNavigation=void 0;var _OptionalReactNativeNavigationWix=require("../optional/OptionalReactNativeNavigationWix");var withReactNativeNavigation=exports.withReactNativeNavigation=function withReactNativeNavigation(txlemetry){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(!_OptionalReactNativeNavigationWix.OptionalReactNativeNavigationWix){return false;}var Navigation=_OptionalReactNativeNavigationWix.OptionalReactNativeNavigationWix.Navigation;Navigation.events().registerComponentDidAppearListener(function(_ref){var componentName=_ref.componentName,passProps=_ref.passProps;var _a,_b,_c,_d,_e;if(!((_a=options.captureScreens)!==null&&_a!==void 0?_a:true)){return;}var currentRouteName=((_c=(_b=options===null||options===void 0?void 0:options.navigation)===null||_b===void 0?void 0:_b.routeToName)===null||_c===void 0?void 0:_c.call(_b,componentName,passProps||{}))||componentName||'Unknown';if(currentRouteName){var properties=(_e=(_d=options===null||options===void 0?void 0:options.navigation)===null||_d===void 0?void 0:_d.routeToProperties)===null||_e===void 0?void 0:_e.call(_d,currentRouteName,passProps||{});txlemetry.screen(currentRouteName,properties);}});return true;};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { JsonType, FeatureFlagValue } from '@txlemetry/core';
|
|
2
|
-
import {
|
|
3
|
-
export declare function useFeatureFlag(flag: string, client?:
|
|
4
|
-
export type FeatureFlagWithPayload = [FeatureFlagValue | undefined, JsonType | undefined];
|
|
5
|
-
export declare function useFeatureFlagWithPayload(flag: string, client?:
|
|
1
|
+
import { JsonType, FeatureFlagValue } from '@txlemetry/core';
|
|
2
|
+
import { Txlemetry } from '../txlemetry-rn';
|
|
3
|
+
export declare function useFeatureFlag(flag: string, client?: Txlemetry): FeatureFlagValue | undefined;
|
|
4
|
+
export type FeatureFlagWithPayload = [FeatureFlagValue | undefined, JsonType | undefined];
|
|
5
|
+
export declare function useFeatureFlagWithPayload(flag: string, client?: Txlemetry): FeatureFlagWithPayload;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useFeatureFlag=useFeatureFlag;exports.useFeatureFlagWithPayload=useFeatureFlagWithPayload;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=require("react");var _utils=require("./utils");function useFeatureFlag(flag,client){var
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useFeatureFlag=useFeatureFlag;exports.useFeatureFlagWithPayload=useFeatureFlagWithPayload;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=require("react");var _utils=require("./utils");function useFeatureFlag(flag,client){var txlemetry=(0,_utils.useOverridableTxlemetry)(client,'useFeatureFlag');var _useState=(0,_react.useState)(txlemetry===null||txlemetry===void 0?void 0:txlemetry.getFeatureFlag(flag)),_useState2=(0,_slicedToArray2["default"])(_useState,2),featureFlag=_useState2[0],setFeatureFlag=_useState2[1];(0,_react.useEffect)(function(){setFeatureFlag(txlemetry===null||txlemetry===void 0?void 0:txlemetry.getFeatureFlag(flag));return txlemetry===null||txlemetry===void 0?void 0:txlemetry.onFeatureFlags(function(){setFeatureFlag(txlemetry.getFeatureFlag(flag));});},[txlemetry,flag]);return featureFlag;}function useFeatureFlagWithPayload(flag,client){var txlemetry=(0,_utils.useOverridableTxlemetry)(client,'useFeatureFlagWithPayload');var _useState3=(0,_react.useState)([undefined,undefined]),_useState4=(0,_slicedToArray2["default"])(_useState3,2),featureFlag=_useState4[0],setFeatureFlag=_useState4[1];(0,_react.useEffect)(function(){var _a;setFeatureFlag([txlemetry===null||txlemetry===void 0?void 0:txlemetry.getFeatureFlag(flag),(_a=txlemetry===null||txlemetry===void 0?void 0:txlemetry.getFeatureFlagResult(flag,{sendEvent:false}))===null||_a===void 0?void 0:_a.payload]);return txlemetry===null||txlemetry===void 0?void 0:txlemetry.onFeatureFlags(function(){var _a;setFeatureFlag([txlemetry.getFeatureFlag(flag),(_a=txlemetry.getFeatureFlagResult(flag,{sendEvent:false}))===null||_a===void 0?void 0:_a.payload]);});},[txlemetry,flag]);return featureFlag;}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FeatureFlagResult } from '@txlemetry/core';
|
|
2
|
-
import {
|
|
3
|
-
export declare function useFeatureFlagResult(flag: string, client?:
|
|
1
|
+
import { FeatureFlagResult } from '@txlemetry/core';
|
|
2
|
+
import { Txlemetry } from '../txlemetry-rn';
|
|
3
|
+
export declare function useFeatureFlagResult(flag: string, client?: Txlemetry): FeatureFlagResult | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useFeatureFlagResult=useFeatureFlagResult;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=require("react");var _utils=require("./utils");function useFeatureFlagResult(flag,client){var
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useFeatureFlagResult=useFeatureFlagResult;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=require("react");var _utils=require("./utils");function useFeatureFlagResult(flag,client){var txlemetry=(0,_utils.useOverridableTxlemetry)(client,'useFeatureFlagResult');var _useState=(0,_react.useState)(txlemetry===null||txlemetry===void 0?void 0:txlemetry.getFeatureFlagResult(flag)),_useState2=(0,_slicedToArray2["default"])(_useState,2),result=_useState2[0],setResult=_useState2[1];(0,_react.useEffect)(function(){setResult(txlemetry===null||txlemetry===void 0?void 0:txlemetry.getFeatureFlagResult(flag));return txlemetry===null||txlemetry===void 0?void 0:txlemetry.onFeatureFlags(function(){setResult(txlemetry.getFeatureFlagResult(flag));});},[txlemetry,flag]);return result;}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
export declare function useFeatureFlags(client?:
|
|
1
|
+
import type { Txlemetry } from '../txlemetry-rn';
|
|
2
|
+
import { TxlemetryFlagsResponse } from '@txlemetry/core';
|
|
3
|
+
export declare function useFeatureFlags(client?: Txlemetry): TxlemetryFlagsResponse['featureFlags'] | undefined;
|