@atlaskit/rovo-agent-analytics 0.10.0 → 0.12.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,21 @@
1
1
  # @atlaskit/rovo-agent-analytics
2
2
 
3
+ ## 0.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`0c769648243fc`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0c769648243fc) -
8
+ Update rovo agents analytics coverage
9
+ - [`442a9eacd5145`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/442a9eacd5145) -
10
+ Fix rovo agent debug modal view analytics
11
+
12
+ ## 0.11.0
13
+
14
+ ### Minor Changes
15
+
16
+ - [`d701db2f15d73`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d701db2f15d73) -
17
+ Rovo agents debug modal analytics
18
+
3
19
  ## 0.10.0
4
20
 
5
21
  ### Minor Changes
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@atlaskit/rovo-agent-analytics/debug",
3
+ "main": "../dist/cjs/debug/index.js",
4
+ "module": "../dist/esm/debug/index.js",
5
+ "module:es2019": "../dist/es2019/debug/index.js",
6
+ "sideEffects": [
7
+ "*.compiled.css"
8
+ ],
9
+ "types": "../dist/types/debug/index.d.ts",
10
+ "typesVersions": {
11
+ ">=4.5 <5.9": {
12
+ "*": [
13
+ "../dist/types-ts4.5/debug/index.d.ts"
14
+ ]
15
+ }
16
+ }
17
+ }
@@ -4,11 +4,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.useRovoAgentActionAnalytics = exports.AgentActions = exports.ANALYTICS_CHANNEL = void 0;
7
+ exports.useRovoAgentActionAnalytics = exports.AgentActions = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _react = require("react");
10
- var _analyticsListeners = require("@atlaskit/analytics-listeners");
11
10
  var _analyticsNext = require("@atlaskit/analytics-next");
11
+ var _constants = require("../common/constants");
12
12
  var _utils = require("../common/utils");
13
13
  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; }
14
14
  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; }
@@ -35,17 +35,18 @@ var AgentActions = exports.AgentActions = /*#__PURE__*/function (AgentActions) {
35
35
  AgentActions["UNVERIFY"] = "unverify";
36
36
  return AgentActions;
37
37
  }({});
38
- var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = _analyticsListeners.FabricChannel.aiMate;
39
38
  var useRovoAgentActionAnalytics = exports.useRovoAgentActionAnalytics = function useRovoAgentActionAnalytics(commonAttributes) {
40
39
  var analyticsContext = (0, _react.useContext)(_analyticsNext.AnalyticsReactContext);
41
40
  var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
42
41
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
43
- var eventConfig = (0, _utils.getDefaultTrackEventConfig)();
42
+ var eventConfig = (0, _react.useMemo)(function () {
43
+ return (0, _utils.getDefaultTrackEventConfig)();
44
+ }, []);
44
45
  var fireAnalyticsEvent = (0, _react.useCallback)(function (event) {
45
46
  var attributes = _objectSpread(_objectSpread(_objectSpread({}, (0, _utils.getAttributesFromContexts)(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributes), event.attributes);
46
47
  createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, eventConfig), event), {}, {
47
48
  attributes: attributes
48
- })).fire(ANALYTICS_CHANNEL);
49
+ })).fire(_constants.ANALYTICS_CHANNEL);
49
50
  }, [createAnalyticsEvent, eventConfig, commonAttributes, analyticsContext]);
50
51
  var trackAgentAction = (0, _react.useCallback)(function (action, attributes) {
51
52
  fireAnalyticsEvent({
@@ -15,12 +15,22 @@ var _utils = require("../common/utils");
15
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
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
17
  var AgentCreateActions = exports.AgentCreateActions = /*#__PURE__*/function (AgentCreateActions) {
18
+ /* Start create flow when user clicks on "Create agent" button */
18
19
  AgentCreateActions["START"] = "createFlowStart";
20
+ /* Skip natural language */
19
21
  AgentCreateActions["SKIP_NL"] = "createFlowSkipNL";
22
+ /* Review natural language */
20
23
  AgentCreateActions["REVIEW_NL"] = "createFlowReviewNL";
24
+ /* Activate agent */
21
25
  AgentCreateActions["ACTIVATE"] = "createFlowActivate";
26
+ /* Restart create flow */
22
27
  AgentCreateActions["RESTART"] = "createFlowRestart";
28
+ /* Error occurred */
23
29
  AgentCreateActions["ERROR"] = "createFlowError";
30
+ /* Land in studio */
31
+ AgentCreateActions["LAND"] = "createLandInStudio";
32
+ /* Discard agent */
33
+ AgentCreateActions["DISCARD"] = "createDiscard";
24
34
  return AgentCreateActions;
25
35
  }({});
26
36
  var useRovoAgentCreateAnalytics = exports.useRovoAgentCreateAnalytics = function useRovoAgentCreateAnalytics(commonAttributes) {
@@ -30,11 +40,15 @@ var useRovoAgentCreateAnalytics = exports.useRovoAgentCreateAnalytics = function
30
40
  refreshCSID = _useRovoAgentCSID2[1].refresh;
31
41
  var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
32
42
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
33
- var eventConfig = (0, _utils.getDefaultTrackEventConfig)();
43
+ var eventConfig = (0, _react.useMemo)(function () {
44
+ return (0, _utils.getDefaultTrackEventConfig)();
45
+ }, []);
34
46
  var fireAnalyticsEvent = (0, _react.useCallback)(function (event) {
47
+ var referrer = typeof window !== 'undefined' ? window.document.referrer : 'unknown';
35
48
  createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, eventConfig), event), {}, {
36
49
  attributes: _objectSpread(_objectSpread({
37
- csid: csid
50
+ csid: csid,
51
+ referrer: referrer
38
52
  }, commonAttributes), event.attributes)
39
53
  })).fire(_constants.ANALYTICS_CHANNEL);
40
54
  }, [createAnalyticsEvent, eventConfig, csid, commonAttributes]);
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useRovoAgentDebugAnalytics = exports.AgentDebugActions = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _react = require("react");
10
+ var _analyticsNext = require("@atlaskit/analytics-next");
11
+ var _constants = require("../common/constants");
12
+ var _utils = require("../common/utils");
13
+ 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; }
14
+ 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; }
15
+ var AgentDebugActions = exports.AgentDebugActions = /*#__PURE__*/function (AgentDebugActions) {
16
+ /* View debug modal */
17
+ AgentDebugActions["VIEW"] = "debugView";
18
+ /* Copy all debug data */
19
+ AgentDebugActions["COPY_ALL"] = "debugCopyAll";
20
+ /* Copy debug data */
21
+ AgentDebugActions["COPY"] = "debugCopy";
22
+ /* Toggle skill info */
23
+ AgentDebugActions["TOGGLE_SKILL_INFO"] = "debugToggleSkillInfo";
24
+ /* Error occurred */
25
+ AgentDebugActions["ERROR"] = "debugError";
26
+ return AgentDebugActions;
27
+ }({});
28
+ var useRovoAgentDebugAnalytics = exports.useRovoAgentDebugAnalytics = function useRovoAgentDebugAnalytics(commonAttributes) {
29
+ var analyticsContext = (0, _react.useContext)(_analyticsNext.AnalyticsReactContext);
30
+ var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
31
+ createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
32
+ var eventConfig = (0, _react.useMemo)(function () {
33
+ return (0, _utils.getDefaultTrackEventConfig)();
34
+ }, []);
35
+ var fireAnalyticsEvent = (0, _react.useCallback)(function (event) {
36
+ var attributes = _objectSpread(_objectSpread(_objectSpread({}, (0, _utils.getAttributesFromContexts)(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributes), event.attributes);
37
+ createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, eventConfig), event), {}, {
38
+ attributes: attributes
39
+ })).fire(_constants.ANALYTICS_CHANNEL);
40
+ }, [createAnalyticsEvent, eventConfig, commonAttributes, analyticsContext]);
41
+ var trackAgentDebug = (0, _react.useCallback)(function (action, attributes) {
42
+ fireAnalyticsEvent({
43
+ actionSubject: 'rovoAgent',
44
+ action: action,
45
+ attributes: attributes
46
+ });
47
+ }, [fireAnalyticsEvent]);
48
+ var trackAgentDebugError = (0, _react.useCallback)(function (action, error, attributes) {
49
+ fireAnalyticsEvent({
50
+ actionSubject: 'rovoAgentError',
51
+ action: action,
52
+ attributes: _objectSpread(_objectSpread({}, attributes), error && {
53
+ error: {
54
+ message: error.message
55
+ }
56
+ })
57
+ });
58
+ }, [fireAnalyticsEvent]);
59
+ return {
60
+ trackAgentDebug: trackAgentDebug,
61
+ trackAgentDebugError: trackAgentDebugError
62
+ };
63
+ };
@@ -1,6 +1,6 @@
1
- import { useCallback, useContext } from 'react';
2
- import { FabricChannel } from '@atlaskit/analytics-listeners';
1
+ import { useCallback, useContext, useMemo } from 'react';
3
2
  import { AnalyticsReactContext, useAnalyticsEvents } from '@atlaskit/analytics-next';
3
+ import { ANALYTICS_CHANNEL } from '../common/constants';
4
4
  import { getAttributesFromContexts, getDefaultTrackEventConfig } from '../common/utils';
5
5
  export let AgentActions = /*#__PURE__*/function (AgentActions) {
6
6
  /* View agent clicked */
@@ -25,13 +25,12 @@ export let AgentActions = /*#__PURE__*/function (AgentActions) {
25
25
  AgentActions["UNVERIFY"] = "unverify";
26
26
  return AgentActions;
27
27
  }({});
28
- export const ANALYTICS_CHANNEL = FabricChannel.aiMate;
29
28
  export const useRovoAgentActionAnalytics = commonAttributes => {
30
29
  const analyticsContext = useContext(AnalyticsReactContext);
31
30
  const {
32
31
  createAnalyticsEvent
33
32
  } = useAnalyticsEvents();
34
- const eventConfig = getDefaultTrackEventConfig();
33
+ const eventConfig = useMemo(() => getDefaultTrackEventConfig(), []);
35
34
  const fireAnalyticsEvent = useCallback(event => {
36
35
  const attributes = {
37
36
  ...getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext()),
@@ -1,15 +1,25 @@
1
- import { useCallback } from 'react';
1
+ import { useCallback, useMemo } from 'react';
2
2
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
3
3
  import { ANALYTICS_CHANNEL } from '../common/constants';
4
4
  import { useRovoAgentCSID } from '../common/csid';
5
5
  import { getDefaultTrackEventConfig } from '../common/utils';
6
6
  export let AgentCreateActions = /*#__PURE__*/function (AgentCreateActions) {
7
+ /* Start create flow when user clicks on "Create agent" button */
7
8
  AgentCreateActions["START"] = "createFlowStart";
9
+ /* Skip natural language */
8
10
  AgentCreateActions["SKIP_NL"] = "createFlowSkipNL";
11
+ /* Review natural language */
9
12
  AgentCreateActions["REVIEW_NL"] = "createFlowReviewNL";
13
+ /* Activate agent */
10
14
  AgentCreateActions["ACTIVATE"] = "createFlowActivate";
15
+ /* Restart create flow */
11
16
  AgentCreateActions["RESTART"] = "createFlowRestart";
17
+ /* Error occurred */
12
18
  AgentCreateActions["ERROR"] = "createFlowError";
19
+ /* Land in studio */
20
+ AgentCreateActions["LAND"] = "createLandInStudio";
21
+ /* Discard agent */
22
+ AgentCreateActions["DISCARD"] = "createDiscard";
13
23
  return AgentCreateActions;
14
24
  }({});
15
25
  export const useRovoAgentCreateAnalytics = commonAttributes => {
@@ -19,13 +29,15 @@ export const useRovoAgentCreateAnalytics = commonAttributes => {
19
29
  const {
20
30
  createAnalyticsEvent
21
31
  } = useAnalyticsEvents();
22
- const eventConfig = getDefaultTrackEventConfig();
32
+ const eventConfig = useMemo(() => getDefaultTrackEventConfig(), []);
23
33
  const fireAnalyticsEvent = useCallback(event => {
34
+ const referrer = typeof window !== 'undefined' ? window.document.referrer : 'unknown';
24
35
  createAnalyticsEvent({
25
36
  ...eventConfig,
26
37
  ...event,
27
38
  attributes: {
28
39
  csid,
40
+ referrer,
29
41
  ...commonAttributes,
30
42
  ...event.attributes
31
43
  }
@@ -0,0 +1,61 @@
1
+ import { useCallback, useContext, useMemo } from 'react';
2
+ import { AnalyticsReactContext, useAnalyticsEvents } from '@atlaskit/analytics-next';
3
+ import { ANALYTICS_CHANNEL } from '../common/constants';
4
+ import { getAttributesFromContexts, getDefaultTrackEventConfig } from '../common/utils';
5
+ export let AgentDebugActions = /*#__PURE__*/function (AgentDebugActions) {
6
+ /* View debug modal */
7
+ AgentDebugActions["VIEW"] = "debugView";
8
+ /* Copy all debug data */
9
+ AgentDebugActions["COPY_ALL"] = "debugCopyAll";
10
+ /* Copy debug data */
11
+ AgentDebugActions["COPY"] = "debugCopy";
12
+ /* Toggle skill info */
13
+ AgentDebugActions["TOGGLE_SKILL_INFO"] = "debugToggleSkillInfo";
14
+ /* Error occurred */
15
+ AgentDebugActions["ERROR"] = "debugError";
16
+ return AgentDebugActions;
17
+ }({});
18
+ export const useRovoAgentDebugAnalytics = commonAttributes => {
19
+ const analyticsContext = useContext(AnalyticsReactContext);
20
+ const {
21
+ createAnalyticsEvent
22
+ } = useAnalyticsEvents();
23
+ const eventConfig = useMemo(() => getDefaultTrackEventConfig(), []);
24
+ const fireAnalyticsEvent = useCallback(event => {
25
+ const attributes = {
26
+ ...getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext()),
27
+ ...commonAttributes,
28
+ ...event.attributes
29
+ };
30
+ createAnalyticsEvent({
31
+ ...eventConfig,
32
+ ...event,
33
+ attributes
34
+ }).fire(ANALYTICS_CHANNEL);
35
+ }, [createAnalyticsEvent, eventConfig, commonAttributes, analyticsContext]);
36
+ const trackAgentDebug = useCallback((action, attributes) => {
37
+ fireAnalyticsEvent({
38
+ actionSubject: 'rovoAgent',
39
+ action,
40
+ attributes
41
+ });
42
+ }, [fireAnalyticsEvent]);
43
+ const trackAgentDebugError = useCallback((action, error, attributes) => {
44
+ fireAnalyticsEvent({
45
+ actionSubject: 'rovoAgentError',
46
+ action,
47
+ attributes: {
48
+ ...attributes,
49
+ ...(error && {
50
+ error: {
51
+ message: error.message
52
+ }
53
+ })
54
+ }
55
+ });
56
+ }, [fireAnalyticsEvent]);
57
+ return {
58
+ trackAgentDebug,
59
+ trackAgentDebugError
60
+ };
61
+ };
@@ -1,9 +1,9 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
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
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
- import { useCallback, useContext } from 'react';
5
- import { FabricChannel } from '@atlaskit/analytics-listeners';
4
+ import { useCallback, useContext, useMemo } from 'react';
6
5
  import { AnalyticsReactContext, useAnalyticsEvents } from '@atlaskit/analytics-next';
6
+ import { ANALYTICS_CHANNEL } from '../common/constants';
7
7
  import { getAttributesFromContexts, getDefaultTrackEventConfig } from '../common/utils';
8
8
  export var AgentActions = /*#__PURE__*/function (AgentActions) {
9
9
  /* View agent clicked */
@@ -28,12 +28,13 @@ export var AgentActions = /*#__PURE__*/function (AgentActions) {
28
28
  AgentActions["UNVERIFY"] = "unverify";
29
29
  return AgentActions;
30
30
  }({});
31
- export var ANALYTICS_CHANNEL = FabricChannel.aiMate;
32
31
  export var useRovoAgentActionAnalytics = function useRovoAgentActionAnalytics(commonAttributes) {
33
32
  var analyticsContext = useContext(AnalyticsReactContext);
34
33
  var _useAnalyticsEvents = useAnalyticsEvents(),
35
34
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
36
- var eventConfig = getDefaultTrackEventConfig();
35
+ var eventConfig = useMemo(function () {
36
+ return getDefaultTrackEventConfig();
37
+ }, []);
37
38
  var fireAnalyticsEvent = useCallback(function (event) {
38
39
  var attributes = _objectSpread(_objectSpread(_objectSpread({}, getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributes), event.attributes);
39
40
  createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, eventConfig), event), {}, {
@@ -2,18 +2,28 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
- import { useCallback } from 'react';
5
+ import { useCallback, useMemo } from 'react';
6
6
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
7
7
  import { ANALYTICS_CHANNEL } from '../common/constants';
8
8
  import { useRovoAgentCSID } from '../common/csid';
9
9
  import { getDefaultTrackEventConfig } from '../common/utils';
10
10
  export var AgentCreateActions = /*#__PURE__*/function (AgentCreateActions) {
11
+ /* Start create flow when user clicks on "Create agent" button */
11
12
  AgentCreateActions["START"] = "createFlowStart";
13
+ /* Skip natural language */
12
14
  AgentCreateActions["SKIP_NL"] = "createFlowSkipNL";
15
+ /* Review natural language */
13
16
  AgentCreateActions["REVIEW_NL"] = "createFlowReviewNL";
17
+ /* Activate agent */
14
18
  AgentCreateActions["ACTIVATE"] = "createFlowActivate";
19
+ /* Restart create flow */
15
20
  AgentCreateActions["RESTART"] = "createFlowRestart";
21
+ /* Error occurred */
16
22
  AgentCreateActions["ERROR"] = "createFlowError";
23
+ /* Land in studio */
24
+ AgentCreateActions["LAND"] = "createLandInStudio";
25
+ /* Discard agent */
26
+ AgentCreateActions["DISCARD"] = "createDiscard";
17
27
  return AgentCreateActions;
18
28
  }({});
19
29
  export var useRovoAgentCreateAnalytics = function useRovoAgentCreateAnalytics(commonAttributes) {
@@ -23,11 +33,15 @@ export var useRovoAgentCreateAnalytics = function useRovoAgentCreateAnalytics(co
23
33
  refreshCSID = _useRovoAgentCSID2[1].refresh;
24
34
  var _useAnalyticsEvents = useAnalyticsEvents(),
25
35
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
26
- var eventConfig = getDefaultTrackEventConfig();
36
+ var eventConfig = useMemo(function () {
37
+ return getDefaultTrackEventConfig();
38
+ }, []);
27
39
  var fireAnalyticsEvent = useCallback(function (event) {
40
+ var referrer = typeof window !== 'undefined' ? window.document.referrer : 'unknown';
28
41
  createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, eventConfig), event), {}, {
29
42
  attributes: _objectSpread(_objectSpread({
30
- csid: csid
43
+ csid: csid,
44
+ referrer: referrer
31
45
  }, commonAttributes), event.attributes)
32
46
  })).fire(ANALYTICS_CHANNEL);
33
47
  }, [createAnalyticsEvent, eventConfig, csid, commonAttributes]);
@@ -0,0 +1,56 @@
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
+ import { useCallback, useContext, useMemo } from 'react';
5
+ import { AnalyticsReactContext, useAnalyticsEvents } from '@atlaskit/analytics-next';
6
+ import { ANALYTICS_CHANNEL } from '../common/constants';
7
+ import { getAttributesFromContexts, getDefaultTrackEventConfig } from '../common/utils';
8
+ export var AgentDebugActions = /*#__PURE__*/function (AgentDebugActions) {
9
+ /* View debug modal */
10
+ AgentDebugActions["VIEW"] = "debugView";
11
+ /* Copy all debug data */
12
+ AgentDebugActions["COPY_ALL"] = "debugCopyAll";
13
+ /* Copy debug data */
14
+ AgentDebugActions["COPY"] = "debugCopy";
15
+ /* Toggle skill info */
16
+ AgentDebugActions["TOGGLE_SKILL_INFO"] = "debugToggleSkillInfo";
17
+ /* Error occurred */
18
+ AgentDebugActions["ERROR"] = "debugError";
19
+ return AgentDebugActions;
20
+ }({});
21
+ export var useRovoAgentDebugAnalytics = function useRovoAgentDebugAnalytics(commonAttributes) {
22
+ var analyticsContext = useContext(AnalyticsReactContext);
23
+ var _useAnalyticsEvents = useAnalyticsEvents(),
24
+ createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
25
+ var eventConfig = useMemo(function () {
26
+ return getDefaultTrackEventConfig();
27
+ }, []);
28
+ var fireAnalyticsEvent = useCallback(function (event) {
29
+ var attributes = _objectSpread(_objectSpread(_objectSpread({}, getAttributesFromContexts(analyticsContext.getAtlaskitAnalyticsContext())), commonAttributes), event.attributes);
30
+ createAnalyticsEvent(_objectSpread(_objectSpread(_objectSpread({}, eventConfig), event), {}, {
31
+ attributes: attributes
32
+ })).fire(ANALYTICS_CHANNEL);
33
+ }, [createAnalyticsEvent, eventConfig, commonAttributes, analyticsContext]);
34
+ var trackAgentDebug = useCallback(function (action, attributes) {
35
+ fireAnalyticsEvent({
36
+ actionSubject: 'rovoAgent',
37
+ action: action,
38
+ attributes: attributes
39
+ });
40
+ }, [fireAnalyticsEvent]);
41
+ var trackAgentDebugError = useCallback(function (action, error, attributes) {
42
+ fireAnalyticsEvent({
43
+ actionSubject: 'rovoAgentError',
44
+ action: action,
45
+ attributes: _objectSpread(_objectSpread({}, attributes), error && {
46
+ error: {
47
+ message: error.message
48
+ }
49
+ })
50
+ });
51
+ }, [fireAnalyticsEvent]);
52
+ return {
53
+ trackAgentDebug: trackAgentDebug,
54
+ trackAgentDebugError: trackAgentDebugError
55
+ };
56
+ };
@@ -1,4 +1,3 @@
1
- import { FabricChannel } from '@atlaskit/analytics-listeners';
2
1
  import type { RemainingRequired } from '../common/types';
3
2
  export declare enum AgentActions {
4
3
  VIEW = "view",
@@ -16,7 +15,6 @@ type CommonAnalyticsAttributes = {
16
15
  touchPoint: string;
17
16
  agentId: string;
18
17
  };
19
- export declare const ANALYTICS_CHANNEL = FabricChannel.aiMate;
20
18
  export declare const useRovoAgentActionAnalytics: <T extends Partial<CommonAnalyticsAttributes>>(commonAttributes: T) => {
21
19
  trackAgentAction: (action: AgentActions, attributes: RemainingRequired<CommonAnalyticsAttributes, T> & Record<string, any>) => void;
22
20
  trackAgentActionError: (action: AgentActions, error: Error, attributes?: RemainingRequired<CommonAnalyticsAttributes, T> & Record<string, any>) => void;
@@ -7,7 +7,9 @@ export declare enum AgentCreateActions {
7
7
  REVIEW_NL = "createFlowReviewNL",
8
8
  ACTIVATE = "createFlowActivate",
9
9
  RESTART = "createFlowRestart",
10
- ERROR = "createFlowError"
10
+ ERROR = "createFlowError",
11
+ LAND = "createLandInStudio",
12
+ DISCARD = "createDiscard"
11
13
  }
12
14
  export declare const useRovoAgentCreateAnalytics: (commonAttributes: CommonAnalyticsAttributes) => readonly [string | null, {
13
15
  readonly trackCreateSession: (action: AgentCreateActions, attributes?: CommonAnalyticsAttributes) => void;
@@ -0,0 +1,16 @@
1
+ import type { RemainingRequired } from '../common/types';
2
+ export declare enum AgentDebugActions {
3
+ VIEW = "debugView",
4
+ COPY_ALL = "debugCopyAll",
5
+ COPY = "debugCopy",
6
+ TOGGLE_SKILL_INFO = "debugToggleSkillInfo",
7
+ ERROR = "debugError"
8
+ }
9
+ type CommonAnalyticsAttributes = {
10
+ agentId: string;
11
+ };
12
+ export declare const useRovoAgentDebugAnalytics: <T extends Partial<CommonAnalyticsAttributes>>(commonAttributes?: T) => {
13
+ trackAgentDebug: (action: AgentDebugActions, attributes?: RemainingRequired<CommonAnalyticsAttributes, T extends undefined ? {} : T> & Record<string, any>) => void;
14
+ trackAgentDebugError: (action: AgentDebugActions, error?: Error, attributes?: RemainingRequired<CommonAnalyticsAttributes, T extends undefined ? {} : T> & Record<string, any>) => void;
15
+ };
16
+ export {};
@@ -1,4 +1,3 @@
1
- import { FabricChannel } from '@atlaskit/analytics-listeners';
2
1
  import type { RemainingRequired } from '../common/types';
3
2
  export declare enum AgentActions {
4
3
  VIEW = "view",
@@ -16,7 +15,6 @@ type CommonAnalyticsAttributes = {
16
15
  touchPoint: string;
17
16
  agentId: string;
18
17
  };
19
- export declare const ANALYTICS_CHANNEL = FabricChannel.aiMate;
20
18
  export declare const useRovoAgentActionAnalytics: <T extends Partial<CommonAnalyticsAttributes>>(commonAttributes: T) => {
21
19
  trackAgentAction: (action: AgentActions, attributes: RemainingRequired<CommonAnalyticsAttributes, T> & Record<string, any>) => void;
22
20
  trackAgentActionError: (action: AgentActions, error: Error, attributes?: RemainingRequired<CommonAnalyticsAttributes, T> & Record<string, any>) => void;
@@ -7,7 +7,9 @@ export declare enum AgentCreateActions {
7
7
  REVIEW_NL = "createFlowReviewNL",
8
8
  ACTIVATE = "createFlowActivate",
9
9
  RESTART = "createFlowRestart",
10
- ERROR = "createFlowError"
10
+ ERROR = "createFlowError",
11
+ LAND = "createLandInStudio",
12
+ DISCARD = "createDiscard"
11
13
  }
12
14
  export declare const useRovoAgentCreateAnalytics: (commonAttributes: CommonAnalyticsAttributes) => readonly [
13
15
  string | null,
@@ -0,0 +1,16 @@
1
+ import type { RemainingRequired } from '../common/types';
2
+ export declare enum AgentDebugActions {
3
+ VIEW = "debugView",
4
+ COPY_ALL = "debugCopyAll",
5
+ COPY = "debugCopy",
6
+ TOGGLE_SKILL_INFO = "debugToggleSkillInfo",
7
+ ERROR = "debugError"
8
+ }
9
+ type CommonAnalyticsAttributes = {
10
+ agentId: string;
11
+ };
12
+ export declare const useRovoAgentDebugAnalytics: <T extends Partial<CommonAnalyticsAttributes>>(commonAttributes?: T) => {
13
+ trackAgentDebug: (action: AgentDebugActions, attributes?: RemainingRequired<CommonAnalyticsAttributes, T extends undefined ? {} : T> & Record<string, any>) => void;
14
+ trackAgentDebugError: (action: AgentDebugActions, error?: Error, attributes?: RemainingRequired<CommonAnalyticsAttributes, T extends undefined ? {} : T> & Record<string, any>) => void;
15
+ };
16
+ export {};
package/package.json CHANGED
@@ -83,7 +83,7 @@
83
83
  ]
84
84
  },
85
85
  "name": "@atlaskit/rovo-agent-analytics",
86
- "version": "0.10.0",
86
+ "version": "0.12.0",
87
87
  "description": "Rovo Agents analytics",
88
88
  "author": "Atlassian Pty Ltd",
89
89
  "license": "Apache-2.0",