@jetbrains/ring-ui 5.0.99 → 5.0.101

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 (50) hide show
  1. package/components/analytics/analytics.d.ts +20 -6
  2. package/components/analytics/analytics.js +19 -24
  3. package/components/analytics/analytics__custom-plugin.d.ts +4 -15
  4. package/components/analytics/analytics__custom-plugin.js +11 -52
  5. package/components/analytics/analytics__fus-plugin.d.ts +15 -25
  6. package/components/analytics/analytics__fus-plugin.js +15 -73
  7. package/components/analytics/analytics__ga-plugin.d.ts +12 -2
  8. package/components/analytics/analytics__ga-plugin.js +35 -5
  9. package/components/analytics/analytics__plugin-utils.d.ts +16 -0
  10. package/components/analytics/analytics__plugin-utils.js +26 -1
  11. package/components/button-ng/button-ng.js +1 -1
  12. package/components/dialog-ng/dialog-ng.js +4 -5
  13. package/components/global/angular-component-factory.js +4 -3
  14. package/components/global/ring-angular-component.js +1 -3
  15. package/components/global/ring-angular-component.test.js +2 -1
  16. package/components/input-ng/input-ng.js +1 -1
  17. package/components/loader-ng/loader-ng.js +1 -1
  18. package/components/promised-click-ng/promised-click-ng.js +1 -1
  19. package/components/shortcuts-hint-ng/shortcuts-hint-ng.js +1 -2
  20. package/components/sidebar-ng/sidebar-ng.js +1 -2
  21. package/components/template-ng/template-ng.js +1 -2
  22. package/components/user-card/card.js +18 -16
  23. package/components/user-card/user-card.css +4 -0
  24. package/dist/_helpers/card.js +4 -2
  25. package/dist/analytics/analytics.d.ts +20 -6
  26. package/dist/analytics/analytics.js +21 -25
  27. package/dist/analytics/analytics__custom-plugin.d.ts +4 -15
  28. package/dist/analytics/analytics__custom-plugin.js +15 -51
  29. package/dist/analytics/analytics__fus-plugin.d.ts +15 -25
  30. package/dist/analytics/analytics__fus-plugin.js +15 -86
  31. package/dist/analytics/analytics__ga-plugin.d.ts +12 -2
  32. package/dist/analytics/analytics__ga-plugin.js +39 -5
  33. package/dist/analytics/analytics__plugin-utils.d.ts +16 -0
  34. package/dist/analytics/analytics__plugin-utils.js +26 -1
  35. package/dist/button-ng/button-ng.js +1 -1
  36. package/dist/dialog-ng/dialog-ng.js +3 -3
  37. package/dist/global/angular-component-factory.js +6 -3
  38. package/dist/global/ring-angular-component.js +2 -2
  39. package/dist/input-ng/input-ng.js +1 -1
  40. package/dist/loader-ng/loader-ng.js +1 -1
  41. package/dist/promised-click-ng/promised-click-ng.js +2 -2
  42. package/dist/shortcuts-hint-ng/shortcuts-hint-ng.js +2 -2
  43. package/dist/sidebar-ng/sidebar-ng.js +2 -2
  44. package/dist/style.css +1 -1
  45. package/dist/template-ng/template-ng.js +1 -1
  46. package/package.json +19 -18
  47. package/components/analytics-ng/analytics-ng.examples.js +0 -61
  48. package/components/analytics-ng/analytics-ng.js +0 -87
  49. package/components/analytics-ng/analytics-ng.test.js +0 -82
  50. package/dist/analytics-ng/analytics-ng.js +0 -89
@@ -19,8 +19,7 @@ function createAngularComponent(Component) {
19
19
  bindings[key] = '<';
20
20
  });
21
21
 
