@atlaskit/rovo-agent-analytics 0.12.1 → 0.14.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,19 @@
1
1
  # @atlaskit/rovo-agent-analytics
2
2
 
3
+ ## 0.14.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`dd26e8d5e8e1b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/dd26e8d5e8e1b) -
8
+ Update rovo agent analytics track landing
9
+
10
+ ## 0.13.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [`d6ab7edf41142`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d6ab7edf41142) -
15
+ Update agent analytics types
16
+
3
17
  ## 0.12.1
4
18
 
5
19
  ### 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,42 +12,53 @@ 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
  }({});
49
+ var globalEventConfig = (0, _utils.getDefaultTrackEventConfig)();
38
50
  var useRovoAgentActionAnalytics = exports.useRovoAgentActionAnalytics = function useRovoAgentActionAnalytics(commonAttributes) {
39
51
  var analyticsContext = (0, _react.useContext)(_analyticsNext.AnalyticsReactContext);
40
52
  var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
41
53
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
42
- var eventConfig = (0, _react.useMemo)(function () {
43
- return (0, _utils.getDefaultTrackEventConfig)();
44
- }, []);
54
+ var commonAttributesRef = (0, _react.useRef)(commonAttributes);
45
55
  var fireAnalyticsEvent = (0, _react.useCallback)(function (event) {
46
- var attributes = _objectSpread(_objectSpread(_objectSpread({}, (0, _utils.getAttributesFromContexts)(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributes), event.attributes);
47
- createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, eventConfig), event), {}, {
56
+ var attributes = _objectSpread(_objectSpread(_objectSpread({}, (0, _utils.getAttributesFromContexts)(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributesRef.current), event.attributes);
57
+ createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, globalEventConfig), event), {}, {
48
58
  attributes: attributes
49
59
  })).fire(_constants.ANALYTICS_CHANNEL);
50
- }, [createAnalyticsEvent, eventConfig, commonAttributes, analyticsContext]);
60
+ }, [createAnalyticsEvent, analyticsContext] // keep number of dependencies minimal to prevent re-rendering
61
+ );
51
62
  var trackAgentAction = (0, _react.useCallback)(function (action, attributes) {
52
63
  fireAnalyticsEvent({
53
64
  actionSubject: 'rovoAgent',
@@ -35,6 +35,7 @@ var useRovoAgentCSID = exports.useRovoAgentCSID = function useRovoAgentCSID() {
35
35
  refresh: function refresh() {
36
36
  var newCSID = generateCSID();
37
37
  setCSID(newCSID);
38
+ return newCSID;
38
39
  },
39
40
  clear: function clear() {
40
41
  // remove CSID query parameter
@@ -44,6 +45,7 @@ var useRovoAgentCSID = exports.useRovoAgentCSID = function useRovoAgentCSID() {
44
45
 
45
46
  // reset state
46
47
  setCSID(null);
48
+ return null;
47
49
  }
48
50
  };
49
51
  }, []);
@@ -33,25 +33,27 @@ var AgentCreateActions = exports.AgentCreateActions = /*#__PURE__*/function (Age
33
33
  AgentCreateActions["DISCARD"] = "createDiscard";
34
34
  return AgentCreateActions;
35
35
  }({});
36
+ var globalEventConfig = (0, _utils.getDefaultTrackEventConfig)();
36
37
  var useRovoAgentCreateAnalytics = exports.useRovoAgentCreateAnalytics = function useRovoAgentCreateAnalytics(commonAttributes) {
37
38
  var _useRovoAgentCSID = (0, _csid.useRovoAgentCSID)(),
38
39
  _useRovoAgentCSID2 = (0, _slicedToArray2.default)(_useRovoAgentCSID, 2),
39
40
  csid = _useRovoAgentCSID2[0],
40
41
  refreshCSID = _useRovoAgentCSID2[1].refresh;
42
+ var analyticsContext = (0, _react.useContext)(_analyticsNext.AnalyticsReactContext);
41
43
  var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
42
44
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
43
- var eventConfig = (0, _react.useMemo)(function () {
44
- return (0, _utils.getDefaultTrackEventConfig)();
45
- }, []);
45
+ var commonAttributesRef = (0, _react.useRef)(commonAttributes);
46
46
  var fireAnalyticsEvent = (0, _react.useCallback)(function (event) {
47
47
  var referrer = typeof window !== 'undefined' ? window.document.referrer : 'unknown';
48
- createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, eventConfig), event), {}, {
49
- attributes: _objectSpread(_objectSpread({
50
- csid: csid,
51
- referrer: referrer
52
- }, commonAttributes), event.attributes)
48
+ var attributes = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, (0, _utils.getAttributesFromContexts)(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributesRef.current), event.attributes), {}, {
49
+ csid: csid,
50
+ referrer: referrer
51
+ });
52
+ createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, globalEventConfig), event), {}, {
53
+ attributes: attributes
53
54
  })).fire(_constants.ANALYTICS_CHANNEL);
