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

Add domain telemetry on app mount #5631

Merged
merged 8 commits into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/Admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Here are all the props accepted by the component:
- [`i18nProvider`](#i18nprovider)
- [`title`](#title)
- [`dashboard`](#dashboard)
- [`disableTelemetry`](#disableTelemetry)
- [`catchAll`](#catchall)
- [`menu`](#menu)
- [`theme`](#theme)
Expand Down Expand Up @@ -138,6 +139,28 @@ const App = () => (

![Custom home page](./img/dashboard.png)

## `disableTelemetry`

In production, react-admin applications send an anonymous request on mount to a telemetry server operated by marmelab. You can see this request by looking at the Network tab of your browser DevTools:

`https://react-admin-telemetry.marmelab.com/react-admin-telemetry`

The only data sent to the telemetry server is the admin domain (e.g. "example.com") - no personal data is ever sent, and no cookie is included in the response. The react-admin team uses these domains to track the usage of the framework.

You can opt out of telemetry by simply adding `disableTelemetry` to the `<Admin>` component:

```jsx
// in src/App.js
import * as React from "react";
import { Admin } from 'react-admin';

const App = () => (
<Admin disableTelemetry>
// ...
</Admin>
);
```

## `catchAll`

When users type URLs that don't match any of the children `<Resource>` components, they see a default "Not Found" page.
Expand Down
1 change: 1 addition & 0 deletions examples/demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const App = () => {
loginPage={Login}
layout={Layout}
i18nProvider={i18nProvider}
disableTelemetry
>
<Resource name="customers" {...visitors} />
<Resource
Expand Down
4 changes: 3 additions & 1 deletion packages/ra-core/src/core/CoreAdmin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export type ChildrenFunction = () => ComponentType[];
* // it's relatively straightforward to replace it:
*
* import * as React from 'react';
import { useEffect, useState } from 'react';
* import { useEffect, useState } from 'react';
* import {
* CoreAdminContext,
* CoreAdminUI,
Expand Down Expand Up @@ -96,6 +96,7 @@ const CoreAdmin: FunctionComponent<AdminProps> = ({
customSagas,
dashboard,
dataProvider,
disableTelemetry,
history,
i18nProvider,
initialState,
Expand All @@ -121,6 +122,7 @@ const CoreAdmin: FunctionComponent<AdminProps> = ({
layout={appLayout || layout}
customRoutes={customRoutes}
dashboard={dashboard}
disableTelemetry={disableTelemetry}
menu={menu}
catchAll={catchAll}
theme={theme}
Expand Down
18 changes: 18 additions & 0 deletions packages/ra-core/src/core/CoreAdminUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
FunctionComponent,
ComponentType,
useMemo,
useEffect,
} from 'react';
import { Switch, Route } from 'react-router-dom';

Expand Down Expand Up @@ -32,6 +33,7 @@ export interface AdminUIProps {
children?: AdminChildren;
customRoutes?: CustomRoutes;
dashboard?: DashboardComponent;
disableTelemetry?: boolean;
layout?: LayoutComponent;
loading?: LoadingComponent;
loginPage?: LoginComponent | boolean;
Expand All @@ -50,6 +52,7 @@ const CoreAdminUI: FunctionComponent<AdminUIProps> = ({
children,
customRoutes = [],
dashboard,
disableTelemetry = false,
layout = DefaultLayout,
loading = Noop,
loginPage = false,
Expand All @@ -62,6 +65,21 @@ const CoreAdminUI: FunctionComponent<AdminUIProps> = ({
const logoutElement = useMemo(() => logout && createElement(logout), [
logout,
]);

useEffect(() => {
if (
disableTelemetry ||
process.env.NODE_ENV !== 'production' ||
typeof window === 'undefined' ||
typeof window.location === 'undefined' ||
typeof Image === 'undefined'
) {
return;
}
const img = new Image();
img.src = `https://react-admin-telemetry.marmelab.com/react-admin-telemetry?domain=${window.location.hostname}`;
}, [disableTelemetry]);

return (
<Switch>
{loginPage !== false && loginPage !== true ? (
Expand Down
1 change: 1 addition & 0 deletions packages/ra-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ export interface AdminProps {
customSagas?: any[];
dashboard?: DashboardComponent;
dataProvider: DataProvider | LegacyDataProvider;
disableTelemetry?: boolean;
history?: History;
i18nProvider?: I18nProvider;
initialState?: InitialState;
Expand Down
2 changes: 2 additions & 0 deletions packages/react-admin/src/Admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const Admin: FunctionComponent<AdminProps> = ({
customSagas,
dashboard,
dataProvider,
disableTelemetry,
history,
i18nProvider,
initialState,
Expand Down Expand Up @@ -137,6 +138,7 @@ const Admin: FunctionComponent<AdminProps> = ({
layout={appLayout || layout}
customRoutes={customRoutes}
dashboard={dashboard}
disableTelemetry={disableTelemetry}
menu={menu}
catchAll={catchAll}
theme={theme}
Expand Down