Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[x-license] Introduce usage telemetry #13530

Merged
merged 67 commits into from
Feb 26, 2025
Merged

Conversation

hasdfa
Copy link
Member

@hasdfa hasdfa commented Jun 18, 2024

Goals

  • More visibility into MUI X feature usage
  • Better prioritization
  • Collecting more feedback from users
  • Testing on the online license key validation

Background

MUI X was released almost 4 years ago, and the library has grown considerably in these 4 years, from new features to better defaults for all users. The way that we've been approaching this improvement process has been very much a manual one.

We're at MUI using the advanced components in some of our applications and plan to extend its usage across our codebases to dogfood MUI X internally more and make improvements based on our experiences.

On top of that, we actively engage with the community to gather feedback. For example, which components or features do you use mostly, ways to customise components, and more. This feedback is extremely valuable in steering feature development for MUI X.

However, there is a problem with this approach, which is that we can only collect feedback from a subset of users. This subset may have different needs and use-cases than you.

For this reason, we're currently exploring a more automated approach to collecting these points of feedback so that we can improve MUI X even more in the near future.

Furthermore, this will allow us to verify if improvements made to the components are improving the baseline of all applications.

Proposal

We're planning to add anonymized telemetry to the MUI X during the development process (excluding NODE_ENV=production). We'll provide an optional opt-out through an environment variable or CLI command. For the start, it will be disabled by default for all users with the ability to opt-in so we would be able to test it.

When enabled the CLI will collect telemetry at development and build time, when telemetry is collected we'll show a message explaining that telemetry is being collected with a link to documentation.

When telemetry is collected it'll be possible to add a flag to see the exact values being sent. These values, as said before, will be completely anonymized (except the license key, which we need for validation).

How we would push it

  1. Publish the first version with only the opt-in mechanism (disabled by default, you should take action to start sending data)
  2. Try this with our docs/projects/etc., polishing the core things, understanding what and how we would collect.
  3. To decide how we would publish it for all users with opt-out.

Demo preview

There's quite a few open source projects that take a similar approach, most notably:

Preview: https://deploy-preview-13530--material-ui-x.netlify.app/x/guides/telemetry/

@hasdfa hasdfa added new feature New feature or request package: x-license Specific to @mui/x-license. MUI X labels Jun 18, 2024
@hasdfa hasdfa self-assigned this Jun 18, 2024
@mui-bot
Copy link

mui-bot commented Jun 18, 2024

Deploy preview: https://deploy-preview-13530--material-ui-x.netlify.app/

Updated pages:

Generated by 🚫 dangerJS against a53d92b

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 18, 2024

This comment was marked as outdated.

hasdfa added 2 commits June 20, 2024 12:57
…emetry

# Conflicts:
#	packages/x-license/package.json
#	pnpm-lock.yaml
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 20, 2024
Copy link
Member

@cherniavskii cherniavskii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this! 🎉

Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 25, 2024
hasdfa added 3 commits July 10, 2024 17:34
…etry

# Conflicts:
#	packages/x-license/package.json
#	packages/x-license/src/verifyLicense/verifyLicense.ts
#	pnpm-lock.yaml
#	tsconfig.json
@github-actions github-actions bot added PR: out-of-date The pull request has merge conflicts and can't be merged and removed PR: out-of-date The pull request has merge conflicts and can't be merged labels Jul 10, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 24, 2025
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 25, 2025
@hasdfa hasdfa merged commit 3697464 into mui:master Feb 26, 2025
18 checks passed
@oliviertassinari
Copy link
Member

oliviertassinari commented Mar 1, 2025

High level, this looks right 👍


There are new console warnings we need to fix when running pnpm docs:dev:

SCR-20250302-btck

MUI_X_TELEMETRY_DISABLED=false
```

> Note that some frameworks may require you to prefix the environment variable with `REACT_APP_`, `NEXT_PUBLIC_`, etc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a quote.

Suggested change
> Note that some frameworks may require you to prefix the environment variable with `REACT_APP_`, `NEXT_PUBLIC_`, etc.
Note that some frameworks may require you to prefix the environment variable with `REACT_APP_`, `NEXT_PUBLIC_`, etc.

muiXTelemetrySettings.enableTelemetry();
```

### Setting the Flag in Your Application
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Setting the Flag in Your Application
### Setting the flag in your application

ponyfillGlobal.__MUI_X_TELEMETRY_DISABLED__ = false;
```

## Opting Out
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Opting Out
## Opting out


<p class="description">MUI X Telemetry collects anonymous usage data to help improve the library. This guide will walk you through how to opt-in, opt-out, and configure telemetry.</p>

## Opting In
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Opting In
## Opting in

MUI_X_TELEMETRY_DISABLED=true
```

> Note that some frameworks may require you to prefix the environment variable with `REACT_APP_`, `NEXT_PUBLIC_`, etc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note a quote

Suggested change
> Note that some frameworks may require you to prefix the environment variable with `REACT_APP_`, `NEXT_PUBLIC_`, etc.
Note that some frameworks may require you to prefix the environment variable with `REACT_APP_`, `NEXT_PUBLIC_`, etc.


function generateId(length: number): string {
let result = '';
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol ai/nanoid#309 it might be pushing it too far.

typeof window === 'undefined' || process.env.NODE_ENV === 'test'
? () => ''
: async () => {
const FingerprintJS = await import('@fingerprintjs/fingerprintjs');
Copy link
Member

@oliviertassinari oliviertassinari Mar 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we should remove this dependency per https://github.com/fingerprintjs/fingerprintjs/blob/master/docs/licensing.md

Suggested change
const FingerprintJS = await import('@fingerprintjs/fingerprintjs');

We could use an older version: https://fingerprint.com/blog/fingerprintjs-license-change/, which most people seem to do, so I guess it's fine https://tools-public.mui.com/prod/pages/npmVersion

SCR-20250302-romf

The problem is that they don't clearly define production https://fossa.com/blog/business-source-license-requirements-provisions-history/

Alternative: https://github.com/thumbmarkjs/thumbmarkjs

import { getTelemetryEnvConfigValue } from './config';
import { TelemetryEvent } from '../types';
import { fetchWithRetry } from './fetcher';
import * as packageJson from '../../package.json';
Copy link
Member

@oliviertassinari oliviertassinari Mar 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import * as packageJson from '../../package.json';
import packageJson from '../../package.json';

maybe this would fix the warning (in our docs, and likely in a lot of other project's).

SCR-20250302-btck

Otherwise, we can use Babel like we did for __RELEASE_INFO__. You can search for MUI_MAJOR_VERSION, similar work, MUI X might need to expose this in other instances: mui/material-ui#43190.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this file and the other files? We don't use the kebab case naming convention for JavaScript/TypeScript files.

'X-Telemetry-Client-Version': packageJson.version,
'X-Telemetry-Node-Env': (process.env.NODE_ENV as any) ?? '<unknown>',
},
body: JSON.stringify([eventPayload]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why make it an array?

Suggested change
body: JSON.stringify([eventPayload]),
body: JSON.stringify(eventPayload),

@hasdfa hasdfa deleted the x-license/add-telemetry branch March 10, 2025 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MUI X new feature New feature or request package: x-license Specific to @mui/x-license.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants