@atlaskit/rovo-agent-analytics 0.19.0 → 0.20.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 (57) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +93 -99
  3. package/actions/evaluation/package.json +17 -0
  4. package/dist/cjs/actions/groups/add-tools-prompt.js +15 -4
  5. package/dist/cjs/actions/groups/agent-interactions.js +16 -5
  6. package/dist/cjs/actions/groups/create-flow.js +15 -3
  7. package/dist/cjs/actions/groups/debug.js +16 -5
  8. package/dist/cjs/actions/groups/editing.js +11 -5
  9. package/dist/cjs/actions/groups/evaluation.js +1 -0
  10. package/dist/cjs/actions/groups/tools.js +13 -5
  11. package/dist/cjs/actions/index.js +37 -6
  12. package/dist/cjs/actions/registry.js +13 -40
  13. package/dist/cjs/common/types.js +13 -1
  14. package/dist/cjs/create/index.js +3 -5
  15. package/dist/es2019/actions/groups/add-tools-prompt.js +15 -4
  16. package/dist/es2019/actions/groups/agent-interactions.js +17 -5
  17. package/dist/es2019/actions/groups/create-flow.js +15 -3
  18. package/dist/es2019/actions/groups/debug.js +17 -5
  19. package/dist/es2019/actions/groups/editing.js +12 -5
  20. package/dist/es2019/actions/groups/evaluation.js +0 -0
  21. package/dist/es2019/actions/groups/tools.js +16 -5
  22. package/dist/es2019/actions/index.js +36 -7
  23. package/dist/es2019/actions/registry.js +11 -43
  24. package/dist/es2019/common/types.js +7 -0
  25. package/dist/es2019/create/index.js +4 -6
  26. package/dist/esm/actions/groups/add-tools-prompt.js +15 -4
  27. package/dist/esm/actions/groups/agent-interactions.js +17 -5
  28. package/dist/esm/actions/groups/create-flow.js +15 -3
  29. package/dist/esm/actions/groups/debug.js +17 -5
  30. package/dist/esm/actions/groups/editing.js +12 -5
  31. package/dist/esm/actions/groups/evaluation.js +0 -0
  32. package/dist/esm/actions/groups/tools.js +16 -5
  33. package/dist/esm/actions/index.js +38 -7
  34. package/dist/esm/actions/registry.js +11 -39
  35. package/dist/esm/common/types.js +7 -0
  36. package/dist/esm/create/index.js +4 -6
  37. package/dist/types/actions/groups/add-tools-prompt.d.ts +22 -4
  38. package/dist/types/actions/groups/agent-interactions.d.ts +46 -4
  39. package/dist/types/actions/groups/create-flow.d.ts +46 -3
  40. package/dist/types/actions/groups/debug.d.ts +29 -4
  41. package/dist/types/actions/groups/editing.d.ts +13 -4
  42. package/dist/types/actions/groups/evaluation.d.ts +56 -0
  43. package/dist/types/actions/groups/tools.d.ts +35 -4
  44. package/dist/types/actions/index.d.ts +2 -1
  45. package/dist/types/actions/registry.d.ts +16 -9
  46. package/dist/types/common/types.d.ts +14 -0
  47. package/dist/types-ts4.5/actions/groups/add-tools-prompt.d.ts +22 -4
  48. package/dist/types-ts4.5/actions/groups/agent-interactions.d.ts +46 -4
  49. package/dist/types-ts4.5/actions/groups/create-flow.d.ts +46 -3
  50. package/dist/types-ts4.5/actions/groups/debug.d.ts +29 -4
  51. package/dist/types-ts4.5/actions/groups/editing.d.ts +13 -4
  52. package/dist/types-ts4.5/actions/groups/evaluation.d.ts +56 -0
  53. package/dist/types-ts4.5/actions/groups/tools.d.ts +35 -4
  54. package/dist/types-ts4.5/actions/index.d.ts +2 -1
  55. package/dist/types-ts4.5/actions/registry.d.ts +16 -9
  56. package/dist/types-ts4.5/common/types.d.ts +14 -0
  57. package/package.json +2 -2
