@atlaskit/rovo-agent-analytics 0.19.0 → 1.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +112 -103
  3. package/dist/cjs/actions/groups/agent-interactions.js +1 -40
  4. package/dist/cjs/actions/groups/debug.js +1 -31
  5. package/dist/cjs/actions/groups/editing.js +1 -22
  6. package/dist/cjs/actions/groups/evaluation.js +1 -0
  7. package/dist/cjs/actions/groups/tools.js +1 -28
  8. package/dist/cjs/actions/index.js +24 -34
  9. package/dist/cjs/common/types.js +18 -1
  10. package/dist/cjs/create/index.js +29 -15
  11. package/dist/es2019/actions/groups/agent-interactions.js +1 -38
  12. package/dist/es2019/actions/groups/debug.js +0 -25
  13. package/dist/es2019/actions/groups/editing.js +1 -20
  14. package/dist/es2019/actions/groups/evaluation.js +0 -0
  15. package/dist/es2019/actions/groups/tools.js +1 -26
  16. package/dist/es2019/actions/index.js +17 -34
  17. package/dist/es2019/common/types.js +12 -0
  18. package/dist/es2019/create/index.js +26 -16
  19. package/dist/esm/actions/groups/agent-interactions.js +1 -38
  20. package/dist/esm/actions/groups/debug.js +0 -25
  21. package/dist/esm/actions/groups/editing.js +1 -20
  22. package/dist/esm/actions/groups/evaluation.js +0 -0
  23. package/dist/esm/actions/groups/tools.js +1 -26
  24. package/dist/esm/actions/index.js +23 -34
  25. package/dist/esm/common/types.js +12 -0
  26. package/dist/esm/create/index.js +27 -14
  27. package/dist/types/actions/groups/agent-interactions.d.ts +42 -26
  28. package/dist/types/actions/groups/debug.d.ts +22 -18
  29. package/dist/types/actions/groups/editing.d.ts +6 -10
  30. package/dist/types/actions/groups/evaluation.d.ts +56 -0
  31. package/dist/types/actions/groups/tools.d.ts +22 -20
  32. package/dist/types/actions/index.d.ts +2 -20
  33. package/dist/types/common/types.d.ts +28 -2
  34. package/dist/types/create/index.d.ts +20 -17
  35. package/dist/types-ts4.5/actions/groups/agent-interactions.d.ts +42 -26
  36. package/dist/types-ts4.5/actions/groups/debug.d.ts +22 -18
  37. package/dist/types-ts4.5/actions/groups/editing.d.ts +6 -10
  38. package/dist/types-ts4.5/actions/groups/evaluation.d.ts +56 -0
  39. package/dist/types-ts4.5/actions/groups/tools.d.ts +22 -20
  40. package/dist/types-ts4.5/actions/index.d.ts +2 -20
  41. package/dist/types-ts4.5/common/types.d.ts +28 -2
  42. package/dist/types-ts4.5/create/index.d.ts +20 -17
  43. package/package.json +2 -2
  44. package/actions/add-tools-prompt/package.json +0 -17
  45. package/actions/agent-interactions/package.json +0 -17
  46. package/actions/create-flow/package.json +0 -17
  47. package/actions/debug/package.json +0 -17
  48. package/actions/editing/package.json +0 -17
  49. package/actions/tool-actions/package.json +0 -17
  50. package/dist/cjs/actions/groups/add-tools-prompt.js +0 -32
  51. package/dist/cjs/actions/groups/create-flow.js +0 -39
  52. package/dist/cjs/actions/registry.js +0 -53
  53. package/dist/es2019/actions/groups/add-tools-prompt.js +0 -26
  54. package/dist/es2019/actions/groups/create-flow.js +0 -33
  55. package/dist/es2019/actions/registry.js +0 -52
  56. package/dist/esm/actions/groups/add-tools-prompt.js +0 -26
  57. package/dist/esm/actions/groups/create-flow.js +0 -33
  58. package/dist/esm/actions/registry.js +0 -48
  59. package/dist/types/actions/groups/add-tools-prompt.d.ts +0 -21
  60. package/dist/types/actions/groups/create-flow.d.ts +0 -22
  61. package/dist/types/actions/registry.d.ts +0 -16
  62. package/dist/types-ts4.5/actions/groups/add-tools-prompt.d.ts +0 -21
  63. package/dist/types-ts4.5/actions/groups/create-flow.d.ts +0 -22
  64. package/dist/types-ts4.5/actions/registry.d.ts +0 -16
@@ -1,38 +1 @@
1
- /**
2
- * Action Group: agentInteractions
3
- *
4
- * User-initiated interactions with an agent — typically from the overflow menu ("...")
5
- * or agent profile surfaces (viewing, editing, deleting, duplicating, starring, sharing, verifying).
6
- *
7
- * NOTE: This is about UI interactions, not backend "actions" (which are being replaced by "tools").
8
- *
9
- * ## Adding a new action
10
- * 1. Add the action to the `AgentInteractionActions` enum below with a data-portal link
11
- * 2. Add the corresponding attribute type in `AgentInteractionAttributes`
12
- * 3. If this action doesn't fit user interactions, create a new group file instead
13
- * (see other files in this directory for the template)
14
- */
15
-
16
- /** The group name sent as `attributes.actionGroup` in analytics events */
17
- export const ACTION_GROUP = 'agentInteractions';
18
- export let AgentInteractionActions = /*#__PURE__*/function (AgentInteractionActions) {
19
- /* View agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97125 */
20
- AgentInteractionActions["VIEW"] = "view";
21
- /* Edit agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97126 */
22
- AgentInteractionActions["EDIT"] = "edit";
23
- /* Copy link clicked - https://data-portal.internal.atlassian.com/analytics/registry/97128 */
24
- AgentInteractionActions["COPY_LINK"] = "copyLink";
25
- /* Delete agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97129 */
26
- AgentInteractionActions["DELETE"] = "delete";
27
- /* Duplicate agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97130 */
28
- AgentInteractionActions["DUPLICATE"] = "duplicate";
29
- /* Star agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97133 */
30
- AgentInteractionActions["STAR"] = "star";
31
- /* Chat with agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97095 */
32
- AgentInteractionActions["CHAT"] = "chat";
33
- /* Verify agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97134 */
34
- AgentInteractionActions["VERIFY"] = "verify";
35
- /* Unverify agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97135 */
36
- AgentInteractionActions["UNVERIFY"] = "unverify";
37
- return AgentInteractionActions;
38
- }({});
1
+ export {};
@@ -1,25 +0,0 @@
1
- /**
2
- * Action Group: debug
3
- *
4
- * Actions related to the agent debug modal (viewing, copying debug data, toggling skill info).
5
- *
6
- * ## Adding a new action
7
- * 1. Add the action to the `AgentDebugActions` enum below with a data-portal link
8
- * 2. Add the corresponding attribute type in `DebugActionAttributes`
9
- * 3. If this action doesn't fit this group, consider creating a new group file instead
10
- * (see other files in this directory for the template)
11
- */
12
-
13
- /** The group name sent as `attributes.actionGroup` in analytics events */
14
- export const ACTION_GROUP = 'debug';
15
- export let 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
- }({});
@@ -1,20 +1 @@
1
- /**
2
- * Action Group: editing
3
- *
4
- * Agent editing/mutation events — fired when an agent's configuration is saved or modified.
5
- * Unlike agentInteractions (user clicks), these track actual data changes.
6
- *
7
- * ## Adding a new action
8
- * 1. Add the action to the `AgentEditingActions` enum below with a data-portal link
9
- * 2. Add the corresponding attribute type in `EditingActionAttributes`
10
- * 3. If this action doesn't fit editing/mutation events, create a new group file instead
11
- * (see other files in this directory for the template)
12
- */
13
-
14
- /** The group name sent as `attributes.actionGroup` in analytics events */
15
- export const ACTION_GROUP = 'editing';
16
- export let AgentEditingActions = /*#__PURE__*/function (AgentEditingActions) {
17
- /* Agent updated - https://data-portal.internal.atlassian.com/analytics/registry/97122 */
18
- AgentEditingActions["UPDATED"] = "updated";
19
- return AgentEditingActions;
20
- }({});
1
+ export {};
File without changes
@@ -1,26 +1 @@
1
- /**
2
- * Action Group: tools
3
- *
4
- * Actions related to agent tool execution during chat
5
- * (confirming, streaming, viewing results, errors).
6
- *
7
- * ## Adding a new action
8
- * 1. Add the action to the `AgentToolActions` enum below with a data-portal link
9
- * 2. Add the corresponding attribute type in `ToolsActionAttributes`
10
- * 3. If this action doesn't fit this group, consider creating a new group file instead
11
- * (see other files in this directory for the template)
12
- */
13
-
14
- /** The group name sent as `attributes.actionGroup` in analytics events */
15
- export const ACTION_GROUP = 'tools';
16
- export let AgentToolActions = /*#__PURE__*/function (AgentToolActions) {
17
- /* When chatting with an agent, and tools confirmation being shown, then user click proceed with the possible actions (e.g. confirm, dismiss etc) https://data-portal.internal.atlassian.com/analytics/registry/97675 */
18
- AgentToolActions["TOOLS_EXECUTION_CONFIRMED"] = "toolsExecutionConfirmed";
19
- /* When tools execution result is being streamed and user stops the stream e.g. by clicking stop button https://data-portal.internal.atlassian.com/analytics/registry/97750 */
20
- AgentToolActions["TOOLS_EXECUTION_STREAM_STOPPED"] = "toolsExecutionStreamStopped";
21
- /* When tools execution result is done streaming and user sees the result https://data-portal.internal.atlassian.com/analytics/registry/97751*/
22
- AgentToolActions["TOOLS_EXECUTION_RESULT_VIEWED"] = "toolsExecutionResultViewed";
23
- /* When tools execution result streaming fails https://data-portal.internal.atlassian.com/analytics/registry/97752 */
24
- AgentToolActions["TOOLS_EXECUTION_RESULT_ERROR"] = "toolsExecutionResultError";
25
- return AgentToolActions;
26
- }({});
1
+ export {};
@@ -1,21 +1,8 @@
1
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
+ import { LIBRARY_ATTRIBUTE } from '../common/types';
4
5
  import { getAttributesFromContexts, getDefaultTrackEventConfig } from '../common/utils';
5
- import { AgentInteractionActions } from './groups/agent-interactions';
6
- import { AgentDebugActions as AgentDebugActionsEnum } from './groups/debug';
7
- import { AgentEditingActions } from './groups/editing';
8
- import { ACTION_TO_GROUP } from './registry';
9
-
10
- // Backward-compatible aliases
11
- // TODO: migrate consumers to use group-specific imports, then remove
12
- export const AgentCommonActions = {
13
- ...AgentInteractionActions,
14
- ...AgentEditingActions
15
- };
16
-
17
- // TODO: Remove the alias, will be breaking change, this is just for backward compatibility
18
- export const AgentDebugActions = AgentDebugActionsEnum;
19
6
  const globalEventConfig = getDefaultTrackEventConfig();
20
7
  export const useRovoAgentActionAnalytics = commonAttributes => {
21
8
  const analyticsContext = useContext(AnalyticsReactContext);
@@ -27,6 +14,7 @@ export const useRovoAgentActionAnalytics = commonAttributes => {
27
14
  const attributes = {
28
15
  ...getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext()),
29
16
  ...commonAttributesRef.current,
17
+ library: LIBRARY_ATTRIBUTE,
30
18
  ...event.attributes
31
19
  };
32
20
  createAnalyticsEvent({
@@ -36,31 +24,26 @@ export const useRovoAgentActionAnalytics = commonAttributes => {
36
24
  }).fire(ANALYTICS_CHANNEL);
37
25
  }, [createAnalyticsEvent, analyticsContext] // keep number of dependencies minimal to prevent re-rendering
38
26
  );
