Skip to content

Commit 5bf5207

Browse files
Redo Segment integration (#2119)
1 parent eb67cf0 commit 5bf5207

File tree

17 files changed

+132
-343
lines changed

17 files changed

+132
-343
lines changed

docusaurus.config.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ const {
1212
MM_RPC_URL,
1313
} = require('./src/plugins/plugin-json-rpc')
1414
const codeTheme = themes.dracula
15-
const remarkCodesandbox = require('remark-codesandbox')
16-
const isProd = process.env.NODE_ENV === 'production'
1715
const helpDropdown = fs.readFileSync("./src/components/NavDropdown/DeveloperTools.html", "utf-8");
1816
const connectDropdown = fs.readFileSync("./src/components/NavDropdown/ConnectMetaMask.html", "utf-8");
1917
const embedDropdown = fs.readFileSync("./src/components/NavDropdown/EmbedMetaMask.html", "utf-8");
@@ -47,6 +45,7 @@ const config = {
4745
DASHBOARD_URL: process.env.DASHBOARD_URL || 'http://localhost:3000',
4846
SENTRY_KEY: process.env.SENTRY_KEY,
4947
LINEA_ENS_URL: process.env.LINEA_ENS_URL,
48+
SEGMENT_ANALYTICS_KEY: process.env.SEGMENT_ANALYTICS_KEY,
5049
},
5150

5251
trailingSlash: true,
@@ -55,11 +54,6 @@ const config = {
5554
{
5655
src: 'https://cmp.osano.com/AzZMxHTbQDOQD8c1J/84e64bce-4a70-4dcc-85cb-7958f22b2371/osano.js',
5756
},
58-
{
59-
src: 'https://plausible.io/js/script.js',
60-
defer: true,
61-
'data-domain': 'docs.metamask.io',
62-
},
6357
],
6458

6559
markdown: {
@@ -197,16 +191,8 @@ const config = {
197191
},
198192
],
199193
'./src/plugins/plugin-json-rpc.ts',
200-
isProd
201-
? [
202-
'docusaurus-plugin-segment',
203-
{
204-
apiKey: process.env.SEGMENT_ANALYTICS_KEY,
205-
load: { cookie: { sameSite: 'None', secure: true } },
206-
page: true,
207-
},
208-
]
209-
: null,
194+
// Custom Segment plugin for controlled analytics
195+
'./src/plugins/segment',
210196
'./src/plugins/launchdarkly',
211197
'./src/plugins/sentry',
212198
],

package-lock.json

Lines changed: 0 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"@types/react": "^18.3.3",
4949
"clsx": "^2.1.1",
5050
"docusaurus-plugin-sass": "^0.2.5",
51-
"docusaurus-plugin-segment": "^1.0.4",
5251
"dotenv": "^16.4.7",
5352
"ethers": "^6.13.5",
5453
"js-cookie": "^3.0.5",

src/components/Accordion/index.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { useState } from "react";
22
import clsx from "clsx";
33
import styles from "./accordion.module.scss";
44
import CloseImg from "./close.svg";
5-
import { trackClickForSegment } from "@site/src/lib/segmentAnalytics";
65

