@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.
- package/CHANGELOG.md +7 -0
- package/README.md +93 -99
- package/actions/evaluation/package.json +17 -0
- package/dist/cjs/actions/groups/add-tools-prompt.js +15 -4
- package/dist/cjs/actions/groups/agent-interactions.js +16 -5
- package/dist/cjs/actions/groups/create-flow.js +15 -3
- package/dist/cjs/actions/groups/debug.js +16 -5
- package/dist/cjs/actions/groups/editing.js +11 -5
- package/dist/cjs/actions/groups/evaluation.js +1 -0
- package/dist/cjs/actions/groups/tools.js +13 -5
- package/dist/cjs/actions/index.js +37 -6
- package/dist/cjs/actions/registry.js +13 -40
- package/dist/cjs/common/types.js +13 -1
- package/dist/cjs/create/index.js +3 -5
- package/dist/es2019/actions/groups/add-tools-prompt.js +15 -4
- package/dist/es2019/actions/groups/agent-interactions.js +17 -5
- package/dist/es2019/actions/groups/create-flow.js +15 -3
- package/dist/es2019/actions/groups/debug.js +17 -5
- package/dist/es2019/actions/groups/editing.js +12 -5
- package/dist/es2019/actions/groups/evaluation.js +0 -0
- package/dist/es2019/actions/groups/tools.js +16 -5
- package/dist/es2019/actions/index.js +36 -7
- package/dist/es2019/actions/registry.js +11 -43
- package/dist/es2019/common/types.js +7 -0
- package/dist/es2019/create/index.js +4 -6
- package/dist/esm/actions/groups/add-tools-prompt.js +15 -4
- package/dist/esm/actions/groups/agent-interactions.js +17 -5
- package/dist/esm/actions/groups/create-flow.js +15 -3
- package/dist/esm/actions/groups/debug.js +17 -5
- package/dist/esm/actions/groups/editing.js +12 -5
- package/dist/esm/actions/groups/evaluation.js +0 -0
- package/dist/esm/actions/groups/tools.js +16 -5
- package/dist/esm/actions/index.js +38 -7
- package/dist/esm/actions/registry.js +11 -39
- package/dist/esm/common/types.js +7 -0
- package/dist/esm/create/index.js +4 -6
- package/dist/types/actions/groups/add-tools-prompt.d.ts +22 -4
- package/dist/types/actions/groups/agent-interactions.d.ts +46 -4
- package/dist/types/actions/groups/create-flow.d.ts +46 -3
- package/dist/types/actions/groups/debug.d.ts +29 -4
- package/dist/types/actions/groups/editing.d.ts +13 -4
- package/dist/types/actions/groups/evaluation.d.ts +56 -0
- package/dist/types/actions/groups/tools.d.ts +35 -4
- package/dist/types/actions/index.d.ts +2 -1
- package/dist/types/actions/registry.d.ts +16 -9
- package/dist/types/common/types.d.ts +14 -0
- package/dist/types-ts4.5/actions/groups/add-tools-prompt.d.ts +22 -4
- package/dist/types-ts4.5/actions/groups/agent-interactions.d.ts +46 -4
- package/dist/types-ts4.5/actions/groups/create-flow.d.ts +46 -3
- package/dist/types-ts4.5/actions/groups/debug.d.ts +29 -4
- package/dist/types-ts4.5/actions/groups/editing.d.ts +13 -4
- package/dist/types-ts4.5/actions/groups/evaluation.d.ts +56 -0
- package/dist/types-ts4.5/actions/groups/tools.d.ts +35 -4
- package/dist/types-ts4.5/actions/index.d.ts +2 -1
- package/dist/types-ts4.5/actions/registry.d.ts +16 -9
- package/dist/types-ts4.5/common/types.d.ts +14 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/rovo-agent-analytics
|
|
2
2
|
|
|
3
|
+
## 0.20.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`30edbd0d978ea`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/30edbd0d978ea) -
|
|
8
|
+
Deprecate trackAgentAction() and enums exports, introduce trackAgentEvent()
|
|
9
|
+
|
|
3
10
|
## 0.19.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
# RovoAgentAnalytics
|
|
2
2
|
|
|
3
|
-
Rovo Agents analytics
|
|
3
|
+
Rovo Agents analytics library for composing and sending typed analytics events.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```typescript
|
|
8
|
+
import { useRovoAgentActionAnalytics } from '@atlaskit/rovo-agent-analytics/actions';
|
|
9
|
+
```
|
|
8
10
|
|
|
9
11
|
Detailed docs and example usage can be found
|
|
10
12
|
[here](https://atlaskit.atlassian.com/packages/ai-mate/rovo-agent-analytics).
|
|
11
13
|
|
|
12
14
|
## Examples
|
|
13
15
|
|
|
14
|
-
### Basic usage with
|
|
16
|
+
### Basic usage with `trackAgentAction()` (deprecated)
|
|
17
|
+
|
|
18
|
+
For simple actions with default `actionSubject: 'rovoAgent'`:
|
|
15
19
|
|
|
16
20
|
```typescript
|
|
17
21
|
import { useRovoAgentActionAnalytics, AgentCommonActions } from '@atlaskit/rovo-agent-analytics';
|
|
@@ -25,142 +29,132 @@ const { trackAgentAction } = useRovoAgentActionAnalytics({
|
|
|
25
29
|
trackAgentAction(AgentCommonActions.DUPLICATE, {});
|
|
26
30
|
```
|
|
27
31
|
|
|
28
|
-
|
|
32
|
+
> **Note:** `trackAgentAction()` is deprecated. Prefer `trackAgentEvent()` for new code.
|
|
29
33
|
|
|
30
|
-
|
|
31
|
-
import { useRovoAgentActionAnalytics, AgentDebugActions } from '@atlaskit/rovo-agent-analytics';
|
|
34
|
+
### Full Event Tracking with `trackAgentEvent()` (recommended)
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
For fully-typed events with explicit `action`, `actionSubject`, and `attributes`:
|
|
34
37
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
```typescript
|
|
39
|
+
import { useRovoAgentActionAnalytics } from '@atlaskit/rovo-agent-analytics/actions';
|
|
40
|
+
|
|
41
|
+
const { trackAgentEvent } = useRovoAgentActionAnalytics({});
|
|
42
|
+
|
|
43
|
+
// Full control over event properties — all fields are type-checked
|
|
44
|
+
trackAgentEvent({
|
|
45
|
+
action: 'created',
|
|
46
|
+
actionSubject: 'batchEvaluationDataset',
|
|
47
|
+
attributes: {
|
|
48
|
+
totalQuestions: 5
|
|
49
|
+
},
|
|
50
|
+
objectType: 'batchEvaluationDataset',
|
|
51
|
+
objectId: 'dataset-123',
|
|
52
|
+
});
|
|
38
53
|
```
|
|
39
54
|
|
|
40
|
-
|
|
55
|
+
### When to use `trackAgentEvent()` vs `trackAgentAction()`
|
|
41
56
|
|
|
42
|
-
|
|
43
|
-
|
|
57
|
+
| Use Case | Function |
|
|
58
|
+
| --- | --- |
|
|
59
|
+
| New code (recommended) | `trackAgentEvent()` |
|
|
60
|
+
| Events with custom `actionSubject` | `trackAgentEvent()` |
|
|
61
|
+
| Events with `source`, `objectType`, `objectId`, etc. | `trackAgentEvent()` |
|
|
62
|
+
| Legacy code with default `actionSubject: 'rovoAgent'` | `trackAgentAction()` (deprecated) |
|
|
44
63
|
|
|
45
|
-
|
|
64
|
+
## Payload Types
|
|
46
65
|
|
|
47
|
-
|
|
48
|
-
| --- | --- | --- | --- |
|
|
49
|
-
| `agentInteractions` | `agent-interactions.ts` | actions | User-initiated interactions from overflow menu / profile (view, edit, delete, duplicate, star, chat, verify…) |
|
|
50
|
-
| `editing` | `editing.ts` | actions | Agent save/mutation events (updated) |
|
|
51
|
-
| `debug` | `debug.ts` | actions | Debug modal actions (view, copy, toggle skill info) |
|
|
52
|
-
| `tools` | `tools.ts` | actions | Tool execution actions (confirm, stream stop, result viewed, error) |
|
|
53
|
-
| `createFlow` | `create-flow.ts` | create | Create agent funnel steps (start, skip NL, review, activate, restart, error, land, discard) |
|
|
54
|
-
| `addToolsPrompt` | `add-tools-prompt.ts` | create | Add tools prompt modal shown when activating an agent with no tools (shown, browse, dismiss) |
|
|
66
|
+
Each group file in `src/actions/groups/` exports a **discriminated union payload type** that defines all valid event shapes for that group.
|
|
55
67
|
|
|
56
|
-
|
|
68
|
+
| File | Payload Type | Description |
|
|
69
|
+
| --- | --- | --- |
|
|
70
|
+
| `agent-interactions.ts` | `AgentInteractionsEventPayload` | User-initiated interactions (view, edit, delete, duplicate, star, chat, verify…) |
|
|
71
|
+
| `editing.ts` | `EditingEventPayload` | Agent save/mutation events (updated) |
|
|
72
|
+
| `debug.ts` | `DebugEventPayload` | Debug modal actions (view, copy, toggle skill info) |
|
|
73
|
+
| `tools.ts` | `ToolsEventPayload` | Tool execution actions (confirm, stream stop, result viewed, error) |
|
|
74
|
+
| `evaluation.ts` | `EvaluationEventPayload` | Batch evaluation events (dataset CRUD, job lifecycle, results viewed) |
|
|
75
|
+
| `create-flow.ts` | `CreateFlowEventPayload` | Create agent funnel steps |
|
|
76
|
+
| `add-tools-prompt.ts` | `AddToolsPromptEventPayload` | Add tools prompt modal events |
|
|
57
77
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
### To an existing group
|
|
78
|
+
The combined `EventPayload` type (exported from `types.ts`) is a union of all these payload types.
|
|
61
79
|
|
|
62
|
-
|
|
63
|
-
2. Add the action to the enum with a data-portal registry link:
|
|
80
|
+
## Adding a New Action
|
|
64
81
|
|
|
65
|
-
|
|
66
|
-
export enum AgentInteractionActions {
|
|
67
|
-
// ... existing actions
|
|
68
|
-
/* My new action - https://data-portal.internal.atlassian.com/analytics/registry/XXXXX */
|
|
69
|
-
MY_NEW_ACTION = 'myNewAction',
|
|
70
|
-
}
|
|
71
|
-
```
|
|
82
|
+
### To an existing payload type
|
|
72
83
|
|
|
73
|
-
|
|
84
|
+
1. Open the group file (e.g. `src/actions/groups/agent-interactions.ts`)
|
|
85
|
+
2. Add a new variant to the payload union type with a data-portal registry link:
|
|
74
86
|
|
|
75
87
|
```typescript
|
|
76
|
-
export type
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
88
|
+
export type AgentInteractionsEventPayload =
|
|
89
|
+
| {
|
|
90
|
+
// https://data-portal.internal.atlassian.com/analytics/registry/XXXXX
|
|
91
|
+
actionSubject: 'rovoAgent';
|
|
92
|
+
action: 'myNewAction';
|
|
93
|
+
attributes: BaseAgentAnalyticsAttributes & {
|
|
94
|
+
myCustomField: string;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
| // ... existing variants
|
|
80
98
|
```
|
|
81
99
|
|
|
82
|
-
That's it —
|
|
100
|
+
That's it — TypeScript will enforce the correct shape when calling `trackAgentEvent()`.
|
|
83
101
|
|
|
84
102
|
### To a new group
|
|
85
103
|
|
|
86
104
|
If your action doesn't fit any existing group, create a new one:
|
|
87
105
|
|
|
88
|
-
1. Create a new file in `src/actions/groups
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
2. Register the group in `src/actions/registry.ts`:
|
|
106
|
+
1. Create a new file in `src/actions/groups/` following the existing template
|
|
107
|
+
2. Export a discriminated union payload type (e.g. `MyFeatureEventPayload`)
|
|
108
|
+
3. Add the new type to the `EventPayload` union in `src/common/types.ts`:
|
|
92
109
|
|
|
93
110
|
```typescript
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
// 2. Add to the combined type
|
|
102
|
-
export type ActionAttributes = AgentInteractionAttributes &
|
|
103
|
-
EditingActionAttributes &
|
|
104
|
-
DebugActionAttributes &
|
|
105
|
-
ToolsActionAttributes &
|
|
106
|
-
MyFeatureActionAttributes;
|
|
107
|
-
|
|
108
|
-
// 3. Add to the runtime group map
|
|
109
|
-
export const ACTION_TO_GROUP: Record<string, string> = {
|
|
110
|
-
...mapActionsToGroup(AgentInteractionActions, AGENT_INTERACTIONS_GROUP),
|
|
111
|
-
...mapActionsToGroup(AgentEditingActions, EDITING_GROUP),
|
|
112
|
-
...mapActionsToGroup(AgentDebugActions, DEBUG_GROUP),
|
|
113
|
-
...mapActionsToGroup(AgentToolActions, TOOLS_GROUP),
|
|
114
|
-
...mapActionsToGroup(MyFeatureActions, MY_FEATURE_GROUP),
|
|
115
|
-
};
|
|
111
|
+
import type { MyFeatureEventPayload } from '../actions/groups/my-feature';
|
|
112
|
+
|
|
113
|
+
export type EventPayload =
|
|
114
|
+
| EditingEventPayload
|
|
115
|
+
| AgentInteractionsEventPayload
|
|
116
|
+
// ... existing types
|
|
117
|
+
| MyFeatureEventPayload;
|
|
116
118
|
```
|
|
117
119
|
|
|
118
|
-
## Defining Custom Attributes
|
|
120
|
+
## Defining Custom Attributes
|
|
119
121
|
|
|
120
|
-
Each action can have its own specific attributes
|
|
121
|
-
will enforce the correct attributes based on the action you pass.
|
|
122
|
+
Each action variant in a payload type can have its own specific attributes:
|
|
122
123
|
|
|
123
124
|
### Using BaseAgentAnalyticsAttributes
|
|
124
125
|
|
|
125
|
-
For actions that
|
|
126
|
+
For actions that need `touchPoint` and `agentId`:
|
|
126
127
|
|
|
127
128
|
```typescript
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
{
|
|
130
|
+
actionSubject: 'rovoAgent';
|
|
131
|
+
action: 'view';
|
|
132
|
+
attributes: BaseAgentAnalyticsAttributes;
|
|
133
|
+
}
|
|
131
134
|
```
|
|
132
135
|
|
|
133
136
|
### Using Custom Attributes
|
|
134
137
|
|
|
135
|
-
For actions that need additional attributes
|
|
136
|
-
|
|
137
|
-
```typescript
|
|
138
|
-
export type EditingActionAttributes = {
|
|
139
|
-
[AgentEditingActions.UPDATED]: BaseAgentAnalyticsAttributes & { agentType: string; field: string };
|
|
140
|
-
};
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
When calling `trackAgentAction`, TypeScript will enforce the custom attributes:
|
|
138
|
+
For actions that need additional attributes:
|
|
144
139
|
|
|
145
140
|
```typescript
|
|
146
|
-
|
|
141
|
+
{
|
|
142
|
+
actionSubject: 'rovoAgent';
|
|
143
|
+
action: 'updated';
|
|
144
|
+
attributes: BaseAgentAnalyticsAttributes & {
|
|
145
|
+
agentType: string;
|
|
146
|
+
field: string;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
147
149
|
```
|
|
148
150
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
The `trackAgentAction` function uses generics to infer required attributes:
|
|
151
|
+
## Backwards Compatibility
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
2. It looks up `ActionAttributes[action]` to get the required attributes for that action
|
|
155
|
-
3. It subtracts any attributes already provided in `commonAttributes` (via `RemainingRequired`)
|
|
156
|
-
4. The remaining attributes must be provided in the `attributes` parameter
|
|
153
|
+
The following exports are **deprecated** but still available for existing consumers:
|
|
157
154
|
|
|
158
|
-
|
|
155
|
+
- `trackAgentAction()` — use `trackAgentEvent()` instead
|
|
156
|
+
- `trackAgentActionError()` — use `trackAgentEvent()` instead
|
|
157
|
+
- Enum exports (e.g. `AgentEditingActions`, `AgentEvalActions`) — use string literals instead
|
|
158
|
+
- `ActionAttributes` type — use `EventPayload` instead
|
|
159
159
|
|
|
160
|
-
|
|
161
|
-
// If commonAttributes already includes agentId
|
|
162
|
-
const { trackAgentAction } = useRovoAgentActionAnalytics({ agentId: '123' });
|
|
163
|
-
|
|
164
|
-
// Only touchPoint is required since agentId was already provided
|
|
165
|
-
trackAgentAction(AgentCommonActions.VIEW, { touchPoint: 'my-touchpoint' });
|
|
166
|
-
```
|
|
160
|
+
These will be removed in a future major version.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/rovo-agent-analytics/actions/evaluation",
|
|
3
|
+
"main": "../../dist/cjs/actions/groups/evaluation.js",
|
|
4
|
+
"module": "../../dist/esm/actions/groups/evaluation.js",
|
|
5
|
+
"module:es2019": "../../dist/es2019/actions/groups/evaluation.js",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"*.compiled.css"
|
|
8
|
+
],
|
|
9
|
+
"types": "../../dist/types/actions/groups/evaluation.d.ts",
|
|
10
|
+
"typesVersions": {
|
|
11
|
+
">=4.5 <5.9": {
|
|
12
|
+
"*": [
|
|
13
|
+
"../../dist/types-ts4.5/actions/groups/evaluation.d.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -14,13 +14,24 @@ exports.AddToolsPromptActions = exports.ACTION_GROUP = void 0;
|
|
|
14
14
|
* regardless of whether the prompt fires from the create flow or a future publish flow.
|
|
15
15
|
*
|
|
16
16
|
* ## Adding a new action
|
|
17
|
-
* 1. Add
|
|
18
|
-
* 2.
|
|
19
|
-
*
|
|
17
|
+
* 1. Add a new variant to the `AddToolsPromptEventPayload` union type below with a data-portal link
|
|
18
|
+
* 2. If this action doesn't fit this group, consider creating a new group file instead
|
|
19
|
+
* (see other files in this directory for the template)
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Discriminated union payload type for add tools prompt events.
|
|
24
|
+
* Use with `trackAgentEvent()`.
|
|
20
25
|
*/
|
|
21
26
|
|
|
22
|
-
|
|
27
|
+
// ============================================================================
|
|
28
|
+
// BACKWARDS COMPAT (deprecated): Keep enum and attributes for trackAgentAction() consumers
|
|
29
|
+
// ============================================================================
|
|
30
|
+
|
|
31
|
+
/** @deprecated Use AddToolsPromptEventPayload with trackAgentEvent() instead */
|
|
23
32
|
var ACTION_GROUP = exports.ACTION_GROUP = 'addToolsPrompt';
|
|
33
|
+
|
|
34
|
+
/** @deprecated Use AddToolsPromptEventPayload with trackAgentEvent() instead */
|
|
24
35
|
var AddToolsPromptActions = exports.AddToolsPromptActions = /*#__PURE__*/function (AddToolsPromptActions) {
|
|
25
36
|
/* Add tools prompt shown (agent has no tools) - https://data-portal.internal.atlassian.com/analytics/registry/98106 */
|
|
26
37
|
AddToolsPromptActions["SHOWN"] = "addToolsPromptShown";
|
|
@@ -13,14 +13,24 @@ exports.AgentInteractionActions = exports.ACTION_GROUP = void 0;
|
|
|
13
13
|
* NOTE: This is about UI interactions, not backend "actions" (which are being replaced by "tools").
|
|
14
14
|
*
|
|
15
15
|
* ## Adding a new action
|
|
16
|
-
* 1. Add
|
|
17
|
-
* 2.
|
|
18
|
-
* 3. If this action doesn't fit user interactions, create a new group file instead
|
|
16
|
+
* 1. Add a new variant to the `AgentInteractionsEventPayload` union type below with a data-portal link
|
|
17
|
+
* 2. If this action doesn't fit user interactions, create a new group file instead
|
|
19
18
|
* (see other files in this directory for the template)
|
|
20
19
|
*/
|
|
21
20
|
|
|
22
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Discriminated union payload type for agent interaction events.
|
|
23
|
+
* Use with `trackAgentEvent()`.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// BACKWARDS COMPAT (deprecated): Keep enum and attributes for trackAgentAction() consumers
|
|
28
|
+
// ============================================================================
|
|
29
|
+
|
|
30
|
+
/** @deprecated Use AgentInteractionsEventPayload with trackAgentEvent() instead */
|
|
23
31
|
var ACTION_GROUP = exports.ACTION_GROUP = 'agentInteractions';
|
|
32
|
+
|
|
33
|
+
/** @deprecated Use AgentInteractionsEventPayload with trackAgentEvent() instead */
|
|
24
34
|
var AgentInteractionActions = exports.AgentInteractionActions = /*#__PURE__*/function (AgentInteractionActions) {
|
|
25
35
|
/* View agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97125 */
|
|
26
36
|
AgentInteractionActions["VIEW"] = "view";
|
|
@@ -41,4 +51,5 @@ var AgentInteractionActions = exports.AgentInteractionActions = /*#__PURE__*/fun
|
|
|
41
51
|
/* Unverify agent clicked - https://data-portal.internal.atlassian.com/analytics/registry/97135 */
|
|
42
52
|
AgentInteractionActions["UNVERIFY"] = "unverify";
|
|
43
53
|
return AgentInteractionActions;
|
|
44
|
-
}({});
|
|
54
|
+
}({});
|
|
55
|
+
/** @deprecated Use AgentInteractionsEventPayload with trackAgentEvent() instead */
|
|
@@ -10,12 +10,24 @@ exports.CreateFlowActions = exports.ACTION_GROUP = void 0;
|
|
|
10
10
|
* Create agent funnel steps — from clicking "Create agent" through to activation or discard,
|
|
11
11
|
*
|
|
12
12
|
* ## Adding a new action
|
|
13
|
-
* 1. Add
|
|
14
|
-
* 2.
|
|
13
|
+
* 1. Add a new variant to the `CreateFlowEventPayload` union type below with a data-portal link
|
|
14
|
+
* 2. If this action doesn't fit this group, consider creating a new group file instead
|
|
15
|
+
* (see other files in this directory for the template)
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Discriminated union payload type for create flow events.
|
|
20
|
+
* Use with `trackAgentEvent()`.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// BACKWARDS COMPAT (deprecated): Keep enum and attributes for trackAgentAction() consumers
|
|
25
|
+
// ============================================================================
|
|
26
|
+
|
|
27
|
+
/** @deprecated Use CreateFlowEventPayload with trackAgentEvent() instead */
|
|
18
28
|
var ACTION_GROUP = exports.ACTION_GROUP = 'createFlow';
|
|
29
|
+
|
|
30
|
+
/** @deprecated Use CreateFlowEventPayload with trackAgentEvent() instead */
|
|
19
31
|
var CreateFlowActions = exports.CreateFlowActions = /*#__PURE__*/function (CreateFlowActions) {
|
|
20
32
|
/* Start create flow when user clicks on "Create agent" button - https://data-portal.internal.atlassian.com/analytics/registry/97089 */
|
|
21
33
|
CreateFlowActions["START"] = "createFlowStart";
|
|
@@ -10,14 +10,24 @@ exports.AgentDebugActions = exports.ACTION_GROUP = void 0;
|
|
|
10
10
|
* Actions related to the agent debug modal (viewing, copying debug data, toggling skill info).
|
|
11
11
|
*
|
|
12
12
|
* ## Adding a new action
|
|
13
|
-
* 1. Add
|
|
14
|
-
* 2.
|
|
15
|
-
* 3. If this action doesn't fit this group, consider creating a new group file instead
|
|
13
|
+
* 1. Add a new variant to the `DebugEventPayload` union type below with a data-portal link
|
|
14
|
+
* 2. If this action doesn't fit this group, consider creating a new group file instead
|
|
16
15
|
* (see other files in this directory for the template)
|
|
17
16
|
*/
|
|
18
17
|
|
|
19
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Discriminated union payload type for debug events.
|
|
20
|
+
* Use with `trackAgentEvent()`.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// BACKWARDS COMPAT (deprecated): Keep enum and attributes for trackAgentAction() consumers
|
|
25
|
+
// ============================================================================
|
|
26
|
+
|
|
27
|
+
/** @deprecated Use DebugEventPayload with trackAgentEvent() instead */
|
|
20
28
|
var ACTION_GROUP = exports.ACTION_GROUP = 'debug';
|
|
29
|
+
|
|
30
|
+
/** @deprecated Use DebugEventPayload with trackAgentEvent() instead */
|
|
21
31
|
var AgentDebugActions = exports.AgentDebugActions = /*#__PURE__*/function (AgentDebugActions) {
|
|
22
32
|
/* View debug modal - https://data-portal.internal.atlassian.com/analytics/registry/97183 */
|
|
23
33
|
AgentDebugActions["VIEW"] = "debugView";
|
|
@@ -28,4 +38,5 @@ var AgentDebugActions = exports.AgentDebugActions = /*#__PURE__*/function (Agent
|
|
|
28
38
|
/* Toggle skill info - https://data-portal.internal.atlassian.com/analytics/registry/97185 */
|
|
29
39
|
AgentDebugActions["TOGGLE_SKILL_INFO"] = "debugToggleSkillInfo";
|
|
30
40
|
return AgentDebugActions;
|
|
31
|
-
}({});
|
|
41
|
+
}({});
|
|
42
|
+
/** @deprecated Use DebugEventPayload with trackAgentEvent() instead */
|
|
@@ -11,16 +11,22 @@ exports.AgentEditingActions = exports.ACTION_GROUP = void 0;
|
|
|
11
11
|
* Unlike agentInteractions (user clicks), these track actual data changes.
|
|
12
12
|
*
|
|
13
13
|
* ## Adding a new action
|
|
14
|
-
* 1. Add
|
|
15
|
-
* 2.
|
|
16
|
-
* 3. If this action doesn't fit editing/mutation events, create a new group file instead
|
|
14
|
+
* 1. Add a new variant to the `EditingEventPayload` union type below with a data-portal link
|
|
15
|
+
* 2. If this action doesn't fit editing/mutation events, create a new group file instead
|
|
17
16
|
* (see other files in this directory for the template)
|
|
18
17
|
*/
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// BACKWARDS COMPAT (deprecated): Keep enum and attributes for trackAgentAction() consumers
|
|
21
|
+
// ============================================================================
|
|
22
|
+
|
|
23
|
+
/** @deprecated Use EditingEventPayload with trackAgentEvent() instead */
|
|
21
24
|
var ACTION_GROUP = exports.ACTION_GROUP = 'editing';
|
|
25
|
+
|
|
26
|
+
/** @deprecated Use EditingEventPayload with trackAgentEvent() instead */
|
|
22
27
|
var AgentEditingActions = exports.AgentEditingActions = /*#__PURE__*/function (AgentEditingActions) {
|
|
23
28
|
/* Agent updated - https://data-portal.internal.atlassian.com/analytics/registry/97122 */
|
|
24
29
|
AgentEditingActions["UPDATED"] = "updated";
|
|
25
30
|
return AgentEditingActions;
|
|
26
|
-
}({});
|
|
31
|
+
}({});
|
|
32
|
+
/** @deprecated Use EditingEventPayload with trackAgentEvent() instead */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -11,14 +11,19 @@ exports.AgentToolActions = exports.ACTION_GROUP = void 0;
|
|
|
11
11
|
* (confirming, streaming, viewing results, errors).
|
|
12
12
|
*
|
|
13
13
|
* ## Adding a new action
|
|
14
|
-
* 1. Add
|
|
15
|
-
* 2.
|
|
16
|
-
* 3. If this action doesn't fit this group, consider creating a new group file instead
|
|
14
|
+
* 1. Add a new variant to the `ToolsEventPayload` union type below with a data-portal link
|
|
15
|
+
* 2. If this action doesn't fit this group, consider creating a new group file instead
|
|
17
16
|
* (see other files in this directory for the template)
|
|
18
17
|
*/
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// BACKWARDS COMPAT (deprecated): Keep enum and attributes for trackAgentAction() consumers
|
|
21
|
+
// ============================================================================
|
|
22
|
+
|
|
23
|
+
/** @deprecated Use ToolsEventPayload with trackAgentEvent() instead */
|
|
21
24
|
var ACTION_GROUP = exports.ACTION_GROUP = 'tools';
|
|
25
|
+
|
|
26
|
+
/** @deprecated Use ToolsEventPayload with trackAgentEvent() instead */
|
|
22
27
|
var AgentToolActions = exports.AgentToolActions = /*#__PURE__*/function (AgentToolActions) {
|
|
23
28
|
/* 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 */
|
|
24
29
|
AgentToolActions["TOOLS_EXECUTION_CONFIRMED"] = "toolsExecutionConfirmed";
|
|
@@ -29,4 +34,7 @@ var AgentToolActions = exports.AgentToolActions = /*#__PURE__*/function (AgentTo
|
|
|
29
34
|
/* When tools execution result streaming fails https://data-portal.internal.atlassian.com/analytics/registry/97752 */
|
|
30
35
|
AgentToolActions["TOOLS_EXECUTION_RESULT_ERROR"] = "toolsExecutionResultError";
|
|
31
36
|
return AgentToolActions;
|
|
32
|
-
}({});
|
|
37
|
+
}({});
|
|
38
|
+
/** @deprecated Use ToolsEventPayload with trackAgentEvent() instead */
|
|
39
|
+
/** @deprecated Use ToolsEventPayload with trackAgentEvent() instead */
|
|
40
|
+
/** @deprecated Use ToolsEventPayload with trackAgentEvent() instead */
|
|
@@ -5,15 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.useRovoAgentActionAnalytics = exports.AgentDebugActions = exports.AgentCommonActions = void 0;
|
|
8
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
8
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
10
|
var _react = require("react");
|
|
10
11
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
11
12
|
var _constants = require("../common/constants");
|
|
13
|
+
var _types = require("../common/types");
|
|
12
14
|
var _utils = require("../common/utils");
|
|
13
15
|
var _agentInteractions = require("./groups/agent-interactions");
|
|
14
16
|
var _debug = require("./groups/debug");
|
|
15
17
|
var _editing = require("./groups/editing");
|
|
16
18
|
var _registry = require("./registry");
|
|
19
|
+
var _excluded = ["action", "actionSubject", "attributes"];
|
|
17
20
|
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; }
|
|
18
21
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
22
|
// Backward-compatible aliases
|
|
@@ -29,27 +32,54 @@ var useRovoAgentActionAnalytics = exports.useRovoAgentActionAnalytics = function
|
|
|
29
32
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
30
33
|
var commonAttributesRef = (0, _react.useRef)(commonAttributes);
|
|
31
34
|
var fireAnalyticsEvent = (0, _react.useCallback)(function (event) {
|
|
32
|
-
var attributes = _objectSpread(_objectSpread(_objectSpread({}, (0, _utils.getAttributesFromContexts)(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributesRef.current),
|
|
35
|
+
var attributes = _objectSpread(_objectSpread(_objectSpread({}, (0, _utils.getAttributesFromContexts)(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributesRef.current), {}, {
|
|
36
|
+
library: _types.LIBRARY_ATTRIBUTE
|
|
37
|
+
}, event.attributes);
|
|
33
38
|
createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, globalEventConfig), event), {}, {
|
|
34
39
|
attributes: attributes
|
|
35
40
|
})).fire(_constants.ANALYTICS_CHANNEL);
|
|
36
41
|
}, [createAnalyticsEvent, analyticsContext] // keep number of dependencies minimal to prevent re-rendering
|
|
37
42
|
);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Simple tracking of just action + attributes only.
|
|
46
|
+
* Uses default actionSubject ('rovoAgent').
|
|
47
|
+
*
|
|
48
|
+
* @deprecated Use trackAgentEvent() with typed payloads instead
|
|
49
|
+
*/
|
|
38
50
|
var trackAgentAction = (0, _react.useCallback)(function (action, attributes) {
|
|
39
51
|
fireAnalyticsEvent({
|
|
40
|
-
actionSubject:
|
|
52
|
+
actionSubject: _registry.DefaultActionSubject,
|
|
41
53
|
action: action,
|
|
42
|
-
attributes:
|
|
43
|
-
actionGroup: _registry.ACTION_TO_GROUP[action]
|
|
44
|
-
})
|
|
54
|
+
attributes: attributes
|
|
45
55
|
});
|
|
46
56
|
}, [fireAnalyticsEvent]);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Fully-typed event tracking using discriminated union payload types.
|
|
60
|
+
* The payload type enforces correct action, actionSubject, and attributes.
|
|
61
|
+
*/
|
|
62
|
+
var trackAgentEvent = (0, _react.useCallback)(function (payload) {
|
|
63
|
+
var action = payload.action,
|
|
64
|
+
actionSubject = payload.actionSubject,
|
|
65
|
+
attributes = payload.attributes,
|
|
66
|
+
eventProps = (0, _objectWithoutProperties2.default)(payload, _excluded);
|
|
67
|
+
fireAnalyticsEvent(_objectSpread(_objectSpread({
|
|
68
|
+
actionSubject: actionSubject,
|
|
69
|
+
action: action
|
|
70
|
+
}, eventProps), {}, {
|
|
71
|
+
attributes: attributes
|
|
72
|
+
}));
|
|
73
|
+
}, [fireAnalyticsEvent]);
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated Use trackAgentEvent() with typed payloads instead
|
|
77
|
+
*/
|
|
47
78
|
var trackAgentActionError = (0, _react.useCallback)(function (action, error, attributes) {
|
|
48
79
|
fireAnalyticsEvent({
|
|
49
80
|
actionSubject: 'rovoAgentError',
|
|
50
81
|
action: action,
|
|
51
82
|
attributes: _objectSpread(_objectSpread({}, attributes), {}, {
|
|
52
|
-
actionGroup: _registry.ACTION_TO_GROUP[action],
|
|
53
83
|
error: {
|
|
54
84
|
message: error.message
|
|
55
85
|
}
|
|
@@ -58,6 +88,7 @@ var useRovoAgentActionAnalytics = exports.useRovoAgentActionAnalytics = function
|
|
|
58
88
|
}, [fireAnalyticsEvent]);
|
|
59
89
|
return {
|
|
60
90
|
trackAgentAction: trackAgentAction,
|
|
91
|
+
trackAgentEvent: trackAgentEvent,
|
|
61
92
|
trackAgentActionError: trackAgentActionError
|
|
62
93
|
};
|
|
63
94
|
};
|
|
@@ -1,53 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _agentInteractions = require("./groups/agent-interactions");
|
|
11
|
-
var _createFlow = require("./groups/create-flow");
|
|
12
|
-
var _debug = require("./groups/debug");
|
|
13
|
-
var _editing = require("./groups/editing");
|
|
14
|
-
var _tools = require("./groups/tools");
|
|
15
|
-
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; }
|
|
16
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
|
|
17
|
-
* Action Registry
|
|
6
|
+
exports.DefaultActionSubject = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Action Registry (Backwards Compatibility)
|
|
18
9
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* runtime mapping from action values to their group names, which gets
|
|
22
|
-
* automatically attached as `attributes.actionGroup` in every fired event.
|
|
10
|
+
* This file contains deprecated exports for backwards compatibility
|
|
11
|
+
* with consumers using `trackAgentAction()`.
|
|
23
12
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
13
|
+
* For new code, use the payload types from each group file directly
|
|
14
|
+
* with `trackAgentEvent()`.
|
|
26
15
|
*
|
|
27
|
-
*
|
|
28
|
-
* 1. Create a new file in ./groups/ following the template of existing group files
|
|
29
|
-
* 2. Import the group's ACTION_GROUP, action enum, and attribute type below
|
|
30
|
-
* 3. If the group is used by the actions hook, add the attribute type to `ActionAttributes`
|
|
31
|
-
* 4. Add the enum + group to `ACTION_TO_GROUP` using `mapActionsToGroup`
|
|
32
|
-
*/
|
|
33
|
-
/**
|
|
34
|
-
* Combined attribute map for action-hook groups (type-safe attributes).
|
|
35
|
-
* Create-flow groups are excluded — they use a looser attribute type via the create hook.
|
|
16
|
+
* @deprecated The registry pattern is deprecated. Use EventPayload from types.ts instead.
|
|
36
17
|
*/
|
|
37
18
|
|
|
38
|
-
|
|
39
|
-
* Helper to build a Record mapping each enum value to its group name.
|
|
40
|
-
*/
|
|
41
|
-
var mapActionsToGroup = function mapActionsToGroup(actionEnum, group) {
|
|
42
|
-
return Object.fromEntries(Object.values(actionEnum).map(function (action) {
|
|
43
|
-
return [action, group];
|
|
44
|
-
}));
|
|
45
|
-
};
|
|
19
|
+
var DefaultActionSubject = exports.DefaultActionSubject = 'rovoAgent';
|
|
46
20
|
|
|
47
21
|
/**
|
|
48
|
-
*
|
|
49
|
-
* Used by
|
|
22
|
+
* Combined attribute map (union of all groups).
|
|
23
|
+
* Used by the backward-compatible `trackAgentAction` helper.
|
|
50
24
|
*
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
|
-
var ACTION_TO_GROUP = exports.ACTION_TO_GROUP = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, mapActionsToGroup(_agentInteractions.AgentInteractionActions, _agentInteractions.ACTION_GROUP)), mapActionsToGroup(_editing.AgentEditingActions, _editing.ACTION_GROUP)), mapActionsToGroup(_debug.AgentDebugActions, _debug.ACTION_GROUP)), mapActionsToGroup(_tools.AgentToolActions, _tools.ACTION_GROUP)), mapActionsToGroup(_createFlow.CreateFlowActions, _createFlow.ACTION_GROUP)), mapActionsToGroup(_addToolsPrompt.AddToolsPromptActions, _addToolsPrompt.ACTION_GROUP));
|
|
25
|
+
* @deprecated Use EventPayload with trackAgentEvent() instead
|
|
26
|
+
*/
|