diff --git a/apps/remix-ide/src/app/plugins/matomo.ts b/apps/remix-ide/src/app/plugins/matomo.ts index 8aa8f61f70..b96a967edb 100644 --- a/apps/remix-ide/src/app/plugins/matomo.ts +++ b/apps/remix-ide/src/app/plugins/matomo.ts @@ -21,6 +21,7 @@ export class Matomo extends Plugin { async track(data: string[]) { if (!allowedPlugins.includes(this.currentRequest.from)) return + console.log('Matomo', data) _paq.push(data) } } \ No newline at end of file diff --git a/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx b/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx index b4a4b5f66a..2ae17389e6 100644 --- a/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx +++ b/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx @@ -14,9 +14,10 @@ interface ICopyToClipboard { title?: string children?: JSX.Element getContent?: () => any + callback?: () => void } export const CopyToClipboard = (props: ICopyToClipboard) => { - const { tip = 'Copy', icon = 'fa-copy', direction = 'right', getContent, children, ...otherProps } = props + const { tip = 'Copy', icon = 'fa-copy', direction = 'right', getContent, children, callback, ...otherProps } = props let { content } = props const [message, setMessage] = useState(tip) @@ -29,6 +30,7 @@ export const CopyToClipboard = (props: ICopyToClipboard) => { if (typeof content !== 'string') { content = JSON.stringify(content, null, '\t') } + callback && callback() copy(content) setMessage('Copied') } catch (e) { diff --git a/libs/remix-ui/git/src/components/buttons/sourcecontrolbuttons.tsx b/libs/remix-ui/git/src/components/buttons/sourcecontrolbuttons.tsx index b01cc67a40..250e44628c 100644 --- a/libs/remix-ui/git/src/components/buttons/sourcecontrolbuttons.tsx +++ b/libs/remix-ui/git/src/components/buttons/sourcecontrolbuttons.tsx @@ -4,10 +4,11 @@ import { CustomTooltip } from "@remix-ui/helper" import React, { useEffect, useState } from "react" import { FormattedMessage } from "react-intl" import { gitActionsContext } from "../../state/context" -import { branch, remote } from "../../types" +import { branch, gitMatomoEventTypes, remote } from "../../types" import { gitPluginContext } from "../gitui" import GitUIButton from "./gituibutton" import { syncStateContext } from "./sourceControlBase" +import { sendToMatomo } from "../../lib/pluginActions" export const SourceControlButtons = () => { const context = React.useContext(gitPluginContext) @@ -51,6 +52,7 @@ export const SourceControlButtons = () => { } const refresh = async() => { + await sendToMatomo(gitMatomoEventTypes.REFRESH) await actions.getFileStatusMatrix(null) await actions.gitlog() } diff --git a/libs/remix-ui/git/src/components/github/devicecode.tsx b/libs/remix-ui/git/src/components/github/devicecode.tsx index e5b34423af..85922441fd 100644 --- a/libs/remix-ui/git/src/components/github/devicecode.tsx +++ b/libs/remix-ui/git/src/components/github/devicecode.tsx @@ -4,6 +4,8 @@ import { gitPluginContext } from "../gitui"; import axios from "axios"; import { CopyToClipboard } from "@remix-ui/clipboard"; import { Card } from "react-bootstrap"; +import { sendToMatomo } from "../../lib/pluginActions"; +import { gitMatomoEventTypes } from "../../types"; export const GetDeviceCode = () => { const context = React.useContext(gitPluginContext) @@ -13,7 +15,7 @@ export const GetDeviceCode = () => { const [authorized, setAuthorized] = React.useState(false) const getDeviceCodeFromGitHub = async () => { - + await sendToMatomo(gitMatomoEventTypes.GETGITHUBDEVICECODE) setAuthorized(false) // Send a POST request const response = await axios({ @@ -36,6 +38,7 @@ export const GetDeviceCode = () => { } const connectApp = async () => { + await sendToMatomo(gitMatomoEventTypes.CONNECTTOGITHUB) // poll https://github.com/login/oauth/access_token const accestokenresponse = await axios({ method: 'post', @@ -56,13 +59,17 @@ export const GetDeviceCode = () => { if (response.access_token) { setAuthorized(true) + await sendToMatomo(gitMatomoEventTypes.CONNECTTOGITHUBSUCCESS) await pluginActions.saveToken(response.access_token) await actions.loadGitHubUserFromToken() + } else { + await sendToMatomo(gitMatomoEventTypes.CONNECTTOGITHUBFAIL) } } const disconnect = async () => { + await sendToMatomo(gitMatomoEventTypes.DISCONNECTFROMGITHUB) setAuthorized(false) setGitHubResponse(null) await pluginActions.saveToken(null) @@ -84,7 +91,7 @@ export const GetDeviceCode = () => {
- + sendToMatomo(gitMatomoEventTypes.COPYGITHUBDEVICECODE)} content={gitHubResponse.user_code} data-id='copyToClipboardCopyIcon' className='far fa-copy ml-1 p-2 mt-1' direction={"top"} />


diff --git a/libs/remix-ui/git/src/components/github/repositoryselect.tsx b/libs/remix-ui/git/src/components/github/repositoryselect.tsx index ec563a3f42..40a9d7b4a3 100644 --- a/libs/remix-ui/git/src/components/github/repositoryselect.tsx +++ b/libs/remix-ui/git/src/components/github/repositoryselect.tsx @@ -1,11 +1,10 @@ import React, { useState, useEffect } from 'react'; -import { Button } from 'react-bootstrap'; import Select from 'react-select'; import { gitActionsContext } from '../../state/context'; -import { repository } from '../../types'; +import { gitMatomoEventTypes, repository } from '../../types'; import { selectStyles, selectTheme } from '../../types/styles'; import { gitPluginContext } from '../gitui'; -import { TokenWarning } from '../panels/tokenWarning'; +import { sendToMatomo } from '../../lib/pluginActions'; interface RepositorySelectProps { select: (repo: repository) => void; @@ -57,6 +56,7 @@ const RepositorySelect = (props: RepositorySelectProps) => { } const fetchRepositories = async () => { + await sendToMatomo(gitMatomoEventTypes.LOADREPOSITORIESFROMGITHUB) try { setShow(true) setLoading(true) diff --git a/libs/remix-ui/git/src/components/gitui.tsx b/libs/remix-ui/git/src/components/gitui.tsx index adc4b7827a..8148ca75dd 100644 --- a/libs/remix-ui/git/src/components/gitui.tsx +++ b/libs/remix-ui/git/src/components/gitui.tsx @@ -1,10 +1,10 @@ import React, { useEffect, useReducer, useState } from 'react' import { add, addall, checkout, checkoutfile, clone, commit, createBranch, remoteBranches, repositories, rm, getCommitChanges, diff, resolveRef, getBranchCommits, setUpstreamRemote, loadGitHubUserFromToken, getBranches, getRemotes, remoteCommits, saveGitHubCredentials, getGitHubCredentialsFromLocalStorage, fetch, pull, push, setDefaultRemote, addRemote, removeRemote, sendToGitLog, clearGitLog, getBranchDifferences, getFileStatusMatrix, init, showAlert, gitlog } from '../lib/gitactions' import { loadFiles, setCallBacks } from '../lib/listeners' -import { openDiff, openFile, saveToken, setModifiedDecorator, setPlugin, setUntrackedDecorator, statusChanged } from '../lib/pluginActions' +import { openDiff, openFile, saveToken, sendToMatomo, setModifiedDecorator, setPlugin, setUntrackedDecorator, statusChanged } from '../lib/pluginActions' import { gitActionsContext, pluginActionsContext } from '../state/context' import { gitReducer } from '../state/gitreducer' -import { defaultGitState, defaultLoaderState, gitState, loaderState } from '../types' +import { defaultGitState, defaultLoaderState, gitMatomoEventTypes, gitState, gitUIPanels, loaderState } from '../types' import { Accordion } from "react-bootstrap"; import { CommitMessage } from './buttons/commitmessage' import { Commits } from './panels/commits' @@ -118,6 +118,13 @@ export const GitUI = (props: IGitUi) => { }, [gitState.gitHubUser, gitState.currentBranch, gitState.remotes, gitState.gitHubAccessToken, gitState.currentHead]) + useEffect(() => { + const panelName = Object.keys(gitUIPanels) + .filter(k => gitUIPanels[k] === activePanel); + if(!(panelName && panelName[0])) return + sendToMatomo(gitMatomoEventTypes.OPENPANEL, [panelName && panelName[0]]) + }, [activePanel]) + const gitActionsProviderValue = { commit, addall, @@ -175,51 +182,51 @@ export const GitUI = (props: IGitUi) => { {needsInit ? : null} {!setup && !needsInit ? - + - +

- - + +

- - + +

- - + +

- - + +

- - + +

- - + +

@@ -227,8 +234,8 @@ export const GitUI = (props: IGitUi) => {

- - + +
diff --git a/libs/remix-ui/git/src/components/navigation/remotesdetails.tsx b/libs/remix-ui/git/src/components/navigation/remotesdetails.tsx index ad3bbd87d6..626834feb1 100644 --- a/libs/remix-ui/git/src/components/navigation/remotesdetails.tsx +++ b/libs/remix-ui/git/src/components/navigation/remotesdetails.tsx @@ -3,7 +3,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { CustomTooltip } from "@remix-ui/helper"; import React, { useContext, useEffect } from "react"; import { gitActionsContext } from "../../state/context"; -import { branch, remote } from "../../types"; +import { branch, gitMatomoEventTypes, remote } from "../../types"; import GitUIButton from "../buttons/gituibutton"; import { gitPluginContext } from "../gitui"; import { removeGitFromUrl } from "../../utils"; @@ -33,7 +33,7 @@ export const RemotesDetailsNavigation = (props: RemotesDetailsNavigationProps) = window.open(`${removeGitFromUrl(remote.url)}`, '_blank'); } - const setAsDefault = () => { + const setAsDefault = async () => { actions.setDefaultRemote(remote) } diff --git a/libs/remix-ui/git/src/components/panels/branches/localbranchdetails.tsx b/libs/remix-ui/git/src/components/panels/branches/localbranchdetails.tsx index d3a7a9465f..2b996a3d34 100644 --- a/libs/remix-ui/git/src/components/panels/branches/localbranchdetails.tsx +++ b/libs/remix-ui/git/src/components/panels/branches/localbranchdetails.tsx @@ -4,12 +4,13 @@ import { Accordion } from "react-bootstrap"; import { CommitDetailsNavigation } from "../../navigation/commitdetails"; import { gitActionsContext } from "../../../state/context"; import { gitPluginContext } from "../../gitui"; -import { branch } from "../../../types"; +import { branch, gitMatomoEventTypes } from "../../../types"; import { BrancheDetailsNavigation } from "../../navigation/branchedetails"; import { CommitDetailsItems } from "../commits/commitdetailsitem"; import { CommitDetails } from "../commits/commitdetails"; import { BranchDifferences } from "./branchdifferences"; import GitUIButton from "../../buttons/gituibutton"; +import { sendToMatomo } from "../../../lib/pluginActions"; export interface BrancheDetailsProps { branch: branch; @@ -32,8 +33,9 @@ export const LocalBranchDetails = (props: BrancheDetailsProps) => { } }, [activePanel]) - const checkout = (branch: branch) => { - actions.checkout({ + const checkout = async (branch: branch) => { + await sendToMatomo(gitMatomoEventTypes.CHECKOUT_LOCAL_BRANCH) + await actions.checkout({ ref: branch.name, remote: branch.remote && branch.remote.name || null, refresh: true diff --git a/libs/remix-ui/git/src/components/panels/branches/remotebranchedetails.tsx b/libs/remix-ui/git/src/components/panels/branches/remotebranchedetails.tsx index bd6b0b51f1..d80e999ee1 100644 --- a/libs/remix-ui/git/src/components/panels/branches/remotebranchedetails.tsx +++ b/libs/remix-ui/git/src/components/panels/branches/remotebranchedetails.tsx @@ -4,11 +4,12 @@ import { Accordion } from "react-bootstrap"; import { CommitDetailsNavigation } from "../../navigation/commitdetails"; import { gitActionsContext } from "../../../state/context"; import { gitPluginContext } from "../../gitui"; -import { branch } from "../../../types"; +import { branch, gitMatomoEventTypes } from "../../../types"; import { BrancheDetailsNavigation } from "../../navigation/branchedetails"; import { CommitDetailsItems } from "../commits/commitdetailsitem"; import { CommitDetails } from "../commits/commitdetails"; import GitUIButton from "../../buttons/gituibutton"; +import { sendToMatomo } from "../../../lib/pluginActions"; export interface BrancheDetailsProps { branch: branch; @@ -47,6 +48,7 @@ export const RemoteBranchDetails = (props: BrancheDetailsProps) => { }, [context.remoteBranchCommits]) const checkout = async (branch: branch) => { + await sendToMatomo(gitMatomoEventTypes.CHECKOUT_REMOTE_BRANCH) await actions.fetch({ remote: branch.remote, ref: branch, diff --git a/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx b/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx index 05da47a162..981542f7cc 100644 --- a/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx +++ b/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx @@ -4,8 +4,9 @@ import { gitPluginContext } from "../../gitui"; import { selectStyles, selectTheme } from "../../../types/styles"; import Select, { Options, OptionsOrGroups } from 'react-select' import GitUIButton from "../../buttons/gituibutton"; -import { remote } from "../../../types"; +import { gitMatomoEventTypes, remote } from "../../../types"; import { relative } from "path"; +import { sendToMatomo } from "../../../lib/pluginActions"; export const PushPull = () => { const context = React.useContext(gitPluginContext) @@ -45,11 +46,13 @@ export const PushPull = () => { } },[context.defaultRemote]) - const onRemoteBranchChange = (value: string) => { + const onRemoteBranchChange = async (value: string) => { + await sendToMatomo(gitMatomoEventTypes.SETREMOTEBRANCHINCOMMANDS) setRemoteBranch(value) } - const onLocalBranchChange = (value: any) => { + const onLocalBranchChange = async (value: any) => { + await sendToMatomo(gitMatomoEventTypes.SETLOCALBRANCHINCOMMANDS) setLocalBranch(value) } diff --git a/libs/remix-ui/git/src/components/panels/githubcredentials.tsx b/libs/remix-ui/git/src/components/panels/githubcredentials.tsx index 8fd33d7102..3635fbe988 100644 --- a/libs/remix-ui/git/src/components/panels/githubcredentials.tsx +++ b/libs/remix-ui/git/src/components/panels/githubcredentials.tsx @@ -5,6 +5,8 @@ import { CustomTooltip } from "@remix-ui/helper"; import { useIntl, FormattedMessage } from "react-intl"; import { CopyToClipboard } from "@remix-ui/clipboard"; +import { gitMatomoEventTypes } from "../../types"; +import { sendToMatomo } from "../../lib/pluginActions"; export const GitHubCredentials = () => { const context = React.useContext(gitPluginContext) @@ -39,6 +41,7 @@ export const GitHubCredentials = () => { } async function saveGithubToken() { + await sendToMatomo(gitMatomoEventTypes.SAVEMANUALGITHUBCREDENTIALS) await pluginactions.saveGitHubCredentials({ username: githubUsername, email: githubEmail, diff --git a/libs/remix-ui/git/src/components/panels/remotes.tsx b/libs/remix-ui/git/src/components/panels/remotes.tsx index da720109b8..a76721e8d1 100644 --- a/libs/remix-ui/git/src/components/panels/remotes.tsx +++ b/libs/remix-ui/git/src/components/panels/remotes.tsx @@ -3,6 +3,8 @@ import { gitActionsContext } from "../../state/context" import { gitPluginContext } from "../gitui" import { Remoteselect } from "./remoteselect" import { RemotesImport } from "./remotesimport" +import { sendToMatomo } from "../../lib/pluginActions" +import { gitMatomoEventTypes } from "../../types" export const Remotes = () => { const context = React.useContext(gitPluginContext) @@ -18,6 +20,7 @@ export const Remotes = () => { } const addRemote = async () => { + await sendToMatomo(gitMatomoEventTypes.ADDMANUALREMOTE) actions.addRemote({ name: remoteName, url: url diff --git a/libs/remix-ui/git/src/lib/gitactions.ts b/libs/remix-ui/git/src/lib/gitactions.ts index 23a4726735..9d9b3f8ecb 100644 --- a/libs/remix-ui/git/src/lib/gitactions.ts +++ b/libs/remix-ui/git/src/lib/gitactions.ts @@ -1,11 +1,11 @@ import { ReadBlobResult, ReadCommitResult } from "isomorphic-git"; import React from "react"; import { fileStatus, fileStatusMerge, setRemoteBranchCommits, resetRemoteBranchCommits, setBranches, setCanCommit, setCommitChanges, setCommits, setCurrentBranch, setGitHubUser, setLoading, setRemoteBranches, setRemotes, setRepos, setUpstream, setLocalBranchCommits, setBranchDifferences, setRemoteAsDefault, setScopes, setLog, clearLog, setUserEmails, setCurrenHead, setStoragePayload, resetBranchDifferences } from "../state/gitpayload"; -import { GitHubUser, branch, commitChange, gitActionDispatch, statusMatrixType, gitState, branchDifference, remote, gitLog, fileStatusResult, customGitApi, IGitApi, cloneInputType, fetchInputType, pullInputType, pushInputType, checkoutInput, rmInput, addInput, repository, userEmails, storage } from '../types'; +import { GitHubUser, branch, commitChange, gitActionDispatch, statusMatrixType, gitState, branchDifference, remote, gitLog, fileStatusResult, customGitApi, IGitApi, cloneInputType, fetchInputType, pullInputType, pushInputType, checkoutInput, rmInput, addInput, repository, userEmails, storage, gitMatomoEventTypes } from '../types'; import { removeSlash } from "../utils"; import { disableCallBacks, enableCallBacks } from "./listeners"; import { ModalTypes } from "@remix-ui/app"; -import { setFileDecorators } from "./pluginActions"; +import { sendToMatomo, setFileDecorators } from "./pluginActions"; import { Plugin } from "@remixproject/engine"; import { CustomRemixApi } from "@remix-api"; @@ -24,27 +24,6 @@ export const fileStatuses = [ ["unstaged,modified", 1, 2, 0] ]; -enum gitEventTypes { - INIT = 'INIT', - COMMIT = 'COMMIT', - PUSH = 'PUSH', - PULL = 'PULL', - ADDREMOTE = 'ADDREMOTE', - RMREMOTE = 'RMREMOTE', - CLONE = 'CLONE', - FETCH = 'FETCH', - ADD = 'ADD', - ADD_ALL = 'ADD_ALL', - RM = 'RM', - CHECKOUT = 'CHECKOUT', - DIFF = 'DIFF', - BRANCH = 'BRANCH', - CREATEBRANCH = 'CREATEBRANCH', -} - - - - const statusmatrix: statusMatrixType[] = fileStatuses.map((x: any) => { return { matrix: x.shift().split(","), @@ -59,12 +38,8 @@ export const setPlugin = (p: Plugin, dispatcher: React.Dispatch { - plugin.call('matomo', 'track', ['trackEvent', 'git', event]) -} - export const init = async () => { - sendToMatomo(gitEventTypes.INIT) + await sendToMatomo(gitMatomoEventTypes.INIT) await plugin.call('dgitApi', "init"); await gitlog(); await getBranches(); @@ -169,7 +144,7 @@ export const currentBranch = async () => { } export const createBranch = async (name: string = "") => { - sendToMatomo(gitEventTypes.CREATEBRANCH) + await sendToMatomo(gitMatomoEventTypes.CREATEBRANCH) dispatch(setLoading(true)) if (name) { await plugin.call('dgitApi', 'branch', { ref: name, force: true, checkout: true }); @@ -200,7 +175,7 @@ const settingsWarning = async () => { export const commit = async (message: string = "") => { - sendToMatomo(gitEventTypes.COMMIT) + await sendToMatomo(gitMatomoEventTypes.COMMIT) try { const credentials = await settingsWarning() if (!credentials) { @@ -228,7 +203,7 @@ export const commit = async (message: string = "") => { } export const addall = async (files: fileStatusResult[]) => { - sendToMatomo(gitEventTypes.ADD_ALL) + await sendToMatomo(gitMatomoEventTypes.ADD_ALL) try { const filesToAdd = files .filter(f => !f.statusNames.includes('deleted')) @@ -254,7 +229,7 @@ export const addall = async (files: fileStatusResult[]) => { } export const add = async (filepath: addInput) => { - sendToMatomo(gitEventTypes.ADD) + await sendToMatomo(gitMatomoEventTypes.ADD) try { if (typeof filepath.filepath === "string") { filepath.filepath = removeSlash(filepath.filepath) @@ -281,7 +256,7 @@ const getLastCommmit = async () => { } export const rm = async (args: rmInput) => { - sendToMatomo(gitEventTypes.RM) + await sendToMatomo(gitMatomoEventTypes.RM) await plugin.call('dgitApi', 'rm', { filepath: removeSlash(args.filepath), }); @@ -318,7 +293,7 @@ export const checkoutfile = async (filename: string) => { } export const checkout = async (cmd: checkoutInput) => { - + sendToMatomo(gitMatomoEventTypes.CHECKOUT) await disableCallBacks(); await plugin.call('fileManager', 'closeAllFiles') try { @@ -332,7 +307,7 @@ export const checkout = async (cmd: checkoutInput) => { export const clone = async (input: cloneInputType) => { - sendToMatomo(gitEventTypes.CLONE) + await sendToMatomo(gitMatomoEventTypes.CLONE) dispatch(setLoading(true)) const urlParts = input.url.split("/"); const lastPart = urlParts[urlParts.length - 1]; @@ -361,7 +336,7 @@ export const clone = async (input: cloneInputType) => { } export const fetch = async (input: fetchInputType) => { - sendToMatomo(gitEventTypes.FETCH) + await sendToMatomo(gitMatomoEventTypes.FETCH) dispatch(setLoading(true)) await disableCallBacks() try { @@ -379,7 +354,7 @@ export const fetch = async (input: fetchInputType) => { } export const pull = async (input: pullInputType) => { - sendToMatomo(gitEventTypes.PULL) + await sendToMatomo(gitMatomoEventTypes.PULL) dispatch(setLoading(true)) await disableCallBacks() try { @@ -394,7 +369,7 @@ export const pull = async (input: pullInputType) => { } export const push = async (input: pushInputType) => { - sendToMatomo(gitEventTypes.PUSH) + await sendToMatomo(gitMatomoEventTypes.PUSH) dispatch(setLoading(true)) await disableCallBacks() try { @@ -420,6 +395,7 @@ const parseError = async (e: any) => { console.trace(e) // if message conttains 401 Unauthorized, show token warning if (e.message.includes('401')) { + await sendToMatomo(gitMatomoEventTypes.ERROR, ['401']) const result = await plugin.call('notification', 'modal' as any, { title: 'The GitHub token may be missing or invalid', message: 'Please check the GitHub token and try again. Error: 401 Unauthorized', @@ -430,6 +406,7 @@ const parseError = async (e: any) => { } // if message contains 404 Not Found, show repo not found else if (e.message.includes('404')) { + await sendToMatomo(gitMatomoEventTypes.ERROR, ['404']) await plugin.call('notification', 'modal' as any, { title: 'Repository not found', message: 'Please check the URL and try again.', @@ -440,6 +417,7 @@ const parseError = async (e: any) => { } // if message contains 403 Forbidden else if (e.message.includes('403')) { + await sendToMatomo(gitMatomoEventTypes.ERROR, ['403']) await plugin.call('notification', 'modal' as any, { title: 'The GitHub token may be missing or invalid', message: 'Please check the GitHub token and try again. Error: 403 Forbidden', @@ -448,6 +426,7 @@ const parseError = async (e: any) => { type: ModalTypes.confirm }) } else if (e.toString().includes('NotFoundError') && !e.toString().includes('fetch')) { + await sendToMatomo(gitMatomoEventTypes.ERROR, ['BRANCH NOT FOUND ON REMOTE']) await plugin.call('notification', 'modal', { title: 'Remote branch not found', message: 'The branch you are trying to fetch does not exist on the remote. If you have forked this branch from another branch, you may need to fetch the original branch first or publish this branch on the remote.', @@ -455,6 +434,7 @@ const parseError = async (e: any) => { type: ModalTypes.alert }) } else { + await sendToMatomo(gitMatomoEventTypes.ERROR, ['UKNOWN']) await plugin.call('notification', 'alert' as any, { title: 'Error', message: e.message @@ -482,6 +462,7 @@ export const repositories = async () => { } } else { + await sendToMatomo(gitMatomoEventTypes.ERROR, ['TOKEN ERROR']) plugin.call('notification', 'alert', { id: 'github-token-error', title: 'Error getting repositories', @@ -491,6 +472,7 @@ export const repositories = async () => { } } catch (e) { console.log(e) + await sendToMatomo(gitMatomoEventTypes.ERROR, ['TOKEN ERROR']) plugin.call('notification', 'alert', { id: 'github-token-error', title: 'Error getting repositories', @@ -519,6 +501,7 @@ export const remoteBranches = async (owner: string, repo: string) => { page++ } } else { + await sendToMatomo(gitMatomoEventTypes.ERROR, ['TOKEN ERROR']) plugin.call('notification', 'alert', { title: 'Error getting branches', id: 'github-token-error', @@ -528,6 +511,7 @@ export const remoteBranches = async (owner: string, repo: string) => { } } catch (e) { console.log(e) + await sendToMatomo(gitMatomoEventTypes.ERROR, ['TOKEN ERROR']) plugin.call('notification', 'alert', { title: 'Error', id: 'github-error', @@ -697,7 +681,7 @@ export const resolveRef = async (ref: string) => { } export const diff = async (commitChange: commitChange) => { - sendToMatomo(gitEventTypes.DIFF) + await sendToMatomo(gitMatomoEventTypes.DIFF) if (!commitChange.hashModified) { const newcontent = await plugin.call( "fileManager", @@ -864,11 +848,12 @@ export const getBranchCommits = async (branch: branch, page: number) => { } export const setDefaultRemote = async (remote: remote) => { + await sendToMatomo(gitMatomoEventTypes.SETDEFAULTREMOTE) dispatch(setRemoteAsDefault(remote)) } export const addRemote = async (remote: remote) => { - sendToMatomo(gitEventTypes.ADDREMOTE) + await sendToMatomo(gitMatomoEventTypes.ADDREMOTE) try { await plugin.call('dgitApi', 'addremote', remote) await getRemotes() @@ -883,7 +868,7 @@ export const addRemote = async (remote: remote) => { } export const removeRemote = async (remote: remote) => { - sendToMatomo(gitEventTypes.RMREMOTE) + await sendToMatomo(gitMatomoEventTypes.RMREMOTE) try { await plugin.call('dgitApi', 'delremote', remote) await getRemotes() diff --git a/libs/remix-ui/git/src/lib/listeners.ts b/libs/remix-ui/git/src/lib/listeners.ts index c2c995f4ce..c0f3e89fb5 100644 --- a/libs/remix-ui/git/src/lib/listeners.ts +++ b/libs/remix-ui/git/src/lib/listeners.ts @@ -1,7 +1,7 @@ import React from "react"; import { setCanUseApp, setLoading, setRepoName, setGItHubToken, setLog, setGitHubUser, setUserEmails } from "../state/gitpayload"; -import { gitActionDispatch, storage } from "../types"; +import { gitActionDispatch, gitUIPanels, storage } from "../types"; import { Plugin } from "@remixproject/engine"; import { getBranches, getFileStatusMatrix, loadGitHubUserFromToken, getRemotes, gitlog, setPlugin, setStorage } from "./gitactions"; import { Profile } from "@remixproject/plugin-utils"; @@ -163,11 +163,8 @@ export const setCallBacks = (viewPlugin: Plugin, gitDispatcher: React.Dispatch { - const panels = { - 'branches': '2' - } - const panelNumber = panels[panel] - setAtivePanel(panelNumber) + + setAtivePanel(panel) }) callBackEnabled = true; diff --git a/libs/remix-ui/git/src/lib/pluginActions.ts b/libs/remix-ui/git/src/lib/pluginActions.ts index ece2b3953a..7d9e81ee7a 100644 --- a/libs/remix-ui/git/src/lib/pluginActions.ts +++ b/libs/remix-ui/git/src/lib/pluginActions.ts @@ -1,5 +1,5 @@ -import { commitChange, fileStatusResult, gitActionDispatch, gitState } from "../types" +import { commitChange, fileStatusResult, gitActionDispatch, gitMatomoEventTypes, gitState } from "../types" import { fileDecoration, fileDecorationType } from "@remix-ui/file-decorators" import { removeSlash } from "../utils" import { getFilesByStatus } from "./fileHelpers" @@ -98,3 +98,8 @@ export const clearFileDecorator = async(path: string) => { await plugin.call('fileDecorator', 'clearFileDecorators', path) } +export const sendToMatomo = async (event: gitMatomoEventTypes, args?: string[]) => { + const trackArgs = args ? ['trackEvent', 'git', event, ...args] : ['trackEvent', 'git', event]; + plugin && await plugin.call('matomo', 'track', trackArgs); +} + diff --git a/libs/remix-ui/git/src/types/index.ts b/libs/remix-ui/git/src/types/index.ts index 0041aaf357..d85a4a025c 100644 --- a/libs/remix-ui/git/src/types/index.ts +++ b/libs/remix-ui/git/src/types/index.ts @@ -143,8 +143,8 @@ export interface repositoriesInput { token: string, page?: number, per_page?: nu export interface statusInput { ref: string, filepaths?: string[] } export const dGitProfile: LibraryProfile = { - name: 'dgitApi', - methods: ['clone', 'branches', 'remotes', 'getCommitChanges', 'log', 'remotecommits'], + name: 'dgitApi', + methods: ['clone', 'branches', 'remotes', 'getCommitChanges', 'log', 'remotecommits'], } export interface customGitApi extends IRemixApi { @@ -266,53 +266,53 @@ export type remoteBranch = { } export const defaultGitState: gitState = { - currentBranch: { name: "", remote: { name: "", url: "" } }, - currentHead: "", - commits: [], - branch: "", - canCommit: true, - branches: [], - remotes: [], - defaultRemote: null, - fileStatusResult: [], - staged: [], - untracked: [], - deleted: [], - modified: [], - allchangesnotstaged: [], - canUseApp: true, - loading: false, - storage: { - used: 0, - total: 0, - available: 0, - percentUsed: 0, - enabled: false - }, - reponame: "", - repositories: [], - remoteBranches: [], - commitChanges: [], - remoteBranchCommits: {}, - localBranchCommits: {}, - branchDifferences: {}, - syncStatus: syncStatus.none, - localCommitCount: 0, - remoteCommitCount: 0, - upstream: null, - gitHubUser: {} as GitHubUser, - userEmails: [] as userEmails, - gitHubScopes: [], - gitHubAccessToken: "", - log: [] + currentBranch: { name: "", remote: { name: "", url: "" } }, + currentHead: "", + commits: [], + branch: "", + canCommit: true, + branches: [], + remotes: [], + defaultRemote: null, + fileStatusResult: [], + staged: [], + untracked: [], + deleted: [], + modified: [], + allchangesnotstaged: [], + canUseApp: true, + loading: false, + storage: { + used: 0, + total: 0, + available: 0, + percentUsed: 0, + enabled: false + }, + reponame: "", + repositories: [], + remoteBranches: [], + commitChanges: [], + remoteBranchCommits: {}, + localBranchCommits: {}, + branchDifferences: {}, + syncStatus: syncStatus.none, + localCommitCount: 0, + remoteCommitCount: 0, + upstream: null, + gitHubUser: {} as GitHubUser, + userEmails: [] as userEmails, + gitHubScopes: [], + gitHubAccessToken: "", + log: [] } export const defaultLoaderState: loaderState = { - branches: false, - commits: false, - sourcecontrol: false, - remotes: false, - plugin: false + branches: false, + commits: false, + sourcecontrol: false, + remotes: false, + plugin: false } export type fileStatusResult = { @@ -338,6 +338,52 @@ export type storage = { enabled: boolean } +export enum gitMatomoEventTypes { + INIT = 'INIT', + COMMIT = 'COMMIT', + PUSH = 'PUSH', + PULL = 'PULL', + ADDREMOTE = 'ADDREMOTE', + RMREMOTE = 'RMREMOTE', + CLONE = 'CLONE', + FETCH = 'FETCH', + ADD = 'ADD', + ADD_ALL = 'ADD_ALL', + RM = 'RM', + CHECKOUT = 'CHECKOUT', + CHECKOUT_LOCAL_BRANCH = 'CHECKOUT_LOCAL_BRANCH', + CHECKOUT_REMOTE_BRANCH = 'CHECKOUT_REMOTE_BRANCH', + DIFF = 'DIFF', + BRANCH = 'BRANCH', + CREATEBRANCH = 'CREATEBRANCH', + GETGITHUBDEVICECODE = 'GET_GITHUB_DEVICECODE', + CONNECTTOGITHUB = 'CONNECT_TO_GITHUB', + DISCONNECTFROMGITHUB = 'DISCONNECT_FROM_GITHUB', + SAVEMANUALGITHUBCREDENTIALS = 'SAVE_MANUAL_GITHUB_CREDENTIALS', + LOADREPOSITORIESFROMGITHUB = 'LOAD_REPOSITORIES_FROM_GITHUB', + COPYGITHUBDEVICECODE = 'COPY_GITHUB_DEVICE_CODE', + CONNECTTOGITHUBSUCCESS = 'CONNECT_TO_GITHUB_SUCCESS', + CONNECTTOGITHUBFAIL = 'CONNECT_TO_GITHUB_FAIL', + OPENPANEL = 'OPEN_PANEL', + ADDMANUALREMOTE = 'ADD_MANUAL_REMOTE', + SETDEFAULTREMOTE = 'SET_DEFAULT_REMOTE', + SETLOCALBRANCHINCOMMANDS = 'SET_LOCAL_BRANCH_IN_COMMANDS', + SETREMOTEBRANCHINCOMMANDS = 'SET_REMOTE_IN_COMMANDS', + REFRESH = 'REFRESH', + ERROR = 'ERROR', +} + +export enum gitUIPanels { + SOURCECONTROL = '0', + COMMANDS = '1', + BRANCHES = '2', + COMMITS = '3', + CLONE = '4', + REMOTES = '5', + GITHUB = '7', + LOG = '6' +} + export interface fileStatusAction { type: string, payload: fileStatusResult[] diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 499578f74c..8c2afd12d3 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -43,7 +43,7 @@ import { ROOT_PATH } from '../utils/constants' import { IndexedDBStorage } from '../../../../../../apps/remix-ide/src/app/files/filesystems/indexedDB' import { getUncommittedFiles } from '../utils/gitStatusFilter' import { AppModal, ModalTypes } from '@remix-ui/app' -import { branch, cloneInputType, IGitApi } from '@remix-ui/git' +import { branch, cloneInputType, IGitApi, gitUIPanels } from '@remix-ui/git' import * as templates from '@remix-project/remix-ws-templates' import { Plugin } from "@remixproject/engine"; import { CustomRemixApi } from '@remix-api' @@ -788,7 +788,7 @@ export const showAllBranches = async () => { const isActive = await plugin.call('manager', 'isActive', 'dgit') if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit') plugin.call('menuicons', 'select', 'dgit') - plugin.call('dgit', 'open', 'branches') + plugin.call('dgit', 'open', gitUIPanels.BRANCHES) } export const getGitConfig = async () => {