76
interface IAccordion {
87
children: [React.ReactElement, React.ReactElement];
@@ -16,14 +15,6 @@ export default function Accordion({
1615
const [isOpened, setIsOpened] = useState(opened);
1716

1817
const handleToggle = () => {
19-
trackClickForSegment({
20-
eventName: `${isOpened ? "Expanded" : "Collapsed"} - ${title}`,
21-
clickType: "Accordion",
22-
userExperience: "B",
23-
responseStatus: null,
24-
responseMsg: null,
25-
timestamp: Date.now(),
26-
});
2718
setIsOpened((value) => !value);
2819
};
2920

src/components/Alert/index.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import SuccessImg from "./success.svg";
77
import ErrorImg from "./error.svg";
88
import Text from "@site/src/components/Text";
99
import styles from "./alert.module.scss";
10-
import { trackClickForSegment } from "@site/src/lib/segmentAnalytics";
1110

1211
export const options = {
1312
position: positions.TOP_CENTER,
@@ -21,14 +20,6 @@ export const options = {
2120

2221
export const AlertTemplate = ({ style, options, message, close }) => {
2322
const handleCloseAlert = () => {
24-
trackClickForSegment({
25-
eventName: "Close",
26-
clickType: "Alert",
27-
userExperience: "B",
28-
responseStatus: null,
29-
responseMsg: null,
30-
timestamp: Date.now(),
31-
});
3223
close();
3324
};
3425

src/components/Faucet/Alerts.tsx

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,5 @@
11
import React from 'react'
22
import { AlertTitle, AlertText } from '@site/src/components/Alert'
3-
import { trackClickForSegment } from '@site/src/lib/segmentAnalytics'
4-
5-
const handleClickCommonIssue = () => {
6-
trackClickForSegment({
7-
eventName: 'Contact us',
8-
clickType: `Common Issue Alert`,
9-
userExperience: 'B',
10-
responseStatus: null,
11-
responseMsg: null,
12-
timestamp: Date.now(),
13-
})
14-
}
15-
16-
const handleClickBalanceLow = () => {
17-
trackClickForSegment({
18-
eventName: 'Add funds using MetaMask',
19-
clickType: `Low Balance Alert`,
20-
userExperience: 'B',
21-
responseStatus: null,
22-
responseMsg: null,
23-
timestamp: Date.now(),
24-
})
25-
}
26-
27-
const handleClickCooldown = () => {
28-
trackClickForSegment({
29-
eventName: 'Contact us',
30-
clickType: `Cooldown Alert`,
31-
userExperience: 'B',
32-
responseStatus: null,
33-
responseMsg: null,
34-
timestamp: Date.now(),
35-
})
36-
}
37-
38-
const handleClickPoh = () => {
39-
trackClickForSegment({
40-
eventName: 'PoH',
41-
clickType: `PoH Alert`,
42-
userExperience: 'B',
43-
responseStatus: null,
44-
responseMsg: null,
45-
timestamp: Date.now(),
46-
})
47-
}
48-
49-
const handleClickViewTransaction = () => {
50-
trackClickForSegment({
51-
eventName: 'View on Etherscan',
52-
clickType: `Success Alert`,
53-
userExperience: 'B',
54-
responseStatus: null,
55-
responseMsg: null,
56-
timestamp: Date.now(),
57-
})
58-
}
593

604
export const AlertCommonIssue = () => (
615
<div>
@@ -66,7 +10,6 @@ export const AlertCommonIssue = () => (
6610
persists please{' '}
6711
<a
6812
data-testid="alert-common-contact-us"
69-
onClick={handleClickCommonIssue}
7013
target="_blank"
7114
href="https://support.metamask.io/">
7215
contact support
@@ -85,7 +28,6 @@ export const AlertFailedPoh = () => (
8528
Free users are required to complete Proof of Humanity to access the faucet. Learn more{' '}
8629
<a
8730
data-testid="alert-poh"
88-
onClick={handleClickPoh}
8931
target="_blank"
9032
href="https://poh.linea.build/">
9133
here
@@ -115,7 +57,6 @@ export const AlertBalanceTooLow = () => (
11557
funds to your address using{' '}
11658
<a
11759
data-testid="alert-balance-add-funds"
118-
onClick={handleClickBalanceLow}
11960
className="underline"
12061
href="https://metamask.io/buy-crypto/">
12162
MetaMask
@@ -134,7 +75,6 @@ export const AlertCooldown = () => (
13475
You already got ETH from the faucet today. Try again in 24 hours.{' '}
13576
<a
13677
data-testid="alert-cooldown-contact-us"
137-
onClick={handleClickCooldown}
13878
target="_blank"
13979
href="https://support.metamask.io/">
14080
Contact us
@@ -154,7 +94,6 @@ export const AlertSuccess = ({ url }: { url: string }) => (
15494
shortly.{' '}
15595
<a
15696
data-testid="alert-success-etherscan"
157-
onClick={handleClickViewTransaction}
15897
target="_blank"
15998
href={url}>
16099
View on Etherscan

src/components/Faucet/Faq.tsx

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from 'react'
22
import Accordion from '@site/src/components/Accordion'
33
import Text from '@site/src/components/Text'
44
import styles from './faq.module.scss'
5-
import { trackClickForSegment } from '@site/src/lib/segmentAnalytics'
65

76
interface IFaq {
87
network: 'linea' | 'sepolia'
@@ -12,49 +11,6 @@ interface IFaq {
1211
}
1312

1413
export default function Faq({ network, className, classNameHeading, isLimitedUserPlan }: IFaq) {
15-
const handleClickContactUs = () => {
16-
trackClickForSegment({
17-
eventName: 'Contact us',
18-
clickType: `Link in ${network} FAQ`,
19-
userExperience: 'B',
20-
responseStatus: null,
21-
responseMsg: null,
22-
timestamp: Date.now(),
23-
})
24-
}
25-
26-
const handleClickLinea = () => {
27-
trackClickForSegment({
28-
eventName: 'What is Linea',
29-
clickType: `Link in ${network} FAQ`,
30-
userExperience: 'B',
31-
responseStatus: null,
32-
responseMsg: null,
33-
timestamp: Date.now(),
34-
})
35-
}
36-
37-
const handleClickDiscord = () => {
38-
trackClickForSegment({
39-
eventName: 'Consensys Discord',
40-
clickType: `Link in ${network} FAQ`,
41-
userExperience: 'B',
42-
responseStatus: null,
43-
responseMsg: null,
44-
timestamp: Date.now(),
45-
})
46-
}
47-
48-
const handleClickBridge = () => {
49-
trackClickForSegment({
50-
eventName: 'Bridge',
51-
clickType: `Link in ${network} FAQ`,
52-
userExperience: 'B',
53-
responseStatus: null,
54-
responseMsg: null,
55-
timestamp: Date.now(),
56-
})
57-
}
5814

5915
switch (network) {
6016
case 'linea':
@@ -100,7 +56,6 @@ export default function Faq({ network, className, classNameHeading, isLimitedUse
10056
<span>
10157
<a
10258
data-testid="faq-linea-what-is-linea"
103-
onClick={handleClickLinea}
10459
target="_blank"
10560
href="https://linea.build">
10661
Linea
@@ -122,7 +77,6 @@ export default function Faq({ network, className, classNameHeading, isLimitedUse
12277
<span>
12378
<a
12479
data-testid="faq-linea-contact-us"
125-
onClick={handleClickContactUs}
12680
target="_blank"
12781
href="https://support.metamask.io/">
12882
Contact support
@@ -140,7 +94,6 @@ export default function Faq({ network, className, classNameHeading, isLimitedUse
14094
If you have ideas on how to improve the faucet, feel free to submit them on{' '}
14195
<a
14296
data-testid="faq-linea-discord"
143-
onClick={handleClickDiscord}
14497
target="_blank"
14598
href="https://discord.com/invite/consensys">
14699
Discord.
@@ -158,7 +111,6 @@ export default function Faq({ network, className, classNameHeading, isLimitedUse
158111
ETH comes from Sepolia ETH that is bridged to Linea using the canonical{' '}
159112
<a
160113
data-testid="faq-linea-bridge"
161-
onClick={handleClickBridge}
162114
target="_blank"
163115
href="https://bridge.linea.build">
164116
bridge.
@@ -211,7 +163,6 @@ export default function Faq({ network, className, classNameHeading, isLimitedUse
211163
<span>
212164
<a
213165
data-testid="faq-sepolia-contact-us"
214-
onClick={handleClickContactUs}
215166
target="_blank"
216167
href="https://support.metamask.io/">
217168
Contact support
@@ -229,7 +180,6 @@ export default function Faq({ network, className, classNameHeading, isLimitedUse
229180
If you have ideas on how to improve the faucet, feel free to submit them on{' '}
230181
<a
231182
data-testid="faq-sepolia-discord"
232-
onClick={handleClickDiscord}
233183
target="_blank"
234184
href="https://discord.com/invite/consensys">
235185
Discord.

0 commit comments

Comments
 (0)