mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
commit
bfd48fec79
@ -15,12 +15,14 @@
|
|||||||
"@oceanprotocol/typographies": "^0.1.0",
|
"@oceanprotocol/typographies": "^0.1.0",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"filesize": "^4.1.2",
|
"filesize": "^4.1.2",
|
||||||
|
"history": "^4.9.0",
|
||||||
"is-url": "^1.2.4",
|
"is-url": "^1.2.4",
|
||||||
"moment": "^2.24.0",
|
"moment": "^2.24.0",
|
||||||
"query-string": "^6.4.2",
|
"query-string": "^6.4.2",
|
||||||
"react": "^16.8.6",
|
"react": "^16.8.6",
|
||||||
"react-datepicker": "^2.3.0",
|
"react-datepicker": "^2.3.0",
|
||||||
"react-dom": "^16.8.6",
|
"react-dom": "^16.8.6",
|
||||||
|
"react-ga": "^2.5.7",
|
||||||
"react-helmet": "^5.2.0",
|
"react-helmet": "^5.2.0",
|
||||||
"react-moment": "^0.8.4",
|
"react-moment": "^0.8.4",
|
||||||
"react-popper": "^1.3.3",
|
"react-popper": "^1.3.3",
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Route, Switch } from 'react-router-dom'
|
import { Route, Switch } from 'react-router-dom'
|
||||||
|
import withTracker from './withTracker'
|
||||||
|
|
||||||
import About from './routes/About'
|
import About from './routes/About'
|
||||||
import Details from './routes/Details/'
|
import Details from './routes/Details/'
|
||||||
@ -13,15 +14,15 @@ import Styleguide from './routes/Styleguide'
|
|||||||
|
|
||||||
const Routes = () => (
|
const Routes = () => (
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact component={Home} path="/" />
|
<Route exact component={withTracker(Home)} path="/" />
|
||||||
<Route component={Styleguide} path="/styleguide" />
|
<Route component={withTracker(Styleguide)} path="/styleguide" />
|
||||||
<Route component={About} path="/about" />
|
<Route component={withTracker(About)} path="/about" />
|
||||||
<Route component={Publish} path="/publish" />
|
<Route component={withTracker(Publish)} path="/publish" />
|
||||||
<Route component={Search} path="/search" />
|
<Route component={withTracker(Search)} path="/search" />
|
||||||
<Route component={Details} path="/asset/:did" />
|
<Route component={withTracker(Details)} path="/asset/:did" />
|
||||||
<Route component={Faucet} path="/faucet" />
|
<Route component={withTracker(Faucet)} path="/faucet" />
|
||||||
<Route component={History} path="/history" />
|
<Route component={withTracker(History)} path="/history" />
|
||||||
<Route component={NotFound} />
|
<Route component={withTracker(NotFound)} />
|
||||||
</Switch>
|
</Switch>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -72,4 +72,4 @@ export const faucetPort = process.env.REACT_APP_FAUCET_PORT || 443
|
|||||||
// export const faucetHost = 'localhost'
|
// export const faucetHost = 'localhost'
|
||||||
// export const faucetPort = 3001
|
// export const faucetPort = 3001
|
||||||
|
|
||||||
export const verbose = true
|
export const verbose = true
|
@ -5,6 +5,7 @@ import Button from '../../components/atoms/Button'
|
|||||||
import Spinner from '../../components/atoms/Spinner'
|
import Spinner from '../../components/atoms/Spinner'
|
||||||
import { User } from '../../context/User'
|
import { User } from '../../context/User'
|
||||||
import styles from './AssetFile.module.scss'
|
import styles from './AssetFile.module.scss'
|
||||||
|
import ReactGA from 'react-ga'
|
||||||
|
|
||||||
interface AssetFileProps {
|
interface AssetFileProps {
|
||||||
file: any
|
file: any
|
||||||
@ -32,10 +33,15 @@ export default class AssetFile extends PureComponent<
|
|||||||
private purchaseAsset = async (ddo: any, index: number) => {
|
private purchaseAsset = async (ddo: any, index: number) => {
|
||||||
this.resetState()
|
this.resetState()
|
||||||
|
|
||||||
const { ocean } = this.context
|
ReactGA.event({
|
||||||
const accounts = await ocean.accounts.list()
|
category: 'Purchase',
|
||||||
|
action: 'purchaseAsset-start ' + ddo.id
|
||||||
|
})
|
||||||
|
|
||||||
|
const { ocean } = this.context
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const accounts = await ocean.accounts.list()
|
||||||
const service = ddo.findServiceByType('Access')
|
const service = ddo.findServiceByType('Access')
|
||||||
const agreementId = await ocean.assets.order(
|
const agreementId = await ocean.assets.order(
|
||||||
ddo.id,
|
ddo.id,
|
||||||
@ -52,11 +58,18 @@ export default class AssetFile extends PureComponent<
|
|||||||
index
|
index
|
||||||
)
|
)
|
||||||
Logger.log('path', path)
|
Logger.log('path', path)
|
||||||
|
ReactGA.event({
|
||||||
|
category: 'Purchase',
|
||||||
|
action: 'purchaseAsset-end ' + ddo.id
|
||||||
|
})
|
||||||
this.setState({ isLoading: false })
|
this.setState({ isLoading: false })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Logger.log('error', error)
|
Logger.log('error', error)
|
||||||
this.setState({ isLoading: false, error: error.message })
|
this.setState({ isLoading: false, error: error.message })
|
||||||
|
ReactGA.event({
|
||||||
|
category: 'Purchase',
|
||||||
|
action: 'purchaseAsset-error ' + error.message
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import AssetModel from '../../models/AssetModel'
|
|||||||
import { User } from '../../context/User'
|
import { User } from '../../context/User'
|
||||||
import Step from './Step'
|
import Step from './Step'
|
||||||
import Progress from './Progress'
|
import Progress from './Progress'
|
||||||
|
import ReactGA from 'react-ga'
|
||||||
|
|
||||||
import { steps } from '../../data/form-publish.json'
|
import { steps } from '../../data/form-publish.json'
|
||||||
|
|
||||||
@ -90,6 +91,12 @@ class Publish extends Component<{}, PublishState> {
|
|||||||
|
|
||||||
currentStep =
|
currentStep =
|
||||||
currentStep >= totalSteps - 1 ? totalSteps : currentStep + 1
|
currentStep >= totalSteps - 1 ? totalSteps : currentStep + 1
|
||||||
|
|
||||||
|
ReactGA.event({
|
||||||
|
category: 'Publish',
|
||||||
|
action: 'nextStep ' + currentStep
|
||||||
|
})
|
||||||
|
|
||||||
this.setState({ currentStep })
|
this.setState({ currentStep })
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,6 +249,10 @@ class Publish extends Component<{}, PublishState> {
|
|||||||
|
|
||||||
private registerAsset = async (event: FormEvent<HTMLFormElement>) => {
|
private registerAsset = async (event: FormEvent<HTMLFormElement>) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
ReactGA.event({
|
||||||
|
category: 'Publish',
|
||||||
|
action: 'registerAsset-start'
|
||||||
|
});
|
||||||
this.setState({
|
this.setState({
|
||||||
publishingError: '',
|
publishingError: '',
|
||||||
isPublishing: true
|
isPublishing: true
|
||||||
@ -281,11 +292,19 @@ class Publish extends Component<{}, PublishState> {
|
|||||||
publishedDid: asset.id,
|
publishedDid: asset.id,
|
||||||
isPublished: true
|
isPublished: true
|
||||||
})
|
})
|
||||||
|
ReactGA.event({
|
||||||
|
category: 'Publish',
|
||||||
|
action: 'registerAsset-end' + asset.id
|
||||||
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// make readable errors
|
// make readable errors
|
||||||
Logger.log('error:', e)
|
Logger.log('error:', e)
|
||||||
this.setState({
|
this.setState({
|
||||||
publishingError: e
|
publishingError: e.message
|
||||||
|
})
|
||||||
|
ReactGA.event({
|
||||||
|
category: 'Publish',
|
||||||
|
action: 'registerAsset-error' + e.message
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
|
41
client/src/withTracker.tsx
Normal file
41
client/src/withTracker.tsx
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import React, { Component } from 'react'
|
||||||
|
import ReactGA from 'react-ga'
|
||||||
|
|
||||||
|
interface TrackerProps {
|
||||||
|
location: any
|
||||||
|
}
|
||||||
|
|
||||||
|
ReactGA.initialize('UA-60614729-11', {testMode: process.env.NODE_ENV === 'test'})
|
||||||
|
|
||||||
|
export default function withTracker(WrappedComponent: any, options: any = {}) {
|
||||||
|
const trackPage = (page: any) => {
|
||||||
|
options.isWeb3 = (window.web3 !== undefined)
|
||||||
|
ReactGA.set({
|
||||||
|
page,
|
||||||
|
...options
|
||||||
|
})
|
||||||
|
ReactGA.pageview(page)
|
||||||
|
}
|
||||||
|
|
||||||
|
const HOC = class extends Component<TrackerProps, {}> {
|
||||||
|
componentDidMount() {
|
||||||
|
const page = this.props.location.pathname + this.props.location.search
|
||||||
|
trackPage(page)
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillReceiveProps(nextProps: any) {
|
||||||
|
const currentPage = this.props.location.pathname;
|
||||||
|
const nextPage = nextProps.location.pathname;
|
||||||
|
|
||||||
|
if (currentPage !== nextPage) {
|
||||||
|
trackPage(nextProps.location.pathname + nextProps.location.search);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return <WrappedComponent {...this.props} />
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return HOC
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user