@atlaskit/rovo-agent-analytics 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/rovo-agent-analytics
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`cffd9dae547c3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cffd9dae547c3) -
8
+ Update rovo agents analytics funnel
9
+
3
10
  ## 1.0.0
4
11
 
5
12
  ### Major Changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ "use strict";
@@ -12,46 +12,35 @@ var CACHED_CSID = null;
12
12
  var generateCSID = function generateCSID() {
13
13
  return crypto.randomUUID();
14
14
  };
15
- var retrieveCSID = function retrieveCSID() {
16
- if (CACHED_CSID) {
17
- return CACHED_CSID;
18
- }
19
- var queryParams = new URLSearchParams(window.location.search);
20
- var querySessionId = queryParams.get(_constants.CSID_QUERY_PARAM);
21
- return querySessionId !== null && querySessionId !== void 0 ? querySessionId : generateCSID();
22
- };
23
15
 
24
16
  /**
25
- * Hook to get Rovo Agent Create Session ID (CSID) from the query parameters or generate a new one if not found.
26
- * @returns Rovo Agent CSID as a string.
17
+ * Hook to manage CSID state for entry point components.
18
+ * The returned csid is used in href attributes and by trackCreateSessionStart.
19
+ * After trackCreateSessionStart fires, it calls refresh() to generate a new CSID
20
+ * for the next session — the component re-renders and the href updates.
27
21
  */
28
22
  var useRovoAgentCSID = exports.useRovoAgentCSID = function useRovoAgentCSID() {
29
- var _useState = (0, _react.useState)(retrieveCSID()),
23
+ var _useState = (0, _react.useState)(CACHED_CSID || generateCSID()),
30
24
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
31
- CSID = _useState2[0],
25
+ csid = _useState2[0],
32
26
  setCSID = _useState2[1];
27
+ var globalCSID = (0, _react.useMemo)(function () {
28
+ var queryParams = new URLSearchParams(window.location.search);
29
+ return queryParams.get(_constants.CSID_QUERY_PARAM);
30
+ }, []);
33
31
  var actions = (0, _react.useMemo)(function () {
34
32
  return {
35
33
  refresh: function refresh() {
36
34
  var newCSID = generateCSID();
37
35
  setCSID(newCSID);
36
+ CACHED_CSID = newCSID;
38
37
  return newCSID;
39
- },
40
- clear: function clear() {
41
- // remove CSID query parameter
42
- var url = new URL(window.location.href);
43
- url.searchParams.delete(_constants.CSID_QUERY_PARAM);
44
- window.history.replaceState({}, '', url.toString());
45
-
46
- // reset state
47
- setCSID(null);
48
- return null;
49
38
  }
50
39
  };
51
40
  }, []);
52
- (0, _react.useEffect)(function () {
53
- // sync cache on state change
54
- CACHED_CSID = CSID;
55
- }, [CSID]);
56
- return [CSID, actions];
41
+ return [{
42
+ csid: csid,
43
+ // generated CSID to be used in href and createFlowStart events
44
+ globalCSID: globalCSID // CSID from the URL query parameter
45
+ }, actions];
57
46
  };
@@ -17,29 +17,18 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
17
17
  var DefaultActionSubject = 'rovoAgent';
18
18
 
19
19
  /**
20
- * Union type of all valid create agent flow actions.
21
- * Includes both CreateFlow and AddToolsPrompt actions.
22
- *
23
- * Data portal registry links:
24
- * - createFlowStart: https://data-portal.internal.atlassian.com/analytics/registry/97089
25
- * - createFlowSkipNL: https://data-portal.internal.atlassian.com/analytics/registry/97127
26
- * - createFlowReviewNL: https://data-portal.internal.atlassian.com/analytics/registry/97124
27
- * - createFlowActivate: https://data-portal.internal.atlassian.com/analytics/registry/97123
28
- * - createFlowRestart: https://data-portal.internal.atlassian.com/analytics/registry/97131
29
- * - createFlowError: https://data-portal.internal.atlassian.com/analytics/registry/97132
30
- * - createLandInStudio: https://data-portal.internal.atlassian.com/analytics/registry/97136
31
- * - createDiscard: https://data-portal.internal.atlassian.com/analytics/registry/97137
32
- * - saDraft: https://data-portal.internal.atlassian.com/analytics/registry/97924
33
- * - addToolsPromptShown: https://data-portal.internal.atlassian.com/analytics/registry/98106
34
- * - addToolsPromptBrowse: https://data-portal.internal.atlassian.com/analytics/registry/98107
35
- * - addToolsPromptDismiss: https://data-portal.internal.atlassian.com/analytics/registry/98108
20
+ * Union of all valid actions for the create agent analytics hook.
21
+ * Derived from the event payload types in the action group files.
22
+ * To add a new action, update the payload type in the relevant group file.
36
23
  */
37
24
 
38
25
  var globalEventConfig = (0, _utils.getDefaultTrackEventConfig)();
39
26
  var useRovoAgentCreateAnalytics = exports.useRovoAgentCreateAnalytics = function useRovoAgentCreateAnalytics(commonAttributes) {
40
27
  var _useRovoAgentCSID = (0, _csid.useRovoAgentCSID)(),
41
28
  _useRovoAgentCSID2 = (0, _slicedToArray2.default)(_useRovoAgentCSID, 2),
42
- csid = _useRovoAgentCSID2[0],
29
+ _useRovoAgentCSID2$ = _useRovoAgentCSID2[0],
30
+ csid = _useRovoAgentCSID2$.csid,
31
+ globalCSID = _useRovoAgentCSID2$.globalCSID,
43
32
  refreshCSID = _useRovoAgentCSID2[1].refresh;
44
33
  var analyticsContext = (0, _react.useContext)(_analyticsNext.AnalyticsReactContext);
45
34
  var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
@@ -49,38 +38,43 @@ var useRovoAgentCreateAnalytics = exports.useRovoAgentCreateAnalytics = function
49
38
  var referrer = typeof window !== 'undefined' ? window.document.referrer : 'unknown';
50
39
  var attributes = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, (0, _utils.getAttributesFromContexts)(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributesRef.current), event.attributes), {}, {
51
40
  actionGroup: 'createFlow',
52
- csid: csid,
53
41
  referrer: referrer
54
42
  });
55
43
  createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, globalEventConfig), event), {}, {
56
44
  attributes: attributes
57
45
  })).fire(_constants.ANALYTICS_CHANNEL);
58
- }, [createAnalyticsEvent, csid, analyticsContext] // keep number of dependencies minimal to prevent re-rendering
46
+ }, [createAnalyticsEvent, analyticsContext] // keep number of dependencies minimal to prevent re-rendering
59
47
  );
60
48
 
61
49
  /**
62
- * This will fire analytics event for intermediate steps in the create agent flow funnel
63
- * To start the create agent flow, use trackCreateSessionStart
50
+ * Fires an analytics event for a step in the create agent flow funnel.
51
+ * Uses the CSID from the URL query parameter.
64
52
  */
65
53
  var trackCreateSession = (0, _react.useCallback)(function (action, attributes) {
66
54
  fireAnalyticsEvent({
67
55
  actionSubject: DefaultActionSubject,
68
56
  action: action,
69
- attributes: attributes
57
+ attributes: _objectSpread({
58
+ csid: globalCSID
59
+ }, attributes)
70
60
  });
71
- }, [fireAnalyticsEvent]);
61
+ }, [fireAnalyticsEvent, globalCSID]);
72
62
 
73
63
  /**
74
- * This should be used ONLY in the beginning of the funnel of create agent flow, it will create a new CSID (CSID = create session ID)
64
+ * Fires `createFlowStart` with the current CSID (matching the href),
65
+ * then refreshes the CSID for the next session.
66
+ * The component re-renders with the new CSID, updating any href attributes.
75
67
  */
76
68
  var trackCreateSessionStart = (0, _react.useCallback)(function (attributes) {
77
69
  fireAnalyticsEvent({
78
70
  actionSubject: DefaultActionSubject,
79
71
  action: 'createFlowStart',
80
- attributes: attributes
72
+ attributes: _objectSpread({
73
+ csid: csid
74
+ }, attributes)
81
75
  });
82
76
  refreshCSID();
83
- }, [fireAnalyticsEvent, refreshCSID]);
77
+ }, [fireAnalyticsEvent, refreshCSID, csid]);
84
78
  var trackCreateSessionError = (0, _react.useCallback)(function (error, attributes) {
85
79
  fireAnalyticsEvent({
86
80
  actionSubject: DefaultActionSubject,
@@ -88,10 +82,11 @@ var useRovoAgentCreateAnalytics = exports.useRovoAgentCreateAnalytics = function
88
82
  attributes: _objectSpread({
89
83
  error: {
90
84
  message: error.message
91
- }
85
+ },
86
+ csid: globalCSID
92
87
  }, attributes)
93
88
  });
94
- }, [fireAnalyticsEvent]);
89
+ }, [fireAnalyticsEvent, globalCSID]);
95
90
  return [csid, {
96
91
  trackCreateSession: trackCreateSession,
97
92
  trackCreateSessionStart: trackCreateSessionStart,
File without changes
File without changes
@@ -1,46 +1,35 @@
1
- import { useEffect, useMemo, useState } from 'react';
1
+ import { useMemo, useState } from 'react';
2
2
  import { CSID_QUERY_PARAM } from '../constants';
3
3
  let CACHED_CSID = null;
4
4
  const generateCSID = () => {
5
5
  return crypto.randomUUID();
6
6
  };
7
- const retrieveCSID = () => {
8
- if (CACHED_CSID) {
9
- return CACHED_CSID;
10
- }
11
- const queryParams = new URLSearchParams(window.location.search);
12
- const querySessionId = queryParams.get(CSID_QUERY_PARAM);
13
- return querySessionId !== null && querySessionId !== void 0 ? querySessionId : generateCSID();
14
- };
15
7
 
16
8
  /**
17
- * Hook to get Rovo Agent Create Session ID (CSID) from the query parameters or generate a new one if not found.
18
- * @returns Rovo Agent CSID as a string.
9
+ * Hook to manage CSID state for entry point components.
10
+ * The returned csid is used in href attributes and by trackCreateSessionStart.
11
+ * After trackCreateSessionStart fires, it calls refresh() to generate a new CSID
12
+ * for the next session — the component re-renders and the href updates.
19
13
  */
20
14
  export const useRovoAgentCSID = () => {
21
- const [CSID, setCSID] = useState(retrieveCSID());
15
+ const [csid, setCSID] = useState(CACHED_CSID || generateCSID());
16
+ const globalCSID = useMemo(() => {
17
+ const queryParams = new URLSearchParams(window.location.search);
18
+ return queryParams.get(CSID_QUERY_PARAM);
19
+ }, []);
22
20
  const actions = useMemo(() => {
23
21
  return {
24
22
  refresh: () => {
25
23
  const newCSID = generateCSID();
26
24
  setCSID(newCSID);
25
+ CACHED_CSID = newCSID;
27
26
  return newCSID;
28
- },
29
- clear: () => {
30
- // remove CSID query parameter
31
- const url = new URL(window.location.href);
32
- url.searchParams.delete(CSID_QUERY_PARAM);
33
- window.history.replaceState({}, '', url.toString());
34
-
35
- // reset state
36
- setCSID(null);
37
- return null;
38
27
  }
39
28
  };
40
29
  }, []);
41
- useEffect(() => {
42
- // sync cache on state change
43
- CACHED_CSID = CSID;
44
- }, [CSID]);
45
- return [CSID, actions];
30
+ return [{
31
+ csid,
32
+ // generated CSID to be used in href and createFlowStart events
33
+ globalCSID // CSID from the URL query parameter
34
+ }, actions];
46
35
  };
@@ -6,27 +6,17 @@ import { getAttributesFromContexts, getDefaultTrackEventConfig } from '../common
6
6
  const DefaultActionSubject = 'rovoAgent';
7
7
 
8
8
  /**
9
- * Union type of all valid create agent flow actions.
10
- * Includes both CreateFlow and AddToolsPrompt actions.
11
- *
12
- * Data portal registry links:
13
- * - createFlowStart: https://data-portal.internal.atlassian.com/analytics/registry/97089
14
- * - createFlowSkipNL: https://data-portal.internal.atlassian.com/analytics/registry/97127
15
- * - createFlowReviewNL: https://data-portal.internal.atlassian.com/analytics/registry/97124
16
- * - createFlowActivate: https://data-portal.internal.atlassian.com/analytics/registry/97123
17
- * - createFlowRestart: https://data-portal.internal.atlassian.com/analytics/registry/97131
18
- * - createFlowError: https://data-portal.internal.atlassian.com/analytics/registry/97132
19
- * - createLandInStudio: https://data-portal.internal.atlassian.com/analytics/registry/97136
20
- * - createDiscard: https://data-portal.internal.atlassian.com/analytics/registry/97137
21
- * - saDraft: https://data-portal.internal.atlassian.com/analytics/registry/97924
22
- * - addToolsPromptShown: https://data-portal.internal.atlassian.com/analytics/registry/98106
23
- * - addToolsPromptBrowse: https://data-portal.internal.atlassian.com/analytics/registry/98107
24
- * - addToolsPromptDismiss: https://data-portal.internal.atlassian.com/analytics/registry/98108
9
+ * Union of all valid actions for the create agent analytics hook.
10
+ * Derived from the event payload types in the action group files.
11
+ * To add a new action, update the payload type in the relevant group file.
25
12
  */
26
13
 
27
14
  const globalEventConfig = getDefaultTrackEventConfig();
28
15
  export const useRovoAgentCreateAnalytics = commonAttributes => {
29
- const [csid, {
16
+ const [{
17
+ csid,
18
+ globalCSID
19
+ }, {
30
20
  refresh: refreshCSID
31
21
  }] = useRovoAgentCSID();
32
22
  const analyticsContext = useContext(AnalyticsReactContext);
@@ -41,7 +31,6 @@ export const useRovoAgentCreateAnalytics = commonAttributes => {
41
31
  ...commonAttributesRef.current,
42
32
  ...event.attributes,
43
33
  actionGroup: 'createFlow',
44
- csid,
45
34
  referrer
46
35
  };
47
36
  createAnalyticsEvent({
@@ -49,32 +38,40 @@ export const useRovoAgentCreateAnalytics = commonAttributes => {
49
38
  ...event,
50
39
  attributes
51
40
  }).fire(ANALYTICS_CHANNEL);
52
- }, [createAnalyticsEvent, csid, analyticsContext] // keep number of dependencies minimal to prevent re-rendering
41
+ }, [createAnalyticsEvent, analyticsContext] // keep number of dependencies minimal to prevent re-rendering
53
42
  );
54
43
 
55
44
  /**
56
- * This will fire analytics event for intermediate steps in the create agent flow funnel
57
- * To start the create agent flow, use trackCreateSessionStart
45
+ * Fires an analytics event for a step in the create agent flow funnel.
46
+ * Uses the CSID from the URL query parameter.
58
47
  */
59
48
  const trackCreateSession = useCallback((action, attributes) => {
60
49
  fireAnalyticsEvent({
61
50
  actionSubject: DefaultActionSubject,
62
51
  action,
63
- attributes
52
+ attributes: {
53
+ csid: globalCSID,
54
+ ...attributes
55
+ }
64
56
  });
65
- }, [fireAnalyticsEvent]);
57
+ }, [fireAnalyticsEvent, globalCSID]);
66
58
 
67
59
  /**
68
- * This should be used ONLY in the beginning of the funnel of create agent flow, it will create a new CSID (CSID = create session ID)
60
+ * Fires `createFlowStart` with the current CSID (matching the href),
61
+ * then refreshes the CSID for the next session.
62
+ * The component re-renders with the new CSID, updating any href attributes.
69
63
  */
70
64
  const trackCreateSessionStart = useCallback(attributes => {
71
65
  fireAnalyticsEvent({
72
66
  actionSubject: DefaultActionSubject,
73
67
  action: 'createFlowStart',
74
- attributes
68
+ attributes: {
69
+ csid,
70
+ ...attributes
71
+ }
75
72
  });
76
73
  refreshCSID();
77
- }, [fireAnalyticsEvent, refreshCSID]);
74
+ }, [fireAnalyticsEvent, refreshCSID, csid]);
78
75
  const trackCreateSessionError = useCallback((error, attributes) => {
79
76
  fireAnalyticsEvent({
80
77
  actionSubject: DefaultActionSubject,
@@ -83,10 +80,11 @@ export const useRovoAgentCreateAnalytics = commonAttributes => {
83
80
  error: {
84
81
  message: error.message
85
82
  },
83
+ csid: globalCSID,
86
84
  ...attributes
87
85
  }
88
86
  });
89
- }, [fireAnalyticsEvent]);
87
+ }, [fireAnalyticsEvent, globalCSID]);
90
88
  return [csid, {
91
89
  trackCreateSession,
92
90
  trackCreateSessionStart,
File without changes
File without changes
@@ -1,50 +1,39 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import { useEffect, useMemo, useState } from 'react';
2
+ import { useMemo, useState } from 'react';
3
3
  import { CSID_QUERY_PARAM } from '../constants';
4
4
  var CACHED_CSID = null;
5
5
  var generateCSID = function generateCSID() {
6
6
  return crypto.randomUUID();
7
7
  };
8
- var retrieveCSID = function retrieveCSID() {
9
- if (CACHED_CSID) {
10
- return CACHED_CSID;
11
- }
12
- var queryParams = new URLSearchParams(window.location.search);
13
- var querySessionId = queryParams.get(CSID_QUERY_PARAM);
14
- return querySessionId !== null && querySessionId !== void 0 ? querySessionId : generateCSID();
15
- };
16
8
 
17
9
  /**
18
- * Hook to get Rovo Agent Create Session ID (CSID) from the query parameters or generate a new one if not found.
19
- * @returns Rovo Agent CSID as a string.
10
+ * Hook to manage CSID state for entry point components.
11
+ * The returned csid is used in href attributes and by trackCreateSessionStart.
12
+ * After trackCreateSessionStart fires, it calls refresh() to generate a new CSID
13
+ * for the next session — the component re-renders and the href updates.
20
14
  */
21
15
  export var useRovoAgentCSID = function useRovoAgentCSID() {
22
- var _useState = useState(retrieveCSID()),
16
+ var _useState = useState(CACHED_CSID || generateCSID()),
23
17
  _useState2 = _slicedToArray(_useState, 2),
24
- CSID = _useState2[0],
18
+ csid = _useState2[0],
25
19
  setCSID = _useState2[1];
20
+ var globalCSID = useMemo(function () {
21
+ var queryParams = new URLSearchParams(window.location.search);
22
+ return queryParams.get(CSID_QUERY_PARAM);
23
+ }, []);
26
24
  var actions = useMemo(function () {
27
25
  return {
28
26
  refresh: function refresh() {
29
27
  var newCSID = generateCSID();
30
28
  setCSID(newCSID);
29
+ CACHED_CSID = newCSID;
31
30
  return newCSID;
32
- },
33
- clear: function clear() {
34
- // remove CSID query parameter
35
- var url = new URL(window.location.href);
36
- url.searchParams.delete(CSID_QUERY_PARAM);
37
- window.history.replaceState({}, '', url.toString());
38
-
39
- // reset state
40
- setCSID(null);
41
- return null;
42
31
  }
43
32
  };
44
33
  }, []);
45
- useEffect(function () {
46
- // sync cache on state change
47
- CACHED_CSID = CSID;
48
- }, [CSID]);
49
- return [CSID, actions];
34
+ return [{
35
+ csid: csid,
36
+ // generated CSID to be used in href and createFlowStart events
37
+ globalCSID: globalCSID // CSID from the URL query parameter
38
+ }, actions];
50
39
  };
@@ -10,29 +10,18 @@ import { getAttributesFromContexts, getDefaultTrackEventConfig } from '../common
10
10
  var DefaultActionSubject = 'rovoAgent';
11
11
 
12
12
  /**
13
- * Union type of all valid create agent flow actions.
14
- * Includes both CreateFlow and AddToolsPrompt actions.
15
- *
16
- * Data portal registry links:
17
- * - createFlowStart: https://data-portal.internal.atlassian.com/analytics/registry/97089
18
- * - createFlowSkipNL: https://data-portal.internal.atlassian.com/analytics/registry/97127
19
- * - createFlowReviewNL: https://data-portal.internal.atlassian.com/analytics/registry/97124
20
- * - createFlowActivate: https://data-portal.internal.atlassian.com/analytics/registry/97123
21
- * - createFlowRestart: https://data-portal.internal.atlassian.com/analytics/registry/97131
22
- * - createFlowError: https://data-portal.internal.atlassian.com/analytics/registry/97132
23
- * - createLandInStudio: https://data-portal.internal.atlassian.com/analytics/registry/97136
24
- * - createDiscard: https://data-portal.internal.atlassian.com/analytics/registry/97137
25
- * - saDraft: https://data-portal.internal.atlassian.com/analytics/registry/97924
26
- * - addToolsPromptShown: https://data-portal.internal.atlassian.com/analytics/registry/98106
27
- * - addToolsPromptBrowse: https://data-portal.internal.atlassian.com/analytics/registry/98107
28
- * - addToolsPromptDismiss: https://data-portal.internal.atlassian.com/analytics/registry/98108
13
+ * Union of all valid actions for the create agent analytics hook.
14
+ * Derived from the event payload types in the action group files.
15
+ * To add a new action, update the payload type in the relevant group file.
29
16
  */
30
17
 
31
18
  var globalEventConfig = getDefaultTrackEventConfig();
32
19
  export var useRovoAgentCreateAnalytics = function useRovoAgentCreateAnalytics(commonAttributes) {
33
20
  var _useRovoAgentCSID = useRovoAgentCSID(),
34
21
  _useRovoAgentCSID2 = _slicedToArray(_useRovoAgentCSID, 2),
35
- csid = _useRovoAgentCSID2[0],
22
+ _useRovoAgentCSID2$ = _useRovoAgentCSID2[0],
23
+ csid = _useRovoAgentCSID2$.csid,
24
+ globalCSID = _useRovoAgentCSID2$.globalCSID,
36
25
  refreshCSID = _useRovoAgentCSID2[1].refresh;
37
26
  var analyticsContext = useContext(AnalyticsReactContext);
38
27
  var _useAnalyticsEvents = useAnalyticsEvents(),
@@ -42,38 +31,43 @@ export var useRovoAgentCreateAnalytics = function useRovoAgentCreateAnalytics(co
42
31
  var referrer = typeof window !== 'undefined' ? window.document.referrer : 'unknown';
43
32
  var attributes = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributesRef.current), event.attributes), {}, {
44
33
  actionGroup: 'createFlow',
45
- csid: csid,
46
34
  referrer: referrer
47
35
  });
48
36
  createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, globalEventConfig), event), {}, {
49
37
  attributes: attributes
50
38
  })).fire(ANALYTICS_CHANNEL);
51
- }, [createAnalyticsEvent, csid, analyticsContext] // keep number of dependencies minimal to prevent re-rendering
39
+ }, [createAnalyticsEvent, analyticsContext] // keep number of dependencies minimal to prevent re-rendering
52
40
  );
53
41
 
54
42
  /**
55
- * This will fire analytics event for intermediate steps in the create agent flow funnel
56
- * To start the create agent flow, use trackCreateSessionStart
43
+ * Fires an analytics event for a step in the create agent flow funnel.
44
+ * Uses the CSID from the URL query parameter.
57
45
  */
58
46
  var trackCreateSession = useCallback(function (action, attributes) {
59
47
  fireAnalyticsEvent({
60
48
  actionSubject: DefaultActionSubject,
61
49
  action: action,
62
- attributes: attributes
50
+ attributes: _objectSpread({
51
+ csid: globalCSID
52
+ }, attributes)
63
53
  });
64
- }, [fireAnalyticsEvent]);
54
+ }, [fireAnalyticsEvent, globalCSID]);
65
55
 
66
56
  /**
67
- * This should be used ONLY in the beginning of the funnel of create agent flow, it will create a new CSID (CSID = create session ID)
57
+ * Fires `createFlowStart` with the current CSID (matching the href),
58
+ * then refreshes the CSID for the next session.
59
+ * The component re-renders with the new CSID, updating any href attributes.
68
60
  */
69
61
  var trackCreateSessionStart = useCallback(function (attributes) {
70
62
  fireAnalyticsEvent({
71
63
  actionSubject: DefaultActionSubject,
72
64
  action: 'createFlowStart',
73
- attributes: attributes
65
+ attributes: _objectSpread({
66
+ csid: csid
67
+ }, attributes)
74
68
  });
75
69
  refreshCSID();
76
- }, [fireAnalyticsEvent, refreshCSID]);
70
+ }, [fireAnalyticsEvent, refreshCSID, csid]);
77
71
  var trackCreateSessionError = useCallback(function (error, attributes) {
78
72
  fireAnalyticsEvent({
79
73
  actionSubject: DefaultActionSubject,
@@ -81,10 +75,11 @@ export var useRovoAgentCreateAnalytics = function useRovoAgentCreateAnalytics(co
81
75
  attributes: _objectSpread({
82
76
  error: {
83
77
  message: error.message
84
- }
78
+ },
79
+ csid: globalCSID
85
80
  }, attributes)
86
81
  });
87
- }, [fireAnalyticsEvent]);
82
+ }, [fireAnalyticsEvent, globalCSID]);
88
83
  return [csid, {
89
84
  trackCreateSession: trackCreateSession,
90
85
  trackCreateSessionStart: trackCreateSessionStart,
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Action Group: addToolsPrompt
3
+ *
4
+ * Events related to the "Add Tools" prompt shown during agent creation.
5
+ *
6
+ * ## Adding a new action
7
+ * 1. Add a new variant to the `AddToolsPromptEventPayload` 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
+ */
10
+ /**
11
+ * Discriminated union payload type for add tools prompt events.
12
+ * Use with `trackAgentEvent()`.
13
+ */
14
+ export type AddToolsPromptEventPayload = {
15
+ actionSubject: 'rovoAgent';
16
+ action: 'addToolsPromptShown';
17
+ attributes: {};
18
+ } | {
19
+ actionSubject: 'rovoAgent';
20
+ action: 'addToolsPromptBrowse';
21
+ attributes: {};
22
+ } | {
23
+ actionSubject: 'rovoAgent';
24
+ action: 'addToolsPromptDismiss';
25
+ attributes: {};
26
+ };
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Action Group: createFlow
3
+ *
4
+ * Create agent funnel steps — from clicking "Create agent" through to activation or discard.
5
+ *
6
+ * ## Funnel overview
7
+ *
8
+ * | Step | v1 (NL flow) event | v2 (SA flow) event | CSID behavior |
9
+ * |-----------------------|------------------------|------------------------|----------------------------------|
10
+ * | Intent to create | createFlowStart | saDraft | Uses existing CSID |
11
+ * | Land in NL page | createLandInStudio | (skipped) | Uses existing CSID |
12
+ * | NL interaction | REVIEW_NL / SKIP_NL | (skipped) | Uses existing CSID |
13
+ * | Land in configure | createLandInConfigure | createLandInConfigure | Uses existing CSID |
14
+ * | Activate agent | createFlowActivate | createFlowActivate | Uses existing CSID |
15
+ *
16
+ * ## CSID (Create Session ID)
17
+ *
18
+ * CSID links all events in a single agent creation session.
19
+ * - `trackCreateSessionStart()` fires `createFlowStart` with the current CSID
20
+ * - `trackCreateSession()` uses the existing CSID (for all other steps including `saDraft`)
21
+ *
22
+ * ## Adding a new action
23
+ * 1. Add a new variant to the `CreateFlowEventPayload` union type below with a data-portal link
24
+ * 2. If this action doesn't fit this group, consider creating a new group file instead
25
+ * (see other files in this directory for the template)
26
+ */
27
+ /**
28
+ * Discriminated union payload type for create flow events.
29
+ * Use with `trackAgentEvent()`.
30
+ */
31
+ export type CreateFlowEventPayload = {
32
+ actionSubject: 'rovoAgent';
33
+ action: 'createFlowStart';
34
+ attributes: {};
35
+ } | {
36
+ actionSubject: 'rovoAgent';
37
+ action: 'createFlowSkipNL';
38
+ attributes: {};
39
+ } | {
40
+ actionSubject: 'rovoAgent';
41
+ action: 'createFlowReviewNL';
42
+ attributes: {};
43
+ } | {
44
+ actionSubject: 'rovoAgent';
45
+ action: 'createFlowActivate';
46
+ attributes: {};
47
+ } | {
48
+ actionSubject: 'rovoAgent';
49
+ action: 'createFlowRestart';
50
+ attributes: {};
51
+ } | {
52
+ actionSubject: 'rovoAgent';
53
+ action: 'createFlowError';
54
+ attributes: {};
55
+ } | {
56
+ actionSubject: 'rovoAgent';
57
+ action: 'createLandInStudio';
58
+ attributes: {};
59
+ } | {
60
+ actionSubject: 'rovoAgent';
61
+ action: 'createDiscard';
62
+ attributes: {};
63
+ } | {
64
+ actionSubject: 'rovoAgent';
65
+ action: 'saDraft';
66
+ attributes: {};
67
+ } | {
68
+ actionSubject: 'rovoAgent';
69
+ action: 'createLandInConfigure';
70
+ attributes: {};
71
+ };
@@ -1,3 +1,3 @@
1
1
  import { FabricChannel } from '@atlaskit/analytics-listeners';
2
- export declare const ANALYTICS_CHANNEL = FabricChannel.aiMate;
2
+ export declare const ANALYTICS_CHANNEL: FabricChannel.aiMate;
3
3
  export declare const CSID_QUERY_PARAM = "csid";
@@ -1,8 +1,12 @@
1
1
  /**
2
- * Hook to get Rovo Agent Create Session ID (CSID) from the query parameters or generate a new one if not found.
3
- * @returns Rovo Agent CSID as a string.
2
+ * Hook to manage CSID state for entry point components.
3
+ * The returned csid is used in href attributes and by trackCreateSessionStart.
4
+ * After trackCreateSessionStart fires, it calls refresh() to generate a new CSID
5
+ * for the next session — the component re-renders and the href updates.
4
6
  */
5
- export declare const useRovoAgentCSID: () => readonly [string | null, {
7
+ export declare const useRovoAgentCSID: () => readonly [{
8
+ readonly csid: string | null;
9
+ readonly globalCSID: string | null;
10
+ }, {
6
11
  refresh: () => `${string}-${string}-${string}-${string}-${string}`;
7
- clear: () => null;
8
12
  }];
@@ -1,22 +1,11 @@
1
+ import type { AddToolsPromptEventPayload } from '../actions/groups/add-tools-prompt';
2
+ import type { CreateFlowEventPayload } from '../actions/groups/create-flow';
1
3
  /**
2
- * Union type of all valid create agent flow actions.
3
- * Includes both CreateFlow and AddToolsPrompt actions.
4
- *
5
- * Data portal registry links:
6
- * - createFlowStart: https://data-portal.internal.atlassian.com/analytics/registry/97089
7
- * - createFlowSkipNL: https://data-portal.internal.atlassian.com/analytics/registry/97127
8
- * - createFlowReviewNL: https://data-portal.internal.atlassian.com/analytics/registry/97124
9
- * - createFlowActivate: https://data-portal.internal.atlassian.com/analytics/registry/97123
10
- * - createFlowRestart: https://data-portal.internal.atlassian.com/analytics/registry/97131
11
- * - createFlowError: https://data-portal.internal.atlassian.com/analytics/registry/97132
12
- * - createLandInStudio: https://data-portal.internal.atlassian.com/analytics/registry/97136
13
- * - createDiscard: https://data-portal.internal.atlassian.com/analytics/registry/97137
14
- * - saDraft: https://data-portal.internal.atlassian.com/analytics/registry/97924
15
- * - addToolsPromptShown: https://data-portal.internal.atlassian.com/analytics/registry/98106
16
- * - addToolsPromptBrowse: https://data-portal.internal.atlassian.com/analytics/registry/98107
17
- * - addToolsPromptDismiss: https://data-portal.internal.atlassian.com/analytics/registry/98108
4
+ * Union of all valid actions for the create agent analytics hook.
5
+ * Derived from the event payload types in the action group files.
6
+ * To add a new action, update the payload type in the relevant group file.
18
7
  */
19
- type AgentCreateAction = 'createFlowStart' | 'createFlowSkipNL' | 'createFlowReviewNL' | 'createFlowActivate' | 'createFlowRestart' | 'createFlowError' | 'createLandInStudio' | 'createDiscard' | 'saDraft' | 'addToolsPromptShown' | 'addToolsPromptBrowse' | 'addToolsPromptDismiss';
8
+ type AgentCreateAction = CreateFlowEventPayload['action'] | AddToolsPromptEventPayload['action'];
20
9
  type CommonAnalyticsAttributes = {
21
10
  touchPoint?: string;
22
11
  } & Record<string, any>;
@@ -24,6 +13,6 @@ export declare const useRovoAgentCreateAnalytics: (commonAttributes: CommonAnaly
24
13
  readonly trackCreateSession: (action: AgentCreateAction, attributes?: CommonAnalyticsAttributes) => void;
25
14
  readonly trackCreateSessionStart: (attributes?: CommonAnalyticsAttributes) => void;
26
15
  readonly trackCreateSessionError: (error: Error, attributes?: CommonAnalyticsAttributes) => void;
27
- readonly refreshCSID: () => `${string}-${string}-${string}-${string}-${string}`;
16
+ readonly refreshCSID: () => string;
28
17
  }];
29
18
  export {};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Action Group: addToolsPrompt
3
+ *
4
+ * Events related to the "Add Tools" prompt shown during agent creation.
5
+ *
6
+ * ## Adding a new action
7
+ * 1. Add a new variant to the `AddToolsPromptEventPayload` 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
+ */
10
+ /**
11
+ * Discriminated union payload type for add tools prompt events.
12
+ * Use with `trackAgentEvent()`.
13
+ */
14
+ export type AddToolsPromptEventPayload = {
15
+ actionSubject: 'rovoAgent';
16
+ action: 'addToolsPromptShown';
17
+ attributes: {};
18
+ } | {
19
+ actionSubject: 'rovoAgent';
20
+ action: 'addToolsPromptBrowse';
21
+ attributes: {};
22
+ } | {
23
+ actionSubject: 'rovoAgent';
24
+ action: 'addToolsPromptDismiss';
25
+ attributes: {};
26
+ };
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Action Group: createFlow
3
+ *
4
+ * Create agent funnel steps — from clicking "Create agent" through to activation or discard.
5
+ *
6
+ * ## Funnel overview
7
+ *
8
+ * | Step | v1 (NL flow) event | v2 (SA flow) event | CSID behavior |
9
+ * |-----------------------|------------------------|------------------------|----------------------------------|
10
+ * | Intent to create | createFlowStart | saDraft | Uses existing CSID |
11
+ * | Land in NL page | createLandInStudio | (skipped) | Uses existing CSID |
12
+ * | NL interaction | REVIEW_NL / SKIP_NL | (skipped) | Uses existing CSID |
13
+ * | Land in configure | createLandInConfigure | createLandInConfigure | Uses existing CSID |
14
+ * | Activate agent | createFlowActivate | createFlowActivate | Uses existing CSID |
15
+ *
16
+ * ## CSID (Create Session ID)
17
+ *
18
+ * CSID links all events in a single agent creation session.
19
+ * - `trackCreateSessionStart()` fires `createFlowStart` with the current CSID
20
+ * - `trackCreateSession()` uses the existing CSID (for all other steps including `saDraft`)
21
+ *
22
+ * ## Adding a new action
23
+ * 1. Add a new variant to the `CreateFlowEventPayload` union type below with a data-portal link
24
+ * 2. If this action doesn't fit this group, consider creating a new group file instead
25
+ * (see other files in this directory for the template)
26
+ */
27
+ /**
28
+ * Discriminated union payload type for create flow events.
29
+ * Use with `trackAgentEvent()`.
30
+ */
31
+ export type CreateFlowEventPayload = {
32
+ actionSubject: 'rovoAgent';
33
+ action: 'createFlowStart';
34
+ attributes: {};
35
+ } | {
36
+ actionSubject: 'rovoAgent';
37
+ action: 'createFlowSkipNL';
38
+ attributes: {};
39
+ } | {
40
+ actionSubject: 'rovoAgent';
41
+ action: 'createFlowReviewNL';
42
+ attributes: {};
43
+ } | {
44
+ actionSubject: 'rovoAgent';
45
+ action: 'createFlowActivate';
46
+ attributes: {};
47
+ } | {
48
+ actionSubject: 'rovoAgent';
49
+ action: 'createFlowRestart';
50
+ attributes: {};
51
+ } | {
52
+ actionSubject: 'rovoAgent';
53
+ action: 'createFlowError';
54
+ attributes: {};
55
+ } | {
56
+ actionSubject: 'rovoAgent';
57
+ action: 'createLandInStudio';
58
+ attributes: {};
59
+ } | {
60
+ actionSubject: 'rovoAgent';
61
+ action: 'createDiscard';
62
+ attributes: {};
63
+ } | {
64
+ actionSubject: 'rovoAgent';
65
+ action: 'saDraft';
66
+ attributes: {};
67
+ } | {
68
+ actionSubject: 'rovoAgent';
69
+ action: 'createLandInConfigure';
70
+ attributes: {};
71
+ };
@@ -1,3 +1,3 @@
1
1
  import { FabricChannel } from '@atlaskit/analytics-listeners';
2
- export declare const ANALYTICS_CHANNEL = FabricChannel.aiMate;
2
+ export declare const ANALYTICS_CHANNEL: FabricChannel.aiMate;
3
3
  export declare const CSID_QUERY_PARAM = "csid";
@@ -1,11 +1,15 @@
1
1
  /**
2
- * Hook to get Rovo Agent Create Session ID (CSID) from the query parameters or generate a new one if not found.
3
- * @returns Rovo Agent CSID as a string.
2
+ * Hook to manage CSID state for entry point components.
3
+ * The returned csid is used in href attributes and by trackCreateSessionStart.
4
+ * After trackCreateSessionStart fires, it calls refresh() to generate a new CSID
5
+ * for the next session — the component re-renders and the href updates.
4
6
  */
5
7
  export declare const useRovoAgentCSID: () => readonly [
6
- string | null,
8
+ {
9
+ readonly csid: string | null;
10
+ readonly globalCSID: string | null;
11
+ },
7
12
  {
8
13
  refresh: () => `${string}-${string}-${string}-${string}-${string}`;
9
- clear: () => null;
10
14
  }
11
15
  ];
@@ -1,22 +1,11 @@
1
+ import type { AddToolsPromptEventPayload } from '../actions/groups/add-tools-prompt';
2
+ import type { CreateFlowEventPayload } from '../actions/groups/create-flow';
1
3
  /**
2
- * Union type of all valid create agent flow actions.
3
- * Includes both CreateFlow and AddToolsPrompt actions.
4
- *
5
- * Data portal registry links:
6
- * - createFlowStart: https://data-portal.internal.atlassian.com/analytics/registry/97089
7
- * - createFlowSkipNL: https://data-portal.internal.atlassian.com/analytics/registry/97127
8
- * - createFlowReviewNL: https://data-portal.internal.atlassian.com/analytics/registry/97124
9
- * - createFlowActivate: https://data-portal.internal.atlassian.com/analytics/registry/97123
10
- * - createFlowRestart: https://data-portal.internal.atlassian.com/analytics/registry/97131
11
- * - createFlowError: https://data-portal.internal.atlassian.com/analytics/registry/97132
12
- * - createLandInStudio: https://data-portal.internal.atlassian.com/analytics/registry/97136
13
- * - createDiscard: https://data-portal.internal.atlassian.com/analytics/registry/97137
14
- * - saDraft: https://data-portal.internal.atlassian.com/analytics/registry/97924
15
- * - addToolsPromptShown: https://data-portal.internal.atlassian.com/analytics/registry/98106
16
- * - addToolsPromptBrowse: https://data-portal.internal.atlassian.com/analytics/registry/98107
17
- * - addToolsPromptDismiss: https://data-portal.internal.atlassian.com/analytics/registry/98108
4
+ * Union of all valid actions for the create agent analytics hook.
5
+ * Derived from the event payload types in the action group files.
6
+ * To add a new action, update the payload type in the relevant group file.
18
7
  */
19
- type AgentCreateAction = 'createFlowStart' | 'createFlowSkipNL' | 'createFlowReviewNL' | 'createFlowActivate' | 'createFlowRestart' | 'createFlowError' | 'createLandInStudio' | 'createDiscard' | 'saDraft' | 'addToolsPromptShown' | 'addToolsPromptBrowse' | 'addToolsPromptDismiss';
8
+ type AgentCreateAction = CreateFlowEventPayload['action'] | AddToolsPromptEventPayload['action'];
20
9
  type CommonAnalyticsAttributes = {
21
10
  touchPoint?: string;
22
11
  } & Record<string, any>;
@@ -26,7 +15,7 @@ export declare const useRovoAgentCreateAnalytics: (commonAttributes: CommonAnaly
26
15
  readonly trackCreateSession: (action: AgentCreateAction, attributes?: CommonAnalyticsAttributes) => void;
27
16
  readonly trackCreateSessionStart: (attributes?: CommonAnalyticsAttributes) => void;
28
17
  readonly trackCreateSessionError: (error: Error, attributes?: CommonAnalyticsAttributes) => void;
29
- readonly refreshCSID: () => `${string}-${string}-${string}-${string}-${string}`;
18
+ readonly refreshCSID: () => string;
30
19
  }
31
20
  ];
32
21
  export {};
package/package.json CHANGED
@@ -1,4 +1,8 @@
1
1
  {
2
+ "name": "@atlaskit/rovo-agent-analytics",
3
+ "version": "1.1.0",
4
+ "description": "Rovo Agents analytics",
5
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend-monorepo",
2
6
  "atlassian": {
3
7
  "team": "Rovo Agents",
4
8
  "website": {
@@ -6,7 +10,11 @@
6
10
  "category": "Layout and structure"
7
11
  }
8
12
  },
9
- "repository": "https://bitbucket.org/atlassian/atlassian-frontend-monorepo",
13
+ "author": "Atlassian Pty Ltd",
14
+ "license": "Apache-2.0",
15
+ "publishConfig": {
16
+ "registry": "https://registry.npmjs.org/"
17
+ },
10
18
  "main": "dist/cjs/index.js",
11
19
  "module": "dist/esm/index.js",
12
20
  "module:es2019": "dist/es2019/index.js",
@@ -19,19 +27,16 @@
19
27
  ]
20
28
  }
21
29
  },
30
+ "atlaskit:src": "src/index.ts",
22
31
  "sideEffects": [
23
32
  "*.compiled.css"
24
33
  ],
25
- "atlaskit:src": "src/index.ts",
26
34
  "dependencies": {
27
35
  "@atlaskit/analytics-listeners": "^10.0.0",
28
36
  "@atlaskit/analytics-next": "^11.1.0",
29
37
  "@babel/runtime": "^7.0.0",
30
38
  "@compiled/react": "^0.20.0"
31
39
  },
32
- "peerDependencies": {
33
- "react": "^18.2.0"
34
- },
35
40
  "devDependencies": {
36
41
  "@af/integration-testing": "workspace:^",
37
42
  "@af/visual-regression": "workspace:^",
@@ -39,6 +44,9 @@
39
44
  "@testing-library/react": "^16.3.0",
40
45
  "react-dom": "^18.2.0"
41
46
  },
47
+ "peerDependencies": {
48
+ "react": "^18.2.0"
49
+ },
42
50
  "techstack": {
43
51
  "@atlassian/frontend": {
44
52
  "import-structure": [
@@ -73,13 +81,5 @@
73
81
  "import-no-extraneous-disable-for-examples-and-docs"
74
82
  ]
75
83
  }
76
- },
77
- "name": "@atlaskit/rovo-agent-analytics",
78
- "version": "1.0.0",
79
- "description": "Rovo Agents analytics",
80
- "author": "Atlassian Pty Ltd",
81
- "license": "Apache-2.0",
82
- "publishConfig": {
83
- "registry": "https://registry.npmjs.org/"
84
84
  }
85
85
  }