22
- return class AngularComponent extends RingAngularComponent {
23
- static $inject = ['$scope', '$element', '$transclude'];
22
+ class AngularComponent extends RingAngularComponent {
24
23
 
25
24
  static bindings = bindings;
26
25
  static transclude = true;
@@ -72,7 +71,9 @@ function createAngularComponent(Component) {
72
71
  container
73
72
  );
74
73
  }
75
- };
74
+ }
75
+ AngularComponent.$inject = ['$scope', '$element', '$transclude'];
76
+ return AngularComponent;
76
77
  }
77
78
 
78
79
  function angularComponentFactory(Component, name) {
@@ -1,6 +1,4 @@
1
1
  export default class RingAngularComponent {
2
- static $inject = [];
3
-
4
2
  static get controller() {
5
3
  return this;
6
4
  }
@@ -8,7 +6,7 @@ export default class RingAngularComponent {
8
6
  $inject = {};
9
7
 
10
8
  constructor(...args) {
11
- this.constructor.$inject.forEach((injectName, i) => {
9
+ (this.constructor.$inject ?? []).forEach((injectName, i) => {
12
10
  this.$inject[injectName] = args[i];
13
11
  });
14
12
  }
@@ -5,8 +5,9 @@ import 'angular-mocks';
5
5
  import RingAngularComponent from './ring-angular-component';
6
6
 
7
7
  class TestComponent extends RingAngularComponent {
8
- static $inject = ['$scope'];
8
+
9
9
  }
10
+ TestComponent.$inject = ['$scope'];
10
11
 
11
12
  const testModule = angular.module('Test', []).component('testComponent', TestComponent).name;
12
13
 
@@ -15,7 +15,6 @@ import styleOverrides from './input-ng.css';
15
15
  const angularModule = angular.module('Ring.input', [ButtonNg]);
16
16
 
17
17
  class RingInputComponent extends RingAngularComponent {
18
- static $inject = ['$element'];
19
18
 
20
19
  static require = {
21
20
  ngModelCtrl: '?ngModel'
@@ -153,6 +152,7 @@ class RingInputComponent extends RingAngularComponent {
153
152
  </div>
154
153
  `;
155
154
  }
155
+ RingInputComponent.$inject = ['$element'];
156
156
 
157
157
  angularModule.component('rgInput', RingInputComponent);
158
158
 
@@ -11,7 +11,6 @@ import LoaderCore from '../loader/loader__core';
11
11
  const angularModule = angular.module('Ring.loader', []);
12
12
 
13
13
  class RgLoaderComponent extends RingAngularComponent {
14
- static $inject = ['$element'];
15
14
 
16
15
  static bindings = {
17
16
  message: '@'
@@ -31,6 +30,7 @@ class RgLoaderComponent extends RingAngularComponent {
31
30
  this.loader.updateMessage(changes.message.currentValue);
32
31
  }
33
32
  }
33
+ RgLoaderComponent.$inject = ['$element'];
34
34
 
35
35
  angularModule.component('rgLoader', RgLoaderComponent);
36
36
 
@@ -15,7 +15,6 @@ const angularModule = angular.module('Ring.promised-click', []);
15
15
  const DEFAULT_MODE = 'active';
16
16
 
17
17
  class PromisedClickController extends RingAngularComponent {
18
- static $inject = ['$scope', '$element', '$attrs', '$parse'];
19
18
  constructor(...args) {
20
19
  super(...args);
21
20
 
@@ -106,6 +105,7 @@ class PromisedClickController extends RingAngularComponent {
106
105
  this.promise.then(done, done);
107
106
  }
108
107
  }
108
+ PromisedClickController.$inject = ['$scope', '$element', '$attrs', '$parse'];
109
109
 
110
110
  function rgPromisedClickDirective() {
111
111
  return {
@@ -25,8 +25,6 @@ const getTitle = title => (typeof title === 'function' ? title() : title);
25
25
 
26
26
 
27
27
  class HintPopupService extends RingAngularComponent {
28
- static $inject = ['dialog', 'shortcuts'];
29
-
30
28
  show(popupConfig = {}, shortcutModes, okButtonLabel = 'Got it', searchPlaceholder = 'Search') {
31
29
  const {dialog, shortcuts} = this.$inject;
32
30
 
@@ -67,6 +65,7 @@ class HintPopupService extends RingAngularComponent {
67
65
  }, popupConfig));
68
66
  }
69
67
  }
68
+ HintPopupService.$inject = ['dialog', 'shortcuts'];
70
69
 
71
70
  function shortcutKeySymbolFilter(shortcut) {
72
71
  return getShortcutTitle(shortcut);
@@ -21,8 +21,6 @@ import buttonTemplate from './sidebar-ng__button-template';
21
21
  const angularModule = angular.module('Ring.sidebar', [PlaceUnder, IconNG, ButtonNG]);
22
22
 
23
23
  class SidebarController extends RingAngularComponent {
24
- static $inject = ['$scope'];
25
-
26
24
  constructor(...args) {
27
25
  super(...args);
28
26
 
@@ -49,6 +47,7 @@ class SidebarController extends RingAngularComponent {
49
47
  };
50
48
  }
51
49
  }
50
+ SidebarController.$inject = ['$scope'];
52
51
 
53
52
  function rgSidebarDirective() {
54
53
  return {
@@ -9,8 +9,6 @@ import RingAngularComponent from '../global/ring-angular-component';
9
9
  const angularModule = angular.module('Ring.template', []);
10
10
 
11
11
  class RgTemplateController extends RingAngularComponent {
12
- static $inject = ['$scope', '$element', '$attrs', '$compile'];
13
-
14
12
  currentScope = null;
15
13
 
16
14
  constructor(...args) {
@@ -48,6 +46,7 @@ class RgTemplateController extends RingAngularComponent {
48
46
  }
49
47
  }
50
48
  }
49
+ RgTemplateController.$inject = ['$scope', '$element', '$attrs', '$compile'];
51
50
 
52
51
  angularModule.directive('rgTemplate', function rgTemplateDirective() {
53
52
  return {
@@ -60,25 +60,27 @@ export default class UserCard extends PureComponent {
60
60
  {!!avatarInfo && avatarInfo}
61
61
  </div>
62
62
  <div className={styles.userInformation}>
63
- <div className={styles.userNameLine}>
64
- {user.href && (<Link href={user.href} className={styles.userName}>
65
- {user.name}
66
- </Link>)}
67
- {!user.href && <span className={styles.userName}>{user.name}</span>}
68
- {typeof user.online === 'boolean' &&
63
+ <div className={styles.userInformationGeneral}>
64
+ <div className={styles.userNameLine}>
65
+ {user.href && (<Link href={user.href} className={styles.userName}>
66
+ {user.name}
67
+ </Link>)}
68
+ {!user.href && <span className={styles.userName}>{user.name}</span>}
69
+ {typeof user.online === 'boolean' &&
69
70
  (<span className={userActiveStatusClasses} title={user.online ? wording.online : wording.offline}/>)}
70
- {!!info && <span className={styles.userNameInfo}>{info}</span>}
71
- {user.banned &&
71
+ {!!info && <span className={styles.userNameInfo}>{info}</span>}
72
+ {user.banned &&
72
73
  (<span className={classNames(badgeStyles.badge, badgeStyles.invalid)} title={user.banReason}>{wording.banned}</span>)}
74
+ </div>
75
+ <div className={styles.userLogin}>{user.login}</div>
76
+ {user.email && (<span className={styles.userEmailWrapper}>
77
+ <Link pseudo onClick={this.copyEmail} className={styles.userEmail}>
78
+ {user.email}
79
+ </Link>
80
+ {user.unverifiedEmail && (<span className={styles.unverifiedLabel}>{wording.unverified}</span>)}
81
+ <Icon title={wording.copyToClipboard} className={styles.userCopyIcon} onClick={this.copyEmail} glyph={copyIcon} size={IconSize.Size14} suppressSizeWarning/>
82
+ </span>)}
73
83
  </div>
74
- <div className={styles.userLogin}>{user.login}</div>
75
- {user.email && (<span className={styles.userEmailWrapper}>
76
- <Link pseudo onClick={this.copyEmail} className={styles.userEmail}>
77
- {user.email}
78
- </Link>
79
- {user.unverifiedEmail && (<span className={styles.unverifiedLabel}>{wording.unverified}</span>)}
80
- <Icon title={wording.copyToClipboard} className={styles.userCopyIcon} onClick={this.copyEmail} glyph={copyIcon} size={IconSize.Size14} suppressSizeWarning/>
81
- </span>)}
82
84
  {children}
83
85
  </div>
84
86
  </div>
@@ -28,6 +28,10 @@
28
28
  line-height: 18px;
29
29
  }
30
30
 
31
+ .userInformationGeneral {
32
+ height: 56px;
33
+ }
34
+
31
35
  .userNameLine {
32
36
  height: var(--ring-line-height-lowest);
33
37
 
@@ -10,7 +10,7 @@ import { m as modules_6c9187df } from './badge.js';
10
10
  import Icon from '../icon/icon.js';
11
11
  import { Size as Size$1 } from '../icon/icon__constants.js';
12
12
 
13
- var modules_a4196c17 = {"unit":"8px","light":"light_rui_6e59","userCardSpaced":"userCardSpaced_rui_6e59","userInformationContainer":"userInformationContainer_rui_6e59","userAvatar":"userAvatar_rui_6e59","userInformation":"userInformation_rui_6e59","userNameLine":"userNameLine_rui_6e59","userName":"userName_rui_6e59","userLogin":"userLogin_rui_6e59","userEmail":"userEmail_rui_6e59","userCopyIcon":"userCopyIcon_rui_6e59","userEmailWrapper":"userEmailWrapper_rui_6e59","unverifiedLabel":"unverifiedLabel_rui_6e59","userNameInfo":"userNameInfo_rui_6e59","userActiveStatus":"userActiveStatus_rui_6e59","online":"online_rui_6e59"};
13
+ var modules_a4196c17 = {"unit":"8px","light":"light_rui_6e59","userCardSpaced":"userCardSpaced_rui_6e59","userInformationContainer":"userInformationContainer_rui_6e59","userAvatar":"userAvatar_rui_6e59","userInformation":"userInformation_rui_6e59","userInformationGeneral":"userInformationGeneral_rui_6e59","userNameLine":"userNameLine_rui_6e59","userName":"userName_rui_6e59","userLogin":"userLogin_rui_6e59","userEmail":"userEmail_rui_6e59","userCopyIcon":"userCopyIcon_rui_6e59","userEmailWrapper":"userEmailWrapper_rui_6e59","unverifiedLabel":"unverifiedLabel_rui_6e59","userNameInfo":"userNameInfo_rui_6e59","userActiveStatus":"userActiveStatus_rui_6e59","online":"online_rui_6e59"};
14
14
 
15
15
  class UserCard extends PureComponent {
16
16
  constructor() {
@@ -46,6 +46,8 @@ class UserCard extends PureComponent {
46
46
  url: user.avatarUrl
47
47
  }), !!avatarInfo && avatarInfo), /*#__PURE__*/React.createElement("div", {
48
48
  className: modules_a4196c17.userInformation
49
+ }, /*#__PURE__*/React.createElement("div", {
50
+ className: modules_a4196c17.userInformationGeneral
49
51
  }, /*#__PURE__*/React.createElement("div", {
50
52
  className: modules_a4196c17.userNameLine
51
53
  }, user.href && /*#__PURE__*/React.createElement(Link, {
@@ -78,7 +80,7 @@ class UserCard extends PureComponent {
78
80
  glyph: copyIcon,
79
81
  size: Size$1.Size14,
80
82
  suppressSizeWarning: true
81
- })), children)));
83
+ }))), children)));
82
84
  }
83
85
  }
84
86
  _defineProperty(UserCard, "propTypes", {
@@ -2,8 +2,11 @@ type Serializable = string | number | boolean | null | undefined | {
2
2
  [K in string | number]?: Serializable;
3
3
  };
4
4
  export interface AnalyticsPlugin {
5
+ /**
6
+ * @deprecated
7
+ */
5
8
  serializeAdditionalInfo: boolean;
6
- trackEvent(category: string, action: string, additionalData?: Record<string, unknown> | undefined): void;
9
+ trackEvent(category: string, action: string, additionalData?: Record<string, string>): void;
7
10
  trackPageView(path: string): void;
8
11
  }
9
12
  /**
@@ -13,12 +16,23 @@ export declare class Analytics {
13
16
  private _plugins;
14
17
  constructor();
15
18
  config(plugins: readonly AnalyticsPlugin[]): void;
16
- track(rawTrackingData: string, additionalData?: Record<string, unknown> | undefined): void;
19
+ /**
20
+ * @deprecated
21
+ */
22
+ track(rawTrackingData: string, additionalData: Record<string, string>): void;
23
+ /**
24
+ * @deprecated
25
+ */
17
26
  trackPageView(path: string): void;
18
- trackEvent(category: string, action: string, additionalData?: Record<string, unknown> | undefined): void;
19
- trackShortcutEvent(category: string, action: string, additionalData?: Record<string, unknown> | undefined): void;
20
- trackEntityProperties(entityName: string, entity: Serializable, propertiesNames: readonly string[], additionalData?: Record<string, unknown> | undefined): void;
21
- private _buildSuffix;
27
+ trackEvent(category: string, action: string, additionalData?: Record<string, string>): void;
28
+ /**
29
+ * @deprecated
30
+ */
31
+ trackShortcutEvent(category: string, action: string, additionalData: Record<string, string>): void;
32
+ /**
33
+ * @deprecated
34
+ */
35
+ trackEntityProperties(entityName: string, entity: Serializable, propertiesNames: readonly string[], additionalData?: Record<string, string>): void;
22
36
  }
23
37
  declare const _default: Analytics;
24
38
  export default _default;
@@ -1,5 +1,7 @@
1
1
  import { _ as _defineProperty } from '../_helpers/_rollupPluginBabelHelpers.js';
2
+ import deprecate from 'util-deprecate';
2
3
 
4
+ const warnOnDeprecationOfAnalyticsMethod = methodName => deprecate(() => {}, `Method analytics::${methodName} is deprecated, use analytics::trackEvent instead`)();
3
5
  /**
4
6
  * @name Analytics
5
7
  */
@@ -11,10 +13,14 @@ class Analytics {
11
13
  config(plugins) {
12
14
  this._plugins = plugins;
13
15
  }
16
+ /**
17
+ * @deprecated
18
+ */
14
19
  track(rawTrackingData, additionalData) {
15
20
  if (!rawTrackingData) {
16
21
  return;
17
22
  }
23
+ warnOnDeprecationOfAnalyticsMethod('track');
18
24
  let splitIdx = rawTrackingData.indexOf(':');
19
25
  if (splitIdx < 0) {
20
26
  splitIdx = rawTrackingData.indexOf('_');
@@ -26,29 +32,32 @@ class Analytics {
26
32
  const subcategory = rawTrackingData.substr(splitIdx + 1);
27
33
  this.trackEvent(category, subcategory, additionalData);
28
34
  }
35
+ /**
36
+ * @deprecated
37
+ */
29
38
  trackPageView(path) {
39
+ warnOnDeprecationOfAnalyticsMethod('trackPageView');
30
40
  this._plugins.forEach(plugin => {
31
41
  plugin.trackPageView(path);
32
42
  });
33
43
  }
34
44
  trackEvent(category, action, additionalData) {
35
- const subaction = additionalData ? action + this._buildSuffix(additionalData) : null;
36
45
  this._plugins.forEach(plugin => {
37
- if (plugin.serializeAdditionalInfo) {
38
- plugin.trackEvent(category, action);
39
- if (subaction) {
40
- plugin.trackEvent(category, subaction);
41
- }
42
- } else {
43
- plugin.trackEvent(category, action, additionalData);
44
- }
46
+ plugin.trackEvent(category, action, additionalData);
45
47
  });
46
48
  }
49
+ /**
50
+ * @deprecated
51
+ */
47
52
  trackShortcutEvent(category, action, additionalData) {
53
+ warnOnDeprecationOfAnalyticsMethod('trackShortcutEvent');
48
54
  this.trackEvent(category, action, additionalData);
49
- this.trackEvent('ring-shortcut', `${category}$${action}`, additionalData);
50
55
  }
56
+ /**
57
+ * @deprecated
58
+ */
51
59
  trackEntityProperties(entityName, entity, propertiesNames, additionalData) {
60
+ warnOnDeprecationOfAnalyticsMethod('trackEntityProperties');
52
61
  for (let i = 0; i < propertiesNames.length; ++i) {
53
62
  const keys = propertiesNames[i].split('.');
54
63
  let value = entity;
@@ -70,20 +79,7 @@ class Analytics {
70
79
  this.trackEvent(entityName, resultAction, additionalData);
71
80
  }
72
81
  }
73
- _buildSuffix(additionalData) {
74
- if (!additionalData) {
75
- return '';
76
- }
77
- let suffix = '';
78
- let key;
79
- for (key in additionalData) {
80
- if (additionalData.hasOwnProperty(key)) {
81
- suffix += `__${key}$${additionalData[key]}`;
82
- }
83
- }
84
- return suffix;
85
- }
86
82
  }
87
- var analyticsInstance = new Analytics();
83
+ var analytics = new Analytics();
88
84
 
89
- export { Analytics, analyticsInstance as default };
85
+ export { Analytics, analytics as default };
@@ -2,12 +2,12 @@ import { AnalyticsPlugin } from './analytics';
2
2
  export interface AnalyticsCustomPluginData {
3
3
  category: string;
4
4
  action: string;
5
+ data?: Record<string, string>;
5
6
  }
6
7
  export interface AnalyticsCustomPluginConfig {
7
8
  send: (data: AnalyticsCustomPluginData[]) => void;
8
9
  isDevelopment?: boolean | undefined;
9
10
  flushInterval?: number | undefined;
10
- flushingAllowedChecker?: (() => boolean) | undefined;
11
11
  flushMaxPackSize?: number | undefined;
12
12
  }
13
13
  export default class AnalyticsCustomPlugin implements AnalyticsPlugin {
@@ -16,24 +16,13 @@ export default class AnalyticsCustomPlugin implements AnalyticsPlugin {
16
16
  private _isDevelopment?;
17
17
  private _flushInterval?;
18
18
  private _flushMaxPackSize?;
19
- private _lastPagePath?;
20
19
  private _hasSendSchedule?;
21
- private _lastPageViewTime?;
22
- constructor(send: AnalyticsCustomPluginConfig['send'], isDevelopment?: AnalyticsCustomPluginConfig['isDevelopment'], flushInterval?: AnalyticsCustomPluginConfig['flushInterval'], flushingAllowedChecker?: AnalyticsCustomPluginConfig['flushingAllowedChecker']);
23
- /**
24
- * @param config
25
- * @property {function} config.send
26
- * @property {boolean} config.isDevelopment
27
- * @property {number} config.flushInterval
28
- * @property {function} config.flushingAllowedChecker
29
- * @property {number} config.flushMaxPackSize
30
- */
20
+ constructor(send: AnalyticsCustomPluginConfig['send'], isDevelopment?: AnalyticsCustomPluginConfig['isDevelopment'], flushInterval?: AnalyticsCustomPluginConfig['flushInterval']);
31
21
  config(config: AnalyticsCustomPluginConfig): void;
32
- trackEvent(category: string, action: string): void;
33
- trackPageView(path: string): void;
22
+ trackEvent(category: string, action: string, additionalData?: Record<string, string>): void;
23
+ trackPageView(path: string, data?: Record<string, string>): void;
34
24
  private _initSendSchedule;
35
25
  private _processEvent;
36
- private _trackPageViewAdditionalInfo;
37
26
  private _addDataToFlushingPack;
38
27
  get serializeAdditionalInfo(): boolean;
39
28
  }
@@ -1,40 +1,25 @@
1
1
  import { _ as _defineProperty } from '../_helpers/_rollupPluginBabelHelpers.js';
2
- import AnalyticsPluginUtils from './analytics__plugin-utils.js';
3
- import '../global/sniffer.js';
4
- import 'sniffr';
5
2
 
6
3
  const DEFAULT_FLUSH_INTERVAL = 10000;
7
4
  const DEFAULT_FLUSH_MAX_PACK_SIZE = 100;
8
5
  class AnalyticsCustomPlugin {
9
- constructor(send, isDevelopment, flushInterval, flushingAllowedChecker) {
6
+ constructor(send, isDevelopment, flushInterval) {
10
7
  _defineProperty(this, "_data", void 0);
11
8
  _defineProperty(this, "_flush", void 0);
12
9
  _defineProperty(this, "_isDevelopment", void 0);
13
10
  _defineProperty(this, "_flushInterval", void 0);
14
11
  _defineProperty(this, "_flushMaxPackSize", void 0);
15
- _defineProperty(this, "_lastPagePath", void 0);
16
12
  _defineProperty(this, "_hasSendSchedule", void 0);
17
- _defineProperty(this, "_lastPageViewTime", void 0);
18
13
  this._data = [];
19
14
  this.config({
20
15
  send,
21
16
  isDevelopment,
22
- flushInterval,
23
- flushingAllowedChecker
17
+ flushInterval
24
18
  });
25
19
  }
26
- /**
27
- * @param config
28
- * @property {function} config.send
29
- * @property {boolean} config.isDevelopment
30
- * @property {number} config.flushInterval
31
- * @property {function} config.flushingAllowedChecker
32
- * @property {number} config.flushMaxPackSize
33
- */
34
20
  config(config) {
35
- const checkFlushingAllowed = typeof config.flushingAllowedChecker === 'function' ? config.flushingAllowedChecker : () => true;
36
21
  this._flush = () => {
37
- if (this._data.length > 0 && checkFlushingAllowed()) {
22
+ if (this._data.length > 0) {
38
23
  config.send(this._data);
39
24
  this._data = [];
40
25
  }
@@ -43,57 +28,36 @@ class AnalyticsCustomPlugin {
43
28
  this._flushInterval = config.flushInterval || DEFAULT_FLUSH_INTERVAL;
44
29
  this._flushMaxPackSize = config.flushMaxPackSize || DEFAULT_FLUSH_MAX_PACK_SIZE;
45
30
  }
46
- trackEvent(category, action) {
47
- this._processEvent(category, action);
31
+ trackEvent(category, action, additionalData) {
32
+ this._processEvent(category, action, additionalData);
48
33
  }
49
- trackPageView(path) {
50
- if (this._lastPagePath === path) {
51
- return;
52
- }
53
- this._trackPageViewAdditionalInfo(path);
54
- this._processEvent('ring-page', path);
55
- this._processEvent('ring-navigator_user-agent', AnalyticsPluginUtils.getUserAgentPresentation());
56
- this._processEvent('ring-navigator_platform', AnalyticsPluginUtils.npeSaveLowerCase(navigator.platform));
57
- this._processEvent('ring-navigator_lang', AnalyticsPluginUtils.npeSaveLowerCase(navigator.language));
58
- this._processEvent('ring-device-pixel-ratio', AnalyticsPluginUtils.getDevicePixelRatioPresentation());
59
- this._processEvent('ring-screen-width', AnalyticsPluginUtils.getScreenWidthPresentation());
34
+ trackPageView(path, data) {
35
+ this._processEvent('page', 'view', data);
60
36
  }
61
37
  _initSendSchedule() {
62
- window.addEventListener('beforeunload', () => {
63
- this._trackPageViewAdditionalInfo();
64
- return this._flush?.();
65
- });
38
+ window.addEventListener('beforeunload', () => this._flush?.());
66
39
  if (this._flush != null) {
67
40
  setInterval(this._flush, this._flushInterval);
68
41
  }
69
42
  this._hasSendSchedule = true;
70
43
  }
71
- _processEvent(rawCategory, rawAction) {
44
+ _processEvent(category, action, data) {
72
45
  if (!this._hasSendSchedule && this._flush) {
73
46
  this._initSendSchedule();
74
47
  }
75
- const category = AnalyticsPluginUtils.reformatString(rawCategory, true);
76
- const action = AnalyticsPluginUtils.reformatString(rawAction);
77
48
  if (this._isDevelopment) {
78
- console.log('TRACKING DATA = ', category, action); // eslint-disable-line no-console
49
+ console.log('TRACKING DATA = ', category, action, data); // eslint-disable-line no-console
79
50
  }
80
51
 
81
- this._addDataToFlushingPack({
52
+ this._addDataToFlushingPack(data ? {
53
+ category,
54
+ action,
55
+ data
56
+ } : {
82
57
  category,
83
58
  action
84
59
  });
85
60
  }
86
- _trackPageViewAdditionalInfo(newPagePath) {
87
- const currentTime = new Date().getTime();
88
- if (this._lastPagePath) {
89
- if (this._lastPageViewTime) {
90
- const duration = AnalyticsPluginUtils.getPageViewDurationPresentation(currentTime - this._lastPageViewTime);
91
- this._processEvent(`ring-pageview-duration_${this._lastPagePath}`, duration);
92
- }
93
- }
94
- this._lastPageViewTime = currentTime;
95
- this._lastPagePath = newPagePath;
96
- }
97
61
  _addDataToFlushingPack(sendingData) {
98
62
  this._data.push(sendingData);
99
63
  if (this._flushMaxPackSize != null && this._data.length >= this._flushMaxPackSize) {
@@ -4,13 +4,6 @@ export interface AnalyticsFUSPluginGroup {
4
4
  version: string;
5
5
  baseline: string;
6
6
  }
7
- export interface AnalyticsFUSPluginConfig {
8
- productId?: string | undefined;
9
- productBuild?: string | undefined;
10
- recorderVersion?: number | string | undefined;
11
- isDevelopment?: boolean | undefined;
12
- groups?: readonly AnalyticsFUSPluginGroup[] | undefined;
13
- }
14
7
  interface FusraInitParams {
15
8
  recorderCode?: string | undefined;
16
9
  recorderVersion: number | string;
@@ -38,25 +31,22 @@ declare global {
38
31
  }
39
32
  }
40
33
  /**
34
+ * @deprecated
41
35
  * @name AnalyticsFUSPlugin
42
- *
43
- * @param * @param {{
44
- * productId: string,
45
- * productBuild: string,
46
- * recorderVersion: string?,
47
- * isDevelopment: boolean?,
48
- * groups: object[]?
49
- * }} config
50
- * @constructor
51
36
  */
52
- export default class AnalyticsFUSPlugin implements AnalyticsPlugin {
53
- private _recorderVersion?;
54
- private _lastPagePath?;
55
- private _groups;
56
- constructor({ productId, productBuild, recorderVersion, isDevelopment, groups }: AnalyticsFUSPluginConfig);
57
- trackEvent(category: string, action: string, additionalInfo?: Record<string, unknown>): void;
58
- trackPageView(path: string): void;
37
+ declare class AnalyticsFUSPlugin implements AnalyticsPlugin {
38
+ /**
39
+ * @deprecated
40
+ */
41
+ trackEvent(): void;
42
+ /**
43
+ * @deprecated
44
+ */
45
+ trackPageView(): void;
46
+ /**
47
+ * @deprecated
48
+ */
59
49
  get serializeAdditionalInfo(): boolean;
60
- private _processEvent;
61
50
  }
62
- export {};
51
+ declare const _default: typeof AnalyticsFUSPlugin;
52
+ export default _default;