@atlaskit/editor-plugin-interactivity 0.1.0 → 0.3.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +65 -6
  3. package/afm-cc/tsconfig.json +12 -0
  4. package/afm-products/tsconfig.json +12 -0
  5. package/dist/cjs/analytics/fire-interactivity-event.js +39 -0
  6. package/dist/cjs/analytics/interactivity-snapshot.js +1 -0
  7. package/dist/cjs/collector/bucket-boundaries.js +137 -0
  8. package/dist/cjs/collector/editor-event-observer.js +63 -0
  9. package/dist/cjs/collector/interaction-events.js +62 -0
  10. package/dist/cjs/collector/interaction-group.js +185 -0
  11. package/dist/cjs/collector/interaction-observer.js +114 -0
  12. package/dist/cjs/collector/interaction-tracker.js +185 -0
  13. package/dist/cjs/collector/interactivity-collector.js +341 -0
  14. package/dist/cjs/collector/interactivity-session.js +55 -0
  15. package/dist/cjs/collector/lifecycle-observer.js +66 -0
  16. package/dist/cjs/collector/snapshot-scheduler.js +70 -0
  17. package/dist/cjs/interactivityPlugin.js +93 -6
  18. package/dist/es2019/analytics/fire-interactivity-event.js +33 -0
  19. package/dist/es2019/analytics/interactivity-snapshot.js +0 -0
  20. package/dist/es2019/collector/bucket-boundaries.js +117 -0
  21. package/dist/es2019/collector/editor-event-observer.js +46 -0
  22. package/dist/es2019/collector/interaction-events.js +55 -0
  23. package/dist/es2019/collector/interaction-group.js +125 -0
  24. package/dist/es2019/collector/interaction-observer.js +90 -0
  25. package/dist/es2019/collector/interaction-tracker.js +156 -0
  26. package/dist/es2019/collector/interactivity-collector.js +274 -0
  27. package/dist/es2019/collector/interactivity-session.js +45 -0
  28. package/dist/es2019/collector/lifecycle-observer.js +46 -0
  29. package/dist/es2019/collector/snapshot-scheduler.js +48 -0
  30. package/dist/es2019/interactivityPlugin.js +87 -6
  31. package/dist/esm/analytics/fire-interactivity-event.js +33 -0
  32. package/dist/esm/analytics/interactivity-snapshot.js +0 -0
  33. package/dist/esm/collector/bucket-boundaries.js +130 -0
  34. package/dist/esm/collector/editor-event-observer.js +57 -0
  35. package/dist/esm/collector/interaction-events.js +55 -0
  36. package/dist/esm/collector/interaction-group.js +179 -0
  37. package/dist/esm/collector/interaction-observer.js +108 -0
  38. package/dist/esm/collector/interaction-tracker.js +179 -0
  39. package/dist/esm/collector/interactivity-collector.js +334 -0
  40. package/dist/esm/collector/interactivity-session.js +48 -0
  41. package/dist/esm/collector/lifecycle-observer.js +59 -0
  42. package/dist/esm/collector/snapshot-scheduler.js +63 -0
  43. package/dist/esm/interactivityPlugin.js +93 -6
  44. package/dist/types/analytics/fire-interactivity-event.d.ts +9 -0
  45. package/dist/types/analytics/interactivity-snapshot.d.ts +66 -0
  46. package/dist/types/collector/bucket-boundaries.d.ts +35 -0
  47. package/dist/types/collector/editor-event-observer.d.ts +19 -0
  48. package/dist/types/collector/interaction-events.d.ts +19 -0
  49. package/dist/types/collector/interaction-group.d.ts +37 -0
  50. package/dist/types/collector/interaction-observer.d.ts +39 -0
  51. package/dist/types/collector/interaction-tracker.d.ts +65 -0
  52. package/dist/types/collector/interactivity-collector.d.ts +90 -0
  53. package/dist/types/collector/interactivity-session.d.ts +42 -0
  54. package/dist/types/collector/lifecycle-observer.d.ts +25 -0
  55. package/dist/types/collector/snapshot-scheduler.d.ts +15 -0
  56. package/dist/types/interactivityPlugin.d.ts +6 -4
  57. package/dist/types/interactivityPluginType.d.ts +11 -2
  58. package/docs/0-intro.tsx +26 -7
  59. package/package.json +8 -3
