Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@atlaskit/analytics-next

atlassian932.1kApache-2.011.1.3TypeScript support: included

React components, HOCs and hooks to assist with tracking user activity with React components

readme

Analytics-next

Tools for tracking interactions with UI components. Easily capture UI context and state when these events occur.

Maintaince Mode: \ This package is officially in maintenance mode, which means only bugfixes or VULN fixes are currently being accepted and no known breaking changes will be approved in the PR process. \ Please refer to this DACI for more details.

Installation

yarn add @atlaskit/analytics-next

Usage

Detailed docs and example usage can be found here.

changelog

@atlaskit/analytics-next

11.1.3

Patch Changes

  • 2752a069d8a01 - Cleaning up feature flag changes that remove the legacy contextTypes API, which is deprecated and will be removed in the next major React release.

11.1.2

Patch Changes

  • 604dd578f00d9 - Types the withAnalyticsEvents WrappedComponent as allowing a forwardRefExoticComponent

11.1.1

Patch Changes

  • 3298a6307027c - Sorted type and interface props to improve Atlaskit docs

11.1.0

Minor Changes

  • #157108 ad595df3d2ec0 - We are testing the migration to the ADS Link component behind a feature flag. If this fix is successful it will be available in a later release.

11.0.0

Major Changes

10.3.1

Patch Changes

  • Updated dependencies

10.3.0

Minor Changes

10.2.1

Patch Changes

  • #179607 ec8b221900f5c - Adds a package.json#overrides in hopes that it will override the peerDependencies of @atlaskit/analytics-next-stable-react-context (NOTE: This may not work across all platforms and was only tested in one scenario, but should have zero impact if it doesn't work)

10.2.0

Minor Changes

  • #176214 c0c1a54579ce7 - Set @atlaskit/analytics deprecated and move functions to @atlaskit/analytics-next

10.1.1

Patch Changes

10.1.0

Minor Changes

  • #127511 db30e29344013 - Widening range of react and react-dom peer dependencies from ^16.8.0 || ^17.0.0 || ~18.2.0 to the wider range of ^16.8.0 || ^17.0.0 || ^18.0.0` (where applicable).

    This change has been done to enable usage of `react@18.3as well as to have a consistent peer dependency range forreactandreact-domfor/platform` packages.

10.0.0

Major Changes

9.3.4

Patch Changes

9.3.3

Patch Changes

9.3.2

Patch Changes

9.3.1

Patch Changes

  • Updated dependencies

9.3.0

Minor Changes

9.2.3

Patch Changes

  • #87314 36ccb66917fb - Fix a bug in ModernAnalyticsContext when it's bit late to update data in new React context when mounting a component

9.2.2

Patch Changes

9.2.1

Patch Changes

9.2.0

Minor Changes

9.1.4

Patch Changes

9.1.3

Patch Changes

9.1.2

Patch Changes

9.1.1

Patch Changes

9.1.0

Minor Changes

9.0.2

Patch Changes

9.0.1

Patch Changes

  • #32312 fbff320b423 - Move package to continuous model and to push model consumption

9.0.0

Major Changes

  • #29470 cf21f06ff72 - Bugfix, removed sending event fn and deprecated AnalyticErrorBoundary

8.3.5

Patch Changes

8.3.4

Patch Changes

8.3.3

Patch Changes

8.3.2

Patch Changes

8.3.1

Patch Changes

8.3.0

Minor Changes

  • #14012 37fd554209e - Add instance checks for analytics events in analytics-next. Update check in mpt-analytics for events too.

8.2.1

Patch Changes

  • #12837 a4420ad5104 - Improves referential stability of analytics-next wrapped callbacks

8.2.0

Minor Changes

  • #12328 0dbf0427287 - [ux] Added new optional props to allow executing on catching error and rendering an error screen on error

8.1.4

Patch Changes

8.1.3

Patch Changes

  • #10230 5a9b102eef0 - Add optional actionSubject parameter to usePlatformLeafHandlerHook

