@atlaskit/analytics-next 9.1.2 → 9.1.3

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 (31) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/version.json +1 -1
  3. package/dist/es2019/version.json +1 -1
  4. package/dist/esm/version.json +1 -1
  5. package/dist/types-ts4.5/components/AnalyticsContext/LegacyAnalyticsContext.d.ts +29 -0
  6. package/dist/types-ts4.5/components/AnalyticsContext/ModernAnalyticsContext.d.ts +3 -0
  7. package/dist/types-ts4.5/components/AnalyticsContext/index.d.ts +3 -0
  8. package/dist/types-ts4.5/components/AnalyticsContext/types.d.ts +9 -0
  9. package/dist/types-ts4.5/components/AnalyticsErrorBoundary.d.ts +24 -0
  10. package/dist/types-ts4.5/components/AnalyticsListener/LegacyAnalyticsListener.d.ts +33 -0
  11. package/dist/types-ts4.5/components/AnalyticsListener/ModernAnalyticsListener.d.ts +3 -0
  12. package/dist/types-ts4.5/components/AnalyticsListener/index.d.ts +3 -0
  13. package/dist/types-ts4.5/components/AnalyticsListener/types.d.ts +12 -0
  14. package/dist/types-ts4.5/events/AnalyticsEvent.d.ts +15 -0
  15. package/dist/types-ts4.5/events/UIAnalyticsEvent.d.ts +20 -0
  16. package/dist/types-ts4.5/hocs/withAnalyticsContext.d.ts +6 -0
  17. package/dist/types-ts4.5/hocs/withAnalyticsEvents.d.ts +12 -0
  18. package/dist/types-ts4.5/hooks/useAnalyticsContext.d.ts +2 -0
  19. package/dist/types-ts4.5/hooks/useAnalyticsEvents.d.ts +5 -0
  20. package/dist/types-ts4.5/hooks/useCallbackWithAnalytics.d.ts +2 -0
  21. package/dist/types-ts4.5/hooks/usePatchedProps.d.ts +5 -0
  22. package/dist/types-ts4.5/hooks/usePlatformLeafEventHandler.d.ts +12 -0
  23. package/dist/types-ts4.5/hooks/usePlatformLeafSyntheticEventHandler.d.ts +11 -0
  24. package/dist/types-ts4.5/hooks/useTrackedRef.d.ts +2 -0
  25. package/dist/types-ts4.5/index.d.ts +25 -0
  26. package/dist/types-ts4.5/performance/examples.d.ts +5 -0
  27. package/dist/types-ts4.5/test-utils/useRenderCounter.d.ts +1 -0
  28. package/dist/types-ts4.5/types.d.ts +6 -0
  29. package/dist/types-ts4.5/utils/cleanProps.d.ts +3 -0
  30. package/dist/types-ts4.5/utils/createAndFireEvent.d.ts +4 -0
  31. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/analytics-next
2
2
 
3
+ ## 9.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
8
+
3
9
  ## 9.1.2
4
10
 
