@atlaskit/rovo-agent-analytics 0.12.1 → 0.13.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/rovo-agent-analytics
2
2
 
3
+ ## 0.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`d6ab7edf41142`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d6ab7edf41142) -
8
+ Update agent analytics types
9
+
3
10
  ## 0.12.1
4
11
 
5
12
  ### Patch Changes
package/README.md CHANGED
@@ -11,14 +11,105 @@ Detailed docs and example usage can be found
11
11
 
12
12
  ## Examples
13
13
 
14
- ```
15
- import { useRovoAgentActionAnalytics, AgentActions } from '@atlaskit/rovo-agent-analytics';
14
+ ### Basic usage with common attributes
15
+
16
+ ```typescript
17
+ import { useRovoAgentActionAnalytics, AgentCommonActions } from '@atlaskit/rovo-agent-analytics';
16
18
 
17
19
  const { trackAgentAction } = useRovoAgentActionAnalytics({
18
20
  agentId,
19
- canEdit,
20
- touchPoint: 'browse-agent-list'
21
+ touchPoint: 'browse-agent-list',
21
22
  });
22
23
 
23
- trackAgentAction(AgentActions.DUPLICATE);
24
+ // No additional attributes needed - agentId and touchPoint already provided
25
+ trackAgentAction(AgentCommonActions.DUPLICATE, {});
26
+ ```
27
+
28
+ ### Usage with debug actions (no attributes required)
29
+
30
+ ```typescript
31
+ import { useRovoAgentActionAnalytics, AgentDebugActions } from '@atlaskit/rovo-agent-analytics';
32
+
33
+ const { trackAgentAction } = useRovoAgentActionAnalytics({});
34
+
35
+ // Debug actions don't require any attributes
36
+ trackAgentAction(AgentDebugActions.VIEW, {});
37
+ trackAgentAction(AgentDebugActions.COPY, {});
38
+ ```
39
+
40
+ ## Adding New Actions
41
+
42
+ ### Step 1: Add the action to the appropriate enum
43
+
44
+ Add your new action to either `AgentCommonActions` or `AgentDebugActions` in
45
+ `src/actions/index.tsx`:
46
+
47
+ ```typescript
48
+ export enum AgentCommonActions {
49
+ // ... existing actions
50
+ /* My new action - https://data-portal.internal.atlassian.com/analytics/registry/XXXXX */
51
+ MY_NEW_ACTION = 'myNewAction',
52
+ }
53
+ ```
54
+
55
+ ### Step 2: Define attributes for the action
56
+
57
+ Add an entry to `ActionAttributes` to specify which attributes this action requires:
58
+
59
+ ```typescript
60
+ type ActionAttributes = {
61
+ // ... existing actions
62
+ [AgentCommonActions.MY_NEW_ACTION]: CommonAnalyticsAttributes;
63
+ };
64
+ ```
65
+
66
+ ## Defining Custom Attributes Per Action
67
+
68
+ Each action can have its own specific attributes. The `trackAgentAction` function is generic and
69
+ will enforce the correct attributes based on the action you pass.
70
+
71
+ ### Using CommonAnalyticsAttributes
72
+
73
+ For actions that only need `touchPoint` and `agentId`:
74
+
75
+ ```typescript
76
+ type ActionAttributes = {
77
+ [AgentCommonActions.VIEW]: CommonAnalyticsAttributes;
78
+ };
79
+ ```
80
+
81
+ ### Using Custom Attributes
82
+
83
+ For actions that need additional attributes beyond the common ones:
84
+
85
+ ```typescript
86
+ type ActionAttributes = {
87
+ [AgentCommonActions.STAR]: CommonAnalyticsAttributes & { isStarred: boolean };
88
+ };
89
+ ```
90
+
91
+ When calling `trackAgentAction`, TypeScript will enforce the custom attributes:
92
+
93
+ ```typescript
94
+ // TypeScript will require isStarred to be provided
95
+ trackAgentAction(AgentCommonActions.STAR, { isStarred: true });
96
+ ```
97
+
98
+ ### How Type Inference Works
99
+
100
+ The `trackAgentAction` function uses generics to infer required attributes:
101
+
102
+ 1. When you call `trackAgentAction(action, attributes)`, TypeScript infers the action type
103
+ 2. It looks up `ActionAttributes[action]` to get the required attributes for that action
104
+ 3. It subtracts any attributes already provided in `commonAttributes` (via `RemainingRequired`)
105
+ 4. The remaining attributes must be provided in the `attributes` parameter
106
+
107
+ Example:
108
+
109
+ ```typescript
110
+ // If commonAttributes already includes agentId
111
+ const { trackAgentAction } = useRovoAgentActionAnalytics({ agentId: '123' });
112
+
113
+ // Only touchPoint is required since agentId was already provided
114
+ trackAgentAction(AgentCommonActions.VIEW, { touchPoint: 'my-touchpoint' });
24
115
  ```
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.useRovoAgentActionAnalytics = exports.AgentActions = void 0;
7
+ exports.useRovoAgentActionAnalytics = exports.AgentDebugActions = exports.AgentCommonActions = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _react = require("react");
10
10
  var _analyticsNext = require("@atlaskit/analytics-next");
@@ -12,28 +12,39 @@ var _constants = require("../common/constants");
12
12
  var _utils = require("../common/utils");
13
13
  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; }
14
14
  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; }
15
- var AgentActions = exports.AgentActions = /*#__PURE__*/function (AgentActions) {
15
+ var AgentDebugActions = exports.AgentDebugActions = /*#__PURE__*/function (AgentDebugActions) {
16
+ /* View debug modal - https://data-portal.internal.atlassian.com/analytics/registry/97183 */
17
+ AgentDebugActions["VIEW"] = "debugView";
18
+ /* Copy all debug data - https://data-portal.internal.atlassian.com/analytics/registry/97186 */
19
+ AgentDebugActions["COPY_ALL"] = "debugCopyAll";
20
+ /* Copy debug data - https://data-portal.internal.atlassian.com/analytics/registry/97184 */
21
+ AgentDebugActions["COPY"] = "debugCopy";
22
+ /* Toggle skill info - https://data-portal.internal.atlassian.com/analytics/registry/97185 */
23
+ AgentDebugActions["TOGGLE_SKILL_INFO"] = "debugToggleSkillInfo";
24
+ return AgentDebugActions;
25
+ }({});
26
+ var AgentCommonActions = exports.AgentCommonActions = /*#__PURE__*/function (AgentCommonActions) {
16
27
  /* View agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97125 */
17
- AgentActions["VIEW"] = "view";
28
+ AgentCommonActions["VIEW"] = "view";
18
29
  /* Edit agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97126 */
19
- AgentActions["EDIT"] = "edit";
30
+ AgentCommonActions["EDIT"] = "edit";
20
31
  /* Agent updated - https://data-portal.internal.atlassian.com/analytics/registry/97122 */
21
- AgentActions["UPDATED"] = "updated";
32
+ AgentCommonActions["UPDATED"] = "updated";
22
33
  /* Copy link clicked - https://data-portal.internal.atlassian.com/analytics/registry/97128 */
23
- AgentActions["COPY_LINK"] = "copyLink";
34
+ AgentCommonActions["COPY_LINK"] = "copyLink";
24
35
  /* Delete agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97129 */
25
- AgentActions["DELETE"] = "delete";
36
+ AgentCommonActions["DELETE"] = "delete";
26
37
  /* Duplicate agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97130 */
27
- AgentActions["DUPLICATE"] = "duplicate";
38
+ AgentCommonActions["DUPLICATE"] = "duplicate";
28
39
  /* Star agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97133 */
29
- AgentActions["STAR"] = "star";
40
+ AgentCommonActions["STAR"] = "star";
30
41
  /* Chat with agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97095 */
31
- AgentActions["CHAT"] = "chat";
42
+ AgentCommonActions["CHAT"] = "chat";
32
43
  /* Verify agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97134 */
33
- AgentActions["VERIFY"] = "verify";
44
+ AgentCommonActions["VERIFY"] = "verify";
34
45
  /* Unverify agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97135 */
35
- AgentActions["UNVERIFY"] = "unverify";
36
- return AgentActions;
46
+ AgentCommonActions["UNVERIFY"] = "unverify";
47
+ return AgentCommonActions;
37
48
  }({});
38
49
  var useRovoAgentActionAnalytics = exports.useRovoAgentActionAnalytics = function useRovoAgentActionAnalytics(commonAttributes) {
39
50
  var analyticsContext = (0, _react.useContext)(_analyticsNext.AnalyticsReactContext);
@@ -2,28 +2,39 @@ import { useCallback, useContext, useMemo } from 'react';
2
2
  import { AnalyticsReactContext, useAnalyticsEvents } from '@atlaskit/analytics-next';
3
3
  import { ANALYTICS_CHANNEL } from '../common/constants';
4
4
  import { getAttributesFromContexts, getDefaultTrackEventConfig } from '../common/utils';
5
- export let AgentActions = /*#__PURE__*/function (AgentActions) {
5
+ export let AgentDebugActions = /*#__PURE__*/function (AgentDebugActions) {
6
+ /* View debug modal - https://data-portal.internal.atlassian.com/analytics/registry/97183 */
7
+ AgentDebugActions["VIEW"] = "debugView";
8
+ /* Copy all debug data - https://data-portal.internal.atlassian.com/analytics/registry/97186 */
9
+ AgentDebugActions["COPY_ALL"] = "debugCopyAll";
10
+ /* Copy debug data - https://data-portal.internal.atlassian.com/analytics/registry/97184 */
11
+ AgentDebugActions["COPY"] = "debugCopy";
12
+ /* Toggle skill info - https://data-portal.internal.atlassian.com/analytics/registry/97185 */
13
+ AgentDebugActions["TOGGLE_SKILL_INFO"] = "debugToggleSkillInfo";
14
+ return AgentDebugActions;
15
+ }({});
16
+ export let AgentCommonActions = /*#__PURE__*/function (AgentCommonActions) {
6
17
  /* View agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97125 */
7
- AgentActions["VIEW"] = "view";
18
+ AgentCommonActions["VIEW"] = "view";
8
19
  /* Edit agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97126 */
9
- AgentActions["EDIT"] = "edit";
20
+ AgentCommonActions["EDIT"] = "edit";
10
21
  /* Agent updated - https://data-portal.internal.atlassian.com/analytics/registry/97122 */
11
- AgentActions["UPDATED"] = "updated";
22
+ AgentCommonActions["UPDATED"] = "updated";
12
23
  /* Copy link clicked - https://data-portal.internal.atlassian.com/analytics/registry/97128 */
13
- AgentActions["COPY_LINK"] = "copyLink";
24
+ AgentCommonActions["COPY_LINK"] = "copyLink";
14
25
  /* Delete agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97129 */
15
- AgentActions["DELETE"] = "delete";
26
+ AgentCommonActions["DELETE"] = "delete";
16
27
  /* Duplicate agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97130 */
17
- AgentActions["DUPLICATE"] = "duplicate";
28
+ AgentCommonActions["DUPLICATE"] = "duplicate";
18
29
  /* Star agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97133 */
19
- AgentActions["STAR"] = "star";
30
+ AgentCommonActions["STAR"] = "star";
20
31
  /* Chat with agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97095 */
21
- AgentActions["CHAT"] = "chat";
32
+ AgentCommonActions["CHAT"] = "chat";
22
33
  /* Verify agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97134 */
23
- AgentActions["VERIFY"] = "verify";
34
+ AgentCommonActions["VERIFY"] = "verify";
24
35
  /* Unverify agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97135 */
25
- AgentActions["UNVERIFY"] = "unverify";
26
- return AgentActions;
36
+ AgentCommonActions["UNVERIFY"] = "unverify";
37
+ return AgentCommonActions;
27
38
  }({});
28
39
  export const useRovoAgentActionAnalytics = commonAttributes => {
29
40
  const analyticsContext = useContext(AnalyticsReactContext);
@@ -5,28 +5,39 @@ import { useCallback, useContext, useMemo } from 'react';
5
5
  import { AnalyticsReactContext, useAnalyticsEvents } from '@atlaskit/analytics-next';
6
6
  import { ANALYTICS_CHANNEL } from '../common/constants';
7
7
  import { getAttributesFromContexts, getDefaultTrackEventConfig } from '../common/utils';
8
- export var AgentActions = /*#__PURE__*/function (AgentActions) {
8
+ export var AgentDebugActions = /*#__PURE__*/function (AgentDebugActions) {
9
+ /* View debug modal - https://data-portal.internal.atlassian.com/analytics/registry/97183 */
10
+ AgentDebugActions["VIEW"] = "debugView";
11
+ /* Copy all debug data - https://data-portal.internal.atlassian.com/analytics/registry/97186 */
12
+ AgentDebugActions["COPY_ALL"] = "debugCopyAll";
13
+ /* Copy debug data - https://data-portal.internal.atlassian.com/analytics/registry/97184 */
14
+ AgentDebugActions["COPY"] = "debugCopy";
15
+ /* Toggle skill info - https://data-portal.internal.atlassian.com/analytics/registry/97185 */
16
+ AgentDebugActions["TOGGLE_SKILL_INFO"] = "debugToggleSkillInfo";
17
+ return AgentDebugActions;
18
+ }({});
19
+ export var AgentCommonActions = /*#__PURE__*/function (AgentCommonActions) {
9
20
  /* View agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97125 */
10
- AgentActions["VIEW"] = "view";
21
+ AgentCommonActions["VIEW"] = "view";
11
22
  /* Edit agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97126 */
12
- AgentActions["EDIT"] = "edit";
23
+ AgentCommonActions["EDIT"] = "edit";
13
24
  /* Agent updated - https://data-portal.internal.atlassian.com/analytics/registry/97122 */
14
- AgentActions["UPDATED"] = "updated";
25
+ AgentCommonActions["UPDATED"] = "updated";
15
26
  /* Copy link clicked - https://data-portal.internal.atlassian.com/analytics/registry/97128 */
16
- AgentActions["COPY_LINK"] = "copyLink";
27
+ AgentCommonActions["COPY_LINK"] = "copyLink";
17
28
  /* Delete agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97129 */
18
- AgentActions["DELETE"] = "delete";
29
+ AgentCommonActions["DELETE"] = "delete";
19
30
  /* Duplicate agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97130 */
20
- AgentActions["DUPLICATE"] = "duplicate";
31
+ AgentCommonActions["DUPLICATE"] = "duplicate";
21
32
  /* Star agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97133 */
22
- AgentActions["STAR"] = "star";
33
+ AgentCommonActions["STAR"] = "star";
23
34
  /* Chat with agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97095 */
24
- AgentActions["CHAT"] = "chat";
35
+ AgentCommonActions["CHAT"] = "chat";
25
36
  /* Verify agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97134 */
26
- AgentActions["VERIFY"] = "verify";
37
+ AgentCommonActions["VERIFY"] = "verify";
27
38
  /* Unverify agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97135 */
28
- AgentActions["UNVERIFY"] = "unverify";
29
- return AgentActions;
39
+ AgentCommonActions["UNVERIFY"] = "unverify";
40
+ return AgentCommonActions;
30
41
  }({});
31
42
  export var useRovoAgentActionAnalytics = function useRovoAgentActionAnalytics(commonAttributes) {
32
43
  var analyticsContext = useContext(AnalyticsReactContext);
@@ -1,5 +1,11 @@
1
1
  import type { RemainingRequired } from '../common/types';
2
- export declare enum AgentActions {
2
+ export declare enum AgentDebugActions {
3
+ VIEW = "debugView",
4
+ COPY_ALL = "debugCopyAll",
5
+ COPY = "debugCopy",
6
+ TOGGLE_SKILL_INFO = "debugToggleSkillInfo"
7
+ }
8
+ export declare enum AgentCommonActions {
3
9
  VIEW = "view",
4
10
  EDIT = "edit",
5
11
  UPDATED = "updated",
@@ -15,8 +21,28 @@ type CommonAnalyticsAttributes = {
15
21
  touchPoint: string;
16
22
  agentId: string;
17
23
  };
18
- export declare const useRovoAgentActionAnalytics: <T extends Partial<CommonAnalyticsAttributes>>(commonAttributes: T) => {
19
- trackAgentAction: (action: AgentActions, attributes: RemainingRequired<CommonAnalyticsAttributes, T> & Record<string, any>) => void;
20
- trackAgentActionError: (action: AgentActions, error: Error, attributes?: RemainingRequired<CommonAnalyticsAttributes, T> & Record<string, any>) => void;
24
+ type EmptyAttributes = {};
25
+ type ActionAttributes = {
26
+ [AgentCommonActions.VIEW]: CommonAnalyticsAttributes;
27
+ [AgentCommonActions.EDIT]: CommonAnalyticsAttributes;
28
+ [AgentCommonActions.UPDATED]: CommonAnalyticsAttributes & {
29
+ agentType: string;
30
+ field: string;
31
+ };
32
+ [AgentCommonActions.COPY_LINK]: CommonAnalyticsAttributes;
33
+ [AgentCommonActions.DELETE]: CommonAnalyticsAttributes;
34
+ [AgentCommonActions.DUPLICATE]: CommonAnalyticsAttributes;
35
+ [AgentCommonActions.STAR]: CommonAnalyticsAttributes;
36
+ [AgentCommonActions.CHAT]: CommonAnalyticsAttributes;
37
+ [AgentCommonActions.VERIFY]: CommonAnalyticsAttributes;
38
+ [AgentCommonActions.UNVERIFY]: CommonAnalyticsAttributes;
39
+ [AgentDebugActions.COPY_ALL]: EmptyAttributes;
40
+ [AgentDebugActions.COPY]: EmptyAttributes;
41
+ [AgentDebugActions.TOGGLE_SKILL_INFO]: EmptyAttributes;
42
+ [AgentDebugActions.VIEW]: EmptyAttributes;
43
+ };
44
+ export declare const useRovoAgentActionAnalytics: <T extends {}>(commonAttributes: T) => {
45
+ trackAgentAction: <A extends keyof ActionAttributes>(action: A, attributes: RemainingRequired<ActionAttributes[A], T>) => void;
46
+ trackAgentActionError: <A extends keyof ActionAttributes>(action: A, error: Error, attributes?: RemainingRequired<ActionAttributes[A], T>) => void;
21
47
  };
22
48
  export {};
@@ -1,5 +1,11 @@
1
1
  import type { RemainingRequired } from '../common/types';
2
- export declare enum AgentActions {
2
+ export declare enum AgentDebugActions {
3
+ VIEW = "debugView",
4
+ COPY_ALL = "debugCopyAll",
5
+ COPY = "debugCopy",
6
+ TOGGLE_SKILL_INFO = "debugToggleSkillInfo"
7
+ }
8
+ export declare enum AgentCommonActions {
3
9
  VIEW = "view",
4
10
  EDIT = "edit",
5
11
  UPDATED = "updated",
@@ -15,8 +21,28 @@ type CommonAnalyticsAttributes = {
15
21
  touchPoint: string;
16
22
  agentId: string;
17
23
  };
18
- export declare const useRovoAgentActionAnalytics: <T extends Partial<CommonAnalyticsAttributes>>(commonAttributes: T) => {
19
- trackAgentAction: (action: AgentActions, attributes: RemainingRequired<CommonAnalyticsAttributes, T> & Record<string, any>) => void;
20
- trackAgentActionError: (action: AgentActions, error: Error, attributes?: RemainingRequired<CommonAnalyticsAttributes, T> & Record<string, any>) => void;
24
+ type EmptyAttributes = {};
25
+ type ActionAttributes = {
26
+ [AgentCommonActions.VIEW]: CommonAnalyticsAttributes;
27
+ [AgentCommonActions.EDIT]: CommonAnalyticsAttributes;
28
+ [AgentCommonActions.UPDATED]: CommonAnalyticsAttributes & {
29
+ agentType: string;
30
+ field: string;
31
+ };
32
+ [AgentCommonActions.COPY_LINK]: CommonAnalyticsAttributes;
33
+ [AgentCommonActions.DELETE]: CommonAnalyticsAttributes;
34
+ [AgentCommonActions.DUPLICATE]: CommonAnalyticsAttributes;
35
+ [AgentCommonActions.STAR]: CommonAnalyticsAttributes;
36
+ [AgentCommonActions.CHAT]: CommonAnalyticsAttributes;
37
+ [AgentCommonActions.VERIFY]: CommonAnalyticsAttributes;
38
+ [AgentCommonActions.UNVERIFY]: CommonAnalyticsAttributes;
39
+ [AgentDebugActions.COPY_ALL]: EmptyAttributes;
40
+ [AgentDebugActions.COPY]: EmptyAttributes;
41
+ [AgentDebugActions.TOGGLE_SKILL_INFO]: EmptyAttributes;
42
+ [AgentDebugActions.VIEW]: EmptyAttributes;
43
+ };
44
+ export declare const useRovoAgentActionAnalytics: <T extends {}>(commonAttributes: T) => {
45
+ trackAgentAction: <A extends keyof ActionAttributes>(action: A, attributes: RemainingRequired<ActionAttributes[A], T>) => void;
46
+ trackAgentActionError: <A extends keyof ActionAttributes>(action: A, error: Error, attributes?: RemainingRequired<ActionAttributes[A], T>) => void;
21
47
  };
22
48
  export {};
package/package.json CHANGED
@@ -83,7 +83,7 @@
83
83
  ]
84
84
  },
85
85
  "name": "@atlaskit/rovo-agent-analytics",
86
- "version": "0.12.1",
86
+ "version": "0.13.0",
87
87
  "description": "Rovo Agents analytics",
88
88
  "author": "Atlassian Pty Ltd",
89
89
  "license": "Apache-2.0",
@@ -1,17 +0,0 @@
1
- {
2
- "name": "@atlaskit/rovo-agent-analytics/debug",
3
- "main": "../dist/cjs/debug/index.js",
4
- "module": "../dist/esm/debug/index.js",
5
- "module:es2019": "../dist/es2019/debug/index.js",
6
- "sideEffects": [
7
- "*.compiled.css"
8
- ],
9
- "types": "../dist/types/debug/index.d.ts",
10
- "typesVersions": {
11
- ">=4.5 <5.9": {
12
- "*": [
13
- "../dist/types-ts4.5/debug/index.d.ts"
14
- ]
15
- }
16
- }
17
- }
@@ -1,63 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.useRovoAgentDebugAnalytics = exports.AgentDebugActions = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _react = require("react");
10
- var _analyticsNext = require("@atlaskit/analytics-next");
11
- var _constants = require("../common/constants");
12
- var _utils = require("../common/utils");
13
- 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; }
14
- 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; }
15
- var AgentDebugActions = exports.AgentDebugActions = /*#__PURE__*/function (AgentDebugActions) {
16
- /* View debug modal */
17
- AgentDebugActions["VIEW"] = "debugView";
18
- /* Copy all debug data */
19
- AgentDebugActions["COPY_ALL"] = "debugCopyAll";
20
- /* Copy debug data */
21
- AgentDebugActions["COPY"] = "debugCopy";
22
- /* Toggle skill info */
23
- AgentDebugActions["TOGGLE_SKILL_INFO"] = "debugToggleSkillInfo";
24
- /* Error occurred */
25
- AgentDebugActions["ERROR"] = "debugError";
26
- return AgentDebugActions;
27
- }({});
28
- var useRovoAgentDebugAnalytics = exports.useRovoAgentDebugAnalytics = function useRovoAgentDebugAnalytics(commonAttributes) {
29
- var analyticsContext = (0, _react.useContext)(_analyticsNext.AnalyticsReactContext);
30
- var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
31
- createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
32
- var eventConfig = (0, _react.useMemo)(function () {
33
- return (0, _utils.getDefaultTrackEventConfig)();
34
- }, []);
35
- var fireAnalyticsEvent = (0, _react.useCallback)(function (event) {
36
- var attributes = _objectSpread(_objectSpread(_objectSpread({}, (0, _utils.getAttributesFromContexts)(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributes), event.attributes);
37
- createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, eventConfig), event), {}, {
38
- attributes: attributes
39
- })).fire(_constants.ANALYTICS_CHANNEL);
40
- }, [createAnalyticsEvent, eventConfig, commonAttributes, analyticsContext]);
41
- var trackAgentDebug = (0, _react.useCallback)(function (action, attributes) {
42
- fireAnalyticsEvent({
43
- actionSubject: 'rovoAgent',
44
- action: action,
45
- attributes: attributes
46
- });
47
- }, [fireAnalyticsEvent]);
48
- var trackAgentDebugError = (0, _react.useCallback)(function (action, error, attributes) {
49
- fireAnalyticsEvent({
50
- actionSubject: 'rovoAgentError',
51
- action: action,
52
- attributes: _objectSpread(_objectSpread({}, attributes), error && {
53
- error: {
54
- message: error.message
55
- }
56
- })
57
- });
58
- }, [fireAnalyticsEvent]);
59
- return {
60
- trackAgentDebug: trackAgentDebug,
61
- trackAgentDebugError: trackAgentDebugError
62
- };
63
- };
@@ -1,61 +0,0 @@
1
- import { useCallback, useContext, useMemo } from 'react';
2
- import { AnalyticsReactContext, useAnalyticsEvents } from '@atlaskit/analytics-next';
3
- import { ANALYTICS_CHANNEL } from '../common/constants';
4
- import { getAttributesFromContexts, getDefaultTrackEventConfig } from '../common/utils';
5
- export let AgentDebugActions = /*#__PURE__*/function (AgentDebugActions) {
6
- /* View debug modal */
7
- AgentDebugActions["VIEW"] = "debugView";
8
- /* Copy all debug data */
9
- AgentDebugActions["COPY_ALL"] = "debugCopyAll";
10
- /* Copy debug data */
11
- AgentDebugActions["COPY"] = "debugCopy";
12
- /* Toggle skill info */
13
- AgentDebugActions["TOGGLE_SKILL_INFO"] = "debugToggleSkillInfo";
14
- /* Error occurred */
15
- AgentDebugActions["ERROR"] = "debugError";
16
- return AgentDebugActions;
17
- }({});
18
- export const useRovoAgentDebugAnalytics = commonAttributes => {
19
- const analyticsContext = useContext(AnalyticsReactContext);
20
- const {
21
- createAnalyticsEvent
22
- } = useAnalyticsEvents();
23
- const eventConfig = useMemo(() => getDefaultTrackEventConfig(), []);
24
- const fireAnalyticsEvent = useCallback(event => {
25
- const attributes = {
26
- ...getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext()),
27
- ...commonAttributes,
28
- ...event.attributes
29
- };
30
- createAnalyticsEvent({
31
- ...eventConfig,
32
- ...event,
33
- attributes
34
- }).fire(ANALYTICS_CHANNEL);
35
- }, [createAnalyticsEvent, eventConfig, commonAttributes, analyticsContext]);
36
- const trackAgentDebug = useCallback((action, attributes) => {
37
- fireAnalyticsEvent({
38
- actionSubject: 'rovoAgent',
39
- action,
40
- attributes
41
- });
42
- }, [fireAnalyticsEvent]);
43
- const trackAgentDebugError = useCallback((action, error, attributes) => {
44
- fireAnalyticsEvent({
45
- actionSubject: 'rovoAgentError',
46
- action,
47
- attributes: {
48
- ...attributes,
49
- ...(error && {
50
- error: {
51
- message: error.message
52
- }
53
- })
54
- }
55
- });
56
- }, [fireAnalyticsEvent]);
57
- return {
58
- trackAgentDebug,
59
- trackAgentDebugError
60
- };
61
- };
@@ -1,56 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- 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; }
3
- 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) { _defineProperty(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; }
4
- import { useCallback, useContext, useMemo } from 'react';
5
- import { AnalyticsReactContext, useAnalyticsEvents } from '@atlaskit/analytics-next';
6
- import { ANALYTICS_CHANNEL } from '../common/constants';
7
- import { getAttributesFromContexts, getDefaultTrackEventConfig } from '../common/utils';
8
- export var AgentDebugActions = /*#__PURE__*/function (AgentDebugActions) {
9
- /* View debug modal */
10
- AgentDebugActions["VIEW"] = "debugView";
11
- /* Copy all debug data */
12
- AgentDebugActions["COPY_ALL"] = "debugCopyAll";
13
- /* Copy debug data */
14
- AgentDebugActions["COPY"] = "debugCopy";
15
- /* Toggle skill info */
16
- AgentDebugActions["TOGGLE_SKILL_INFO"] = "debugToggleSkillInfo";
17
- /* Error occurred */
18
- AgentDebugActions["ERROR"] = "debugError";
19
- return AgentDebugActions;
20
- }({});
21
- export var useRovoAgentDebugAnalytics = function useRovoAgentDebugAnalytics(commonAttributes) {
22
- var analyticsContext = useContext(AnalyticsReactContext);
23
- var _useAnalyticsEvents = useAnalyticsEvents(),
24
- createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
25
- var eventConfig = useMemo(function () {
26
- return getDefaultTrackEventConfig();
27
- }, []);
28
- var fireAnalyticsEvent = useCallback(function (event) {
29
- var attributes = _objectSpread(_objectSpread(_objectSpread({}, getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributes), event.attributes);
30
- createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, eventConfig), event), {}, {
31
- attributes: attributes
32
- })).fire(ANALYTICS_CHANNEL);
33
- }, [createAnalyticsEvent, eventConfig, commonAttributes, analyticsContext]);
34
- var trackAgentDebug = useCallback(function (action, attributes) {
35
- fireAnalyticsEvent({
36
- actionSubject: 'rovoAgent',
37
- action: action,
38
- attributes: attributes
39
- });
40
- }, [fireAnalyticsEvent]);
41
- var trackAgentDebugError = useCallback(function (action, error, attributes) {
42
- fireAnalyticsEvent({
43
- actionSubject: 'rovoAgentError',
44
- action: action,
45
- attributes: _objectSpread(_objectSpread({}, attributes), error && {
46
- error: {
47
- message: error.message
48
- }
49
- })
50
- });
51
- }, [fireAnalyticsEvent]);
52
- return {
53
- trackAgentDebug: trackAgentDebug,
54
- trackAgentDebugError: trackAgentDebugError
55
- };
56
- };
@@ -1,16 +0,0 @@
1
- import type { RemainingRequired } from '../common/types';
2
- export declare enum AgentDebugActions {
3
- VIEW = "debugView",
4
- COPY_ALL = "debugCopyAll",
5
- COPY = "debugCopy",
6
- TOGGLE_SKILL_INFO = "debugToggleSkillInfo",
7
- ERROR = "debugError"
8
- }
9
- type CommonAnalyticsAttributes = {
10
- agentId: string;
11
- };
12
- export declare const useRovoAgentDebugAnalytics: <T extends Partial<CommonAnalyticsAttributes>>(commonAttributes?: T) => {
13
- trackAgentDebug: (action: AgentDebugActions, attributes?: RemainingRequired<CommonAnalyticsAttributes, T extends undefined ? {} : T> & Record<string, any>) => void;
14
- trackAgentDebugError: (action: AgentDebugActions, error?: Error, attributes?: RemainingRequired<CommonAnalyticsAttributes, T extends undefined ? {} : T> & Record<string, any>) => void;
15
- };
16
- export {};
@@ -1,16 +0,0 @@
1
- import type { RemainingRequired } from '../common/types';
2
- export declare enum AgentDebugActions {
3
- VIEW = "debugView",
4
- COPY_ALL = "debugCopyAll",
5
- COPY = "debugCopy",
6
- TOGGLE_SKILL_INFO = "debugToggleSkillInfo",
7
- ERROR = "debugError"
8
- }
9
- type CommonAnalyticsAttributes = {
10
- agentId: string;
11
- };
12
- export declare const useRovoAgentDebugAnalytics: <T extends Partial<CommonAnalyticsAttributes>>(commonAttributes?: T) => {
13
- trackAgentDebug: (action: AgentDebugActions, attributes?: RemainingRequired<CommonAnalyticsAttributes, T extends undefined ? {} : T> & Record<string, any>) => void;
14
- trackAgentDebugError: (action: AgentDebugActions, error?: Error, attributes?: RemainingRequired<CommonAnalyticsAttributes, T extends undefined ? {} : T> & Record<string, any>) => void;
15
- };
16
- export {};