@atlaskit/react-ufo 4.14.4 → 4.14.5

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/ufo-interaction-ignore
2
2
 
3
+ ## 4.14.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`7fa9699d9340f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7fa9699d9340f) -
8
+ Marks first ufo segment load time
9
+
3
10
  ## 4.14.4
4
11
 
5
12
  ### Patch Changes
@@ -35,7 +35,9 @@ exports.addSpanToAll = addSpanToAll;
35
35
  exports.extractModuleName = extractModuleName;
36
36
  exports.getActiveInteraction = getActiveInteraction;
37
37
  exports.getCurrentInteractionType = getCurrentInteractionType;
38
- exports.postInteractionLog = exports.interactionSpans = exports.interactionExtraMetrics = exports.getPerformanceObserver = void 0;
38
+ exports.interactionSpans = exports.interactionExtraMetrics = exports.getPerformanceObserver = void 0;
39
+ exports.markFirstSegmentLoad = markFirstSegmentLoad;
40
+ exports.postInteractionLog = void 0;
39
41
  exports.remove = remove;
40
42
  exports.removeHoldByID = removeHoldByID;
41
43
  exports.removeSegment = removeSegment;
@@ -78,6 +80,7 @@ var interactionQueue = [];
78
80
  var segmentCache = new Map();
79
81
  var segmentUnmountCache = exports.segmentUnmountCache = new Map(); // Temporarily store segment unmount counts
80
82
 
83
+ var firstSegmentLoadMarked = false;
81
84
  var segmentObservers = [];
82
85
  function getActiveInteraction() {
83
86
  var interactionId = (0, _interactionIdContext.getInteractionId)();
@@ -274,6 +277,22 @@ function addMark(interactionId, type, name, labelStack) {
274
277
  });
275
278
  }
276
279
  }
280
+ function markFirstSegmentLoad(interactionId, labelStack) {
281
+ var time = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : performance.now();
282
+ if (!(0, _platformFeatureFlags.fg)('platform_mark_ufo_segment_first_load')) {
283
+ return;
284
+ }
285
+ var interaction = _constants.interactions.get(interactionId);
286
+ if (interaction != null && !firstSegmentLoadMarked) {
287
+ firstSegmentLoadMarked = true;
288
+ interaction.marks.push({
289
+ type: 'first_segment_load',
290
+ name: 'first_segment_load',
291
+ labelStack: labelStack,
292
+ time: time
293
+ });
294
+ }
295
+ }
277
296
  function addMarkToAll(type, name, labelStack) {
278
297
  var time = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : performance.now();
279
298
  _constants.interactions.forEach(function (interaction) {
@@ -24,6 +24,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
24
24
  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; }
25
25
  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; } // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
26
26
  var tryCompleteHandle;
27
+ var hasMarkedFirstSegmentLoad = false;
27
28
 
28
29
  /** A portion of the page we apply measurement to */
29
30
  function UFOSegment(_ref) {
@@ -66,6 +67,10 @@ function UFOSegment(_ref) {
66
67
  } : {})];
67
68
  }, [parentContext, segmentName, segmentId, type]);
68
69
  var interactionId = (0, _react.useContext)(_interactionIdContext.default);
70
+ if (interactionId.current != null && !hasMarkedFirstSegmentLoad) {
71
+ (0, _interactionMetrics.markFirstSegmentLoad)(interactionId.current, labelStack, performance.now());
72
+ hasMarkedFirstSegmentLoad = true;
73
+ }
69
74
  var interactionContext = (0, _react.useMemo)(function () {
70
75
  var lastCompleteEndTime = 0;
71
76
  function complete() {
@@ -23,6 +23,7 @@ const interactionQueue = [];
23
23
  const segmentCache = new Map();
24
24
  export const segmentUnmountCache = new Map(); // Temporarily store segment unmount counts
25
25
 
26
+ let firstSegmentLoadMarked = false;
26
27
  const segmentObservers = [];
27
28
  export function getActiveInteraction() {
28
29
  const interactionId = getInteractionId();
@@ -194,6 +195,21 @@ export function addMark(interactionId, type, name, labelStack, time = performanc
194
195
  });
195
196
  }
196
197
  }
198
+ export function markFirstSegmentLoad(interactionId, labelStack, time = performance.now()) {
199
+ if (!fg('platform_mark_ufo_segment_first_load')) {
200
+ return;
201
+ }
202
+ const interaction = interactions.get(interactionId);
203
+ if (interaction != null && !firstSegmentLoadMarked) {
204
+ firstSegmentLoadMarked = true;
205
+ interaction.marks.push({
206
+ type: 'first_segment_load',
207
+ name: 'first_segment_load',
208
+ labelStack,
209
+ time
210
+ });
211
+ }
212
+ }
197
213
  export function addMarkToAll(type, name, labelStack, time = performance.now()) {
198
214
  interactions.forEach(interaction => {
199
215
  interaction.marks.push({
@@ -7,11 +7,12 @@ import { getConfig, getDoNotAbortActivePressInteraction, getInteractionRate, get
7
7
  import { getActiveTrace, setInteractionActiveTrace } from '../experience-trace-id-context';
8
8
  import UFOInteractionContext from '../interaction-context';
9
9
  import UFOInteractionIDContext from '../interaction-id-context';
10
- import { abortByNewInteraction, addApdex, addCustomData, addCustomTiming, addHold, addHoldByID, addMark, addNewInteraction, addProfilerTimings, addRequestInfo, addSegment, addSpan, getActiveInteraction, removeHoldByID, removeSegment, tryComplete } from '../interaction-metrics';
10
+ import { abortByNewInteraction, addApdex, addCustomData, addCustomTiming, addHold, addHoldByID, addMark, addNewInteraction, addProfilerTimings, addRequestInfo, addSegment, addSpan, getActiveInteraction, markFirstSegmentLoad, removeHoldByID, removeSegment, tryComplete } from '../interaction-metrics';
11
11
  import UFORouteName from '../route-name-context';
12
12
  import generateId from '../short-id';
13
13
  import scheduleOnPaint from './schedule-on-paint';
14
14
  let tryCompleteHandle;
15
+ let hasMarkedFirstSegmentLoad = false;
15
16
 
16
17
  /** A portion of the page we apply measurement to */
17
18
  export default function UFOSegment({
@@ -53,6 +54,10 @@ export default function UFOSegment({
53
54
  } : {})
54
55
  }], [parentContext, segmentName, segmentId, type]);
55
56
  const interactionId = useContext(UFOInteractionIDContext);
57
+ if (interactionId.current != null && !hasMarkedFirstSegmentLoad) {
58
+ markFirstSegmentLoad(interactionId.current, labelStack, performance.now());
59
+ hasMarkedFirstSegmentLoad = true;
60
+ }
56
61
  const interactionContext = useMemo(() => {
57
62
  let lastCompleteEndTime = 0;
58
63
  function complete(endTime = performance.now()) {
@@ -33,6 +33,7 @@ var interactionQueue = [];
33
33
  var segmentCache = new Map();
34
34
  export var segmentUnmountCache = new Map(); // Temporarily store segment unmount counts
35
35
 
36
+ var firstSegmentLoadMarked = false;
36
37
  var segmentObservers = [];
37
38
  export function getActiveInteraction() {
38
39
  var interactionId = getInteractionId();
@@ -229,6 +230,22 @@ export function addMark(interactionId, type, name, labelStack) {
229
230
  });
230
231
  }
231
232
  }
233
+ export function markFirstSegmentLoad(interactionId, labelStack) {
234
+ var time = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : performance.now();
235
+ if (!fg('platform_mark_ufo_segment_first_load')) {
236
+ return;
237
+ }
238
+ var interaction = interactions.get(interactionId);
239
+ if (interaction != null && !firstSegmentLoadMarked) {
240
+ firstSegmentLoadMarked = true;
241
+ interaction.marks.push({
242
+ type: 'first_segment_load',
243
+ name: 'first_segment_load',
244
+ labelStack: labelStack,
245
+ time: time
246
+ });
247
+ }
248
+ }
232
249
  export function addMarkToAll(type, name, labelStack) {
233
250
  var time = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : performance.now();
234
251
  interactions.forEach(function (interaction) {
@@ -11,11 +11,12 @@ import { getConfig, getDoNotAbortActivePressInteraction, getInteractionRate, get
11
11
  import { getActiveTrace, setInteractionActiveTrace } from '../experience-trace-id-context';
12
12
  import UFOInteractionContext from '../interaction-context';
13
13
  import UFOInteractionIDContext from '../interaction-id-context';
14
- import { abortByNewInteraction, addApdex as _addApdex, addCustomData as _addCustomData, addCustomTiming, addHold, addHoldByID, addMark as _addMark, addNewInteraction, addProfilerTimings, addRequestInfo, addSegment, addSpan, getActiveInteraction, removeHoldByID, removeSegment, tryComplete } from '../interaction-metrics';
14
+ import { abortByNewInteraction, addApdex as _addApdex, addCustomData as _addCustomData, addCustomTiming, addHold, addHoldByID, addMark as _addMark, addNewInteraction, addProfilerTimings, addRequestInfo, addSegment, addSpan, getActiveInteraction, markFirstSegmentLoad, removeHoldByID, removeSegment, tryComplete } from '../interaction-metrics';
15
15
  import UFORouteName from '../route-name-context';
16
16
  import generateId from '../short-id';
17
17
  import scheduleOnPaint from './schedule-on-paint';
18
18
  var tryCompleteHandle;
19
+ var hasMarkedFirstSegmentLoad = false;
19
20
 
20
21
  /** A portion of the page we apply measurement to */
21
22
  export default function UFOSegment(_ref) {
@@ -58,6 +59,10 @@ export default function UFOSegment(_ref) {
58
59
  } : {})];
59
60
  }, [parentContext, segmentName, segmentId, type]);
60
61
  var interactionId = useContext(UFOInteractionIDContext);
62
+ if (interactionId.current != null && !hasMarkedFirstSegmentLoad) {
63
+ markFirstSegmentLoad(interactionId.current, labelStack, performance.now());
64
+ hasMarkedFirstSegmentLoad = true;
65
+ }
61
66
  var interactionContext = useMemo(function () {
62
67
  var lastCompleteEndTime = 0;
63
68
  function complete() {
@@ -4,7 +4,7 @@ import type { LabelStack, UFOInteractionContextType } from '../../interaction-co
4
4
  import type { VCObserverInterface } from '../../vc/types';
5
5
  import { type VCRawDataType, type VCResult } from '../vc/types';
6
6
  export type LifecycleMarkType = 'render' | 'beforePaint' | 'afterPaint' | 'nextTick' | 'mount' | 'commit';
7
- export type MarkType = ('placeholder' | 'bm3_stop' | 'bundle_preload' | 'custom') | LifecycleMarkType;
7
+ export type MarkType = ('placeholder' | 'bm3_stop' | 'bundle_preload' | 'custom' | 'first_segment_load') | LifecycleMarkType;
8
8
  export type SpanType = 'placeholder' | 'relay' | 'hidden_timing' | 'bundle_load' | 'graphql' | 'fetch' | 'reducer' | 'custom';
9
9
  export type InteractionType = 'page_load' | 'press' | 'typing' | 'transition' | 'segment';
10
10
  export type AbortReasonType = 'new_interaction' | 'unload' | 'transition' | 'timeout' | 'excluded_by_sampling';
@@ -18,6 +18,7 @@ export declare function addCustomData(interactionId: string, labelStack: LabelSt
18
18
  export declare function addCohortingCustomData(interactionId: string, key: string, value: number | boolean | string | null | undefined): void;
19
19
  export declare function addCustomTiming(interactionId: string, labelStack: LabelStack, data: CustomTiming): void;
20
20
  export declare function addMark(interactionId: string, type: MarkType, name: string, labelStack: LabelStack | null, time?: number): void;
21
+ export declare function markFirstSegmentLoad(interactionId: string, labelStack: LabelStack | null, time?: number): void;
21
22
  export declare function addMarkToAll(type: MarkType, name: string, labelStack: LabelStack | null, time?: number): void;
22
23
  export declare function addSpan(interactionId: string, type: SpanType, name: string, labelStack: LabelStack | null, start: number, end?: number, size?: number): void;
23
24
  export declare function addSpanToAll(type: SpanType, name: string, labelStack: LabelStack | null, start: number, end?: number, size?: number): void;
@@ -4,7 +4,7 @@ import type { LabelStack, UFOInteractionContextType } from '../../interaction-co
4
4
  import type { VCObserverInterface } from '../../vc/types';
5
5
  import { type VCRawDataType, type VCResult } from '../vc/types';
6
6
  export type LifecycleMarkType = 'render' | 'beforePaint' | 'afterPaint' | 'nextTick' | 'mount' | 'commit';
7
- export type MarkType = ('placeholder' | 'bm3_stop' | 'bundle_preload' | 'custom') | LifecycleMarkType;
7
+ export type MarkType = ('placeholder' | 'bm3_stop' | 'bundle_preload' | 'custom' | 'first_segment_load') | LifecycleMarkType;
8
8
  export type SpanType = 'placeholder' | 'relay' | 'hidden_timing' | 'bundle_load' | 'graphql' | 'fetch' | 'reducer' | 'custom';
9
9
  export type InteractionType = 'page_load' | 'press' | 'typing' | 'transition' | 'segment';
10
10
  export type AbortReasonType = 'new_interaction' | 'unload' | 'transition' | 'timeout' | 'excluded_by_sampling';
@@ -18,6 +18,7 @@ export declare function addCustomData(interactionId: string, labelStack: LabelSt
18
18
  export declare function addCohortingCustomData(interactionId: string, key: string, value: number | boolean | string | null | undefined): void;
19
19
  export declare function addCustomTiming(interactionId: string, labelStack: LabelStack, data: CustomTiming): void;
20
20
  export declare function addMark(interactionId: string, type: MarkType, name: string, labelStack: LabelStack | null, time?: number): void;
21
+ export declare function markFirstSegmentLoad(interactionId: string, labelStack: LabelStack | null, time?: number): void;
21
22
  export declare function addMarkToAll(type: MarkType, name: string, labelStack: LabelStack | null, time?: number): void;
22
23
  export declare function addSpan(interactionId: string, type: SpanType, name: string, labelStack: LabelStack | null, start: number, end?: number, size?: number): void;
23
24
  export declare function addSpanToAll(type: SpanType, name: string, labelStack: LabelStack | null, start: number, end?: number, size?: number): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "4.14.4",
3
+ "version": "4.14.5",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -172,6 +172,9 @@
172
172
  },
173
173
  "platform_ufo_enable_vc_raw_data": {
174
174
  "type": "boolean"
175
+ },
176
+ "platform_mark_ufo_segment_first_load": {
177
+ "type": "boolean"
175
178
  }
176
179
  }
177
180
  }