@@ -0,0 +1,25 @@
1
+ export type LifecycleHandlers = {
2
+ /** The tab became hidden. */
3
+ onHidden: () => void;
4
+ /** The page is being unloaded. May arrive right after `onHidden`. */
5
+ onPageHide: () => void;
6
+ /** The page came back from the back/forward cache. */
7
+ onPageShow: () => void;
8
+ /** The tab became visible again — the session continues. */
9
+ onVisible: () => void;
10
+ };
11
+ /**
12
+ * Reports the page lifecycle signals that force an extra snapshot: the tab being hidden or
13
+ * shown again, and the page being unloaded or restored from the back/forward cache.
14
+ *
15
+ * None of them is guaranteed to arrive — a mobile browser being killed raises nothing at all.
16
+ * Snapshots carry session-to-date values, so losing the last one costs only the tail of that
17
+ * session.
18
+ */
19
+ export declare class LifecycleObserver {
20
+ private readonly handlers;
21
+ private unbind;
22
+ constructor(handlers: LifecycleHandlers);
23
+ start(): void;
24
+ stop(): void;
25
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Fires `onTick` on the snapshot cadence. Timings are offsets from `start()`, so a
3
+ * restart (a new session in the same editor) restarts the cadence too.
4
+ */
5
+ export declare class SnapshotScheduler {
6
+ private readonly onTick;
7
+ private timeoutId;
8
+ private tickIndex;
9
+ constructor(onTick: () => void);
10
+ start(): void;
11
+ restart(): void;
12
+ stop(): void;
13
+ private scheduleNext;
14
+ private delayForNextTick;
15
+ }
@@ -1,9 +1,11 @@
1
1
  import type { InteractivityPlugin } from './interactivityPluginType';
2
2
  /**
3
- * Reports interaction latency distributions for full page editor sessions as the
4
- * `editor interactivity` operational event.
3
+ * Reports session-to-date interaction latency distributions for full page editor sessions
4
+ * as the `editor interactivity` operational event.
5
5
  *
6
- * A stub for now: the plugin only registers itself. The collector and the event land in
7
- * EDITOR-8553.
6
+ * The session runs for as long as the plugin's hook stays mounted, which is one editor
7
+ * mount: `MountPluginHooks` in editor-core keys hook fibers by plugin name, so a preset
8
+ * reconfigure — which destroys and recreates ProseMirror plugin views — leaves this hook,
9
+ * and the session, in place.
8
10
  */
9
11
  export declare const interactivityPlugin: InteractivityPlugin;
@@ -1,2 +1,11 @@
1
- import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
- export type InteractivityPlugin = NextEditorPlugin<'interactivity'>;
1
+ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics/analyticsPluginType';
3
+ import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier/contextIdentifierPluginType';
4
+ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode/editorViewmodePluginType';
5
+ export type InteractivityPlugin = NextEditorPlugin<'interactivity', {
6
+ dependencies: [
7
+ OptionalPlugin<AnalyticsPlugin>,
8
+ OptionalPlugin<ContextIdentifierPlugin>,
9
+ OptionalPlugin<EditorViewModePlugin>
10
+ ];
11
+ }>;
package/docs/0-intro.tsx CHANGED
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
3
  import { AtlassianInternalWarning, code, md } from '@atlaskit/docs';
4
- // eslint-disable-next-line @atlassian/tangerine/import/entry-points
5
4
  import { createEditorUseOnlyNotice } from '@atlaskit/editor-common/doc-utils';
6
5
  import { token } from '@atlaskit/tokens';
7
6
 
@@ -24,24 +23,44 @@ ${createEditorUseOnlyNotice('Editor Plugin Interactivity', [
24
23
 
25
24
  This package includes the interactivity plugin used by \`@atlaskit/editor-core\`.
26
25
 
27
- It will report the \`editor interactivity\` operational event: how interaction latencies were
28
- spread over an editor session, as bucketed counts, per [RFC 095](https://hello.atlassian.net/wiki/spaces/EDITOR/pages/7527607488/Editor+RFC+095+Confluence+editor+responsiveness+bucketed+INP+telemetry).
29
- The plugin is a stub at this point and collects nothing.
26
+ It reports the \`editor interactivity\` operational event: session-to-date interaction latency
27
+ histograms for full page editor sessions — for the page as a whole, and for the editor's typing,
28
+ pointer and other interactions per [RFC 095](https://hello.atlassian.net/wiki/spaces/EDITOR/pages/7527607488/Editor+RFC+095+Confluence+editor+responsiveness+bucketed+INP+telemetry).
29
+ See the package README for the event shape, the snapshot cadence and what ends a session.
30
+
31
+ The plugin has no configuration, state, actions or commands — adding it to a preset is what turns
32
+ collection on.
30
33
 
31
34
  ## Usage
32
35
  ---
33
36
 
34
- Add the plugin to a preset. It has no configuration, state, actions or commands, so there is
37
+ Add the plugin to a preset. It reports for as long as the editor stays mounted, so there is
35
38
  nothing to call:
36
39
 
37
40
  ${code`
38
41
  import { interactivityPlugin } from '@atlaskit/editor-plugin-interactivity';
39
42
 
40
- const preset = new EditorPresetBuilder().add(interactivityPlugin);
43
+ const preset = new EditorPresetBuilder()
44
+ .add(analyticsPlugin)
45
+ .add(contextIdentifierPlugin)
46
+ .add(editorViewModePlugin)
47
+ .add(interactivityPlugin);
41
48
  `}
42
49
 
50
+ All three dependencies are optional, but the event is only fired when the analytics plugin is
51
+ present, and the session is only split per document and per mode when the other two are:
52
+
43
53
  ${code`
44
- type InteractivityPlugin = NextEditorPlugin<'interactivity'>
54
+ type InteractivityPlugin = NextEditorPlugin<
55
+ 'interactivity',
56
+ {
57
+ dependencies: [
58
+ OptionalPlugin<AnalyticsPlugin>,
59
+ OptionalPlugin<ContextIdentifierPlugin>,
60
+ OptionalPlugin<EditorViewModePlugin>,
61
+ ];
62
+ }
63
+ >
45
64
  `}
46
65
 
47
66
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-interactivity",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Interactivity plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -19,10 +19,15 @@
19
19
  "types": "dist/types/index.d.ts",
20
20
  "sideEffects": false,
21
21
  "dependencies": {
22
- "@babel/runtime": "^7.0.0"
22
+ "@atlaskit/browser-apis": "^1.2.0",
23
+ "@atlaskit/editor-plugin-analytics": "^15.0.0",
24
+ "@atlaskit/editor-plugin-context-identifier": "^15.0.0",
25
+ "@atlaskit/editor-plugin-editor-viewmode": "^17.0.0",
26
+ "@babel/runtime": "^7.0.0",
27
+ "bind-event-listener": "^3.0.0"
23
28
  },
24
29
  "peerDependencies": {
25
- "@atlaskit/editor-common": "^119.5.0",
30
+ "@atlaskit/editor-common": "^119.10.0",
26
31
  "react": "^18.2.0 || ^19.2.0"
27
32
  },
28
33
  "devDependencies": {