@atlaskit/editor-common 110.29.0 → 110.29.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/afm-jira/tsconfig.json +1 -1
  3. package/dist/cjs/experiences/Experience.js +83 -33
  4. package/dist/cjs/experiences/ExperienceCheckDomMutation.js +2 -6
  5. package/dist/cjs/experiences/ExperienceCheckTimeout.js +1 -3
  6. package/dist/cjs/experiences/consts.js +18 -4
  7. package/dist/cjs/experiences/experience-state.js +0 -4
  8. package/dist/cjs/experiences/index.js +6 -0
  9. package/dist/cjs/experiences/types.js +1 -0
  10. package/dist/cjs/monitoring/error.js +1 -1
  11. package/dist/cjs/ui/DropList/index.js +1 -1
  12. package/dist/cjs/utils/annotation/index.js +0 -3
  13. package/dist/es2019/experiences/Experience.js +86 -33
  14. package/dist/es2019/experiences/ExperienceCheckDomMutation.js +2 -6
  15. package/dist/es2019/experiences/ExperienceCheckTimeout.js +1 -3
  16. package/dist/es2019/experiences/consts.js +17 -3
  17. package/dist/es2019/experiences/experience-state.js +0 -4
  18. package/dist/es2019/experiences/index.js +1 -1
  19. package/dist/es2019/experiences/types.js +0 -0
  20. package/dist/es2019/monitoring/error.js +1 -1
  21. package/dist/es2019/ui/DropList/index.js +1 -1
  22. package/dist/es2019/utils/annotation/index.js +0 -3
  23. package/dist/esm/experiences/Experience.js +84 -34
  24. package/dist/esm/experiences/ExperienceCheckDomMutation.js +2 -6
  25. package/dist/esm/experiences/ExperienceCheckTimeout.js +1 -3
  26. package/dist/esm/experiences/consts.js +17 -3
  27. package/dist/esm/experiences/experience-state.js +0 -4
  28. package/dist/esm/experiences/index.js +1 -1
  29. package/dist/esm/experiences/types.js +0 -0
  30. package/dist/esm/monitoring/error.js +1 -1
  31. package/dist/esm/ui/DropList/index.js +1 -1
  32. package/dist/esm/utils/annotation/index.js +0 -3
  33. package/dist/types/analytics/types/experience-events.d.ts +27 -4
  34. package/dist/types/analytics/types/mention-events.d.ts +1 -0
  35. package/dist/types/experiences/Experience.d.ts +67 -15
  36. package/dist/types/experiences/ExperienceCheck.d.ts +3 -2
  37. package/dist/types/experiences/ExperienceCheckDomMutation.d.ts +2 -2
  38. package/dist/types/experiences/ExperienceCheckTimeout.d.ts +1 -1
  39. package/dist/types/experiences/consts.d.ts +16 -3
  40. package/dist/types/experiences/experience-state.d.ts +1 -4
  41. package/dist/types/experiences/index.d.ts +1 -1
  42. package/dist/types/experiences/types.d.ts +10 -0
  43. package/dist/types-ts4.5/analytics/types/experience-events.d.ts +27 -4
  44. package/dist/types-ts4.5/analytics/types/mention-events.d.ts +1 -0
  45. package/dist/types-ts4.5/experiences/Experience.d.ts +67 -15
  46. package/dist/types-ts4.5/experiences/ExperienceCheck.d.ts +3 -2
  47. package/dist/types-ts4.5/experiences/ExperienceCheckDomMutation.d.ts +2 -2
  48. package/dist/types-ts4.5/experiences/ExperienceCheckTimeout.d.ts +1 -1
  49. package/dist/types-ts4.5/experiences/consts.d.ts +16 -3
  50. package/dist/types-ts4.5/experiences/experience-state.d.ts +1 -4
  51. package/dist/types-ts4.5/experiences/index.d.ts +1 -1
  52. package/dist/types-ts4.5/experiences/types.d.ts +10 -0
  53. package/package.json +4 -7
@@ -19,13 +19,27 @@ export const EXPERIENCE_FAILURE_REASON = {
19
19
  DOM_MUTATION_CHECK_ERROR: 'dom-mutation-check-error'
20
20
  };
21
21
 
22
+ /**
23
+ * Built-in abort reasons for experiences.
24
+ *
25
+ * These may be used by various ExperienceCheck implementations to
26
+ * provide consistent, well-known abort reasons for analytics and debugging.
27
+ */
28
+ export const EXPERIENCE_ABORT_REASON = {
29
+ /**
30
+ * Experience was aborted because it was restarted while already in progress
31
+ */
32
+ RESTARTED: 'restarted'
33
+ };
34
+
22
35
  /**
23
36
  * Default sample rate for experienceSampled events.
24
37
  * Set to 1 in 1000 (0.001) to balance data collection with event volume.
25
38
  *
26
39
  * Newly defined experiences should use this default unless they have data
27
- * to justify a different rate. The expectation is that measurements will be
28
- * gathered after initial instrumentation, then the sample rate can be tuned
29
- * up to a safe threshold.
40
+ * to justify a different rate.
41
+ *
42
+ * The expectation is that measurements will be gathered after initial
43
+ * instrumentation, then the sample rate can be tuned up to a safe threshold.
30
44
  */
31
45
  export const DEFAULT_EXPERIENCE_SAMPLE_RATE = 0.001;
@@ -1,7 +1,3 @@
1
- /**
2
- * Represents the state of an experience throughout its lifecycle.
3
- */
4
-
5
1
  /**
6
2
  * State transition map defining valid state transitions.
7
3
  */
@@ -2,7 +2,7 @@
2
2
  /* eslint-disable @atlaskit/editor/no-re-export */
3
3
 
4
4
  export { Experience } from './Experience';
5
- export { EXPERIENCE_FAILURE_REASON } from './consts';
5
+ export { EXPERIENCE_ABORT_REASON, EXPERIENCE_FAILURE_REASON } from './consts';
6
6
  export { ExperienceCheckComposite } from './ExperienceCheckComposite';
7
7
  export { ExperienceCheckDomMutation } from './ExperienceCheckDomMutation';
8
8
  export { ExperienceCheckTimeout } from './ExperienceCheckTimeout';
File without changes
@@ -1,7 +1,7 @@
1
1
  import { isFedRamp } from './environment';
2
2
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
3
3
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
4
- const packageVersion = "110.28.0";
4
+ const packageVersion = "0.0.0-development";
5
5
  const sanitiseSentryEvents = (data, _hint) => {
6
6
  // Remove URL as it has UGC
7
7
  // Ignored via go/ees007
@@ -14,7 +14,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import { fg } from '@atlaskit/platform-feature-flags';
15
15
  import Layer from '../Layer';
16
16
  const packageName = "@atlaskit/editor-common";
17
- const packageVersion = "110.28.0";
17
+ const packageVersion = "0.0.0-development";
18
18
  const halfFocusRing = 1;
19
19
  const dropOffset = '0, 8';
20
20
  const fadeIn = keyframes({
@@ -214,9 +214,6 @@ export function getAnnotationInlineNodeTypes(state, annotationId) {
214
214
  Used with the creation of the inline nodes: emoji, status, dates, mentions & inlineCards.
215
215
  */
216
216
  export function getAnnotationMarksForPos(pos) {
217
- if (!fg('editor_inline_comments_paste_insert_nodes')) {
218
- return undefined;
219
- }
220
217
  const annotationMarks = pos.marks().filter(mark => mark.type === pos.doc.type.schema.marks.annotation);
221
218
  return annotationMarks;
222
219
  }
@@ -4,7 +4,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
6
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '../analytics';
7
- import { DEFAULT_EXPERIENCE_SAMPLE_RATE } from './consts';
7
+ import { DEFAULT_EXPERIENCE_SAMPLE_RATE, EXPERIENCE_ABORT_REASON } from './consts';
8
8
  import { canTransition } from './experience-state';
9
9
  import { ExperienceCheckComposite } from './ExperienceCheckComposite';
10
10
  export var Experience = /*#__PURE__*/function () {
@@ -16,14 +16,45 @@ export var Experience = /*#__PURE__*/function () {
16
16
  * Ensures that every tracked start has corresponding abort/fail/success tracked.
17
17
  */
18
18
 
19
+ /**
20
+ * Timestamp (in milliseconds) when the experience transitioned to 'started' state.
21
+ *
22
+ * Used to calculate experience duration. Set via Date.now() when experience starts.
23
+ */
24
+
25
+ /**
26
+ * Metadata provided at experience start time to merge into subsequent events.
27
+ *
28
+ * Used to retain experienceStartMethod and other start-specific metadata.
29
+ */
30
+
31
+ /**
32
+ * Creates a new Experience instance for tracking user experiences.
33
+ *
34
+ * @param id - Unique identifier for the experience
35
+ * @param options - Configuration options for the experience
36
+ * @param options.checks - Experience checks to monitor for completion
37
+ * @param options.dispatchAnalyticsEvent - Function to dispatch analytics events
38
+ * @param options.sampleRate - Sample rate for experienceSampled events
39
+ * @param options.metadata - Global metadata to attach to all events
40
+ * @param options.action - Optional sub identifier for the specific experience action
41
+ */
19
42
  function Experience(id, options) {
20
43
  var _options$sampleRate;
21
44
  _classCallCheck(this, Experience);
22
45
  _defineProperty(this, "currentState", 'pending');
46
+ /**
47
+ * Set of experience states that have been seen in the current session.
48
+ *
49
+ * Used to determine if experienceStatusFirstSeen flag should be set in events.
50
+ */
23
51
  _defineProperty(this, "statesSeen", new Set());
24
52
  this.id = id;
25
53
  this.dispatchAnalyticsEvent = options.dispatchAnalyticsEvent;
26
54
  this.sampleRate = (_options$sampleRate = options.sampleRate) !== null && _options$sampleRate !== void 0 ? _options$sampleRate : DEFAULT_EXPERIENCE_SAMPLE_RATE;
55
+ this.globalMetadata = _objectSpread(_objectSpread({}, options.metadata), {}, {
56
+ experienceAction: options.action
57
+ });
27
58
  this.check = new ExperienceCheckComposite(options.checks || []);
28
59
  }
29
60
  return _createClass(Experience, [{
@@ -33,17 +64,21 @@ export var Experience = /*#__PURE__*/function () {
33
64
  this.stopCheck();
34
65
  this.check.start(function (_ref) {
35
66
  var status = _ref.status,
67
+ reason = _ref.reason,
36
68
  metadata = _ref.metadata;
37
69
  if (status === 'success') {
38
70
  _this.success({
71
+ reason: reason,
39
72
  metadata: metadata
40
73
  });
41
74
  } else if (status === 'abort') {
42
75
  _this.abort({
76
+ reason: reason,
43
77
  metadata: metadata
44
78
  });
45
79
  } else if (status === 'failure') {
46
80
  _this.failure({
81
+ reason: reason,
47
82
  metadata: metadata
48
83
  });
49
84
  }
@@ -55,12 +90,13 @@ export var Experience = /*#__PURE__*/function () {
55
90
  this.check.stop();
56
91
  }
57
92
  }, {
58
- key: "getEndStateConfig",
59
- value: function getEndStateConfig(options) {
60
- var _this$startOptions, _this$startOptions2;
61
- return {
62
- metadata: options !== null && options !== void 0 && options.metadata || (_this$startOptions = this.startOptions) !== null && _this$startOptions !== void 0 && _this$startOptions.metadata ? _objectSpread(_objectSpread({}, (_this$startOptions2 = this.startOptions) === null || _this$startOptions2 === void 0 ? void 0 : _this$startOptions2.metadata), options === null || options === void 0 ? void 0 : options.metadata) : undefined
63
- };
93
+ key: "getEndStateMetadata",
94
+ value: function getEndStateMetadata(options) {
95
+ var metadata = _objectSpread({}, options === null || options === void 0 ? void 0 : options.metadata);
96
+ if (options !== null && options !== void 0 && options.reason) {
97
+ metadata.experienceEndReason = options.reason;
98
+ }
99
+ return metadata;
64
100
  }
65
101
 
66
102
  /**
@@ -80,12 +116,20 @@ export var Experience = /*#__PURE__*/function () {
80
116
  if (!canTransition(this.currentState, toState)) {
81
117
  return false;
82
118
  }
83
- this.statesSeen.add(toState);
84
119
  this.currentState = toState;
85
120
  if (toState === 'started') {
86
121
  this.isSampledTrackingEnabled = Math.random() < this.sampleRate;
122
+ this.startTimeMs = Date.now();
123
+ this.startMetadata = metadata;
87
124
  }
88
125
  this.trackTransition(toState, metadata);
126
+ if (toState === 'started') {
127
+ this.startCheck();
128
+ } else {
129
+ this.stopCheck();
130
+ this.startMetadata = undefined;
131
+ }
132
+ this.statesSeen.add(toState);
89
133
  return true;
90
134
  }
91
135
 
@@ -100,11 +144,13 @@ export var Experience = /*#__PURE__*/function () {
100
144
  }, {
101
145
  key: "trackTransition",
102
146
  value: function trackTransition(toState, metadata) {
103
- var attributes = _objectSpread({
147
+ var attributes = _objectSpread(_objectSpread(_objectSpread({
104
148
  experienceKey: this.id,
105
149
  experienceStatus: toState,
106
- firstInSession: !this.statesSeen.has(toState)
107
- }, metadata);
150
+ experienceStatusFirstSeen: !this.statesSeen.has(toState),
151
+ experienceStartTime: this.startTimeMs || 0,
152
+ experienceDuration: this.startTimeMs ? Date.now() - this.startTimeMs : 0
153
+ }, this.globalMetadata), this.startMetadata), metadata);
108
154
  var experienceMeasuredEvent = {
109
155
  action: ACTION.EXPERIENCE_MEASURED,
110
156
  actionSubject: ACTION_SUBJECT.EDITOR,
@@ -131,31 +177,36 @@ export var Experience = /*#__PURE__*/function () {
131
177
  * Metadata from options will be merged with metadata provided in subsequent events.
132
178
  *
133
179
  * @param options - Configuration for starting the experience
134
- * @param options.metadata - Optional metadata attached to all subsequent events for this started experience
180
+ * @param options.metadata - Optional custom metadata attached to all subsequent events for this started experience
181
+ * @param options.forceRestart - If true and experience already in progress will abort and restart
182
+ * @param options.method - Optional method for experience start, e.g., how the experience was initiated
135
183
  */
136
184
  }, {
137
185
  key: "start",
138
186
  value: function start(options) {
139
- this.startOptions = options;
140
- if (this.transitionTo('started', options === null || options === void 0 ? void 0 : options.metadata)) {
141
- this.startCheck();
187
+ if (options.forceRestart && this.currentState === 'started') {
188
+ this.abort({
189
+ reason: EXPERIENCE_ABORT_REASON.RESTARTED
190
+ });
142
191
  }
192
+ return this.transitionTo('started', _objectSpread({
193
+ experienceStartMethod: options.method
194
+ }, options.metadata));
143
195
  }
144
196
 
145
197
  /**
146
198
  * Marks the experience as successful and stops any ongoing checks.
147
199
  *
148
200
  * @param options - Configuration for the success event
149
- * @param options.metadata - Optional metadata attached to the success event
201
+ * @param options.metadata - Optional custom metadata attached to the success event
202
+ * @param options.reason - Optional reason for success
203
+ * @returns false if transition to success state was not valid
150
204
  */
151
205
  }, {
152
206
  key: "success",
153
207
  value: function success(options) {
154
- var mergedConfig = this.getEndStateConfig(options);
155
- if (this.transitionTo('succeeded', mergedConfig.metadata)) {
156
- this.stopCheck();
157
- this.startOptions = undefined;
158
- }
208
+ var metadata = this.getEndStateMetadata(options);
209
+ return this.transitionTo('succeeded', metadata);
159
210
  }
160
211
 
161
212
  /**
@@ -165,22 +216,22 @@ export var Experience = /*#__PURE__*/function () {
165
216
  * (e.g., component unmount, navigation). This is neither success nor failure.
166
217
  *
167
218
  * @param options - Configuration for the abort event
168
- * @param options.metadata - Optional metadata attached to the abort event
219
+ * @param options.metadata - Optional custom metadata attached to the abort event
220
+ * @param options.reason - Optional reason for abort
169
221
  *
170
222
  * @example
171
223
  * // Abort on component unmount
172
224
  * useEffect(() => {
173
- * return () => experience.abort({ metadata: { reason: 'unmount' } });
225
+ * return () => experience.abort({ reason: 'unmount', metadata: { someKey: 'someValue' } });
174
226
  * }, []);
227
+ *
228
+ * @returns false if transition to aborted state was not valid
175
229
  */
176
230
  }, {
177
231
  key: "abort",
178
232
  value: function abort(options) {
179
- var mergedConfig = this.getEndStateConfig(options);
180
- if (this.transitionTo('aborted', mergedConfig.metadata)) {
181
- this.stopCheck();
182
- this.startOptions = undefined;
183
- }
233
+ var metadata = this.getEndStateMetadata(options);
234
+ return this.transitionTo('aborted', metadata);
184
235
  }
185
236
 
186
237
  /**
@@ -189,16 +240,15 @@ export var Experience = /*#__PURE__*/function () {
189
240
  * Use this for actual failures in the experience flow (e.g., timeout, error conditions).
190
241
  *
191
242
  * @param options - Configuration for the failure event
192
- * @param options.metadata - Optional metadata attached to the failure event
243
+ * @param options.metadata - Optional custom metadata attached to the failure event
244
+ * @param options.reason - Optional reason for failure
245
+ * @returns false if transition to failed state was not valid
193
246
  */
194
247
  }, {
195
248
  key: "failure",
196
249
  value: function failure(options) {
197
- var mergedConfig = this.getEndStateConfig(options);
198
- if (this.transitionTo('failed', mergedConfig.metadata)) {
199
- this.stopCheck();
200
- this.startOptions = undefined;
201
- }
250
+ var metadata = this.getEndStateMetadata(options);
251
+ return this.transitionTo('failed', metadata);
202
252
  }
203
253
  }]);
204
254
  }();
@@ -26,9 +26,7 @@ export var ExperienceCheckDomMutation = /*#__PURE__*/function () {
26
26
  if (!(config !== null && config !== void 0 && config.target)) {
27
27
  callback({
28
28
  status: 'failure',
29
- metadata: {
30
- reason: EXPERIENCE_FAILURE_REASON.DOM_MUTATION_TARGET_NOT_FOUND
31
- }
29
+ reason: EXPERIENCE_FAILURE_REASON.DOM_MUTATION_TARGET_NOT_FOUND
32
30
  });
33
31
  return;
34
32
  }
@@ -43,9 +41,7 @@ export var ExperienceCheckDomMutation = /*#__PURE__*/function () {
43
41
  } catch (error) {
44
42
  callback({
45
43
  status: 'failure',
46
- metadata: {
47
- reason: EXPERIENCE_FAILURE_REASON.DOM_MUTATION_CHECK_ERROR
48
- }
44
+ reason: EXPERIENCE_FAILURE_REASON.DOM_MUTATION_CHECK_ERROR
49
45
  });
50
46
  }
51
47
  });
@@ -4,9 +4,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  import { EXPERIENCE_FAILURE_REASON } from './consts';
5
5
  var DEFAULT_FAILURE_RESULT = {
6
6
  status: 'failure',
7
- metadata: {
8
- reason: EXPERIENCE_FAILURE_REASON.TIMEOUT
9
- }
7
+ reason: EXPERIENCE_FAILURE_REASON.TIMEOUT
10
8
  };
11
9
 
12
10
  /**
@@ -19,13 +19,27 @@ export var EXPERIENCE_FAILURE_REASON = {
19
19
  DOM_MUTATION_CHECK_ERROR: 'dom-mutation-check-error'
20
20
  };
21
21
 
22
+ /**
23
+ * Built-in abort reasons for experiences.
24
+ *
25
+ * These may be used by various ExperienceCheck implementations to
26
+ * provide consistent, well-known abort reasons for analytics and debugging.
27
+ */
28
+ export var EXPERIENCE_ABORT_REASON = {
29
+ /**
30
+ * Experience was aborted because it was restarted while already in progress
31
+ */
32
+ RESTARTED: 'restarted'
33
+ };
34
+
22
35
  /**
23
36
  * Default sample rate for experienceSampled events.
24
37
  * Set to 1 in 1000 (0.001) to balance data collection with event volume.
25
38
  *
26
39
  * Newly defined experiences should use this default unless they have data
27
- * to justify a different rate. The expectation is that measurements will be
28
- * gathered after initial instrumentation, then the sample rate can be tuned
29
- * up to a safe threshold.
40
+ * to justify a different rate.
41
+ *
42
+ * The expectation is that measurements will be gathered after initial
43
+ * instrumentation, then the sample rate can be tuned up to a safe threshold.
30
44
  */
31
45
  export var DEFAULT_EXPERIENCE_SAMPLE_RATE = 0.001;
@@ -1,7 +1,3 @@
1
- /**
2
- * Represents the state of an experience throughout its lifecycle.
3
- */
4
-
5
1
  /**
6
2
  * State transition map defining valid state transitions.
7
3
  */
@@ -2,7 +2,7 @@
2
2
  /* eslint-disable @atlaskit/editor/no-re-export */
3
3
 
4
4
  export { Experience } from './Experience';
5
- export { EXPERIENCE_FAILURE_REASON } from './consts';
5
+ export { EXPERIENCE_ABORT_REASON, EXPERIENCE_FAILURE_REASON } from './consts';
6
6
  export { ExperienceCheckComposite } from './ExperienceCheckComposite';
7
7
  export { ExperienceCheckDomMutation } from './ExperienceCheckDomMutation';
8
8
  export { ExperienceCheckTimeout } from './ExperienceCheckTimeout';
File without changes
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
7
  import { isFedRamp } from './environment';
8
8
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
9
9
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
10
- var packageVersion = "110.28.0";
10
+ var packageVersion = "0.0.0-development";
11
11
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
12
12
  // Remove URL as it has UGC
13
13
  // Ignored via go/ees007
@@ -21,7 +21,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import { fg } from '@atlaskit/platform-feature-flags';
22
22
  import Layer from '../Layer';
23
23
  var packageName = "@atlaskit/editor-common";
24
- var packageVersion = "110.28.0";
24
+ var packageVersion = "0.0.0-development";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var fadeIn = keyframes({
@@ -203,9 +203,6 @@ export function getAnnotationInlineNodeTypes(state, annotationId) {
203
203
  Used with the creation of the inline nodes: emoji, status, dates, mentions & inlineCards.
204
204
  */
205
205
  export function getAnnotationMarksForPos(pos) {
206
- if (!fg('editor_inline_comments_paste_insert_nodes')) {
207
- return undefined;
208
- }
209
206
  var annotationMarks = pos.marks().filter(function (mark) {
210
207
  return mark.type === pos.doc.type.schema.marks.annotation;
211
208
  });
@@ -1,11 +1,10 @@
1
- import type { ExperienceState } from '../../experiences/experience-state';
1
+ import type { CustomExperienceMetadata, ExperienceState } from '../../experiences/types';
2
2
  import type { ACTION, ACTION_SUBJECT } from './enums';
3
3
  import type { OperationalAEP } from './utils';
4
4
  /**
5
5
  * Experience event attributes for tracking experience state transitions.
6
6
  */
7
- type ExperienceEventAttributes = {
8
- [key: string]: unknown;
7
+ export type ExperienceEventAttributes = CustomExperienceMetadata & {
9
8
  /**
10
9
  * The unique key identifying the experience being tracked.
11
10
  */
@@ -18,7 +17,31 @@ type ExperienceEventAttributes = {
18
17
  * Whether this is the first transition to this status for this experience
19
18
  * in the current editor session.
20
19
  */
21
- firstInSession: boolean;
20
+ experienceStatusFirstSeen: boolean;
21
+ /**
22
+ * Timestamp when the experience started.
23
+ *
24
+ * Milliseconds since epoch.
25
+ */
26
+ experienceStartTime: number;
27
+ /**
28
+ * Duration from experience start to current status transition.
29
+ *
30
+ * Measured in milliseconds.
31
+ */
32
+ experienceDuration: number;
33
+ /**
34
+ * Optional method for experience start, e.g., how the experience was initiated.
35
+ */
36
+ experienceStartMethod?: string;
37
+ /**
38
+ * Optional reason for experience end, e.g., abort or failure reason.
39
+ */
40
+ experienceEndReason?: string;
41
+ /**
42
+ * Optional action that triggered the experience, if applicable.
43
+ */
44
+ experienceAction?: string;
22
45
  };
23
46
  /**
24
47
  * Event fired on every successful experience state transition.
@@ -16,6 +16,7 @@ type MentionTypeaheadInviteItemViewedPayload = UIAEP<ACTION.RENDERED, ACTION_SUB
16
16
  containerId: string;
17
17
  objectId: string;
18
18
  sessionId: string;
19
+ source: string;
19
20
  userRole?: string;
20
21
  }, undefined>;
21
22
  type MentionTypeaheadInviteItemClickedPayload = UIAEP<ACTION.CLICKED | ACTION.PRESSED, ACTION_SUBJECT.INVITE_ITEM, undefined, {
@@ -1,6 +1,6 @@
1
- import type { CustomData } from '@atlaskit/ufo';
2
1
  import type { DispatchAnalyticsEvent } from '../analytics';
3
2
  import type { ExperienceCheck } from './ExperienceCheck';
3
+ import type { CustomExperienceMetadata } from './types';
4
4
  type ExperienceOptions = {
5
5
  /**
6
6
  * Checks used to control experience transition to various states.
@@ -25,20 +25,40 @@ type ExperienceOptions = {
25
25
  * instrumentation, then the sample rate can be tuned up to a safe threshold.
26
26
  */
27
27
  sampleRate?: number;
28
+ /**
29
+ * Optional global metadata to attach to all analytics events for this experience.
30
+ *
31
+ * Can be overridden by metadata provided in individual start/abort/fail/success calls.
32
+ */
33
+ metadata?: CustomExperienceMetadata;
34
+ /**
35
+ * An optional sub identifier to further classify the specific experience action taken
36
+ *
37
+ * e.g. 'bold' 'bullet' 'insert-table'
38
+ */
39
+ action?: string;
28
40
  };
29
41
  type ExperienceStartOptions = {
30
- metadata?: CustomData;
42
+ metadata?: CustomExperienceMetadata;
43
+ method?: string;
44
+ forceRestart?: boolean;
31
45
  };
32
46
  type ExperienceEndOptions = {
33
- metadata?: CustomData;
47
+ reason?: string;
48
+ metadata?: CustomExperienceMetadata;
34
49
  };
35
50
  export declare class Experience {
36
51
  private readonly id;
37
52
  private readonly dispatchAnalyticsEvent;
38
53
  private readonly sampleRate;
39
- private check;
40
- private startOptions;
54
+ private readonly globalMetadata;
55
+ private readonly check;
41
56
  private currentState;
57
+ /**
58
+ * Set of experience states that have been seen in the current session.
59
+ *
60
+ * Used to determine if experienceStatusFirstSeen flag should be set in events.
61
+ */
42
62
  private statesSeen;
43
63
  /**
44
64
  * Indicates whether sampled tracking is enabled for this current experience session.
@@ -48,10 +68,33 @@ export declare class Experience {
48
68
  * Ensures that every tracked start has corresponding abort/fail/success tracked.
49
69
  */
50
70
  private isSampledTrackingEnabled;
71
+ /**
72
+ * Timestamp (in milliseconds) when the experience transitioned to 'started' state.
73
+ *
74
+ * Used to calculate experience duration. Set via Date.now() when experience starts.
75
+ */
76
+ private startTimeMs;
77
+ /**
78
+ * Metadata provided at experience start time to merge into subsequent events.
79
+ *
80
+ * Used to retain experienceStartMethod and other start-specific metadata.
81
+ */
82
+ private startMetadata;
83
+ /**
84
+ * Creates a new Experience instance for tracking user experiences.
85
+ *
86
+ * @param id - Unique identifier for the experience
87
+ * @param options - Configuration options for the experience
88
+ * @param options.checks - Experience checks to monitor for completion
89
+ * @param options.dispatchAnalyticsEvent - Function to dispatch analytics events
90
+ * @param options.sampleRate - Sample rate for experienceSampled events
91
+ * @param options.metadata - Global metadata to attach to all events
92
+ * @param options.action - Optional sub identifier for the specific experience action
93
+ */
51
94
  constructor(id: string, options: ExperienceOptions);
52
95
  private startCheck;
53
96
  private stopCheck;
54
- private getEndStateConfig;
97
+ private getEndStateMetadata;
55
98
  /**
56
99
  * Transitions to a new experience state and tracks analytics events.
57
100
  *
@@ -79,16 +122,20 @@ export declare class Experience {
79
122
  * Metadata from options will be merged with metadata provided in subsequent events.
80
123
  *
81
124
  * @param options - Configuration for starting the experience
82
- * @param options.metadata - Optional metadata attached to all subsequent events for this started experience
125
+ * @param options.metadata - Optional custom metadata attached to all subsequent events for this started experience
126
+ * @param options.forceRestart - If true and experience already in progress will abort and restart
127
+ * @param options.method - Optional method for experience start, e.g., how the experience was initiated
83
128
  */
84
- start(options?: ExperienceStartOptions): void;
129
+ start(options: ExperienceStartOptions): boolean;
85
130
  /**
86
131
  * Marks the experience as successful and stops any ongoing checks.
87
132
  *
88
133
  * @param options - Configuration for the success event
89
- * @param options.metadata - Optional metadata attached to the success event
134
+ * @param options.metadata - Optional custom metadata attached to the success event
135
+ * @param options.reason - Optional reason for success
136
+ * @returns false if transition to success state was not valid
90
137
  */
91
- success(options?: ExperienceEndOptions): void;
138
+ success(options?: ExperienceEndOptions): boolean;
92
139
  /**
93
140
  * Aborts the experience and stops any ongoing checks.
94
141
  *
@@ -96,23 +143,28 @@ export declare class Experience {
96
143
  * (e.g., component unmount, navigation). This is neither success nor failure.
97
144
  *
98
145
  * @param options - Configuration for the abort event
99
- * @param options.metadata - Optional metadata attached to the abort event
146
+ * @param options.metadata - Optional custom metadata attached to the abort event
147
+ * @param options.reason - Optional reason for abort
100
148
  *
101
149
  * @example
102
150
  * // Abort on component unmount
103
151
  * useEffect(() => {
104
- * return () => experience.abort({ metadata: { reason: 'unmount' } });
152
+ * return () => experience.abort({ reason: 'unmount', metadata: { someKey: 'someValue' } });
105
153
  * }, []);
154
+ *
155
+ * @returns false if transition to aborted state was not valid
106
156
  */
107
- abort(options?: ExperienceEndOptions): void;
157
+ abort(options?: ExperienceEndOptions): boolean;
108
158
  /**
109
159
  * Manually marks the experience as failed and stops any ongoing checks.
110
160
  *
111
161
  * Use this for actual failures in the experience flow (e.g., timeout, error conditions).
112
162
  *
113
163
  * @param options - Configuration for the failure event
114
- * @param options.metadata - Optional metadata attached to the failure event
164
+ * @param options.metadata - Optional custom metadata attached to the failure event
165
+ * @param options.reason - Optional reason for failure
166
+ * @returns false if transition to failed state was not valid
115
167
  */
116
- failure(options?: ExperienceEndOptions): void;
168
+ failure(options?: ExperienceEndOptions): boolean;
117
169
  }
118
170
  export {};
@@ -1,7 +1,8 @@
1
- import type { CustomData } from '@atlaskit/ufo';
1
+ import type { CustomExperienceMetadata } from './types';
2
2
  type ExperienceCheckResultStatus = 'success' | 'failure' | 'abort';
3
3
  export type ExperienceCheckResult = {
4
- metadata?: CustomData;
4
+ metadata?: CustomExperienceMetadata;
5
+ reason?: string;
5
6
  status: ExperienceCheckResultStatus;
6
7
  };
7
8
  export type ExperienceCheckCallback = (result: ExperienceCheckResult) => void;