8.1.2

Patch Changes

8.1.1

Patch Changes

8.1.0

Minor Changes

  • #5693 4eb71695b5 - Added usePlatformLeafSyntheticEventHandler, which acts similarly to usePlatformLeafEventHandler but is used for synthetic events where the event handler takes no value prop

8.0.2

Patch Changes

  • #5497 5f58283e1f - Export types using Typescript's new "export type" syntax to satisfy Typescript's --isolatedModules compiler option. This requires version 3.8 of Typescript, read more about how we handle Typescript versions here: https://atlaskit.atlassian.com/get-started Also add typescript to devDependencies to denote version that the package was built with.

8.0.1

Patch Changes

8.0.0

Major Changes

  • #5344 b485472340 - Export WithContextProps type to prevent deep import path references in dependent packages declaration output.

    Released as a major to prevent existing Atlaskit dependencies that use analytics-next from breaking when analytics-next file structure changes in the future.

7.1.1

Patch Changes

  • #5164 2ac834240e - Undo analytics-next file restructure to allow external ts definitions to continue working

7.1.0

Minor Changes

  • #4749 0e2a914932 - ### Additions

    • Added a new hook useAnalyticsEventHandler for sole use in Atlaskit components

    Removals

    • Removed some entry points that were unintentionally exposed
      • AnalyticsContextConsumer
      • withAnalyticsHook
      • usePatchedProps
      • cleanProps
      • AnalyticsReactContext
      • AnalyticsEventMap

    Improvements

    • Optimization of components to prevent unnecessary re-renders via inline callbacks or jsons
    • Conversion to Function Components where possible
    • Preparation for dropping legacy React context in a future major release (see note below)
    • Documentation improvements
    • Improved directory structure
    • Adoption of new standards

    IMPORTANT: Note on React Context changes

    (Legacy React context)[https://reactjs.org/docs/legacy-context.html] will be removed in a future version of React.

    In addition its presence can be (problematic for performance)[https://twitter.com/dan_abramov/status/1064559184010723330].

    As a result, we have taken steps to migrate away from it and use the new (React Context API)[https://reactjs.org/docs/context.html].

    To achieve this we are rolling the drop out in 2 phases:

    Phase I (this release)

    We have changed analytics components to receive modern context. Listeners and the Context layer will provide both modern and legacy context by default.

    At their own risk, package consumers can opt in to no longer supply legacy context by using the environment variable ANALYTICS_NEXT_MODERN_CONTEXT=true.

    When doing so, any analytics consumers that rely on legacy context will not receive any, and events may be lost! This would happen when using old atlaskit packages that consume a version of @atlaskit/analytics-next before this version.

    Phase II (future major)

    In a future release (TBA) we will remove all legacy context support and clean up the branching around ANALYTICS_NEXT_MODERN_CONTEXT. After this point, @atlaskit/analytics-next will not work with components that use a version prior to this one.

Patch Changes

  • 967279b3f8 - Fix for type names that ship with new hook

7.0.3

Patch Changes

  • #3885 6c525a8229 - Upgraded to TypeScript 3.9.6 and tslib to 2.0.0

    Since tslib is a dependency for all our packages we recommend that products also follow this tslib upgrade to prevent duplicates of tslib being bundled.

  • Updated dependencies

7.0.2

Patch Changes

  • #4344 723a322186 - Hotfix to have a stable react context across multiple versions of @atlaskit/analytics-next

7.0.1

Patch Changes

  • #3428 bff2f273bf - useAnalyticsEvents will no longer log errors when used without an AnalyticsListerner or AnalyticsContext

7.0.0

Major Changes

6.3.6

Patch Changes

6.3.5

Patch Changes

6.3.4

Patch Changes

  • [patch]6940a2107f:

    Removes cycle in internal components.

6.3.3

Patch Changes

6.3.2

Patch Changes

  • [patch]768bac6d81:

    Remove redundant object check (which was previously required to appease type checking)

6.3.1

Patch Changes

  • [patch]35d2229b2a:

    Adding missing license to packages and update to Copyright 2019 Atlassian Pty Ltd.

6.3.0

Minor Changes

  • [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.

6.2.0

Minor Changes

  • [minor]42fd897e16:

    • Introduces a new custom React hook, 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.

6.1.0

Minor Changes

6.0.3

Patch 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

6.0.2

Patch Changes

6.0.1

Patch Changes

  • [patch]de35ce8c67:

    Updates component maintainers

6.0.0

Major Changes

  • [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 withAnalyticsEvents
    • AnalyticsContextWrappedComp alias has been removed, please use withAnalyticsContext

    Breaking 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.
    • Type WithAnalyticsEventProps has been renamed to WithAnalyticsEventsProps to match source code
    • Type CreateUIAnalyticsEventSignature has been renamed to CreateUIAnalyticsEvent to match source code
    • Type UIAnalyticsEventHandlerSignature has been renamed to UIAnalyticsEventHandler to match source code
    • Type AnalyticsEventsPayload has been renamed to AnalyticsEventPayload
    • Type ObjectType has been removed, please use Record<string, any> or [key: string]: any
    • Type UIAnalyticsEventInterface has been removed, please use UIAnalyticsEvent
    • Type AnalyticsEventInterface has been removed, please use AnalyticsEvent
    • Type CreateAndFireEventFunction removed and should now be inferred by TypeScript
    • Type AnalyticsEventUpdater removed and should now be inferred by TypeScript

5.4.1

Patch Changes

  • [patch]1439241943:

    Adding error boundary in media picker dropzone

5.4.0

Minor Changes

  • [minor]e1f8aaf33b:

    • Adding entry point for AnalyticsErrorBoundary package
    // How to use
    
    // Import via entry point
    import AnalyticsListener from '@atlaskit/analytics-next/AnalyticsListener';
    import AnalyticsErrorBoundary from '@atlaskit/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: '@atlaskit/button',
                componentVersion: '999.9.9',
              }}
            >
              <Button>Click me</Button>
            </AnalyticsErrorBoundary>
          </AnalyticsListener>
        )
      }
    }

    Notes on new API:

    • Plug-and-play component. As soon and it's wrapping a component it's fully integrated.
    • It has Analytics context and events integrated already. Keep in mind it requires AnalyticsListener as a top level component to work properly, otherwise it won't trigger analytics events.

5.3.1

Patch Changes

  • [patch]281451e6dc:

    Republishing package to export AnalyticsErrorBoundaryProps

5.3.0

Minor Changes

  • [minor]ed9ae90c94:

    Adding Analytics Error Boundary component

5.2.0

Minor Changes

  • [minor]8fcbe23ec6:

    Updated types for analytics-next and buttons to make them easier to consume

5.1.3

Patch Changes

  • [patch]c6ad66d326:

    The types property in package.json now points to the correct file"

5.1.2

Patch Changes

  • [patch]9f8ab1084b:

    Consume analytics-next ts type definitions as an ambient declaration.

5.1.1

Patch Changes

  • [patch]6ea9bb7873:

    analytics-next now exports an ambient module declaration which resolves an issue with types being required via relative imports

5.1.0

Minor Changes

  • [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);

5.0.2

Patch Changes

  • [patch]4615439434:

    index.ts will now be ignored when publishing to npm

5.0.1

Patch Changes

  • [patch]47acb57783:

    • Avoid unnecessary re-renders on components that use withAnalytics

5.0.0

  • [major]7c17b35107:

    • Updates react and react-dom peer dependencies to react@^16.8.0 and react-dom@^16.8.0. To use this package, please ensure you use at least this version of react and react-dom.

4.0.5

  • [patch]3f28e6443c:

    • @atlaskit/analytics-next-types is deprecated. Now you can use types for @atlaskit/analytics-next supplied from itself.

