-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Changes from all commits
db7dbdb
af07f13
13e41b3
28249c2
ece6315
f0a6600
caff09e
0ac2fc0
9bf2d39
2a27bcd
d55225b
8db1506
c167280
d8b72e4
dbac0ce
1036451
2efc840
40906b6
1079497
05d4aba
3263b54
8062625
496600c
6adaf71
9c2b241
b243b60
c29713e
fd4f623
978d0fd
496c3a2
40976db
bf0b4ce
9f503c4
f40d374
fef329d
a471d5e
e3528fd
8ab7d77
19e142e
e2ed8b8
556db6b
4d80ebd
db6561a
ae01cef
6d099ac
c5cc5eb
273cc90
063d9ec
076f6f4
46a3a04
aa0c680
a677b58
ff6158b
fd6fc77
4de1301
086bd1f
51b3076
3dcd184
ee3beda
3f4a467
a13e68a
ad6d4ba
a5e4a3f
00f7134
0829a35
e59d1f2
a53d92b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,75 @@ | ||||||
--- | ||||||
packageName: '@mui/x-telemetry' | ||||||
--- | ||||||
|
||||||
# MUI X Telemetry guide | ||||||
|
||||||
<p class="description">MUI X Telemetry collects anonymous usage data to help improve the library. This guide walk you through how to opt-in, opt-out, and configure telemetry.</p> | ||||||
|
||||||
## Opting In | ||||||
|
||||||
Currently, **Telemetry is disabled by default**. To opt-in, you can use one of the following methods: | ||||||
|
||||||
### Setting the Environment Variable | ||||||
|
||||||
You can set the `MUI_X_TELEMETRY_DISABLED` environment variable to `false` to enable telemetry: | ||||||
|
||||||
```bash | ||||||
MUI_X_TELEMETRY_DISABLED=false | ||||||
``` | ||||||
|
||||||
> Note that some frameworks may require you to prefix the environment variable with `REACT_APP_`, `NEXT_PUBLIC_`, etc. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a quote.
Suggested change
|
||||||
|
||||||
### Import telemetry settings from `@mui/x-license` package | ||||||
|
||||||
You can use `muiXTelemetrySettings` to enable telemetry: | ||||||
|
||||||
```js | ||||||
import { muiXTelemetrySettings } from '@mui/x-license'; | ||||||
|
||||||
muiXTelemetrySettings.enableTelemetry(); | ||||||
``` | ||||||
|
||||||
### Setting the Flag in Your Application | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
You can set the `__MUI_X_TELEMETRY_DISABLED__` flag in your application to `false` to enable telemetry: | ||||||
|
||||||
```js | ||||||
import { ponyfillGlobal } from '@mui/utils'; | ||||||
|
||||||
ponyfillGlobal.__MUI_X_TELEMETRY_DISABLED__ = false; | ||||||
``` | ||||||
|
||||||
## Opting Out | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
To opt-out of telemetry, you can use one of the following methods: | ||||||
|
||||||
### Setting the Environment Variable | ||||||
|
||||||
You can set the `MUI_X_TELEMETRY_DISABLED` environment variable to `true` to disable telemetry: | ||||||
|
||||||
```bash | ||||||
MUI_X_TELEMETRY_DISABLED=true | ||||||
``` | ||||||
|
||||||
> Note that some frameworks may require you to prefix the environment variable with `REACT_APP_`, `NEXT_PUBLIC_`, etc. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note a quote
Suggested change
|
||||||
|
||||||
### Import telemetry settings from `@mui/x-license` package | ||||||
|
||||||
You can use `muiXTelemetrySettings` to disable telemetry: | ||||||
|
||||||
```js | ||||||
import { muiXTelemetrySettings } from '@mui/x-license'; | ||||||
|
||||||
muiXTelemetrySettings.disableTelemetry(); | ||||||
``` | ||||||
|
||||||
### Setting the Flag in Your Application | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
You can set the `__MUI_X_TELEMETRY_DISABLED__` flag in your application to `true` to disable telemetry: | ||||||
|
||||||
```js | ||||||
import { ponyfillGlobal } from '@mui/utils'; | ||||||
|
||||||
ponyfillGlobal.__MUI_X_TELEMETRY_DISABLED__ = true; | ||||||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as React from 'react'; | ||
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs'; | ||
import * as pageProps from 'docsx/data/guides/telemetry/telemetry.md?muiMarkdown'; | ||
|
||
export default function Page() { | ||
return <MarkdownDocs {...pageProps} disableAd />; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Commercial License | ||
|
||
Copyright (c) 2020 Material-UI SAS | ||
|
||
MUI X Pro (https://mui.com/pricing/) is commercial software. You MUST agree to the | ||
End User License Agreement (EULA: https://mui.com/r/x-license-eula) to be able to | ||
use the software. | ||
|
||
This means that you either need to purchase a commercial license at | ||
https://mui.com/r/x-get-license?scope=pro or be eligible for the Evaluation (trial) | ||
licenses detailed at https://mui.com/r/x-license-trial. | ||
hasdfa marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# @mui/x-telemetry | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likely to move to a dedicated docs page |
||
|
||
Package used by some of MUI X to collects **anonymous** telemetry data about general usage. Participation in this anonymous program is optional, and you may opt-out if you'd not like to share any information. | ||
|
||
## How to opt-in | ||
|
||
Currently, **it's disabled by default,** and you could opt-in to it in 3 ways: | ||
|
||
1. By setting it directly to package settings on the application start (e.g. in main file). | ||
Check failure on line 9 in packages/x-telemetry/README.md
|
||
|
||
```js | ||
import { muiXTelemetrySettings } from '@mui/x-telemetry'; | ||
// or | ||
import { muiXTelemetrySettings } from '@mui/x-license'; | ||
|
||
muiXTelemetrySettings.enableTelemetry(); // to enable telemetry collection and sending | ||
// or | ||
muiXTelemetrySettings.disableTelemetry(); // to disable telemetry collection and sending | ||
``` | ||
|
||
2. By setting the environment variable. | ||
|
||
```dotenv | ||
MUI_X_TELEMETRY_DISABLED=false # Enable telemetry | ||
# or | ||
MUI_X_TELEMETRY_DISABLED=true # Enable telemetry | ||
``` | ||
|
||
> ⚠️ Note that some frameworks requires to prefix the variable with `REACT_APP_`, `NEXT_PUBLIC_`, etc. | ||
|
||
3. By setting the flag to global object on the application start (e.g. in main file). | ||
Check failure on line 31 in packages/x-telemetry/README.md
|
||
|
||
```js | ||
import { ponyfillGlobal } from '@mui/utils'; | ||
|
||
ponyfillGlobal.__MUI_X_TELEMETRY_DISABLED__ = false; // enabled | ||
// or | ||
ponyfillGlobal.__MUI_X_TELEMETRY_DISABLED__ = true; // disabled | ||
``` | ||
|
||
OR | ||
|
||
```js | ||
if (typeof window !== 'undefined') { | ||
window.__MUI_X_TELEMETRY_DISABLED__ = false; // enabled | ||
} | ||
// or | ||
if (typeof window !== 'undefined') { | ||
window.__MUI_X_TELEMETRY_DISABLED__ = true; // disabled | ||
} | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"name": "@mui/x-telemetry", | ||
"version": "8.0.0-alpha.12", | ||
"description": "MUI X Telemetry", | ||
"author": "MUI Team", | ||
"main": "src/index.ts", | ||
"license": "SEE LICENSE IN LICENSE", | ||
"bugs": { | ||
"url": "https://github.com/mui/mui-x/issues" | ||
}, | ||
"homepage": "https://mui.com/x/guides/telemetry/", | ||
"publishConfig": { | ||
"access": "public", | ||
"directory": "build" | ||
}, | ||
"scripts": { | ||
"typescript": "tsc -p tsconfig.json", | ||
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files ", | ||
"build:modern": "node ../../scripts/build.mjs modern", | ||
"build:node": "node ../../scripts/build.mjs node", | ||
"build:stable": "node ../../scripts/build.mjs stable", | ||
"build:copy-files": "node ../../scripts/copyFiles.mjs && node ./scripts/addPackageScripts.js", | ||
"build:types": "tsx ../../scripts/buildTypes.mts", | ||
"prebuild": "rimraf build tsconfig.build.tsbuildinfo" | ||
}, | ||
"sideEffects": false, | ||
"packageScripts": { | ||
"postinstall": "node ./postinstall/index.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mui/mui-x.git", | ||
"directory": "packages/x-telemetry" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.26.9", | ||
"@fingerprintjs/fingerprintjs": "^4.6.0", | ||
"@mui/utils": "^5.16.6 || ^6.0.0", | ||
"ci-info": "^4.0.0", | ||
"conf": "^5.0.0", | ||
"is-docker": "^2.2.1", | ||
"node-machine-id": "^1.1.12" | ||
}, | ||
"devDependencies": { | ||
"@mui/internal-test-utils": "^2.0.2", | ||
"@types/device-uuid": "^1.0.3", | ||
"rimraf": "^6.0.1" | ||
}, | ||
"engines": { | ||
"node": ">=14.0.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const packageDir = process.cwd(); | ||
|
||
const packageJsonPath = path.join(packageDir, 'package.json'); | ||
const packageJsonFileContent = fs.readFileSync(packageJsonPath, 'utf8'); | ||
const packageJson = JSON.parse(packageJsonFileContent); | ||
|
||
if (packageJson.packageScripts) { | ||
const buildPackageJsonPath = path.join(packageDir, 'build/package.json'); | ||
const buildPackageJsonFileContent = fs.readFileSync(buildPackageJsonPath, 'utf8'); | ||
const buildPackageJson = JSON.parse(buildPackageJsonFileContent); | ||
|
||
buildPackageJson.scripts = packageJson.packageScripts; | ||
delete buildPackageJson.packageScripts; | ||
|
||
fs.writeFileSync(buildPackageJsonPath, JSON.stringify(buildPackageJson, null, 2)); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// This file will be modified by the `postinstall` script. | ||
// See postinstall/index.ts for more information. | ||
|
||
export interface TelemetryContextType { | ||
config: { | ||
isInitialized: boolean; | ||
}; | ||
traits: Record<string, any> & { | ||
machineId?: string | null; | ||
projectId?: string | null; | ||
sessionId?: string | null; | ||
anonymousId?: string | null; | ||
isDocker?: boolean; | ||
isCI?: boolean; | ||
}; | ||
} | ||
|
||
const defaultValue: TelemetryContextType = { | ||
config: { | ||
isInitialized: false, | ||
}, | ||
traits: {}, | ||
}; | ||
|
||
export default defaultValue; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import muiXTelemetryEvents from './runtime/events'; | ||
import sendMuiXTelemetryEventOriginal from './runtime/sender'; | ||
import muiXTelemetrySettingsOriginal from './runtime/settings'; | ||
|
||
const noop = () => {}; | ||
|
||
// To cut unused imports in production as early as possible | ||
const sendMuiXTelemetryEvent = | ||
process.env.NODE_ENV === 'production' ? noop : sendMuiXTelemetryEventOriginal; | ||
|
||
// To cut unused imports in production as early as possible | ||
const muiXTelemetrySettings = | ||
process.env.NODE_ENV === 'production' | ||
? { | ||
enableDebug: noop, | ||
enableTelemetry: noop, | ||
disableTelemetry: noop, | ||
} | ||
: muiXTelemetrySettingsOriginal; | ||
|
||
export { muiXTelemetryEvents, sendMuiXTelemetryEvent, muiXTelemetrySettings }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joserodolfofreitas It would be great to have a few paragraphs here explaining what's the purpose of telemetry and why would users want to enable it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll address this separately together with the blog post to announce telemetry to the public. For now, we can merge this for the internal testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.