54
- }, [createAnalyticsEvent, eventConfig, csid, commonAttributes]);
55
+ }, [createAnalyticsEvent, csid, analyticsContext] // keep number of dependencies minimal to prevent re-rendering
56
+ );
55
57
 
56
58
  /**
57
59
  * This will fire analytics event for intermediate steps in the create agent flow funnel
@@ -90,6 +92,7 @@ var useRovoAgentCreateAnalytics = exports.useRovoAgentCreateAnalytics = function
90
92
  return [csid, {
91
93
  trackCreateSession: trackCreateSession,
92
94
  trackCreateSessionStart: trackCreateSessionStart,
93
- trackCreateSessionError: trackCreateSessionError
95
+ trackCreateSessionError: trackCreateSessionError,
96
+ refreshCSID: refreshCSID
94
97
  }];
95
98
  };
@@ -1,48 +1,61 @@
1
- import { useCallback, useContext, useMemo } from 'react';
1
+ import { useCallback, useContext, useRef } 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
  }({});
39
+ const globalEventConfig = getDefaultTrackEventConfig();
28
40
  export const useRovoAgentActionAnalytics = commonAttributes => {
29
41
  const analyticsContext = useContext(AnalyticsReactContext);
30
42
  const {
31
43
  createAnalyticsEvent
32
44
  } = useAnalyticsEvents();
33
- const eventConfig = useMemo(() => getDefaultTrackEventConfig(), []);
45
+ const commonAttributesRef = useRef(commonAttributes);
34
46
  const fireAnalyticsEvent = useCallback(event => {
35
47
  const attributes = {
36
48
  ...getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext()),
37
- ...commonAttributes,
49
+ ...commonAttributesRef.current,
38
50
  ...event.attributes
39
51
  };
40
52
  createAnalyticsEvent({
41
- ...eventConfig,
53
+ ...globalEventConfig,
42
54
  ...event,
43
55
  attributes
44
56
  }).fire(ANALYTICS_CHANNEL);
45
- }, [createAnalyticsEvent, eventConfig, commonAttributes, analyticsContext]);
57
+ }, [createAnalyticsEvent, analyticsContext] // keep number of dependencies minimal to prevent re-rendering
58
+ );
46
59
  const trackAgentAction = useCallback((action, attributes) => {
47
60
  fireAnalyticsEvent({
48
61
  actionSubject: 'rovoAgent',
@@ -24,6 +24,7 @@ export const useRovoAgentCSID = () => {
24
24
  refresh: () => {
25
25
  const newCSID = generateCSID();
26
26
  setCSID(newCSID);
27
+ return newCSID;
27
28
  },
28
29
  clear: () => {
29
30
  // remove CSID query parameter
@@ -33,6 +34,7 @@ export const useRovoAgentCSID = () => {
33
34
 
34
35
  // reset state
35
36
  setCSID(null);
37
+ return null;
36
38
  }
37
39
  };
38
40
  }, []);
@@ -1,8 +1,8 @@
1
- import { useCallback, useMemo } from 'react';
2
- import { useAnalyticsEvents } from '@atlaskit/analytics-next';
1
+ import { useCallback, useContext, useRef } from 'react';
2
+ import { AnalyticsReactContext, useAnalyticsEvents } from '@atlaskit/analytics-next';
3
3
  import { ANALYTICS_CHANNEL } from '../common/constants';
4
4
  import { useRovoAgentCSID } from '../common/csid';
5
- import { getDefaultTrackEventConfig } from '../common/utils';
5
+ import { getAttributesFromContexts, getDefaultTrackEventConfig } from '../common/utils';
6
6
  export let AgentCreateActions = /*#__PURE__*/function (AgentCreateActions) {
7
7
  /* Start create flow when user clicks on "Create agent" button - https://data-portal.internal.atlassian.com/analytics/registry/97089 */
8
8
  AgentCreateActions["START"] = "createFlowStart";
@@ -22,27 +22,32 @@ export let AgentCreateActions = /*#__PURE__*/function (AgentCreateActions) {
22
22
  AgentCreateActions["DISCARD"] = "createDiscard";
23
23
  return AgentCreateActions;
24
24
  }({});
25
+ const globalEventConfig = getDefaultTrackEventConfig();
25
26
  export const useRovoAgentCreateAnalytics = commonAttributes => {
26
27
  const [csid, {
27
28
  refresh: refreshCSID
28
29
  }] = useRovoAgentCSID();
30
+ const analyticsContext = useContext(AnalyticsReactContext);
29
31
  const {
30
32
  createAnalyticsEvent
31
33
  } = useAnalyticsEvents();
32
- const eventConfig = useMemo(() => getDefaultTrackEventConfig(), []);
34
+ const commonAttributesRef = useRef(commonAttributes);
33
35
  const fireAnalyticsEvent = useCallback(event => {
34
36
  const referrer = typeof window !== 'undefined' ? window.document.referrer : 'unknown';
37
+ const attributes = {
38
+ ...getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext()),
39
+ ...commonAttributesRef.current,
40
+ ...event.attributes,
41
+ csid,
42
+ referrer
43
+ };
35
44
  createAnalyticsEvent({
36
- ...eventConfig,
45
+ ...globalEventConfig,
37
46
  ...event,
38
- attributes: {
39
- csid,
40
- referrer,
41
- ...commonAttributes,
42
- ...event.attributes
43
- }
47
+ attributes
44
48
  }).fire(ANALYTICS_CHANNEL);
45
- }, [createAnalyticsEvent, eventConfig, csid, commonAttributes]);
49
+ }, [createAnalyticsEvent, csid, analyticsContext] // keep number of dependencies minimal to prevent re-rendering
50
+ );
46
51
 
