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

[explorer] Add plausible analytics to explorer #4689

Merged
merged 1 commit into from
Sep 16, 2022
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
3 changes: 2 additions & 1 deletion explorer/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"bn.js": "^5.2.0",
"class-variance-authority": "^0.2.3",
"classnames": "^2.3.1",
"plausible-tracker": "^0.3.8",
"prism-react-renderer": "^1.3.5",
"prism-themes": "^1.9.0",
"prismjs": "^1.28.0",
Expand All @@ -56,7 +57,7 @@
"@testing-library/user-event": "^14.4.3",
"@types/bn.js": "^5.1.0",
"@types/node": "^16.11.24",
"@types/react": "^18.0.17",
"@types/react": "^18.0.20",
"@types/react-dom": "^18.0.6",
"@types/topojson-client": "^3.1.1",
"@vitejs/plugin-react": "^2.0.1",
Expand Down
12 changes: 8 additions & 4 deletions explorer/client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
import * as Sentry from '@sentry/react';
import { BrowserTracing } from '@sentry/tracing';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactDOM from 'react-dom/client';
import { BrowserRouter as Router } from 'react-router-dom';

import App from './app/App';
import { CURRENT_ENV } from './utils/envUtil';
import { plausible } from './utils/plausible';

import './index.css';

// NOTE: The plausible tracker ensures it doesn't run on localhost, so we don't
// need to gate this call.
plausible.enableAutoPageviews();

if (import.meta.env.PROD) {
Sentry.init({
dsn: 'https://[email protected]/6564988',
Expand All @@ -24,11 +29,10 @@ if (import.meta.env.PROD) {
});
}

ReactDOM.render(
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<Router>
<App />
</Router>
</React.StrictMode>,
document.getElementById('root')
</React.StrictMode>
);
11 changes: 11 additions & 0 deletions explorer/client/src/utils/plausible.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import Plausible from 'plausible-tracker';

export const plausible = Plausible({
// NOTE: If you want to test the plausible integration, you can uncomment
// the following two lines which will start emitting events to plausible.
// domain: 'explorer.ci.sui.io',
// trackLocalhost: true,
});
Loading