39
- const trackAgentAction = useCallback((action, attributes) => {
40
- fireAnalyticsEvent({
41
- actionSubject: 'rovoAgent',
27
+
28
+ /**
29
+ * Fully-typed event tracking using discriminated union payload types.
30
+ * The payload type enforces correct action, actionSubject, and attributes.
31
+ */
32
+ const trackAgentEvent = useCallback(payload => {
33
+ const {
42
34
  action,
43
- attributes: {
44
- ...attributes,
45
- actionGroup: ACTION_TO_GROUP[action]
46
- }
47
- });
48
- }, [fireAnalyticsEvent]);
49
- const trackAgentActionError = useCallback((action, error, attributes) => {
35
+ actionSubject,
36
+ attributes,
37
+ ...eventProps
38
+ } = payload;
50
39
  fireAnalyticsEvent({
51
- actionSubject: 'rovoAgentError',
40
+ actionSubject,
52
41
  action,
53
- attributes: {
54
- ...attributes,
55
- actionGroup: ACTION_TO_GROUP[action],
56
- error: {
57
- message: error.message
58
- }
59
- }
42
+ ...eventProps,
43
+ attributes
60
44
  });
61
45
  }, [fireAnalyticsEvent]);
62
46
  return {
63
- trackAgentAction,
64
- trackAgentActionError
47
+ trackAgentEvent
65
48
  };
66
49
  };
@@ -0,0 +1,12 @@
1
+ /** Common library attribute injected into all events */
2
+ export const LIBRARY_ATTRIBUTE = 'agents-analytics';
3
+
4
+ /**
5
+ * Generic error event payload type.
6
+ * Use with `trackAgentEvent()` to track error events.
7
+ */
8
+
9
+ /**
10
+ * Union of all event payload types.
11
+ * Use with `trackAgentEvent()` for typed event tracking.
12
+ */
@@ -1,18 +1,29 @@
1
1
  import { useCallback, useContext, useRef } from 'react';
2
2
  import { AnalyticsReactContext, useAnalyticsEvents } from '@atlaskit/analytics-next';
3
- import { AddToolsPromptActions } from '../actions/groups/add-tools-prompt';
4
- import { CreateFlowActions } from '../actions/groups/create-flow';
5
- import { ACTION_TO_GROUP } from '../actions/registry';
6
3
  import { ANALYTICS_CHANNEL } from '../common/constants';
7
4
  import { useRovoAgentCSID } from '../common/csid';
8
5
  import { getAttributesFromContexts, getDefaultTrackEventConfig } from '../common/utils';
6
+ const DefaultActionSubject = 'rovoAgent';
7
+
8
+ /**
9
+ * Union type of all valid create agent flow actions.
10
+ * Includes both CreateFlow and AddToolsPrompt actions.
11
+ *
12
+ * Data portal registry links:
13
+ * - createFlowStart: https://data-portal.internal.atlassian.com/analytics/registry/97089
14
+ * - createFlowSkipNL: https://data-portal.internal.atlassian.com/analytics/registry/97127
15
+ * - createFlowReviewNL: https://data-portal.internal.atlassian.com/analytics/registry/97124
16
+ * - createFlowActivate: https://data-portal.internal.atlassian.com/analytics/registry/97123
17
+ * - createFlowRestart: https://data-portal.internal.atlassian.com/analytics/registry/97131
18
+ * - createFlowError: https://data-portal.internal.atlassian.com/analytics/registry/97132
19
+ * - createLandInStudio: https://data-portal.internal.atlassian.com/analytics/registry/97136
20
+ * - createDiscard: https://data-portal.internal.atlassian.com/analytics/registry/97137
21
+ * - saDraft: https://data-portal.internal.atlassian.com/analytics/registry/97924
22
+ * - addToolsPromptShown: https://data-portal.internal.atlassian.com/analytics/registry/98106
23
+ * - addToolsPromptBrowse: https://data-portal.internal.atlassian.com/analytics/registry/98107
24
+ * - addToolsPromptDismiss: https://data-portal.internal.atlassian.com/analytics/registry/98108
25
+ */
9
26
 
10
- // Backward-compatible alias
11
- // TODO: migrate consumers to use CreateFlowActions / AddToolsPromptActions directly, then remove
12
- export const AgentCreateActions = {
13
- ...CreateFlowActions,
14
- ...AddToolsPromptActions
15
- };
16
27
  const globalEventConfig = getDefaultTrackEventConfig();
17
28
  export const useRovoAgentCreateAnalytics = commonAttributes => {
18
29
  const [csid, {
@@ -25,12 +36,11 @@ export const useRovoAgentCreateAnalytics = commonAttributes => {
25
36
  const commonAttributesRef = useRef(commonAttributes);
26
37
  const fireAnalyticsEvent = useCallback(event => {
27
38
  const referrer = typeof window !== 'undefined' ? window.document.referrer : 'unknown';
28
- const action = event.action;
29
39
  const attributes = {
30
40
  ...getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext()),
31
41
  ...commonAttributesRef.current,
32
42
  ...event.attributes,
33
- actionGroup: ACTION_TO_GROUP[action],
43
+ actionGroup: 'createFlow',
34
44
  csid,
35
45
  referrer
36
46
  };
@@ -48,7 +58,7 @@ export const useRovoAgentCreateAnalytics = commonAttributes => {
48
58
  */
49
59
  const trackCreateSession = useCallback((action, attributes) => {
50
60
  fireAnalyticsEvent({
51
- actionSubject: 'rovoAgent',
61
+ actionSubject: DefaultActionSubject,
52
62
  action,
53
63
  attributes
54
64
  });
@@ -59,16 +69,16 @@ export const useRovoAgentCreateAnalytics = commonAttributes => {
59
69
  */
60
70
  const trackCreateSessionStart = useCallback(attributes => {
61
71
  fireAnalyticsEvent({
62
- actionSubject: 'rovoAgent',
63
- action: CreateFlowActions.START,
72
+ actionSubject: DefaultActionSubject,
73
+ action: 'createFlowStart',
64
74
  attributes
65
75
  });
66
76
  refreshCSID();
67
77
  }, [fireAnalyticsEvent, refreshCSID]);
68
78
  const trackCreateSessionError = useCallback((error, attributes) => {
69
79
  fireAnalyticsEvent({
70
- actionSubject: 'rovoAgent',
71
- action: CreateFlowActions.ERROR,
80
+ actionSubject: DefaultActionSubject,
81
+ action: 'createFlowError',
72
82
  attributes: {
73
83
  error: {
74
84
  message: error.message
@@ -1,38 +1 @@
1
- /**
2
- * Action Group: agentInteractions
3
- *
4
- * User-initiated interactions with an agent — typically from the overflow menu ("...")
5
- * or agent profile surfaces (viewing, editing, deleting, duplicating, starring, sharing, verifying).
6
- *
7
- * NOTE: This is about UI interactions, not backend "actions" (which are being replaced by "tools").
8
- *
9
- * ## Adding a new action
10
- * 1. Add the action to the `AgentInteractionActions` enum below with a data-portal link
11
- * 2. Add the corresponding attribute type in `AgentInteractionAttributes`
12
- * 3. If this action doesn't fit user interactions, create a new group file instead
13
- * (see other files in this directory for the template)
14
- */
15
-
16
- /** The group name sent as `attributes.actionGroup` in analytics events */
17
- export var ACTION_GROUP = 'agentInteractions';
18
- export var AgentInteractionActions = /*#__PURE__*/function (AgentInteractionActions) {
19
- /* View agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97125 */
20
- AgentInteractionActions["VIEW"] = "view";
21
- /* Edit agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97126 */
22
- AgentInteractionActions["EDIT"] = "edit";
23
- /* Copy link clicked - https://data-portal.internal.atlassian.com/analytics/registry/97128 */
24
- AgentInteractionActions["COPY_LINK"] = "copyLink";
25
- /* Delete agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97129 */
26
- AgentInteractionActions["DELETE"] = "delete";
27
- /* Duplicate agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97130 */
28
- AgentInteractionActions["DUPLICATE"] = "duplicate";
29
- /* Star agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97133 */
30
- AgentInteractionActions["STAR"] = "star";
31
- /* Chat with agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97095 */
32
- AgentInteractionActions["CHAT"] = "chat";
33
- /* Verify agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97134 */
34
- AgentInteractionActions["VERIFY"] = "verify";
35
- /* Unverify agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97135 */
36
- AgentInteractionActions["UNVERIFY"] = "unverify";
37
- return AgentInteractionActions;
38
- }({});
1
+ export {};
@@ -1,25 +0,0 @@
1
- /**
2
- * Action Group: debug
3
- *
4
- * Actions related to the agent debug modal (viewing, copying debug data, toggling skill info).
5
- *
6
- * ## Adding a new action
7
- * 1. Add the action to the `AgentDebugActions` enum below with a data-portal link
8
- * 2. Add the corresponding attribute type in `DebugActionAttributes`
9
- * 3. If this action doesn't fit this group, consider creating a new group file instead
10
- * (see other files in this directory for the template)
11
- */
12
-
13
- /** The group name sent as `attributes.actionGroup` in analytics events */
14
- export var ACTION_GROUP = 'debug';
15
- export var 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
- }({});
@@ -1,20 +1 @@
1
- /**
2
- * Action Group: editing
3
- *
4
- * Agent editing/mutation events — fired when an agent's configuration is saved or modified.
5
- * Unlike agentInteractions (user clicks), these track actual data changes.
6
- *
7
- * ## Adding a new action
8
- * 1. Add the action to the `AgentEditingActions` enum below with a data-portal link
9
- * 2. Add the corresponding attribute type in `EditingActionAttributes`
10
- * 3. If this action doesn't fit editing/mutation events, create a new group file instead
11
- * (see other files in this directory for the template)
12
- */
13
-
14
- /** The group name sent as `attributes.actionGroup` in analytics events */
15
- export var ACTION_GROUP = 'editing';
16
- export var AgentEditingActions = /*#__PURE__*/function (AgentEditingActions) {
17
- /* Agent updated - https://data-portal.internal.atlassian.com/analytics/registry/97122 */
18
- AgentEditingActions["UPDATED"] = "updated";
19
- return AgentEditingActions;
20
- }({});
1
+ export {};
File without changes
@@ -1,26 +1 @@
1
- /**
2
- * Action Group: tools
3
- *
4
- * Actions related to agent tool execution during chat
5
- * (confirming, streaming, viewing results, errors).
6
- *
7
- * ## Adding a new action
8
- * 1. Add the action to the `AgentToolActions` enum below with a data-portal link
9
- * 2. Add the corresponding attribute type in `ToolsActionAttributes`
10
- * 3. If this action doesn't fit this group, consider creating a new group file instead
11
- * (see other files in this directory for the template)
12
- */
13
-
14
- /** The group name sent as `attributes.actionGroup` in analytics events */
15
- export var ACTION_GROUP = 'tools';
16
- export var AgentToolActions = /*#__PURE__*/function (AgentToolActions) {
17
- /* When chatting with an agent, and tools confirmation being shown, then user click proceed with the possible actions (e.g. confirm, dismiss etc) https://data-portal.internal.atlassian.com/analytics/registry/97675 */
18
- AgentToolActions["TOOLS_EXECUTION_CONFIRMED"] = "toolsExecutionConfirmed";
19
- /* When tools execution result is being streamed and user stops the stream e.g. by clicking stop button https://data-portal.internal.atlassian.com/analytics/registry/97750 */
20
- AgentToolActions["TOOLS_EXECUTION_STREAM_STOPPED"] = "toolsExecutionStreamStopped";
21
- /* When tools execution result is done streaming and user sees the result https://data-portal.internal.atlassian.com/analytics/registry/97751*/
22
- AgentToolActions["TOOLS_EXECUTION_RESULT_VIEWED"] = "toolsExecutionResultViewed";
23
- /* When tools execution result streaming fails https://data-portal.internal.atlassian.com/analytics/registry/97752 */
24
- AgentToolActions["TOOLS_EXECUTION_RESULT_ERROR"] = "toolsExecutionResultError";
25
- return AgentToolActions;
26
- }({});
1
+ export {};
@@ -1,21 +1,13 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
1
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ var _excluded = ["action", "actionSubject", "attributes"];
2
4
  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
5
  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
6
  import { useCallback, useContext, useRef } from 'react';
5
7
  import { AnalyticsReactContext, useAnalyticsEvents } from '@atlaskit/analytics-next';
6
8
  import { ANALYTICS_CHANNEL } from '../common/constants';
9
+ import { LIBRARY_ATTRIBUTE } from '../common/types';
7
10
  import { getAttributesFromContexts, getDefaultTrackEventConfig } from '../common/utils';
8
- import { AgentInteractionActions } from './groups/agent-interactions';
9
- import { AgentDebugActions as AgentDebugActionsEnum } from './groups/debug';
10
- import { AgentEditingActions } from './groups/editing';
11
- import { ACTION_TO_GROUP } from './registry';
12
-
13
- // Backward-compatible aliases
14
- // TODO: migrate consumers to use group-specific imports, then remove
15
- export var AgentCommonActions = _objectSpread(_objectSpread({}, AgentInteractionActions), AgentEditingActions);
16
-
17
- // TODO: Remove the alias, will be breaking change, this is just for backward compatibility
18
- export var AgentDebugActions = AgentDebugActionsEnum;
19
11
  var globalEventConfig = getDefaultTrackEventConfig();
20
12
  export var useRovoAgentActionAnalytics = function useRovoAgentActionAnalytics(commonAttributes) {
21
13
  var analyticsContext = useContext(AnalyticsReactContext);
@@ -23,35 +15,32 @@ export var useRovoAgentActionAnalytics = function useRovoAgentActionAnalytics(co
23
15
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
24
16
  var commonAttributesRef = useRef(commonAttributes);
25
17
  var fireAnalyticsEvent = useCallback(function (event) {
26
- var attributes = _objectSpread(_objectSpread(_objectSpread({}, getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributesRef.current), event.attributes);
18
+ var attributes = _objectSpread(_objectSpread(_objectSpread({}, getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributesRef.current), {}, {
19
+ library: LIBRARY_ATTRIBUTE
20
+ }, event.attributes);
27
21
  createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, globalEventConfig), event), {}, {
28
22
  attributes: attributes
29
23
  })).fire(ANALYTICS_CHANNEL);
30
24
  }, [createAnalyticsEvent, analyticsContext] // keep number of dependencies minimal to prevent re-rendering
31
25
  );
32
- var trackAgentAction = useCallback(function (action, attributes) {
33
- fireAnalyticsEvent({
34
- actionSubject: 'rovoAgent',
35
- action: action,
36
- attributes: _objectSpread(_objectSpread({}, attributes), {}, {
37
- actionGroup: ACTION_TO_GROUP[action]
38
- })
39
- });
40
- }, [fireAnalyticsEvent]);
41
- var trackAgentActionError = useCallback(function (action, error, attributes) {
42
- fireAnalyticsEvent({
43
- actionSubject: 'rovoAgentError',
44
- action: action,
45
- attributes: _objectSpread(_objectSpread({}, attributes), {}, {
46
- actionGroup: ACTION_TO_GROUP[action],
47
- error: {
48
- message: error.message
49
- }
50
- })
51
- });
26
+
27
+ /**
28
+ * Fully-typed event tracking using discriminated union payload types.
29
+ * The payload type enforces correct action, actionSubject, and attributes.
30
+ */
31
+ var trackAgentEvent = useCallback(function (payload) {
32
+ var action = payload.action,
33
+ actionSubject = payload.actionSubject,
34
+ attributes = payload.attributes,
35
+ eventProps = _objectWithoutProperties(payload, _excluded);
36
+ fireAnalyticsEvent(_objectSpread(_objectSpread({
37
+ actionSubject: actionSubject,
38
+ action: action
39
+ }, eventProps), {}, {
40
+ attributes: attributes
41
+ }));
52
42
  }, [fireAnalyticsEvent]);
53
43
  return {
54
- trackAgentAction: trackAgentAction,
55
- trackAgentActionError: trackAgentActionError
44
+ trackAgentEvent: trackAgentEvent
56
45
  };
57
46
  };
@@ -0,0 +1,12 @@
1
+ /** Common library attribute injected into all events */
2
+ export var LIBRARY_ATTRIBUTE = 'agents-analytics';
3
+
4
+ /**
5
+ * Generic error event payload type.
6
+ * Use with `trackAgentEvent()` to track error events.
7
+ */
8
+
9
+ /**
10
+ * Union of all event payload types.
11
+ * Use with `trackAgentEvent()` for typed event tracking.
12
+ */
@@ -1,19 +1,33 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
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
5
  import { useCallback, useContext, useRef } from 'react';
6
6
  import { AnalyticsReactContext, useAnalyticsEvents } from '@atlaskit/analytics-next';
7
- import { AddToolsPromptActions } from '../actions/groups/add-tools-prompt';
8
- import { CreateFlowActions } from '../actions/groups/create-flow';
9
- import { ACTION_TO_GROUP } from '../actions/registry';
10
7
  import { ANALYTICS_CHANNEL } from '../common/constants';
11
8
  import { useRovoAgentCSID } from '../common/csid';
12
9
  import { getAttributesFromContexts, getDefaultTrackEventConfig } from '../common/utils';
10
+ var DefaultActionSubject = 'rovoAgent';
11
+
12
+ /**
13
+ * Union type of all valid create agent flow actions.
14
+ * Includes both CreateFlow and AddToolsPrompt actions.
15
+ *
16
+ * Data portal registry links:
17
+ * - createFlowStart: https://data-portal.internal.atlassian.com/analytics/registry/97089
18
+ * - createFlowSkipNL: https://data-portal.internal.atlassian.com/analytics/registry/97127
19
+ * - createFlowReviewNL: https://data-portal.internal.atlassian.com/analytics/registry/97124
20
+ * - createFlowActivate: https://data-portal.internal.atlassian.com/analytics/registry/97123
21
+ * - createFlowRestart: https://data-portal.internal.atlassian.com/analytics/registry/97131
22
+ * - createFlowError: https://data-portal.internal.atlassian.com/analytics/registry/97132
23
+ * - createLandInStudio: https://data-portal.internal.atlassian.com/analytics/registry/97136
24
+ * - createDiscard: https://data-portal.internal.atlassian.com/analytics/registry/97137
25
+ * - saDraft: https://data-portal.internal.atlassian.com/analytics/registry/97924
26
+ * - addToolsPromptShown: https://data-portal.internal.atlassian.com/analytics/registry/98106
27
+ * - addToolsPromptBrowse: https://data-portal.internal.atlassian.com/analytics/registry/98107
28
+ * - addToolsPromptDismiss: https://data-portal.internal.atlassian.com/analytics/registry/98108
29
+ */
13
30
 
14
- // Backward-compatible alias
15
- // TODO: migrate consumers to use CreateFlowActions / AddToolsPromptActions directly, then remove
16
- export var AgentCreateActions = _objectSpread(_objectSpread({}, CreateFlowActions), AddToolsPromptActions);
17
31
  var globalEventConfig = getDefaultTrackEventConfig();
18
32
  export var useRovoAgentCreateAnalytics = function useRovoAgentCreateAnalytics(commonAttributes) {
19
33
  var _useRovoAgentCSID = useRovoAgentCSID(),
@@ -26,9 +40,8 @@ export var useRovoAgentCreateAnalytics = function useRovoAgentCreateAnalytics(co
26
40
  var commonAttributesRef = useRef(commonAttributes);
27
41
  var fireAnalyticsEvent = useCallback(function (event) {
28
42
  var referrer = typeof window !== 'undefined' ? window.document.referrer : 'unknown';
29
- var action = event.action;
30
43
  var attributes = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributesRef.current), event.attributes), {}, {
31
- actionGroup: ACTION_TO_GROUP[action],
44
+ actionGroup: 'createFlow',
32
45
  csid: csid,
33
46
  referrer: referrer
34
47
  });
@@ -44,7 +57,7 @@ export var useRovoAgentCreateAnalytics = function useRovoAgentCreateAnalytics(co
44
57
  */
45
58
  var trackCreateSession = useCallback(function (action, attributes) {
46
59
  fireAnalyticsEvent({
47
- actionSubject: 'rovoAgent',
60
+ actionSubject: DefaultActionSubject,
48
61
  action: action,
49
62
  attributes: attributes
50
63
  });
@@ -55,16 +68,16 @@ export var useRovoAgentCreateAnalytics = function useRovoAgentCreateAnalytics(co
55
68
  */
56
69
  var trackCreateSessionStart = useCallback(function (attributes) {
57
70
  fireAnalyticsEvent({
58
- actionSubject: 'rovoAgent',
59
- action: CreateFlowActions.START,
71
+ actionSubject: DefaultActionSubject,
72
+ action: 'createFlowStart',
60
73
  attributes: attributes
61
74
  });
62
75
  refreshCSID();
63
76
  }, [fireAnalyticsEvent, refreshCSID]);
64
77
  var trackCreateSessionError = useCallback(function (error, attributes) {
65
78
  fireAnalyticsEvent({
66
- actionSubject: 'rovoAgent',
67
- action: CreateFlowActions.ERROR,
79
+ actionSubject: DefaultActionSubject,
80
+ action: 'createFlowError',
68
81
  attributes: _objectSpread({
69
82
  error: {
70
83
  message: error.message