47
52
  /**
48
53
  * This will fire analytics event for intermediate steps in the create agent flow funnel
@@ -82,6 +87,7 @@ export const useRovoAgentCreateAnalytics = commonAttributes => {
82
87
  return [csid, {
83
88
  trackCreateSession,
84
89
  trackCreateSessionStart,
85
- trackCreateSessionError
90
+ trackCreateSessionError,
91
+ refreshCSID
86
92
  }];
87
93
  };
@@ -1,46 +1,57 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
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
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';
4
+ import { useCallback, useContext, useRef } 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
  }({});
42
+ var globalEventConfig = getDefaultTrackEventConfig();
31
43
  export var useRovoAgentActionAnalytics = function useRovoAgentActionAnalytics(commonAttributes) {
32
44
  var analyticsContext = useContext(AnalyticsReactContext);
33
45
  var _useAnalyticsEvents = useAnalyticsEvents(),
34
46
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
35
- var eventConfig = useMemo(function () {
36
- return getDefaultTrackEventConfig();
37
- }, []);
47
+ var commonAttributesRef = useRef(commonAttributes);
38
48
  var fireAnalyticsEvent = useCallback(function (event) {
39
- var attributes = _objectSpread(_objectSpread(_objectSpread({}, getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributes), event.attributes);
40
- createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, eventConfig), event), {}, {
49
+ var attributes = _objectSpread(_objectSpread(_objectSpread({}, getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributesRef.current), event.attributes);
50
+ createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, globalEventConfig), event), {}, {
41
51
  attributes: attributes
42
52
  })).fire(ANALYTICS_CHANNEL);
43
- }, [createAnalyticsEvent, eventConfig, commonAttributes, analyticsContext]);
53
+ }, [createAnalyticsEvent, analyticsContext] // keep number of dependencies minimal to prevent re-rendering
54
+ );
44
55
  var trackAgentAction = useCallback(function (action, attributes) {
45
56
  fireAnalyticsEvent({
46
57
  actionSubject: 'rovoAgent',
@@ -28,6 +28,7 @@ export var useRovoAgentCSID = function useRovoAgentCSID() {
28
28
  refresh: function refresh() {
29
29
  var newCSID = generateCSID();
30
30
  setCSID(newCSID);
31
+ return newCSID;
31
32
  },
32
33
  clear: function clear() {
33
34
  // remove CSID query parameter
@@ -37,6 +38,7 @@ export var useRovoAgentCSID = function useRovoAgentCSID() {
37
38
 
38
39
  // reset state
39
40
  setCSID(null);
41
+ return null;
40
42
  }
41
43
  };
42
44
  }, []);
@@ -2,11 +2,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  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; }
4
4
  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; }
5
- import { useCallback, useMemo } from 'react';
6
- import { useAnalyticsEvents } from '@atlaskit/analytics-next';
5
+ import { useCallback, useContext, useRef } from 'react';
6
+ import { AnalyticsReactContext, useAnalyticsEvents } from '@atlaskit/analytics-next';
7
7
  import { ANALYTICS_CHANNEL } from '../common/constants';
8
8
  import { useRovoAgentCSID } from '../common/csid';
9
- import { getDefaultTrackEventConfig } from '../common/utils';
9
+ import { getAttributesFromContexts, getDefaultTrackEventConfig } from '../common/utils';
10
10
  export var AgentCreateActions = /*#__PURE__*/function (AgentCreateActions) {
11
11
  /* Start create flow when user clicks on "Create agent" button - https://data-portal.internal.atlassian.com/analytics/registry/97089 */
12
12
  AgentCreateActions["START"] = "createFlowStart";
@@ -26,25 +26,27 @@ export var AgentCreateActions = /*#__PURE__*/function (AgentCreateActions) {
26
26
  AgentCreateActions["DISCARD"] = "createDiscard";
27
27
  return AgentCreateActions;
28
28
  }({});
29
+ var globalEventConfig = getDefaultTrackEventConfig();
29
30
  export var useRovoAgentCreateAnalytics = function useRovoAgentCreateAnalytics(commonAttributes) {
30
31
  var _useRovoAgentCSID = useRovoAgentCSID(),
31
32
  _useRovoAgentCSID2 = _slicedToArray(_useRovoAgentCSID, 2),
32
33
  csid = _useRovoAgentCSID2[0],
33
34
  refreshCSID = _useRovoAgentCSID2[1].refresh;
35
+ var analyticsContext = useContext(AnalyticsReactContext);
34
36
  var _useAnalyticsEvents = useAnalyticsEvents(),
35
37
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
36
- var eventConfig = useMemo(function () {
37
- return getDefaultTrackEventConfig();
38
- }, []);
38
+ var commonAttributesRef = useRef(commonAttributes);
39
39
  var fireAnalyticsEvent = useCallback(function (event) {
40
40
  var referrer = typeof window !== 'undefined' ? window.document.referrer : 'unknown';
41
- createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, eventConfig), event), {}, {
42
- attributes: _objectSpread(_objectSpread({
43
- csid: csid,
44
- referrer: referrer
45
- }, commonAttributes), event.attributes)
41
+ var attributes = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributesRef.current), event.attributes), {}, {
42
+ csid: csid,
43
+ referrer: referrer
44
+ });
45
+ createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, globalEventConfig), event), {}, {
46
+ attributes: attributes
46
47
  })).fire(ANALYTICS_CHANNEL);
