@atlaskit/react-ufo 4.5.4 → 4.5.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 4.5.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`d2a5fe501a90f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d2a5fe501a90f) -
8
+ useUFOReportError hook for centrally managed error reporting for UFO
9
+
3
10
  ## 4.5.4
4
11
 
5
12
  ### Patch Changes
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useUFOReportError = useUFOReportError;
7
+ var _interactionContext = require("../interaction-context");
8
+ var _interactionMetrics = require("../interaction-metrics");
9
+ /**
10
+ * Usage:
11
+ * ```
12
+ * import { useUFOReportError } from '@atlaskit/react-ufo/use-error-handler';
13
+ *
14
+ * const reportError = useUFOReportError();
15
+ *
16
+ * try {
17
+ * // something that can throw an error
18
+ * } catch (error) {
19
+ * reportError(error)
20
+ * }
21
+ * ```
22
+ * @returns `reportError` function
23
+ */
24
+ function useUFOReportError() {
25
+ var interaction = (0, _interactionMetrics.getActiveInteraction)();
26
+ var ufoContext = (0, _interactionContext.useInteractionContext)();
27
+ var reportError = function reportError(error) {
28
+ if (interaction !== null && interaction !== void 0 && interaction.id) {
29
+ (0, _interactionMetrics.addError)(interaction.id, error.name, (ufoContext === null || ufoContext === void 0 ? void 0 : ufoContext.labelStack) || null, error.name, error.errorMessage, error.errorStack, error.forcedError);
30
+ } else {
31
+ (0, _interactionMetrics.addErrorToAll)(error.name, (ufoContext === null || ufoContext === void 0 ? void 0 : ufoContext.labelStack) || null, error.name, error.errorMessage, error.errorStack);
32
+ }
33
+ };
34
+ return reportError;
35
+ }
@@ -0,0 +1,30 @@
1
+ import { useInteractionContext } from '../interaction-context';
2
+ import { addError, addErrorToAll, getActiveInteraction } from '../interaction-metrics';
3
+
4
+ /**
5
+ * Usage:
6
+ * ```
7
+ * import { useUFOReportError } from '@atlaskit/react-ufo/use-error-handler';
8
+ *
9
+ * const reportError = useUFOReportError();
10
+ *
11
+ * try {
12
+ * // something that can throw an error
13
+ * } catch (error) {
14
+ * reportError(error)
15
+ * }
16
+ * ```
17
+ * @returns `reportError` function
18
+ */
19
+ export function useUFOReportError() {
20
+ const interaction = getActiveInteraction();
21
+ const ufoContext = useInteractionContext();
22
+ const reportError = error => {
23
+ if (interaction !== null && interaction !== void 0 && interaction.id) {
24
+ addError(interaction.id, error.name, (ufoContext === null || ufoContext === void 0 ? void 0 : ufoContext.labelStack) || null, error.name, error.errorMessage, error.errorStack, error.forcedError);
25
+ } else {
26
+ addErrorToAll(error.name, (ufoContext === null || ufoContext === void 0 ? void 0 : ufoContext.labelStack) || null, error.name, error.errorMessage, error.errorStack);
27
+ }
28
+ };
29
+ return reportError;
30
+ }
@@ -0,0 +1,30 @@
1
+ import { useInteractionContext } from '../interaction-context';
2
+ import { addError, addErrorToAll, getActiveInteraction } from '../interaction-metrics';
3
+
4
+ /**
5
+ * Usage:
6
+ * ```
7
+ * import { useUFOReportError } from '@atlaskit/react-ufo/use-error-handler';
8
+ *
9
+ * const reportError = useUFOReportError();
10
+ *
11
+ * try {
12
+ * // something that can throw an error
13
+ * } catch (error) {
14
+ * reportError(error)
15
+ * }
16
+ * ```
17
+ * @returns `reportError` function
18
+ */
19
+ export function useUFOReportError() {
20
+ var interaction = getActiveInteraction();
21
+ var ufoContext = useInteractionContext();
22
+ var reportError = function reportError(error) {
23
+ if (interaction !== null && interaction !== void 0 && interaction.id) {
24
+ addError(interaction.id, error.name, (ufoContext === null || ufoContext === void 0 ? void 0 : ufoContext.labelStack) || null, error.name, error.errorMessage, error.errorStack, error.forcedError);
25
+ } else {
26
+ addErrorToAll(error.name, (ufoContext === null || ufoContext === void 0 ? void 0 : ufoContext.labelStack) || null, error.name, error.errorMessage, error.errorStack);
27
+ }
28
+ };
29
+ return reportError;
30
+ }
@@ -0,0 +1,17 @@
1
+ import { type InteractionError } from '../interaction-metrics';
2
+ /**
3
+ * Usage:
4
+ * ```
5
+ * import { useUFOReportError } from '@atlaskit/react-ufo/use-error-handler';
6
+ *
7
+ * const reportError = useUFOReportError();
8
+ *
9
+ * try {
10
+ * // something that can throw an error
11
+ * } catch (error) {
12
+ * reportError(error)
13
+ * }
14
+ * ```
15
+ * @returns `reportError` function
16
+ */
17
+ export declare function useUFOReportError(): (error: InteractionError) => void;
@@ -0,0 +1,17 @@
1
+ import { type InteractionError } from '../interaction-metrics';
2
+ /**
3
+ * Usage:
4
+ * ```
5
+ * import { useUFOReportError } from '@atlaskit/react-ufo/use-error-handler';
6
+ *
7
+ * const reportError = useUFOReportError();
8
+ *
9
+ * try {
10
+ * // something that can throw an error
11
+ * } catch (error) {
12
+ * reportError(error)
13
+ * }
14
+ * ```
15
+ * @returns `reportError` function
16
+ */
17
+ export declare function useUFOReportError(): (error: InteractionError) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "4.5.4",
3
+ "version": "4.5.5",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/react-ufo/report-error",
3
+ "main": "../dist/cjs/report-error/index.js",
4
+ "module": "../dist/esm/report-error/index.js",
5
+ "module:es2019": "../dist/es2019/report-error/index.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/report-error/index.d.ts",
8
+ "typesVersions": {
9
+ ">=4.5 <5.9": {
10
+ "*": [
11
+ "../dist/types-ts4.5/report-error/index.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }