@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
@@ -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 var ACTION_GROUP = 'tools';
19
+
20
+ /** @deprecated Use ToolsEventPayload with trackAgentEvent() instead */
16
21
  export var 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 var 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,14 +1,17 @@
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
11
  import { AgentInteractionActions } from './groups/agent-interactions';
9
12
  import { AgentDebugActions as AgentDebugActionsEnum } from './groups/debug';
10
13
  import { AgentEditingActions } from './groups/editing';
11
- import { ACTION_TO_GROUP } from './registry';
14
+ import { DefaultActionSubject } from './registry';
12
15
 
13
16
  // Backward-compatible aliases
14
17
  // TODO: migrate consumers to use group-specific imports, then remove
@@ -23,27 +26,54 @@ export var useRovoAgentActionAnalytics = function useRovoAgentActionAnalytics(co
23
26
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
24
27
  var commonAttributesRef = useRef(commonAttributes);
25
28
  var fireAnalyticsEvent = useCallback(function (event) {
26
- var attributes = _objectSpread(_objectSpread(_objectSpread({}, getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributesRef.current), event.attributes);
29
+ var attributes = _objectSpread(_objectSpread(_objectSpread({}, getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributesRef.current), {}, {
30
+ library: LIBRARY_ATTRIBUTE
31
+ }, event.attributes);
27
32
  createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, globalEventConfig), event), {}, {
28
33
  attributes: attributes
29
34
  })).fire(ANALYTICS_CHANNEL);
30
35
  }, [createAnalyticsEvent, analyticsContext] // keep number of dependencies minimal to prevent re-rendering
31
36
  );
37
+
38
+ /**
39
+ * Simple tracking of just action + attributes only.
40
+ * Uses default actionSubject ('rovoAgent').
41
+ *
42
+ * @deprecated Use trackAgentEvent() with typed payloads instead
43
+ */
32
44
  var trackAgentAction = useCallback(function (action, attributes) {
33
45
  fireAnalyticsEvent({
34
- actionSubject: 'rovoAgent',
46
+ actionSubject: DefaultActionSubject,
35
47
  action: action,
36
- attributes: _objectSpread(_objectSpread({}, attributes), {}, {
37
- actionGroup: ACTION_TO_GROUP[action]
38
- })
48
+ attributes: attributes
39
49
  });
40
50
  }, [fireAnalyticsEvent]);
51
+
52
+ /**
53
+ * Fully-typed event tracking using discriminated union payload types.
54
+ * The payload type enforces correct action, actionSubject, and attributes.
55
+ */
56
+ var trackAgentEvent = useCallback(function (payload) {
57
+ var action = payload.action,
58
+ actionSubject = payload.actionSubject,
59
+ attributes = payload.attributes,
60
+ eventProps = _objectWithoutProperties(payload, _excluded);
61
+ fireAnalyticsEvent(_objectSpread(_objectSpread({
62
+ actionSubject: actionSubject,
63
+ action: action
64
+ }, eventProps), {}, {
65
+ attributes: attributes
66
+ }));
67
+ }, [fireAnalyticsEvent]);
68
+
69
+ /**
70
+ * @deprecated Use trackAgentEvent() with typed payloads instead
71
+ */
41
72
  var trackAgentActionError = useCallback(function (action, error, attributes) {
42
73
  fireAnalyticsEvent({
43
74
  actionSubject: 'rovoAgentError',
44
75
  action: action,
45
76
  attributes: _objectSpread(_objectSpread({}, attributes), {}, {
46
- actionGroup: ACTION_TO_GROUP[action],
47
77
  error: {
48
78
  message: error.message
49
79
  }
@@ -52,6 +82,7 @@ export var useRovoAgentActionAnalytics = function useRovoAgentActionAnalytics(co
52
82
  }, [fireAnalyticsEvent]);
53
83
  return {
54
84
  trackAgentAction: trackAgentAction,
85
+ trackAgentEvent: trackAgentEvent,
55
86
  trackAgentActionError: trackAgentActionError
56
87
  };
57
88
  };
@@ -1,48 +1,20 @@
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
1
  /**
5
- * Action Registry
2
+ * Action Registry (Backwards Compatibility)
6
3
  *
7
- * Single source of truth for ALL action groups across the library.
8
- * This file composes all groups into a type-safe registry and builds the
9
- * runtime mapping from action values to their group names, which gets
10
- * automatically attached as `attributes.actionGroup` in every fired event.
4
+ * This file contains deprecated exports for backwards compatibility
5
+ * with consumers using `trackAgentAction()`.
11
6
  *
12
- * Both `useRovoAgentActionAnalytics` and `useRovoAgentCreateAnalytics` hooks
13
- * use `ACTION_TO_GROUP` from this registry.
7
+ * For new code, use the payload types from each group file directly
8
+ * with `trackAgentEvent()`.
14
9
  *
15
- * ## Adding a new action group
16
- * 1. Create a new file in ./groups/ following the template of existing group files
17
- * 2. Import the group's ACTION_GROUP, action enum, and attribute type below
18
- * 3. If the group is used by the actions hook, add the attribute type to `ActionAttributes`
19
- * 4. Add the enum + group to `ACTION_TO_GROUP` using `mapActionsToGroup`
10
+ * @deprecated The registry pattern is deprecated. Use EventPayload from types.ts instead.
20
11
  */
21
- import { AddToolsPromptActions, ACTION_GROUP as ADD_TOOLS_PROMPT_GROUP } from './groups/add-tools-prompt';
22
- import { AgentInteractionActions, ACTION_GROUP as AGENT_INTERACTIONS_GROUP } from './groups/agent-interactions';
23
- import { CreateFlowActions, ACTION_GROUP as CREATE_FLOW_GROUP } from './groups/create-flow';
24
- import { AgentDebugActions, ACTION_GROUP as DEBUG_GROUP } from './groups/debug';
25
- import { AgentEditingActions, ACTION_GROUP as EDITING_GROUP } from './groups/editing';
26
- import { AgentToolActions, ACTION_GROUP as TOOLS_GROUP } from './groups/tools';
27
12
 
28
- /**
29
- * Combined attribute map for action-hook groups (type-safe attributes).
30
- * Create-flow groups are excluded — they use a looser attribute type via the create hook.
31
- */
32
-
33
- /**
34
- * Helper to build a Record mapping each enum value to its group name.
35
- */
36
- var mapActionsToGroup = function mapActionsToGroup(actionEnum, group) {
37
- return Object.fromEntries(Object.values(actionEnum).map(function (action) {
38
- return [action, group];
39
- }));
40
- };
13
+ export var DefaultActionSubject = 'rovoAgent';
41
14
 
42
15
  /**
43
- * Runtime lookup: action value group name.
44
- * 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.
45
18
  *
46
- * When you add a new group, add it here too.
47
- */
48
- export var ACTION_TO_GROUP = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, mapActionsToGroup(AgentInteractionActions, AGENT_INTERACTIONS_GROUP)), mapActionsToGroup(AgentEditingActions, EDITING_GROUP)), mapActionsToGroup(AgentDebugActions, DEBUG_GROUP)), mapActionsToGroup(AgentToolActions, TOOLS_GROUP)), mapActionsToGroup(CreateFlowActions, CREATE_FLOW_GROUP)), mapActionsToGroup(AddToolsPromptActions, ADD_TOOLS_PROMPT_GROUP));
19
+ * @deprecated Use EventPayload with trackAgentEvent() instead
20
+ */
@@ -0,0 +1,7 @@
1
+ /** Common library attribute injected into all events */
2
+ export var LIBRARY_ATTRIBUTE = 'agents-analytics';
3
+
4
+ /**
5
+ * Union of all event payload types.
6
+ * Use with `trackAgentEvent()` for typed event tracking.
7
+ */
@@ -6,7 +6,7 @@ import { useCallback, useContext, useRef } from 'react';
6
6
  import { AnalyticsReactContext, useAnalyticsEvents } from '@atlaskit/analytics-next';
7
7
  import { AddToolsPromptActions } from '../actions/groups/add-tools-prompt';
8
8
  import { CreateFlowActions } from '../actions/groups/create-flow';
9
- import { ACTION_TO_GROUP } from '../actions/registry';
9
+ import { DefaultActionSubject } from '../actions/registry';
10
10
  import { ANALYTICS_CHANNEL } from '../common/constants';
11
11
  import { useRovoAgentCSID } from '../common/csid';
12
12
  import { getAttributesFromContexts, getDefaultTrackEventConfig } from '../common/utils';
@@ -26,9 +26,7 @@ export var useRovoAgentCreateAnalytics = function useRovoAgentCreateAnalytics(co
26
26
  var commonAttributesRef = useRef(commonAttributes);
27
27
  var fireAnalyticsEvent = useCallback(function (event) {
28
28
  var referrer = typeof window !== 'undefined' ? window.document.referrer : 'unknown';
29
- var action = event.action;
30
29
  var attributes = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributesRef.current), event.attributes), {}, {
31
- actionGroup: ACTION_TO_GROUP[action],
32
30
  csid: csid,
33
31
  referrer: referrer
34
32
  });
@@ -44,7 +42,7 @@ export var useRovoAgentCreateAnalytics = function useRovoAgentCreateAnalytics(co
44
42
  */
45
43
  var trackCreateSession = useCallback(function (action, attributes) {
46
44
  fireAnalyticsEvent({
47
- actionSubject: 'rovoAgent',
45
+ actionSubject: DefaultActionSubject,
48
46
  action: action,
49
47
  attributes: attributes
50
48
  });
@@ -55,7 +53,7 @@ export var useRovoAgentCreateAnalytics = function useRovoAgentCreateAnalytics(co
55
53
  */
56
54
  var trackCreateSessionStart = useCallback(function (attributes) {
57
55
  fireAnalyticsEvent({
58
- actionSubject: 'rovoAgent',
56
+ actionSubject: DefaultActionSubject,
59
57
  action: CreateFlowActions.START,
60
58
  attributes: attributes
61
59
  });
@@ -63,7 +61,7 @@ export var useRovoAgentCreateAnalytics = function useRovoAgentCreateAnalytics(co
63
61
  }, [fireAnalyticsEvent, refreshCSID]);
64
62
  var trackCreateSessionError = useCallback(function (error, attributes) {
65
63
  fireAnalyticsEvent({
66
- actionSubject: 'rovoAgent',
64
+ actionSubject: DefaultActionSubject,
67
65
  action: CreateFlowActions.ERROR,
68
66
  attributes: _objectSpread({
69
67
  error: {
@@ -8,12 +8,30 @@
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
+ * Discriminated union payload type for add tools prompt events.
17
+ * Use with `trackAgentEvent()`.
14
18
  */
15
- /** The group name sent as `attributes.actionGroup` in analytics events */
19
+ export type AddToolsPromptEventPayload = {
20
+ actionSubject: 'rovoAgent';
21
+ action: 'addToolsPromptShown';
22
+ attributes: {};
23
+ } | {
24
+ actionSubject: 'rovoAgent';
25
+ action: 'addToolsPromptBrowse';
26
+ attributes: {};
27
+ } | {
28
+ actionSubject: 'rovoAgent';
29
+ action: 'addToolsPromptDismiss';
30
+ attributes: {};
31
+ };
32
+ /** @deprecated Use AddToolsPromptEventPayload with trackAgentEvent() instead */
16
33
  export declare const ACTION_GROUP: "addToolsPrompt";
34
+ /** @deprecated Use AddToolsPromptEventPayload with trackAgentEvent() instead */
17
35
  export declare enum AddToolsPromptActions {
18
36
  SHOWN = "addToolsPromptShown",
19
37
  BROWSE = "addToolsPromptBrowse",
@@ -7,14 +7,55 @@
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
  import type { BaseAgentAnalyticsAttributes } from '../../common/types';
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
+ export type AgentInteractionsEventPayload = {
20
+ actionSubject: 'rovoAgent';
21
+ action: 'view';
22
+ attributes: BaseAgentAnalyticsAttributes;
23
+ } | {
24
+ actionSubject: 'rovoAgent';
25
+ action: 'edit';
26
+ attributes: BaseAgentAnalyticsAttributes;
27
+ } | {
28
+ actionSubject: 'rovoAgent';
29
+ action: 'copyLink';
30
+ attributes: BaseAgentAnalyticsAttributes;
31
+ } | {
32
+ actionSubject: 'rovoAgent';
33
+ action: 'delete';
34
+ attributes: BaseAgentAnalyticsAttributes;
35
+ } | {
36
+ actionSubject: 'rovoAgent';
37
+ action: 'duplicate';
38
+ attributes: BaseAgentAnalyticsAttributes;
39
+ } | {
40
+ actionSubject: 'rovoAgent';
41
+ action: 'star';
42
+ attributes: BaseAgentAnalyticsAttributes;
43
+ } | {
44
+ actionSubject: 'rovoAgent';
45
+ action: 'chat';
46
+ attributes: BaseAgentAnalyticsAttributes;
47
+ } | {
48
+ actionSubject: 'rovoAgent';
49
+ action: 'verify';
50
+ attributes: BaseAgentAnalyticsAttributes;
51
+ } | {
52
+ actionSubject: 'rovoAgent';
53
+ action: 'unverify';
54
+ attributes: BaseAgentAnalyticsAttributes;
55
+ };
56
+ /** @deprecated Use AgentInteractionsEventPayload with trackAgentEvent() instead */
17
57
  export declare const ACTION_GROUP: "agentInteractions";
58
+ /** @deprecated Use AgentInteractionsEventPayload with trackAgentEvent() instead */
18
59
  export declare enum AgentInteractionActions {
19
60
  VIEW = "view",
20
61
  EDIT = "edit",
@@ -26,6 +67,7 @@ export declare enum AgentInteractionActions {
26
67
  VERIFY = "verify",
27
68
  UNVERIFY = "unverify"
28
69
  }
70
+ /** @deprecated Use AgentInteractionsEventPayload with trackAgentEvent() instead */
29
71
  export type AgentInteractionAttributes = {
30
72
  [AgentInteractionActions.VIEW]: BaseAgentAnalyticsAttributes;
31
73
  [AgentInteractionActions.EDIT]: BaseAgentAnalyticsAttributes;
@@ -4,11 +4,54 @@
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
- /** The group name sent as `attributes.actionGroup` in analytics events */
11
+ /**
12
+ * Discriminated union payload type for create flow events.
13
+ * Use with `trackAgentEvent()`.
14
+ */
15
+ export type CreateFlowEventPayload = {
16
+ actionSubject: 'rovoAgent';
17
+ action: 'createFlowStart';
18
+ attributes: {};
19
+ } | {
20
+ actionSubject: 'rovoAgent';
21
+ action: 'createFlowSkipNL';
22
+ attributes: {};
23
+ } | {
24
+ actionSubject: 'rovoAgent';
25
+ action: 'createFlowReviewNL';
26
+ attributes: {};
27
+ } | {
28
+ actionSubject: 'rovoAgent';
29
+ action: 'createFlowActivate';
30
+ attributes: {};
31
+ } | {
32
+ actionSubject: 'rovoAgent';
33
+ action: 'createFlowRestart';
34
+ attributes: {};
35
+ } | {
36
+ actionSubject: 'rovoAgent';
37
+ action: 'createFlowError';
38
+ attributes: {};
39
+ } | {
40
+ actionSubject: 'rovoAgent';
41
+ action: 'createLandInStudio';
42
+ attributes: {};
43
+ } | {
44
+ actionSubject: 'rovoAgent';
45
+ action: 'createDiscard';
46
+ attributes: {};
47
+ } | {
48
+ actionSubject: 'rovoAgent';
49
+ action: 'saDraft';
50
+ attributes: {};
51
+ };
52
+ /** @deprecated Use CreateFlowEventPayload with trackAgentEvent() instead */
11
53
  export declare const ACTION_GROUP: "createFlow";
54
+ /** @deprecated Use CreateFlowEventPayload with trackAgentEvent() instead */
12
55
  export declare enum CreateFlowActions {
13
56
  START = "createFlowStart",
14
57
  SKIP_NL = "createFlowSkipNL",
@@ -4,13 +4,37 @@
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
- /** The group name sent as `attributes.actionGroup` in analytics events */
11
+ /**
12
+ * Discriminated union payload type for debug events.
13
+ * Use with `trackAgentEvent()`.
14
+ */
15
+ export type DebugEventPayload = {
16
+ actionSubject: 'rovoAgent';
17
+ action: 'debugView';
18
+ attributes: {};
19
+ } | {
20
+ actionSubject: 'rovoAgent';
21
+ action: 'debugCopyAll';
22
+ attributes: {};
23
+ } | {
24
+ actionSubject: 'rovoAgent';
25
+ action: 'debugCopy';
26
+ attributes: {};
27
+ } | {
28
+ actionSubject: 'rovoAgent';
29
+ action: 'debugToggleSkillInfo';
30
+ attributes: {
31
+ toolId: string;
32
+ isExpanded: boolean;
33
+ };
34
+ };
35
+ /** @deprecated Use DebugEventPayload with trackAgentEvent() instead */
13
36
  export declare const ACTION_GROUP: "debug";
37
+ /** @deprecated Use DebugEventPayload with trackAgentEvent() instead */
14
38
  export declare enum AgentDebugActions {
15
39
  VIEW = "debugView",
16
40
  COPY_ALL = "debugCopyAll",
@@ -18,6 +42,7 @@ export declare enum AgentDebugActions {
18
42
  TOGGLE_SKILL_INFO = "debugToggleSkillInfo"
19
43
  }
20
44
  type EmptyAttributes = {};
45
+ /** @deprecated Use DebugEventPayload with trackAgentEvent() instead */
21
46
  export type DebugActionAttributes = {
22
47
  [AgentDebugActions.COPY_ALL]: EmptyAttributes;
23
48
  [AgentDebugActions.COPY]: EmptyAttributes;
@@ -5,17 +5,26 @@
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
  import type { BaseAgentAnalyticsAttributes } from '../../common/types';
14
- /** The group name sent as `attributes.actionGroup` in analytics events */
13
+ export type EditingEventPayload = {
14
+ actionSubject: 'rovoAgent';
15
+ action: 'updated';
16
+ attributes: BaseAgentAnalyticsAttributes & {
17
+ agentType: string;
18
+ field: string;
19
+ };
20
+ };
21
+ /** @deprecated Use EditingEventPayload with trackAgentEvent() instead */
15
22
  export declare const ACTION_GROUP: "editing";
23
+ /** @deprecated Use EditingEventPayload with trackAgentEvent() instead */
16
24
  export declare enum AgentEditingActions {
17
25
  UPDATED = "updated"
18
26
  }
27
+ /** @deprecated Use EditingEventPayload with trackAgentEvent() instead */
19
28
  export type EditingActionAttributes = {
20
29
  [AgentEditingActions.UPDATED]: BaseAgentAnalyticsAttributes & {
21
30
  agentType: string;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Action Group: evaluation
3
+ *
4
+ * Batch evaluation events — dataset CRUD, job lifecycle, and validation UI events
5
+ * fired from the shared `agent-evaluation` package.
6
+ *
7
+ * ## Adding a new action
8
+ * 1. Add a new variant to the `EvaluationEventPayload` 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
10
+ * (see other files in this directory for the template)
11
+ */
12
+ type EvalAttributesBase = {
13
+ objectType?: string;
14
+ objectId?: string;
15
+ containerType?: string;
16
+ containerId?: string;
17
+ actionSubjectId?: string;
18
+ };
19
+ export type EvaluationEventPayload = ({
20
+ actionSubject: 'batchEvaluationDataset';
21
+ action: 'created';
22
+ attributes: {
23
+ totalQuestions: number;
24
+ };
25
+ } & EvalAttributesBase) | ({
26
+ actionSubject: 'batchEvaluationJob';
27
+ action: 'created';
28
+ attributes: {
29
+ datasetSize: number;
30
+ isDraftAgent: boolean;
31
+ judgeMode: string | undefined;
32
+ };
33
+ } & EvalAttributesBase) | ({
34
+ actionSubject: 'batchEvaluationDataset';
35
+ action: 'deleted';
36
+ attributes: {};
37
+ } & EvalAttributesBase) | ({
38
+ actionSubject: 'batchEvaluationDatasetQuestion';
39
+ action: 'deleted';
40
+ attributes: {};
41
+ } & EvalAttributesBase) | ({
42
+ actionSubject: 'evalResultsModal';
43
+ action: 'viewed';
44
+ attributes: {
45
+ trigger: 'row_action' | 'flag_action';
46
+ };
47
+ } & EvalAttributesBase) | ({
48
+ actionSubject: 'batchEvaluationJob';
49
+ action: 'completed';
50
+ attributes: {
51
+ status: string | null;
52
+ durationMs: number | null;
53
+ datasetSize: number | null | undefined;
54
+ };
55
+ } & EvalAttributesBase);
56
+ export {};
@@ -5,20 +5,48 @@
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
  import type { BaseAgentAnalyticsAttributes } from '../../common/types';
14
- /** The group name sent as `attributes.actionGroup` in analytics events */
13
+ type ToolsExecutionAttributesBase = BaseAgentAnalyticsAttributes & {
14
+ tools: {
15
+ toolId: string;
16
+ toolSource: string;
17
+ resolutionType: string;
18
+ }[];
19
+ singleInstrumentationId: string | undefined;
20
+ };
21
+ export type ToolsEventPayload = {
22
+ actionSubject: 'rovoAgent';
23
+ action: 'toolsExecutionConfirmed';
24
+ attributes: ToolsExecutionAttributesBase;
25
+ } | {
26
+ actionSubject: 'rovoAgent';
27
+ action: 'toolsExecutionStreamStopped';
28
+ attributes: ToolsExecutionAttributesBase;
29
+ } | {
30
+ actionSubject: 'rovoAgent';
31
+ action: 'toolsExecutionResultViewed';
32
+ attributes: ToolsExecutionAttributesBase & {
33
+ scenarioId: string | null | undefined;
34
+ };
35
+ } | {
36
+ actionSubject: 'rovoAgent';
37
+ action: 'toolsExecutionResultError';
38
+ attributes: ToolsExecutionAttributesBase;
39
+ };
40
+ /** @deprecated Use ToolsEventPayload with trackAgentEvent() instead */
15
41
  export declare const ACTION_GROUP: "tools";
42
+ /** @deprecated Use ToolsEventPayload with trackAgentEvent() instead */
16
43
  export declare enum AgentToolActions {
17
44
  TOOLS_EXECUTION_CONFIRMED = "toolsExecutionConfirmed",
18
45
  TOOLS_EXECUTION_STREAM_STOPPED = "toolsExecutionStreamStopped",
19
46
  TOOLS_EXECUTION_RESULT_VIEWED = "toolsExecutionResultViewed",
20
47
  TOOLS_EXECUTION_RESULT_ERROR = "toolsExecutionResultError"
21
48
  }
49
+ /** @deprecated Use ToolsEventPayload with trackAgentEvent() instead */
22
50
  export type ToolsExecutionAttributes = BaseAgentAnalyticsAttributes & {
23
51
  tools: {
24
52
  toolId: string;
@@ -27,12 +55,15 @@ export type ToolsExecutionAttributes = BaseAgentAnalyticsAttributes & {
27
55
  }[];
28
56
  singleInstrumentationId: string | undefined;
29
57
  };
58
+ /** @deprecated Use ToolsEventPayload with trackAgentEvent() instead */
30
59
  export type ToolsExecutionResultAttributes = ToolsExecutionAttributes & {
31
60
  scenarioId: string | null | undefined;
32
61
  };
62
+ /** @deprecated Use ToolsEventPayload with trackAgentEvent() instead */
33
63
  export type ToolsActionAttributes = {
34
64
  [AgentToolActions.TOOLS_EXECUTION_CONFIRMED]: ToolsExecutionAttributes;
35
65
  [AgentToolActions.TOOLS_EXECUTION_STREAM_STOPPED]: ToolsExecutionAttributes;
36
66
  [AgentToolActions.TOOLS_EXECUTION_RESULT_VIEWED]: ToolsExecutionResultAttributes;
37
67
  [AgentToolActions.TOOLS_EXECUTION_RESULT_ERROR]: ToolsExecutionAttributes;
38
68
  };
69
+ export {};
@@ -1,4 +1,4 @@
1
- import type { RemainingRequired } from '../common/types';
1
+ import { type EventPayload, type RemainingRequired } from '../common/types';
2
2
  import { AgentInteractionActions } from './groups/agent-interactions';
3
3
  import { AgentDebugActions as AgentDebugActionsEnum } from './groups/debug';
4
4
  import { AgentEditingActions } from './groups/editing';
@@ -18,5 +18,6 @@ export declare const AgentCommonActions: {
18
18
  export declare const AgentDebugActions: typeof AgentDebugActionsEnum;
19
19
  export declare const useRovoAgentActionAnalytics: <T extends {}>(commonAttributes: T) => {
20
20
  trackAgentAction: <A extends keyof ActionAttributes>(action: A, attributes: RemainingRequired<ActionAttributes[A], T>) => void;
21
+ trackAgentEvent: (payload: EventPayload) => void;
21
22
  trackAgentActionError: <A extends keyof ActionAttributes>(action: A, error: Error, attributes?: RemainingRequired<ActionAttributes[A], T>) => void;
22
23
  };
@@ -1,16 +1,23 @@
1
+ /**
2
+ * Action Registry (Backwards Compatibility)
3
+ *
4
+ * This file contains deprecated exports for backwards compatibility
5
+ * with consumers using `trackAgentAction()`.
6
+ *
7
+ * For new code, use the payload types from each group file directly
8
+ * with `trackAgentEvent()`.
9
+ *
10
+ * @deprecated The registry pattern is deprecated. Use EventPayload from types.ts instead.
11
+ */
1
12
  import { type AgentInteractionAttributes } from './groups/agent-interactions';
2
13
  import { type DebugActionAttributes } from './groups/debug';
3
14
  import { type EditingActionAttributes } from './groups/editing';
4
15
  import { type ToolsActionAttributes } from './groups/tools';
16
+ export declare const DefaultActionSubject = "rovoAgent";
5
17
  /**
6
- * Combined attribute map for action-hook groups (type-safe attributes).
7
- * Create-flow groups are excluded they use a looser attribute type via the create hook.
8
- */
9
- export type ActionAttributes = AgentInteractionAttributes & EditingActionAttributes & DebugActionAttributes & ToolsActionAttributes;
10
- /**
11
- * Runtime lookup: action value → group name.
12
- * Used by ALL analytics hooks to auto-inject `attributes.actionGroup`.
18
+ * Combined attribute map (union of all groups).
19
+ * Used by the backward-compatible `trackAgentAction` helper.
13
20
  *
14
- * When you add a new group, add it here too.
21
+ * @deprecated Use EventPayload with trackAgentEvent() instead
15
22
  */
16
- export declare const ACTION_TO_GROUP: Record<string, string>;
23
+ export type ActionAttributes = AgentInteractionAttributes & EditingActionAttributes & DebugActionAttributes & ToolsActionAttributes;