47
- }, [createAnalyticsEvent, eventConfig, csid, commonAttributes]);
48
+ }, [createAnalyticsEvent, csid, analyticsContext] // keep number of dependencies minimal to prevent re-rendering
49
+ );
48
50
 
49
51
  /**
50
52
  * This will fire analytics event for intermediate steps in the create agent flow funnel
@@ -83,6 +85,7 @@ export var useRovoAgentCreateAnalytics = function useRovoAgentCreateAnalytics(co
83
85
  return [csid, {
84
86
  trackCreateSession: trackCreateSession,
85
87
  trackCreateSessionStart: trackCreateSessionStart,
86
- trackCreateSessionError: trackCreateSessionError
88
+ trackCreateSessionError: trackCreateSessionError,
89
+ refreshCSID: refreshCSID
87
90
  }];
88
91
  };
@@ -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 {};
@@ -3,6 +3,6 @@
3
3
  * @returns Rovo Agent CSID as a string.
4
4
  */
5
5
  export declare const useRovoAgentCSID: () => readonly [string | null, {
6
- refresh: () => void;
7
- clear: () => void;
6
+ refresh: () => `${string}-${string}-${string}-${string}-${string}`;
7
+ clear: () => null;
8
8
  }];
@@ -15,5 +15,6 @@ export declare const useRovoAgentCreateAnalytics: (commonAttributes: CommonAnaly
15
15
  readonly trackCreateSession: (action: Omit<AgentCreateActions, AgentCreateActions.START>, attributes?: CommonAnalyticsAttributes) => void;
16
16
  readonly trackCreateSessionStart: (attributes?: CommonAnalyticsAttributes) => void;
17
17
  readonly trackCreateSessionError: (error: Error, attributes?: CommonAnalyticsAttributes) => void;
18
+ readonly refreshCSID: () => `${string}-${string}-${string}-${string}-${string}`;
18
19
  }];
19
20
  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 {};
@@ -5,7 +5,7 @@
5
5
  export declare const useRovoAgentCSID: () => readonly [
6
6
  string | null,
7
7
  {
8
- refresh: () => void;
9
- clear: () => void;
8
+ refresh: () => `${string}-${string}-${string}-${string}-${string}`;
9
+ clear: () => null;
10
10
  }
11
11
  ];
@@ -17,6 +17,7 @@ export declare const useRovoAgentCreateAnalytics: (commonAttributes: CommonAnaly
17
17
  readonly trackCreateSession: (action: Omit<AgentCreateActions, AgentCreateActions.START>, attributes?: CommonAnalyticsAttributes) => void;
18
18
  readonly trackCreateSessionStart: (attributes?: CommonAnalyticsAttributes) => void;
19
19
  readonly trackCreateSessionError: (error: Error, attributes?: CommonAnalyticsAttributes) => void;
20
+ readonly refreshCSID: () => `${string}-${string}-${string}-${string}-${string}`;
20
21
  }
21
22
  ];
22
23
  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.14.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 {};