@atlaskit/analytics-next 8.2.1 → 8.3.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.
- package/AnalyticsContext/package.json +1 -0
- package/AnalyticsErrorBoundary/package.json +1 -0
- package/AnalyticsEvent/package.json +1 -0
- package/AnalyticsListener/package.json +1 -0
- package/CHANGELOG.md +18 -0
- package/UIAnalyticsEvent/package.json +1 -0
- package/createAndFireEvents/package.json +1 -0
- package/dist/cjs/components/AnalyticsErrorBoundary.js +2 -2
- package/dist/cjs/events/AnalyticsEvent.js +13 -3
- package/dist/cjs/events/UIAnalyticsEvent.js +11 -1
- package/dist/cjs/hocs/withAnalyticsContext.js +5 -3
- package/dist/cjs/hooks/usePatchedProps.js +2 -2
- package/dist/cjs/hooks/usePlatformLeafEventHandler.js +2 -2
- package/dist/cjs/hooks/usePlatformLeafSyntheticEventHandler.js +2 -2
- package/dist/cjs/index.js +39 -21
- package/dist/cjs/utils/cleanProps.js +3 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/events/AnalyticsEvent.js +8 -0
- package/dist/es2019/events/UIAnalyticsEvent.js +8 -0
- package/dist/es2019/index.js +2 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/AnalyticsErrorBoundary.js +2 -2
- package/dist/esm/events/AnalyticsEvent.js +11 -2
- package/dist/esm/events/UIAnalyticsEvent.js +8 -0
- package/dist/esm/hocs/withAnalyticsContext.js +4 -3
- package/dist/esm/hooks/usePatchedProps.js +2 -2
- package/dist/esm/hooks/usePlatformLeafEventHandler.js +2 -2
- package/dist/esm/hooks/usePlatformLeafSyntheticEventHandler.js +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/utils/cleanProps.js +2 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/components/AnalyticsContext/LegacyAnalyticsContext.d.ts +4 -4
- package/dist/types/components/AnalyticsErrorBoundary.d.ts +1 -1
- package/dist/types/components/AnalyticsListener/LegacyAnalyticsListener.d.ts +4 -4
- package/dist/types/events/AnalyticsEvent.d.ts +2 -0
- package/dist/types/events/UIAnalyticsEvent.d.ts +2 -0
- package/dist/types/hocs/withAnalyticsContext.d.ts +1 -1
- package/dist/types/hocs/withAnalyticsEvents.d.ts +1 -1
- package/dist/types/hooks/usePatchedProps.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/performance/examples.d.ts +1 -0
- package/package.json +5 -6
- package/report.api.md +7572 -0
- package/types/package.json +1 -0
- package/useAnalyticsEvents/package.json +1 -0
- package/useCallbackWithAnalytics/package.json +1 -0
- package/usePatchedProps/package.json +1 -0
- package/usePlatformLeafEventHandler/package.json +1 -0
- package/withAnalyticsContext/package.json +1 -0
- package/withAnalyticsEvents/package.json +1 -0
- package/dist/cjs/performance/examples.js +0 -258
- package/dist/es2019/performance/examples.js +0 -197
- package/dist/esm/performance/examples.js +0 -228
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
-
import React, { useCallback } from 'react';
|
|
4
|
-
import { fireEvent } from '@testing-library/react';
|
|
5
|
-
import AnalyticsListener from '../components/AnalyticsListener';
|
|
6
|
-
import withAnalyticsContext from '../hocs/withAnalyticsContext';
|
|
7
|
-
import withAnalyticsEvents from '../hocs/withAnalyticsEvents';
|
|
8
|
-
import { useAnalyticsEvents } from '../hooks/useAnalyticsEvents';
|
|
9
|
-
import { useCallbackWithAnalytics } from '../hooks/useCallbackWithAnalytics';
|
|
10
|
-
import { usePlatformLeafEventHandler } from '../hooks/usePlatformLeafEventHandler';
|
|
11
|
-
import createAndFireEvent from '../utils/createAndFireEvent';
|
|
12
|
-
|
|
13
|
-
var ButtonWithUsePlatformLeafEventHandlerHook = function ButtonWithUsePlatformLeafEventHandlerHook(_ref) {
|
|
14
|
-
var providedOnClick = _ref.onClick;
|
|
15
|
-
var onClick = usePlatformLeafEventHandler({
|
|
16
|
-
fn: providedOnClick,
|
|
17
|
-
componentName: 'perf-test-button',
|
|
18
|
-
packageName: '@atlaskit/perf-test-button',
|
|
19
|
-
packageVersion: '0.1.0',
|
|
20
|
-
action: 'clicked',
|
|
21
|
-
analyticsData: {
|
|
22
|
-
additionalData: true
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
return /*#__PURE__*/React.createElement("button", {
|
|
26
|
-
onClick: onClick,
|
|
27
|
-
"data-testid": "button"
|
|
28
|
-
}, "Click me");
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
var ButtonWithUseAnalyticsEventHook = withAnalyticsContext({
|
|
32
|
-
componentName: 'perf-test-button',
|
|
33
|
-
packageName: '@atlaskit/perf-test-button',
|
|
34
|
-
packageVersion: '0.1.0',
|
|
35
|
-
additionalData: true
|
|
36
|
-
})(function (_ref2) {
|
|
37
|
-
var providedOnClick = _ref2.onClick;
|
|
38
|
-
|
|
39
|
-
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
40
|
-
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
41
|
-
|
|
42
|
-
var onClick = useCallback(function (mouseEvt) {
|
|
43
|
-
var analyticsEvent = createAnalyticsEvent({
|
|
44
|
-
action: 'clicked',
|
|
45
|
-
actionSubject: 'perf-test-button',
|
|
46
|
-
attributes: {
|
|
47
|
-
componentName: 'perf-test-button',
|
|
48
|
-
packageName: '@atlaskit/perf-test-button',
|
|
49
|
-
packageVersion: '0.1.0'
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
analyticsEvent.fire('atlaskit');
|
|
53
|
-
providedOnClick(mouseEvt);
|
|
54
|
-
}, [providedOnClick, createAnalyticsEvent]);
|
|
55
|
-
return /*#__PURE__*/React.createElement("button", {
|
|
56
|
-
onClick: onClick,
|
|
57
|
-
"data-testid": "button"
|
|
58
|
-
}, "Click me");
|
|
59
|
-
});
|
|
60
|
-
var ButtonWithUseCallbackWithAnalyticsHook = withAnalyticsContext({
|
|
61
|
-
componentName: 'perf-test-button',
|
|
62
|
-
packageName: '@atlaskit/perf-test-button',
|
|
63
|
-
packageVersion: '0.1.0',
|
|
64
|
-
additionalData: true
|
|
65
|
-
})(function (_ref3) {
|
|
66
|
-
var providedOnClick = _ref3.onClick;
|
|
67
|
-
var onClick = useCallbackWithAnalytics(providedOnClick, {
|
|
68
|
-
action: 'clicked',
|
|
69
|
-
actionSubject: 'perf-test-button',
|
|
70
|
-
attributes: {
|
|
71
|
-
componentName: 'perf-test-button',
|
|
72
|
-
packageName: '@atlaskit/perf-test-button',
|
|
73
|
-
packageVersion: '0.1.0'
|
|
74
|
-
}
|
|
75
|
-
}, 'atlaskit');
|
|
76
|
-
return /*#__PURE__*/React.createElement("button", {
|
|
77
|
-
onClick: onClick,
|
|
78
|
-
"data-testid": "button"
|
|
79
|
-
}, "Click me");
|
|
80
|
-
});
|
|
81
|
-
var ButtonWithHOCs = withAnalyticsContext({
|
|
82
|
-
componentName: 'perf-test-button',
|
|
83
|
-
packageName: '@atlaskit/perf-test-button',
|
|
84
|
-
packageVersion: '0.1.0',
|
|
85
|
-
additionalData: true
|
|
86
|
-
})(withAnalyticsEvents({
|
|
87
|
-
onClick: createAndFireEvent('atlaskit')({
|
|
88
|
-
action: 'clicked',
|
|
89
|
-
actionSubject: 'perf-test-button',
|
|
90
|
-
attributes: {
|
|
91
|
-
componentName: 'perf-test-button',
|
|
92
|
-
packageName: '@atlaskit/perf-test-button',
|
|
93
|
-
packageVersion: '0.1.0'
|
|
94
|
-
}
|
|
95
|
-
})
|
|
96
|
-
})(function (_ref4) {
|
|
97
|
-
var onClick = _ref4.onClick;
|
|
98
|
-
return /*#__PURE__*/React.createElement("button", {
|
|
99
|
-
onClick: onClick,
|
|
100
|
-
"data-testid": "button"
|
|
101
|
-
}, "Click me");
|
|
102
|
-
}));
|
|
103
|
-
|
|
104
|
-
var createEventHandler = function createEventHandler() {
|
|
105
|
-
var done = function done() {};
|
|
106
|
-
|
|
107
|
-
var promise;
|
|
108
|
-
|
|
109
|
-
var onEvent = function onEvent() {
|
|
110
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
111
|
-
args[_key] = arguments[_key];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
done(args);
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
var create = function create() {
|
|
118
|
-
promise = new Promise(function (resolve) {
|
|
119
|
-
done = resolve;
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
var getPromise = function getPromise() {
|
|
124
|
-
return promise;
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
onEvent: onEvent,
|
|
129
|
-
create: create,
|
|
130
|
-
getPromise: getPromise
|
|
131
|
-
};
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
var eventHandler = createEventHandler();
|
|
135
|
-
|
|
136
|
-
var WithListener = function WithListener(Component) {
|
|
137
|
-
return function () {
|
|
138
|
-
eventHandler.create();
|
|
139
|
-
var onEvent = eventHandler.onEvent;
|
|
140
|
-
|
|
141
|
-
var onClick = function onClick() {};
|
|
142
|
-
|
|
143
|
-
return /*#__PURE__*/React.createElement(AnalyticsListener, {
|
|
144
|
-
channel: "atlaskit",
|
|
145
|
-
onEvent: onEvent
|
|
146
|
-
}, /*#__PURE__*/React.createElement(Component, {
|
|
147
|
-
onClick: onClick
|
|
148
|
-
}));
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
var interactionTasks = [{
|
|
153
|
-
name: 'Dispatch event',
|
|
154
|
-
description: 'Recording how long it takes to fire and receive an event on the listener',
|
|
155
|
-
run: function () {
|
|
156
|
-
var _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref5) {
|
|
157
|
-
var container, button;
|
|
158
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
159
|
-
while (1) {
|
|
160
|
-
switch (_context.prev = _context.next) {
|
|
161
|
-
case 0:
|
|
162
|
-
container = _ref5.container;
|
|
163
|
-
button = container.querySelector('button');
|
|
164
|
-
|
|
165
|
-
if (!(button == null)) {
|
|
166
|
-
_context.next = 4;
|
|
167
|
-
break;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
throw new Error('Could not find button element');
|
|
171
|
-
|
|
172
|
-
case 4:
|
|
173
|
-
fireEvent.click(button);
|
|
174
|
-
_context.next = 7;
|
|
175
|
-
return eventHandler.getPromise();
|
|
176
|
-
|
|
177
|
-
case 7:
|
|
178
|
-
case "end":
|
|
179
|
-
return _context.stop();
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}, _callee);
|
|
183
|
-
}));
|
|
184
|
-
|
|
185
|
-
function run(_x) {
|
|
186
|
-
return _run.apply(this, arguments);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return run;
|
|
190
|
-
}()
|
|
191
|
-
}];
|
|
192
|
-
export var UsePlatformLeafEventHandlerHookTest = WithListener(ButtonWithUsePlatformLeafEventHandlerHook);
|
|
193
|
-
export var UseAnalyticsEventHookTest = WithListener(ButtonWithUseAnalyticsEventHook);
|
|
194
|
-
export var UseCallbackWithAnalyticsHookTest = WithListener(ButtonWithUseCallbackWithAnalyticsHook);
|
|
195
|
-
export var HOCSTest = WithListener(ButtonWithHOCs);
|
|
196
|
-
UsePlatformLeafEventHandlerHookTest.story = {
|
|
197
|
-
name: 'usePlatformLeafEventHandler based component',
|
|
198
|
-
component: UsePlatformLeafEventHandlerHookTest,
|
|
199
|
-
parameters: {
|
|
200
|
-
performance: {
|
|
201
|
-
interactions: interactionTasks
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
UseAnalyticsEventHookTest.story = {
|
|
206
|
-
name: 'useAnalyticsEvent based component',
|
|
207
|
-
parameters: {
|
|
208
|
-
performance: {
|
|
209
|
-
interactions: interactionTasks
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
UseCallbackWithAnalyticsHookTest.story = {
|
|
214
|
-
name: 'useCallbackWithAnalytics based component',
|
|
215
|
-
parameters: {
|
|
216
|
-
performance: {
|
|
217
|
-
interactions: interactionTasks
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
HOCSTest.story = {
|
|
222
|
-
name: 'HOC based component',
|
|
223
|
-
parameters: {
|
|
224
|
-
performance: {
|
|
225
|
-
interactions: interactionTasks
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
};
|