5
11
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/analytics-next",
3
- "version": "9.1.2",
3
+ "version": "9.1.3",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/analytics-next",
3
- "version": "9.1.2",
3
+ "version": "9.1.3",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/analytics-next",
3
- "version": "9.1.2",
3
+ "version": "9.1.3",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,29 @@
1
+ import React, { Component } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { AnalyticsReactContextInterface } from '@atlaskit/analytics-next-stable-react-context';
4
+ interface Props {
5
+ /** Children! */
6
+ children: React.ReactNode;
7
+ /** Arbitrary data. Any events created below this component in the tree will
8
+ * have this added as an item in their context array. */
9
+ data: Object;
10
+ }
11
+ declare class AnalyticsContext extends Component<Props, AnalyticsReactContextInterface> {
12
+ static contextTypes: {
13
+ getAtlaskitAnalyticsContext: PropTypes.Requireable<(...args: any[]) => any>;
14
+ getAtlaskitAnalyticsEventHandlers: PropTypes.Requireable<(...args: any[]) => any>;
15
+ };
16
+ static childContextTypes: {
17
+ getAtlaskitAnalyticsContext: PropTypes.Requireable<(...args: any[]) => any>;
18
+ getAtlaskitAnalyticsEventHandlers: PropTypes.Requireable<(...args: any[]) => any>;
19
+ };
20
+ contextValue: AnalyticsReactContextInterface;
21
+ constructor(props: Props);
22
+ getChildContext: () => {
23
+ getAtlaskitAnalyticsContext: () => any[];
24
+ };
25
+ getAnalyticsContext: () => any[];
26
+ getAnalyticsEventHandlers: () => any;
27
+ render(): JSX.Element;
28
+ }
29
+ export default AnalyticsContext;
@@ -0,0 +1,3 @@
1
+ import { AnalyticsContextFunction } from './types';
2
+ declare const AnalyticsContext: AnalyticsContextFunction;
3
+ export default AnalyticsContext;
@@ -0,0 +1,3 @@
1
+ import { AnalyticsContextFunction } from './types';
2
+ declare let ExportedAnalyticsContext: AnalyticsContextFunction;
3
+ export default ExportedAnalyticsContext;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { AnalyticsReactContextInterface } from '@atlaskit/analytics-next-stable-react-context';
3
+ export type AnalyticsContextFunction = (props: {
4
+ /** Children! */
5
+ children: React.ReactNode;
6
+ /** Arbitrary data. Any events created below this component in the tree will
7
+ * have this added as an item in their context array. */
8
+ data: Object;
9
+ }, context?: AnalyticsReactContextInterface) => JSX.Element;
@@ -0,0 +1,24 @@
1
+ import React, { Component, ReactNode } from 'react';
2
+ type AnalyticsErrorBoundaryErrorInfo = {
3
+ componentStack: string;
4
+ };
5
+ export interface AnalyticsErrorBoundaryProps {
6
+ /** React component to be wrapped */
7
+ children: ReactNode;
8
+ channel: string;
9
+ data: {};
10
+ ErrorComponent?: React.ComponentType;
11
+ onError?: (error: Error, info?: AnalyticsErrorBoundaryErrorInfo) => void;
12
+ }
13
+ type AnalyticsErrorBoundaryState = {
14
+ hasError: boolean;
15
+ };
16
+ /**
17
+ * @deprecated
18
+ */
19
+ export default class AnalyticsErrorBoundary extends Component<AnalyticsErrorBoundaryProps, AnalyticsErrorBoundaryState> {
20
+ constructor(props: AnalyticsErrorBoundaryProps);
21
+ componentDidCatch(error: Error, info?: AnalyticsErrorBoundaryErrorInfo): void;
22
+ render(): JSX.Element | null;
23
+ }
24
+ export {};
@@ -0,0 +1,33 @@
1
+ import React, { Component } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { AnalyticsReactContextInterface } from '@atlaskit/analytics-next-stable-react-context';
4
+ import UIAnalyticsEvent from '../../events/UIAnalyticsEvent';
5
+ type Props = {
6
+ /** Children! */
7
+ children?: React.ReactNode;
8
+ /** The channel to listen for events on. */
9
+ channel?: string;
10
+ /** A function which will be called when an event is fired on this Listener's
11
+ * channel. It is passed the event and the channel as arguments. */
12
+ onEvent: (event: UIAnalyticsEvent, channel?: string) => void;
13
+ };
14
+ declare class AnalyticsListener extends Component<Props> {
15
+ static contextTypes: {
16
+ getAtlaskitAnalyticsEventHandlers: PropTypes.Requireable<(...args: any[]) => any>;
17
+ getAtlaskitAnalyticsContext: PropTypes.Requireable<(...args: any[]) => any>;
18
+ };
19
+ static childContextTypes: {
20
+ getAtlaskitAnalyticsEventHandlers: PropTypes.Requireable<(...args: any[]) => any>;
21
+ getAtlaskitAnalyticsContext: PropTypes.Requireable<(...args: any[]) => any>;
22
+ };
23
+ contextValue: AnalyticsReactContextInterface;
24
+ constructor(props: Props);
25
+ getChildContext: () => {
26
+ getAtlaskitAnalyticsEventHandlers: () => any[];
27
+ getAtlaskitAnalyticsContext: () => any;
28
+ };
29
+ getAnalyticsEventHandlers: () => any[];
30
+ getAtlaskitAnalyticsContext: () => any;
31
+ render(): JSX.Element;
32
+ }
33
+ export default AnalyticsListener;
@@ -0,0 +1,3 @@
1
+ import { AnalyticsListenerFunction } from './types';
2
+ declare const AnalyticsListener: AnalyticsListenerFunction;
3
+ export default AnalyticsListener;
@@ -0,0 +1,3 @@
1
+ import { AnalyticsListenerFunction } from './types';
2
+ declare let ExportedAnalyticsListener: AnalyticsListenerFunction;
3
+ export default ExportedAnalyticsListener;
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { AnalyticsReactContextInterface } from '@atlaskit/analytics-next-stable-react-context';
3
+ import UIAnalyticsEvent from '../../events/UIAnalyticsEvent';
4
+ export type AnalyticsListenerFunction = (props: {
5
+ /** Children! */
6
+ children?: React.ReactNode;
7
+ /** The channel to listen for events on. */
8
+ channel?: string;
9
+ /** A function which will be called when an event is fired on this Listener's
10
+ * channel. It is passed the event and the channel as arguments. */
11
+ onEvent: (event: UIAnalyticsEvent, channel?: string) => void;
12
+ }, context?: AnalyticsReactContextInterface) => JSX.Element;
@@ -0,0 +1,15 @@
1
+ export type AnalyticsEventPayload = Record<string, any>;
2
+ type AnalyticsEventCallback = (payload: AnalyticsEventPayload) => AnalyticsEventPayload;
3
+ type AnalyticsEventUpdater = AnalyticsEventPayload | AnalyticsEventCallback;
4
+ export type AnalyticsEventProps = {
5
+ payload: AnalyticsEventPayload;
6
+ };
7
+ export declare const isAnalyticsEvent: (obj: any) => boolean;
8
+ export default class AnalyticsEvent {
9
+ payload: AnalyticsEventPayload;
10
+ _isAnalyticsEvent: boolean;
11
+ constructor(props: AnalyticsEventProps);
12
+ clone: () => AnalyticsEvent | null;
13
+ update(updater: AnalyticsEventUpdater): this;
14
+ }
15
+ export {};
@@ -0,0 +1,20 @@
1
+ import AnalyticsEvent, { AnalyticsEventPayload, AnalyticsEventProps } from './AnalyticsEvent';
2
+ type ChannelIdentifier = string;
3
+ type Context = Record<string, any>[];
4
+ export type UIAnalyticsEventHandler = (event: UIAnalyticsEvent, channel?: ChannelIdentifier) => void;
5
+ export type UIAnalyticsEventProps = AnalyticsEventProps & {
6
+ context?: Context;
7
+ handlers?: UIAnalyticsEventHandler[];
8
+ };
9
+ export declare const isUIAnalyticsEvent: (obj: any) => boolean;
10
+ export default class UIAnalyticsEvent extends AnalyticsEvent {
11
+ context: Context;
12
+ handlers: UIAnalyticsEventHandler[];
13
+ hasFired: boolean;
14
+ _isUIAnalyticsEvent: boolean;
15
+ constructor(props: UIAnalyticsEventProps);
16
+ clone: () => UIAnalyticsEvent | null;
17
+ fire: (channel?: string) => void;
18
+ update(updater: Record<string, any> | ((payload: AnalyticsEventPayload) => AnalyticsEventPayload)): this;
19
+ }
20
+ export {};
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export interface WithContextProps {
3
+ analyticsContext?: Record<string, any>;
4
+ }
5
+ declare const withAnalyticsContext: (defaultData?: any) => <Props, Component>(WrappedComponent: React.JSXElementConstructor<Props> & Component) => React.ForwardRefExoticComponent<React.PropsWithoutRef<JSX.LibraryManagedAttributes<Component, Props & WithContextProps>> & React.RefAttributes<any>>;
6
+ export default withAnalyticsContext;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { CreateEventMap, CreateUIAnalyticsEvent } from '../types';
3
+ export interface WithAnalyticsEventsProps {
4
+ /**
5
+ * You should not be accessing this prop under any circumstances.
6
+ * It is provided by `@atlaskit/analytics-next` and integrated in the component
7
+ */
8
+ createAnalyticsEvent?: CreateUIAnalyticsEvent;
9
+ ref?: React.Ref<any>;
10
+ }
11
+ declare const withAnalyticsEvents: (createEventMap?: CreateEventMap) => <Props extends WithAnalyticsEventsProps, Component>(WrappedComponent: React.JSXElementConstructor<Props> & Component) => React.ForwardRefExoticComponent<React.PropsWithoutRef<JSX.LibraryManagedAttributes<Component, Omit<Props, keyof WithAnalyticsEventsProps>>> & React.RefAttributes<any>>;
12
+ export default withAnalyticsEvents;
@@ -0,0 +1,2 @@
1
+ import { AnalyticsReactContextInterface } from '@atlaskit/analytics-next-stable-react-context';
2
+ export declare const useAnalyticsContext: () => AnalyticsReactContextInterface;
@@ -0,0 +1,5 @@
1
+ import { CreateUIAnalyticsEvent } from '../types';
2
+ export type UseAnalyticsEventsHook = {
3
+ createAnalyticsEvent: CreateUIAnalyticsEvent;
4
+ };
5
+ export declare function useAnalyticsEvents(): UseAnalyticsEventsHook;
@@ -0,0 +1,2 @@
1
+ export type UseCallbackWithAnalyticsHook = (method: (...args: any[]) => void, payload: Record<string, any> | ((...args: any[]) => void), channel?: string) => (...args: any[]) => void;
2
+ export declare const useCallbackWithAnalytics: UseCallbackWithAnalyticsHook;
@@ -0,0 +1,5 @@
1
+ import { CreateEventMap } from '../types';
2
+ export type PatchedPropsHook = {
3
+ patchedEventProps: CreateEventMap;
4
+ };
5
+ export declare function usePatchedProps<Props extends Record<string, any>>(createEventMap: CreateEventMap | undefined, wrappedComponentProps: Props): PatchedPropsHook;
@@ -0,0 +1,12 @@
1
+ import UIAnalyticsEvent from '../events/UIAnalyticsEvent';
2
+ export type UsePlatformLeafEventHandlerHookArgs<T> = {
3
+ fn: (value: T, analyticsEvent: UIAnalyticsEvent) => void;
4
+ action: string;
5
+ componentName: string;
6
+ actionSubject?: string;
7
+ packageName: string;
8
+ packageVersion: string;
9
+ analyticsData?: Record<string, any>;
10
+ };
11
+ export type UsePlatformLeafEventHandlerHook<T> = (value: T) => void;
12
+ export declare function usePlatformLeafEventHandler<T>({ fn, action, componentName, actionSubject, packageName, packageVersion, analyticsData, }: UsePlatformLeafEventHandlerHookArgs<T>): (value: T) => void;
@@ -0,0 +1,11 @@
1
+ import UIAnalyticsEvent from '../events/UIAnalyticsEvent';
2
+ export type UsePlatformLeafSyntheticEventHandlerHookArgs = {
3
+ fn: (analyticsEvent: UIAnalyticsEvent) => void;
4
+ action: string;
5
+ componentName: string;
6
+ packageName: string;
7
+ packageVersion: string;
8
+ analyticsData?: Record<string, any>;
9
+ };
10
+ export type UsePlatformLeafSyntheticEventHandlerHook = () => void;
11
+ export declare function usePlatformLeafSyntheticEventHandler({ fn, action, componentName, packageName, packageVersion, analyticsData, }: UsePlatformLeafSyntheticEventHandlerHookArgs): () => void;
@@ -0,0 +1,2 @@
1
+ import { MutableRefObject } from 'react';
2
+ export declare const useTrackedRef: <T>(value: T) => MutableRefObject<T>;
@@ -0,0 +1,25 @@
1
+ export type { CreateUIAnalyticsEvent } from './types';
2
+ export { default as AnalyticsEvent, isAnalyticsEvent, } from './events/AnalyticsEvent';
3
+ export type { AnalyticsEventPayload, AnalyticsEventProps, } from './events/AnalyticsEvent';
4
+ export { default as UIAnalyticsEvent, isUIAnalyticsEvent, } from './events/UIAnalyticsEvent';
5
+ export type { UIAnalyticsEventProps, UIAnalyticsEventHandler, } from './events/UIAnalyticsEvent';
6
+ export { default as AnalyticsListener } from './components/AnalyticsListener/index';
7
+ export { default as AnalyticsContext } from './components/AnalyticsContext/index';
8
+ export { default as withAnalyticsContext } from './hocs/withAnalyticsContext';
9
+ export type { WithContextProps } from './hocs/withAnalyticsContext';
10
+ export { default as AnalyticsErrorBoundary } from './components/AnalyticsErrorBoundary';
11
+ export type { AnalyticsErrorBoundaryProps } from './components/AnalyticsErrorBoundary';
12
+ export { default as withAnalyticsEvents } from './hocs/withAnalyticsEvents';
13
+ export type { WithAnalyticsEventsProps } from './hocs/withAnalyticsEvents';
14
+ export { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';
15
+ export type { AnalyticsReactContextInterface } from '@atlaskit/analytics-next-stable-react-context';
16
+ export { useAnalyticsEvents } from './hooks/useAnalyticsEvents';
17
+ export type { UseAnalyticsEventsHook } from './hooks/useAnalyticsEvents';
18
+ export { useCallbackWithAnalytics } from './hooks/useCallbackWithAnalytics';
19
+ export type { UseCallbackWithAnalyticsHook } from './hooks/useCallbackWithAnalytics';
20
+ export { usePlatformLeafEventHandler } from './hooks/usePlatformLeafEventHandler';
21
+ export type { UsePlatformLeafEventHandlerHookArgs, UsePlatformLeafEventHandlerHook, } from './hooks/usePlatformLeafEventHandler';
22
+ export { usePlatformLeafSyntheticEventHandler } from './hooks/usePlatformLeafSyntheticEventHandler';
23
+ export type { UsePlatformLeafSyntheticEventHandlerHookArgs, UsePlatformLeafSyntheticEventHandlerHook, } from './hooks/usePlatformLeafSyntheticEventHandler';
24
+ export { default as createAndFireEvent } from './utils/createAndFireEvent';
25
+ export { default as cleanProps } from './utils/cleanProps';
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export declare const UsePlatformLeafEventHandlerHookTest: () => JSX.Element;
3
+ export declare const UseAnalyticsEventHookTest: () => JSX.Element;
4
+ export declare const UseCallbackWithAnalyticsHookTest: () => JSX.Element;
5
+ export declare const HOCSTest: () => JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const useRenderCounter: () => number;
@@ -0,0 +1,6 @@
1
+ import { AnalyticsEventPayload } from './events/AnalyticsEvent';
2
+ import UIAnalyticsEvent from './events/UIAnalyticsEvent';
3
+ export type CreateUIAnalyticsEvent = (payload: AnalyticsEventPayload) => UIAnalyticsEvent;
4
+ export type AnalyticsEventCreator = (create: CreateUIAnalyticsEvent, props: Record<string, any>) => UIAnalyticsEvent | undefined;
5
+ export type CreateEventMapValue = AnalyticsEventPayload | AnalyticsEventCreator;
6
+ export type CreateEventMap = Record<string, CreateEventMapValue>;
@@ -0,0 +1,3 @@
1
+ export default function cleanProps(props: Record<string, any>): {
2
+ [x: string]: any;
3
+ };
@@ -0,0 +1,4 @@
1
+ import { AnalyticsEventPayload } from '../events/AnalyticsEvent';
2
+ import { CreateUIAnalyticsEvent } from '../types';
3
+ declare const _default: (channel?: string) => (payload: AnalyticsEventPayload) => (createAnalyticsEvent: CreateUIAnalyticsEvent) => import("..").UIAnalyticsEvent;
4
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/analytics-next",
3
- "version": "9.1.2",
3
+ "version": "9.1.3",
4
4
  "description": "React components, HOCs and hooks to assist with tracking user activity with React components",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"