@@ -1 +1,13 @@
1
- "use strict";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LIBRARY_ATTRIBUTE = void 0;
7
+ /** Common library attribute injected into all events */
8
+ var LIBRARY_ATTRIBUTE = exports.LIBRARY_ATTRIBUTE = 'agents-analytics';
9
+
10
+ /**
11
+ * Union of all event payload types.
12
+ * Use with `trackAgentEvent()` for typed event tracking.
13
+ */
@@ -32,9 +32,7 @@ var useRovoAgentCreateAnalytics = exports.useRovoAgentCreateAnalytics = function
32
32
  var commonAttributesRef = (0, _react.useRef)(commonAttributes);
33
33
  var fireAnalyticsEvent = (0, _react.useCallback)(function (event) {
34
34
  var referrer = typeof window !== 'undefined' ? window.document.referrer : 'unknown';
35
- var action = event.action;
36
35
  var attributes = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, (0, _utils.getAttributesFromContexts)(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributesRef.current), event.attributes), {}, {
37
- actionGroup: _registry.ACTION_TO_GROUP[action],
38
36
  csid: csid,
39
37
  referrer: referrer
40
38
  });
@@ -50,7 +48,7 @@ var useRovoAgentCreateAnalytics = exports.useRovoAgentCreateAnalytics = function
50
48
  */
51
49
  var trackCreateSession = (0, _react.useCallback)(function (action, attributes) {
52
50
  fireAnalyticsEvent({
53
- actionSubject: 'rovoAgent',
51
+ actionSubject: _registry.DefaultActionSubject,
54
52
  action: action,
55
53
  attributes: attributes
56
54
  });
@@ -61,7 +59,7 @@ var useRovoAgentCreateAnalytics = exports.useRovoAgentCreateAnalytics = function
61
59
  */
62
60
  var trackCreateSessionStart = (0, _react.useCallback)(function (attributes) {
63
61
  fireAnalyticsEvent({
64
- actionSubject: 'rovoAgent',
62
+ actionSubject: _registry.DefaultActionSubject,
65
63
  action: _createFlow.CreateFlowActions.START,
66
64
  attributes: attributes
67
65
  });
@@ -69,7 +67,7 @@ var useRovoAgentCreateAnalytics = exports.useRovoAgentCreateAnalytics = function
69
67
  }, [fireAnalyticsEvent, refreshCSID]);
70
68
  var trackCreateSessionError = (0, _react.useCallback)(function (error, attributes) {
71
69
  fireAnalyticsEvent({
72
- actionSubject: 'rovoAgent',
70
+ actionSubject: _registry.DefaultActionSubject,
73
71
  action: _createFlow.CreateFlowActions.ERROR,
74
72
  attributes: _objectSpread({
75
73
  error: {
@@ -8,13 +8,24 @@
8
8
  * regardless of whether the prompt fires from the create flow or a future publish flow.
9
9
  *
10
10
  * ## Adding a new action
11
- * 1. Add the action to the `AddToolsPromptActions` enum below with a data-portal link
12
- * 2. Register this group in ../registry.ts (if this is a new group file)
13
- *
11
+ * 1. Add a new variant to the `AddToolsPromptEventPayload` union type below with a data-portal link
12
+ * 2. If this action doesn't fit this group, consider creating a new group file instead
13
+ * (see other files in this directory for the template)
14
+ */
15
+
16
+ /**
17
+ * Discriminated union payload type for add tools prompt events.
18
+ * Use with `trackAgentEvent()`.
14
19
  */
15
20
 
16
- /** The group name sent as `attributes.actionGroup` in analytics events */
21
+ // ============================================================================
22
+ // BACKWARDS COMPAT (deprecated): Keep enum and attributes for trackAgentAction() consumers
23
+ // ============================================================================
24
+
25
+ /** @deprecated Use AddToolsPromptEventPayload with trackAgentEvent() instead */
17
26
  export const ACTION_GROUP = 'addToolsPrompt';
27
+
28
+ /** @deprecated Use AddToolsPromptEventPayload with trackAgentEvent() instead */
18
29
  export let AddToolsPromptActions = /*#__PURE__*/function (AddToolsPromptActions) {
19
30
  /* Add tools prompt shown (agent has no tools) - https://data-portal.internal.atlassian.com/analytics/registry/98106 */
20
31
  AddToolsPromptActions["SHOWN"] = "addToolsPromptShown";
@@ -7,14 +7,24 @@
7
7
  * NOTE: This is about UI interactions, not backend "actions" (which are being replaced by "tools").
8
8
  *
9
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
10
+ * 1. Add a new variant to the `AgentInteractionsEventPayload` union type below with a data-portal link
11
+ * 2. If this action doesn't fit user interactions, create a new group file instead
13
12
  * (see other files in this directory for the template)
14
13
  */
15
14
 
16
- /** The group name sent as `attributes.actionGroup` in analytics events */
15
+ /**
16
+ * Discriminated union payload type for agent interaction events.
17
+ * Use with `trackAgentEvent()`.
18
+ */
19
+
20
+ // ============================================================================
21
+ // BACKWARDS COMPAT (deprecated): Keep enum and attributes for trackAgentAction() consumers
22
+ // ============================================================================
23
+
24
+ /** @deprecated Use AgentInteractionsEventPayload with trackAgentEvent() instead */
17
25
  export const ACTION_GROUP = 'agentInteractions';
26
+
27
+ /** @deprecated Use AgentInteractionsEventPayload with trackAgentEvent() instead */
18
28
  export let AgentInteractionActions = /*#__PURE__*/function (AgentInteractionActions) {
19
29
  /* View agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97125 */
20
30
  AgentInteractionActions["VIEW"] = "view";
@@ -35,4 +45,6 @@ export let AgentInteractionActions = /*#__PURE__*/function (AgentInteractionActi
35
45
  /* Unverify agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97135 */
36
46
  AgentInteractionActions["UNVERIFY"] = "unverify";
37
47
  return AgentInteractionActions;
38
- }({});
48
+ }({});
49
+
50
+ /** @deprecated Use AgentInteractionsEventPayload with trackAgentEvent() instead */
@@ -4,12 +4,24 @@
4
4
  * Create agent funnel steps — from clicking "Create agent" through to activation or discard,
5
5
  *
6
6
  * ## Adding a new action
7
- * 1. Add the action to the `CreateFlowActions` enum below with a data-portal link
8
- * 2. Register this group in ../registry.ts (if this is a new group file)
7
+ * 1. Add a new variant to the `CreateFlowEventPayload` union type below with a data-portal link
8
+ * 2. If this action doesn't fit this group, consider creating a new group file instead
9
+ * (see other files in this directory for the template)
9
10
  */
10
11
 
11
- /** The group name sent as `attributes.actionGroup` in analytics events */
12
+ /**
13
+ * Discriminated union payload type for create flow events.
14
+ * Use with `trackAgentEvent()`.
15
+ */
16
+
17
+ // ============================================================================
18
+ // BACKWARDS COMPAT (deprecated): Keep enum and attributes for trackAgentAction() consumers
19
+ // ============================================================================
20
+
21
+ /** @deprecated Use CreateFlowEventPayload with trackAgentEvent() instead */
12
22
  export const ACTION_GROUP = 'createFlow';
23
+
24
+ /** @deprecated Use CreateFlowEventPayload with trackAgentEvent() instead */
13
25
  export let CreateFlowActions = /*#__PURE__*/function (CreateFlowActions) {
14
26
  /* Start create flow when user clicks on "Create agent" button - https://data-portal.internal.atlassian.com/analytics/registry/97089 */
15
27
  CreateFlowActions["START"] = "createFlowStart";
@@ -4,14 +4,24 @@
4
4
  * Actions related to the agent debug modal (viewing, copying debug data, toggling skill info).
5
5
  *
6
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
7
+ * 1. Add a new variant to the `DebugEventPayload` union type below with a data-portal link
8
+ * 2. If this action doesn't fit this group, consider creating a new group file instead
10
9
  * (see other files in this directory for the template)
11
10
  */
12
11
 
13
- /** The group name sent as `attributes.actionGroup` in analytics events */
12
+ /**
13
+ * Discriminated union payload type for debug events.
14
+ * Use with `trackAgentEvent()`.
15
+ */
16
+
17
+ // ============================================================================
18
+ // BACKWARDS COMPAT (deprecated): Keep enum and attributes for trackAgentAction() consumers
19
+ // ============================================================================
20
+
21
+ /** @deprecated Use DebugEventPayload with trackAgentEvent() instead */
14
22
  export const ACTION_GROUP = 'debug';
23
+
24
+ /** @deprecated Use DebugEventPayload with trackAgentEvent() instead */
15
25
  export let AgentDebugActions = /*#__PURE__*/function (AgentDebugActions) {
16
26
  /* View debug modal - https://data-portal.internal.atlassian.com/analytics/registry/97183 */
17
27
  AgentDebugActions["VIEW"] = "debugView";
@@ -22,4 +32,6 @@ export let AgentDebugActions = /*#__PURE__*/function (AgentDebugActions) {
22
32
  /* Toggle skill info - https://data-portal.internal.atlassian.com/analytics/registry/97185 */
23
33
  AgentDebugActions["TOGGLE_SKILL_INFO"] = "debugToggleSkillInfo";
24
34
  return AgentDebugActions;
25
- }({});
35
+ }({});
36
+
37
+ /** @deprecated Use DebugEventPayload with trackAgentEvent() instead */
@@ -5,16 +5,23 @@
5
5
  * Unlike agentInteractions (user clicks), these track actual data changes.
6
6
  *
7
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
8
+ * 1. Add a new variant to the `EditingEventPayload` union type below with a data-portal link
9
+ * 2. If this action doesn't fit editing/mutation events, create a new group file instead
11
10
  * (see other files in this directory for the template)
12
11
  */
13
12
 
14
- /** The group name sent as `attributes.actionGroup` in analytics events */
13
+ // ============================================================================
14
+ // BACKWARDS COMPAT (deprecated): Keep enum and attributes for trackAgentAction() consumers
15
+ // ============================================================================
16
+
17
+ /** @deprecated Use EditingEventPayload with trackAgentEvent() instead */
15
18
  export const ACTION_GROUP = 'editing';
19
+
20
+ /** @deprecated Use EditingEventPayload with trackAgentEvent() instead */
16
21
  export let AgentEditingActions = /*#__PURE__*/function (AgentEditingActions) {
17
22
  /* Agent updated - https://data-portal.internal.atlassian.com/analytics/registry/97122 */
18
23
  AgentEditingActions["UPDATED"] = "updated";
19
24
  return AgentEditingActions;
20
- }({});
25
+ }({});
26
+
27
+ /** @deprecated Use EditingEventPayload with trackAgentEvent() instead */
File without changes
@@ -5,14 +5,19 @@
5
5
  * (confirming, streaming, viewing results, errors).
6
6
  *
7
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
8
+ * 1. Add a new variant to the `ToolsEventPayload` union type below with a data-portal link
9
+ * 2. If this action doesn't fit this group, consider creating a new group file instead
11
10
  * (see other files in this directory for the template)
12
11
  */
13
12
 
14
- /** The group name sent as `attributes.actionGroup` in analytics events */
13
+ // ============================================================================
14
+ // BACKWARDS COMPAT (deprecated): Keep enum and attributes for trackAgentAction() consumers
15
+ // ============================================================================
16
+
17
+ /** @deprecated Use ToolsEventPayload with trackAgentEvent() instead */
15
18
  export const ACTION_GROUP = 'tools';
19
+
20
+ /** @deprecated Use ToolsEventPayload with trackAgentEvent() instead */
16
21
  export let AgentToolActions = /*#__PURE__*/function (AgentToolActions) {
17
22
  /* 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
23
  AgentToolActions["TOOLS_EXECUTION_CONFIRMED"] = "toolsExecutionConfirmed";
@@ -23,4 +28,10 @@ export let AgentToolActions = /*#__PURE__*/function (AgentToolActions) {
23
28
  /* When tools execution result streaming fails https://data-portal.internal.atlassian.com/analytics/registry/97752 */
24
29
  AgentToolActions["TOOLS_EXECUTION_RESULT_ERROR"] = "toolsExecutionResultError";
25
30
  return AgentToolActions;
26
- }({});
31
+ }({});
32
+
33
+ /** @deprecated Use ToolsEventPayload with trackAgentEvent() instead */
34
+
35
+ /** @deprecated Use ToolsEventPayload with trackAgentEvent() instead */
36
+
37
+ /** @deprecated Use ToolsEventPayload with trackAgentEvent() instead */
@@ -1,11 +1,12 @@
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
6
  import { AgentInteractionActions } from './groups/agent-interactions';
6
7
  import { AgentDebugActions as AgentDebugActionsEnum } from './groups/debug';
7
8
  import { AgentEditingActions } from './groups/editing';
8
- import { ACTION_TO_GROUP } from './registry';
9
+ import { DefaultActionSubject } from './registry';
9
10
 
10
11
  // Backward-compatible aliases
11
12
  // TODO: migrate consumers to use group-specific imports, then remove
@@ -27,6 +28,7 @@ export const useRovoAgentActionAnalytics = commonAttributes => {
27
28
  const attributes = {
28
29
  ...getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext()),
29
30
  ...commonAttributesRef.current,
31
+ library: LIBRARY_ATTRIBUTE,
30
32
  ...event.attributes
31
33
  };
32
34
  createAnalyticsEvent({
@@ -36,23 +38,49 @@ export const useRovoAgentActionAnalytics = commonAttributes => {
36
38
  }).fire(ANALYTICS_CHANNEL);
37
39
  }, [createAnalyticsEvent, analyticsContext] // keep number of dependencies minimal to prevent re-rendering
38
40
  );
41
+
42
+ /**
43
+ * Simple tracking of just action + attributes only.
44
+ * Uses default actionSubject ('rovoAgent').
45
+ *
46
+ * @deprecated Use trackAgentEvent() with typed payloads instead
47
+ */
39
48
  const trackAgentAction = useCallback((action, attributes) => {
40
49
  fireAnalyticsEvent({
41
- actionSubject: 'rovoAgent',
50
+ actionSubject: DefaultActionSubject,
42
51
  action,
43
- attributes: {
44
- ...attributes,
45
- actionGroup: ACTION_TO_GROUP[action]
46
- }
52
+ attributes
47
53
  });
48
54
  }, [fireAnalyticsEvent]);
55
+
56
+ /**
57
+ * Fully-typed event tracking using discriminated union payload types.
58
+ * The payload type enforces correct action, actionSubject, and attributes.
59
+ */
60
+ const trackAgentEvent = useCallback(payload => {
61
+ const {
62
+ action,
63
+ actionSubject,
64
+ attributes,
65
+ ...eventProps
66
+ } = payload;
67
+ fireAnalyticsEvent({
68
+ actionSubject,
69
+ action,
70
+ ...eventProps,
71
+ attributes
72
+ });
73
+ }, [fireAnalyticsEvent]);
74
+
75
+ /**
76
+ * @deprecated Use trackAgentEvent() with typed payloads instead
77
+ */
49
78
  const trackAgentActionError = useCallback((action, error, attributes) => {
50
79
  fireAnalyticsEvent({
51
80
  actionSubject: 'rovoAgentError',
52
81
  action,
53
82
  attributes: {
54
83
  ...attributes,
55
- actionGroup: ACTION_TO_GROUP[action],
56
84
  error: {
57
85
  message: error.message
58
86
  }
@@ -61,6 +89,7 @@ export const useRovoAgentActionAnalytics = commonAttributes => {
61
89
  }, [fireAnalyticsEvent]);
62
90
  return {
63
91
  trackAgentAction,
92
+ trackAgentEvent,
64
93
  trackAgentActionError
65
94
  };
66
95
  };
@@ -1,52 +1,20 @@
1
1
  /**
2
- * Action Registry
2
+ * Action Registry (Backwards Compatibility)
3
3
  *
4
- * Single source of truth for ALL action groups across the library.
5
- * This file composes all groups into a type-safe registry and builds the
6
- * runtime mapping from action values to their group names, which gets
7
- * automatically attached as `attributes.actionGroup` in every fired event.
4
+ * This file contains deprecated exports for backwards compatibility
5
+ * with consumers using `trackAgentAction()`.
8
6
  *
9
- * Both `useRovoAgentActionAnalytics` and `useRovoAgentCreateAnalytics` hooks
10
- * use `ACTION_TO_GROUP` from this registry.
7
+ * For new code, use the payload types from each group file directly
8
+ * with `trackAgentEvent()`.
11
9
  *
12
- * ## Adding a new action group
13
- * 1. Create a new file in ./groups/ following the template of existing group files
14
- * 2. Import the group's ACTION_GROUP, action enum, and attribute type below
15
- * 3. If the group is used by the actions hook, add the attribute type to `ActionAttributes`
16
- * 4. Add the enum + group to `ACTION_TO_GROUP` using `mapActionsToGroup`
10
+ * @deprecated The registry pattern is deprecated. Use EventPayload from types.ts instead.
17
11
  */
18
- import { AddToolsPromptActions, ACTION_GROUP as ADD_TOOLS_PROMPT_GROUP } from './groups/add-tools-prompt';
19
- import { AgentInteractionActions, ACTION_GROUP as AGENT_INTERACTIONS_GROUP } from './groups/agent-interactions';
20
- import { CreateFlowActions, ACTION_GROUP as CREATE_FLOW_GROUP } from './groups/create-flow';
21
- import { AgentDebugActions, ACTION_GROUP as DEBUG_GROUP } from './groups/debug';
22
- import { AgentEditingActions, ACTION_GROUP as EDITING_GROUP } from './groups/editing';
23
- import { AgentToolActions, ACTION_GROUP as TOOLS_GROUP } from './groups/tools';
24
12
 
25
- /**
26
- * Combined attribute map for action-hook groups (type-safe attributes).
27
- * Create-flow groups are excluded — they use a looser attribute type via the create hook.
28
- */
29
-
30
- /**
31
- * Helper to build a Record mapping each enum value to its group name.
32
- */
33
- const mapActionsToGroup = (actionEnum, group) => {
34
- return Object.fromEntries(Object.values(actionEnum).map(action => [action, group]));
35
- };
13
+ export const DefaultActionSubject = 'rovoAgent';
36
14
 
37
15
  /**
38
- * Runtime lookup: action value group name.
39
- * Used by ALL analytics hooks to auto-inject `attributes.actionGroup`.
16
+ * Combined attribute map (union of all groups).
17
+ * Used by the backward-compatible `trackAgentAction` helper.
40
18
  *
41
- * When you add a new group, add it here too.
42
- */
43
- export const ACTION_TO_GROUP = {
44
- // Action hook groups
45
- ...mapActionsToGroup(AgentInteractionActions, AGENT_INTERACTIONS_GROUP),
46
- ...mapActionsToGroup(AgentEditingActions, EDITING_GROUP),
47
- ...mapActionsToGroup(AgentDebugActions, DEBUG_GROUP),
48
- ...mapActionsToGroup(AgentToolActions, TOOLS_GROUP),
49
- // Create hook groups
50
- ...mapActionsToGroup(CreateFlowActions, CREATE_FLOW_GROUP),
51
- ...mapActionsToGroup(AddToolsPromptActions, ADD_TOOLS_PROMPT_GROUP)
52
- };
19
+ * @deprecated Use EventPayload with trackAgentEvent() instead
20
+ */
@@ -0,0 +1,7 @@
1
+ /** Common library attribute injected into all events */
2
+ export const LIBRARY_ATTRIBUTE = 'agents-analytics';
3
+
4
+ /**
5
+ * Union of all event payload types.
6
+ * Use with `trackAgentEvent()` for typed event tracking.
7
+ */
@@ -2,7 +2,7 @@ import { useCallback, useContext, useRef } from 'react';
2
2
  import { AnalyticsReactContext, useAnalyticsEvents } from '@atlaskit/analytics-next';
3
3
  import { AddToolsPromptActions } from '../actions/groups/add-tools-prompt';
4
4
  import { CreateFlowActions } from '../actions/groups/create-flow';
5
- import { ACTION_TO_GROUP } from '../actions/registry';
5
+ import { DefaultActionSubject } from '../actions/registry';
6
6
  import { ANALYTICS_CHANNEL } from '../common/constants';
7
7
  import { useRovoAgentCSID } from '../common/csid';
8
8
  import { getAttributesFromContexts, getDefaultTrackEventConfig } from '../common/utils';
@@ -25,12 +25,10 @@ export const useRovoAgentCreateAnalytics = commonAttributes => {
25
25
  const commonAttributesRef = useRef(commonAttributes);
26
26
  const fireAnalyticsEvent = useCallback(event => {
27
27
  const referrer = typeof window !== 'undefined' ? window.document.referrer : 'unknown';
28
- const action = event.action;
29
28
  const attributes = {
30
29
  ...getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext()),
31
30
  ...commonAttributesRef.current,
32
31
  ...event.attributes,
33
- actionGroup: ACTION_TO_GROUP[action],
34
32
  csid,
35
33
  referrer
36
34
  };
@@ -48,7 +46,7 @@ export const useRovoAgentCreateAnalytics = commonAttributes => {
48
46
  */
49
47
  const trackCreateSession = useCallback((action, attributes) => {
50
48
  fireAnalyticsEvent({
51
- actionSubject: 'rovoAgent',
49
+ actionSubject: DefaultActionSubject,
52
50
  action,
53
51
  attributes
54
52
  });
@@ -59,7 +57,7 @@ export const useRovoAgentCreateAnalytics = commonAttributes => {
59
57
  */
60
58
  const trackCreateSessionStart = useCallback(attributes => {
61
59
  fireAnalyticsEvent({
62
- actionSubject: 'rovoAgent',
60
+ actionSubject: DefaultActionSubject,
63
61
  action: CreateFlowActions.START,
64
62
  attributes
65
63
  });
@@ -67,7 +65,7 @@ export const useRovoAgentCreateAnalytics = commonAttributes => {
67
65
  }, [fireAnalyticsEvent, refreshCSID]);
68
66
  const trackCreateSessionError = useCallback((error, attributes) => {
69
67
  fireAnalyticsEvent({
70
- actionSubject: 'rovoAgent',
68
+ actionSubject: DefaultActionSubject,
71
69
  action: CreateFlowActions.ERROR,
72
70
  attributes: {
73
71
  error: {
@@ -8,13 +8,24 @@
8
8
  * regardless of whether the prompt fires from the create flow or a future publish flow.
9
9
  *
10
10
  * ## Adding a new action
11
- * 1. Add the action to the `AddToolsPromptActions` enum below with a data-portal link
12
- * 2. Register this group in ../registry.ts (if this is a new group file)
13
- *
11
+ * 1. Add a new variant to the `AddToolsPromptEventPayload` union type below with a data-portal link
12
+ * 2. If this action doesn't fit this group, consider creating a new group file instead
13
+ * (see other files in this directory for the template)
14
+ */
15
+
16
+ /**
17
+ * Discriminated union payload type for add tools prompt events.
18
+ * Use with `trackAgentEvent()`.
14
19
  */
15
20
 
16
- /** The group name sent as `attributes.actionGroup` in analytics events */
21
+ // ============================================================================
22
+ // BACKWARDS COMPAT (deprecated): Keep enum and attributes for trackAgentAction() consumers
23
+ // ============================================================================
24
+
25
+ /** @deprecated Use AddToolsPromptEventPayload with trackAgentEvent() instead */
17
26
  export var ACTION_GROUP = 'addToolsPrompt';
27
+
28
+ /** @deprecated Use AddToolsPromptEventPayload with trackAgentEvent() instead */
18
29
  export var AddToolsPromptActions = /*#__PURE__*/function (AddToolsPromptActions) {
19
30
  /* Add tools prompt shown (agent has no tools) - https://data-portal.internal.atlassian.com/analytics/registry/98106 */
20
31
  AddToolsPromptActions["SHOWN"] = "addToolsPromptShown";
@@ -7,14 +7,24 @@
7
7
  * NOTE: This is about UI interactions, not backend "actions" (which are being replaced by "tools").
8
8
  *
9
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
10
+ * 1. Add a new variant to the `AgentInteractionsEventPayload` union type below with a data-portal link
11
+ * 2. If this action doesn't fit user interactions, create a new group file instead
13
12
  * (see other files in this directory for the template)
14
13
  */
15
14
 
16
- /** The group name sent as `attributes.actionGroup` in analytics events */
15
+ /**
16
+ * Discriminated union payload type for agent interaction events.
17
+ * Use with `trackAgentEvent()`.
18
+ */
19
+
20
+ // ============================================================================
21
+ // BACKWARDS COMPAT (deprecated): Keep enum and attributes for trackAgentAction() consumers
22
+ // ============================================================================
23
+
24
+ /** @deprecated Use AgentInteractionsEventPayload with trackAgentEvent() instead */
17
25
  export var ACTION_GROUP = 'agentInteractions';
26
+
27
+ /** @deprecated Use AgentInteractionsEventPayload with trackAgentEvent() instead */
18
28
  export var AgentInteractionActions = /*#__PURE__*/function (AgentInteractionActions) {
19
29
  /* View agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97125 */
20
30
  AgentInteractionActions["VIEW"] = "view";
@@ -35,4 +45,6 @@ export var AgentInteractionActions = /*#__PURE__*/function (AgentInteractionActi
35
45
  /* Unverify agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97135 */
36
46
  AgentInteractionActions["UNVERIFY"] = "unverify";
37
47
  return AgentInteractionActions;
38
- }({});
48
+ }({});
49
+
50
+ /** @deprecated Use AgentInteractionsEventPayload with trackAgentEvent() instead */
@@ -4,12 +4,24 @@
4
4
  * Create agent funnel steps — from clicking "Create agent" through to activation or discard,
5
5
  *
6
6
  * ## Adding a new action
7
- * 1. Add the action to the `CreateFlowActions` enum below with a data-portal link
8
- * 2. Register this group in ../registry.ts (if this is a new group file)
7
+ * 1. Add a new variant to the `CreateFlowEventPayload` union type below with a data-portal link
8
+ * 2. If this action doesn't fit this group, consider creating a new group file instead
9
+ * (see other files in this directory for the template)
9
10
  */
10
11
 
11
- /** The group name sent as `attributes.actionGroup` in analytics events */
12
+ /**
13
+ * Discriminated union payload type for create flow events.
14
+ * Use with `trackAgentEvent()`.
15
+ */
16
+
17
+ // ============================================================================
18
+ // BACKWARDS COMPAT (deprecated): Keep enum and attributes for trackAgentAction() consumers
19
+ // ============================================================================
20
+
21
+ /** @deprecated Use CreateFlowEventPayload with trackAgentEvent() instead */
12
22
  export var ACTION_GROUP = 'createFlow';
23
+
24
+ /** @deprecated Use CreateFlowEventPayload with trackAgentEvent() instead */
13
25
  export var CreateFlowActions = /*#__PURE__*/function (CreateFlowActions) {
14
26
  /* Start create flow when user clicks on "Create agent" button - https://data-portal.internal.atlassian.com/analytics/registry/97089 */
15
27
  CreateFlowActions["START"] = "createFlowStart";
@@ -4,14 +4,24 @@
4
4
  * Actions related to the agent debug modal (viewing, copying debug data, toggling skill info).
5
5
  *
6
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
7
+ * 1. Add a new variant to the `DebugEventPayload` union type below with a data-portal link
8
+ * 2. If this action doesn't fit this group, consider creating a new group file instead
10
9
  * (see other files in this directory for the template)
11
10
  */
12
11
 
13
- /** The group name sent as `attributes.actionGroup` in analytics events */
12
+ /**
13
+ * Discriminated union payload type for debug events.
14
+ * Use with `trackAgentEvent()`.
15
+ */
16
+
17
+ // ============================================================================
18
+ // BACKWARDS COMPAT (deprecated): Keep enum and attributes for trackAgentAction() consumers
19
+ // ============================================================================
20
+
21
+ /** @deprecated Use DebugEventPayload with trackAgentEvent() instead */
14
22
  export var ACTION_GROUP = 'debug';
23
+
24
+ /** @deprecated Use DebugEventPayload with trackAgentEvent() instead */
15
25
  export var AgentDebugActions = /*#__PURE__*/function (AgentDebugActions) {
16
26
  /* View debug modal - https://data-portal.internal.atlassian.com/analytics/registry/97183 */
17
27
  AgentDebugActions["VIEW"] = "debugView";
@@ -22,4 +32,6 @@ export var AgentDebugActions = /*#__PURE__*/function (AgentDebugActions) {
22
32
  /* Toggle skill info - https://data-portal.internal.atlassian.com/analytics/registry/97185 */
23
33
  AgentDebugActions["TOGGLE_SKILL_INFO"] = "debugToggleSkillInfo";
24
34
  return AgentDebugActions;
25
- }({});
35
+ }({});
36
+
37
+ /** @deprecated Use DebugEventPayload with trackAgentEvent() instead */
@@ -5,16 +5,23 @@
5
5
  * Unlike agentInteractions (user clicks), these track actual data changes.
6
6
  *
7
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
8
+ * 1. Add a new variant to the `EditingEventPayload` union type below with a data-portal link
9
+ * 2. If this action doesn't fit editing/mutation events, create a new group file instead
11
10
  * (see other files in this directory for the template)
12
11
  */
13
12
 
14
- /** The group name sent as `attributes.actionGroup` in analytics events */
13
+ // ============================================================================
14
+ // BACKWARDS COMPAT (deprecated): Keep enum and attributes for trackAgentAction() consumers
15
+ // ============================================================================
16
+
17
+ /** @deprecated Use EditingEventPayload with trackAgentEvent() instead */
15
18
  export var ACTION_GROUP = 'editing';
19
+
20
+ /** @deprecated Use EditingEventPayload with trackAgentEvent() instead */
16
21
  export var AgentEditingActions = /*#__PURE__*/function (AgentEditingActions) {
17
22
  /* Agent updated - https://data-portal.internal.atlassian.com/analytics/registry/97122 */
18
23
  AgentEditingActions["UPDATED"] = "updated";
19
24
  return AgentEditingActions;
20
- }({});
25
+ }({});
26
+
27
+ /** @deprecated Use EditingEventPayload with trackAgentEvent() instead */
File without changes