4.0.4

  • [patch]9321da655d:

    • Update AnalyticsEventMap, as per major inline edit rewrite

4.0.3

4.0.2

  • [patch]98e11001ff:

    • Removes duplicate babel-runtime dependency

4.0.1

4.0.0

  • [major]76299208e6:

    • Drop ES5 from all the flow modules

    Dropping CJS support in all @atlaskit packages

    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 `@atlaskit/theme/colors`;

    Previously this was sort of possible for consumers by doing something like:

    import colors from `@atlaskit/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.

3.2.1

  • [patch]8de4c3f:

    • Added missing export

3.2.0

  • [minor]c3fa0b6:

    • Added support for props of Sum type

3.1.2

3.1.1

3.1.0

  • [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 @atlaskit/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.

3.0.11

  • [patch]d903ab5:

    • Updates list of instrumented components

3.0.10

  • [patch] Adds missing implicit @babel/runtime dependency b71751b

3.0.9

  • [patch] adds missing babel-runtime dependency to package json 93b031a

3.0.8

  • [patch] Fixing analytics events for checkbox/radio/select 3e428e3

3.0.7

  • [patch] Loosen AnalyticsEventPayload type to cater for Screen events 2d4b52e

3.0.5

  • [patch] Loosen AnalyticsEventCreator return type f7432a2
  • [none] Updated dependencies f7432a2

3.0.4

3.0.3

3.0.2

3.0.1

3.0.0

2.1.9

  • [patch] removes requirement of children to be a single React node 53cba6b
  • [none] Updated dependencies 53cba6b

2.1.8

2.1.7

2.1.6

  • [patch] Unpublish fake TS declaration file ec9f11f
  • [none] Updated dependencies ec9f11f

2.1.5

2.1.4

2.1.3

  • [patch] Removed ambient typescript type declaration file from analytics-next - this may be a breaking change for typescript consumers 290d804
  • [none] Updated dependencies 290d804

2.1.2

  • [patch] Fix prop callbacks specified in the create event map to not change reference values each render and instead only update when the original prop callback changes 586a80c
  • [none] Updated dependencies 586a80c

2.1.1

2.1.0

  • [minor] Export cleanProps function that can be used to strip analytics props provided by our HOCs, useful when spreading props to a child element 973d6ea

2.0.0

  • [major] Bump to React 16.3. 4251858

1.1.10

  • [patch] Adjusted exports to prevent attempted exporting of flow types in built code. 183ee96

1.1.9

  • [patch] Updates flow types of withAnalyticsEvents and withAnalyticsContext HOCs 26778bc
  • [patch] Uses element config flow type with button deprecation warnings hoc a9aa90a

1.1.8

  • [patch] Add "sideEffects: false" to AKM2 packages to allow consumer's to tree-shake c3b018a

1.1.7

  • [patch] Fix/revert TS TDs in analytics-next 1284d32

1.1.6

  • [patch] Fix analytics-next TS type definition 9faaa5f
  • [patch] Fix analytics-next TS type definition 7e26229

1.1.5

  • [patch] Add analytics events for click and show actions of media-card 031d5da
  • [patch] Add analytics events for click and show actions of media-card b361185

1.1.4

  • [patch] fixes problem with withAnalyticsEvents HOC passing old function props to wrapped component c88b030

1.1.3

  • [patch] adds displayName to analytics HOCs f69ccad

1.1.2

  • [patch] Re-releasing due to potentially broken babel release 9ed0bba

1.1.1

  • [patch] Remove min requirement of node 8 for analytics-next c864671

1.1.0

  • [minor] adds createAndFireEvent utility method and updates docs 24a93fc

1.0.3

  • [patch] fixes flow type problem with wrapping stateless functional components in withAnalyticsEvents 8344ffb

1.0.2

  • [patch] Adds action key to analytics payload type 7deeaef

1.0.1

1.0.0

  • [major] release @atlaskit/analytics-next package 80695ea