Analytics-next
Tools for tracking interactions with UI components. Easily capture UI context and state when these events occur.
Installation
yarn add @kalamazoo/analytics-nextUsage
Detailed docs and example usage can be found here.
The 🆕 Atlaskit component analytics framework
Tools for tracking interactions with UI components. Easily capture UI context and state when these events occur.
yarn add @kalamazoo/analytics-nextDetailed docs and example usage can be found here.
[patch]6940a2107f:
Removes cycle in internal components.
[patch]24865cfaff:
Fixes useAnalyticsEvents() not having a stable function reference.- [patch]24865cfaff:
Fixes data type to Object- Updated dependencies 24865cfaff:
[patch]768bac6d81:
Remove redundant object check (which was previously required to appease type checking)
[patch]35d2229b2a:
Adding missing license to packages and update to Copyright 2019 Atlassian Pty Ltd.
[minor]2252a7a999:
Bug fix for using the hook with nested contexts, performance improvements, new useAnalyticsEventsCallback hook to provide a performance enhanced-abstraction for firing events with a callback.
[minor]42fd897e16:
useAnalyticsEvents_experimental, for creating analytics events within functional components. This hook replaces the need for the withAnalyticsEvents HOC. See the Reference documentation for details on how to use this new hook.[minor]c6efb2f5b6:
Prefix the legacy lifecycle methods with UNSAFE_* to avoid warning in React 16.9+
More information about the deprecation of lifecycles methods can be found here: https://reactjs.org/blog/2018/03/29/react-v-16-3.html#component-lifecycle-changes
[patch]097b696613:
Components now depend on TS 3.6 internally, in order to fix an issue with TS resolving non-relative imports as relative imports
[patch]ecca4d1dbb:
Upgraded Typescript to 3.3.x
[patch]de35ce8c67:
Updates component maintainers
[major]926b43142b:
Analytics-next has been converted to Typescript. Typescript consumers will now get static type safety. Flow types are no longer provided. No behavioural changes.
Breaking changes
withAnalyticsForSumTypeProps alias has been removed, please use withAnalyticsEventsAnalyticsContextWrappedComp alias has been removed, please use withAnalyticsContextBreaking changes to TypeScript annotations
withAnalyticsEvents now infers proptypes automatically, consumers no longer need to provide props as a generic type.withAnalyticsContext now infers proptypes automatically, consumers no longer need to provide props as a generic type.WithAnalyticsEventProps has been renamed to WithAnalyticsEventsProps to match source codeCreateUIAnalyticsEventSignature has been renamed to CreateUIAnalyticsEvent to match source codeUIAnalyticsEventHandlerSignature has been renamed to UIAnalyticsEventHandler to match source codeAnalyticsEventsPayload has been renamed to AnalyticsEventPayloadObjectType has been removed, please use Record<string, any> or [key: string]: anyUIAnalyticsEventInterface has been removed, please use UIAnalyticsEventAnalyticsEventInterface has been removed, please use AnalyticsEventCreateAndFireEventFunction removed and should now be inferred by TypeScriptAnalyticsEventUpdater removed and should now be inferred by TypeScript[patch]1439241943:
Adding error boundary in media picker dropzone
[minor]e1f8aaf33b:
AnalyticsErrorBoundary package// How to use
// Import via entry point
import AnalyticsListener from '@kalamazoo/analytics-next/AnalyticsListener';
import AnalyticsErrorBoundary from '@kalamazoo/analytics-next/AnalyticsErrorBoundary';
// Wrapping your component with the component
class ButtonWithAnalyticsErrorBoundary extends React.Component {
handleEvent = (analyticsEvent) => {
const { payload, context } = analyticsEvent;
console.log('Received event:', analyticsEvent, { payload, context });
};
render() {
return (
<AnalyticsListener channel="atlaskit" onEvent={this.handleEvent}>
<AnalyticsErrorBoundary
channel="atlaskit"
data={{
componentName: 'button',
packageName: '@kalamazoo/button',
componentVersion: '999.9.9',
}}
>
<Button>Click me</Button>
</AnalyticsErrorBoundary>
</AnalyticsListener>
)
}
}Notes on new API:
AnalyticsListener as a top level component to work properly, otherwise it won't trigger analytics events.[patch]281451e6dc:
Republishing package to export AnalyticsErrorBoundaryProps
[minor]ed9ae90c94:
Adding Analytics Error Boundary component
[minor]8fcbe23ec6:
Updated types for analytics-next and buttons to make them easier to consume
[patch]c6ad66d326:
The types property in package.json now points to the correct file"
[patch]9f8ab1084b:
Consume analytics-next ts type definitions as an ambient declaration.
[patch]6ea9bb7873:
analytics-next now exports an ambient module declaration which resolves an issue with types being required via relative imports
[minor]d0db01b410:
TypeScript users of withAnalyticsEvents and withAnalyticsContext are now required to provide props as a generic type. This is so that TypeScript can correctly calculate the props and defaultProps of the returned component.
Before:
withAnalyticsEvents()(Button) as ComponentClass<Props>;After:
withAnalyticsEvents<Props>()(Button);[patch]4615439434:
index.ts will now be ignored when publishing to npm
[patch]47acb57783:
[major]7c17b35107:
[patch]3f28e6443c:
[patch]9321da655d:
[patch]98e11001ff:
[major]76299208e6:
As a breaking change, all @atlaskit packages will be dropping cjs distributions and will only distribute esm. This means all distributed code will be transpiled, but will still contain import and
export declarations.
The major reason for doing this is to allow us to support multiple entry points in packages, e.g:
import colors from `@kalamazoo/theme/colors`;Previously this was sort of possible for consumers by doing something like:
import colors from `@kalamazoo/theme/dist/esm/colors`;This has a couple of issues. 1, it treats the file system as API making internal refactors harder, we have to worry about how consumers might be using things that aren't actually supposed to be used. 2. We are unable to do this internally in @atlaskit packages. This leads to lots of packages bundling all of theme, just to use a single color, especially in situations where tree shaking fails.
To support being able to use multiple entrypoints internally, we unfortunately cannot have multiple distributions as they would need to have very different imports from of their own internal dependencies.
ES Modules are widely supported by all modern bundlers and can be worked around in node environments.
We may choose to revisit this solution in the future if we find any unintended condequences, but we see this as a pretty sane path forward which should lead to some major bundle size decreases, saner API's and simpler package architecture.
Please reach out to #fabric-build (if in Atlassian) or create an issue in Design System Support (for external) if you have any questions or queries about this.
[patch]8de4c3f:
[minor]c3fa0b6:
[minor]cffeed0:
Type withAnalyticsEvents and withAnalyticsContext HOCs so that they do not lose flow types of the components they wrap when chained together.
This will fix flow types not flowing through all of the components that we have instrumented with analytics as they are typically wrapped with both HOCs. To get flow types flowing through your components again, upgrade them to the latest version and also update their @kalamazoo/analytics-next dependency to the latest version.
We also now export AnalyticsContextWrappedComp and AnalyticsEventsWrappedComp parameterised types that allow you to explicitly type components wrapped with these HOCs which is necessary in cases where the HOC wrapping is extracted into another function.
[patch]d903ab5: