mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
analytics
This commit is contained in:
parent
699b45da0e
commit
f3db82b59d
@ -1,5 +1,6 @@
|
||||
import React from 'react'
|
||||
import { Route, Switch } from 'react-router-dom'
|
||||
import withTracker from './withTracker'
|
||||
|
||||
import About from './routes/About'
|
||||
import Details from './routes/Details/'
|
||||
@ -13,15 +14,15 @@ import Styleguide from './routes/Styleguide'
|
||||
|
||||
const Routes = () => (
|
||||
<Switch>
|
||||
<Route exact component={Home} path="/" />
|
||||
<Route component={Styleguide} path="/styleguide" />
|
||||
<Route component={About} path="/about" />
|
||||
<Route component={Publish} path="/publish" />
|
||||
<Route component={Search} path="/search" />
|
||||
<Route component={Details} path="/asset/:did" />
|
||||
<Route component={Faucet} path="/faucet" />
|
||||
<Route component={History} path="/history" />
|
||||
<Route component={NotFound} />
|
||||
<Route exact component={withTracker(Home)} path="/" />
|
||||
<Route component={withTracker(Styleguide)} path="/styleguide" />
|
||||
<Route component={withTracker(About)} path="/about" />
|
||||
<Route component={withTracker(Publish)} path="/publish" />
|
||||
<Route component={withTracker(Search)} path="/search" />
|
||||
<Route component={withTracker(Details)} path="/asset/:did" />
|
||||
<Route component={withTracker(Faucet)} path="/faucet" />
|
||||
<Route component={withTracker(History)} path="/history" />
|
||||
<Route component={withTracker(NotFound)} />
|
||||
</Switch>
|
||||
)
|
||||
|
||||
|
@ -1,68 +1,66 @@
|
||||
//
|
||||
// commons-server connection
|
||||
//
|
||||
export const serviceScheme = process.env.REACT_APP_SERVICE_SCHEME || 'http'
|
||||
export const serviceHost = process.env.REACT_APP_SERVICE_HOST || 'localhost'
|
||||
export const servicePort = process.env.REACT_APP_SERVICE_PORT || 4000
|
||||
export const serviceScheme = 'http'
|
||||
export const serviceHost = 'localhost'
|
||||
export const servicePort = 4000
|
||||
|
||||
//
|
||||
// OCEAN REMOTE CONNECTIONS
|
||||
//
|
||||
export const nodeScheme = process.env.REACT_APP_NODE_SCHEME || 'https'
|
||||
export const nodeHost = process.env.REACT_APP_NODE_HOST || 'nile.dev-ocean.com'
|
||||
export const nodePort = process.env.REACT_APP_NODE_PORT || 443
|
||||
/*
|
||||
export const nodeScheme = 'https'
|
||||
export const nodeHost = 'nile.dev-ocean.com'
|
||||
export const nodePort = 443
|
||||
|
||||
export const aquariusScheme = process.env.REACT_APP_AQUARIUS_SCHEME || 'https'
|
||||
export const aquariusHost = process.env.REACT_APP_AQUARIUS_HOST || 'nginx-aquarius.dev-ocean.com'
|
||||
export const aquariusPort = process.env.REACT_APP_AQUARIUS_PORT || 443
|
||||
export const aquariusScheme = 'https'
|
||||
export const aquariusHost = 'nginx-aquarius.dev-ocean.com'
|
||||
export const aquariusPort = 443
|
||||
|
||||
export const brizoScheme = process.env.REACT_APP_BRIZO_SCHEME || 'https'
|
||||
export const brizoHost = process.env.REACT_APP_BRIZO_HOST || 'nginx-brizo.dev-ocean.com'
|
||||
export const brizoPort = process.env.REACT_APP_BRIZO_PORT || 443
|
||||
export const brizoAddress = process.env.REACT_APP_BRIZO_ADDRESS || '0x376817c638d2a04f475a73af37f7b51a2862d567'
|
||||
export const brizoScheme = 'https'
|
||||
export const brizoHost = 'nginx-brizo.dev-ocean.com'
|
||||
export const brizoPort = 443
|
||||
export const brizoAddress = '0x376817c638d2a04f475a73af37f7b51a2862d567'
|
||||
|
||||
export const parityScheme = process.env.REACT_APP_PARITY_SCHEME || 'https'
|
||||
export const parityHost = process.env.REACT_APP_PARITY_HOST || 'nile.dev-ocean.com'
|
||||
export const parityPort = process.env.REACT_APP_PARITY_PORT || 443
|
||||
export const parityScheme = 'https'
|
||||
export const parityHost = 'nile.dev-ocean.com'
|
||||
export const parityPort = 443
|
||||
|
||||
export const secretStoreScheme = process.env.REACT_APP_SECRET_STORE_SCHEME || 'https'
|
||||
export const secretStoreHost = process.env.REACT_APP_SECRET_STORE_HOST || 'secret-store.dev-ocean.com'
|
||||
export const secretStorePort = process.env.REACT_APP_SECRET_STORE_PORT || 443
|
||||
|
||||
export const faucetScheme = process.env.REACT_APP_FAUCET_SCHEME || 'https'
|
||||
export const faucetHost = process.env.REACT_APP_FAUCET_HOST || 'faucet.nile.dev-ocean.com'
|
||||
export const faucetPort = process.env.REACT_APP_FAUCET_PORT || 443
|
||||
export const secretStoreScheme = 'https'
|
||||
export const secretStoreHost = 'secret-store.dev-ocean.com'
|
||||
export const secretStorePort = 443
|
||||
|
||||
export const faucetScheme = 'https'
|
||||
export const faucetHost = 'faucet.nile.dev-ocean.com'
|
||||
export const faucetPort = 443
|
||||
*/
|
||||
//
|
||||
// OCEAN LOCAL CONNECTIONS
|
||||
// e.g. when running with barge
|
||||
//
|
||||
// export const nodeScheme = 'http'
|
||||
// export const nodeHost = 'localhost'
|
||||
// export const nodePort = 8545
|
||||
export const nodeScheme = 'http'
|
||||
export const nodeHost = 'localhost'
|
||||
export const nodePort = 8545
|
||||
|
||||
// export const aquariusScheme = 'http'
|
||||
// export const aquariusHost = 'aquarius'
|
||||
// export const aquariusPort = 5000
|
||||
export const aquariusScheme = 'http'
|
||||
export const aquariusHost = 'aquarius'
|
||||
export const aquariusPort = 5000
|
||||
|
||||
// export const brizoScheme = 'http'
|
||||
// export const brizoHost = 'localhost'
|
||||
// export const brizoPort = 8030
|
||||
export const brizoScheme = 'http'
|
||||
export const brizoHost = 'localhost'
|
||||
export const brizoPort = 8030
|
||||
export const brizoAddress = '0x00Bd138aBD70e2F00903268F3Db08f2D25677C9e'
|
||||
|
||||
// export const parityScheme = 'http'
|
||||
// export const parityHost = 'localhost'
|
||||
// export const parityPort = 8545
|
||||
// export const threshold = 0
|
||||
// export const password = 'node0'
|
||||
// export const address = '0x00bd138abd70e2f00903268f3db08f2d25677c9e'
|
||||
export const parityScheme = 'http'
|
||||
export const parityHost = 'localhost'
|
||||
export const parityPort = 8545
|
||||
|
||||
// export const secretStoreScheme = 'http'
|
||||
// export const secretStoreHost = 'localhost'
|
||||
// export const secretStorePort = 12001
|
||||
export const secretStoreScheme = 'http'
|
||||
export const secretStoreHost = 'localhost'
|
||||
export const secretStorePort = 12001
|
||||
|
||||
// export const faucetScheme = 'http'
|
||||
// export const faucetHost = 'localhost'
|
||||
// export const faucetPort = 3001
|
||||
export const faucetScheme = 'http'
|
||||
export const faucetHost = 'localhost'
|
||||
export const faucetPort = 3001
|
||||
|
||||
export const verbose = true
|
||||
|
||||
|
@ -5,6 +5,7 @@ import { User } from '../../context/User'
|
||||
import Button from '../../components/atoms/Button'
|
||||
import Spinner from '../../components/atoms/Spinner'
|
||||
import styles from './AssetFile.module.scss'
|
||||
import ReactGA from 'react-ga'
|
||||
|
||||
interface AssetFileProps {
|
||||
file: any
|
||||
@ -32,10 +33,15 @@ export default class AssetFile extends PureComponent<
|
||||
private purchaseAsset = async (ddo: any, index: number) => {
|
||||
this.resetState()
|
||||
|
||||
const { ocean } = this.context
|
||||
const accounts = await ocean.accounts.list()
|
||||
ReactGA.event({
|
||||
category: 'Purchase',
|
||||
action: 'purchaseAsset-start ' + ddo.id
|
||||
})
|
||||
|
||||
const { ocean } = this.context
|
||||
|
||||
try {
|
||||
const accounts = await ocean.accounts.list()
|
||||
const service = ddo.findServiceByType('Access')
|
||||
const agreementId = await ocean.assets.order(
|
||||
ddo.id,
|
||||
@ -52,11 +58,18 @@ export default class AssetFile extends PureComponent<
|
||||
index
|
||||
)
|
||||
Logger.log('path', path)
|
||||
|
||||
ReactGA.event({
|
||||
category: 'Purchase',
|
||||
action: 'purchaseAsset-end ' + ddo.id
|
||||
})
|
||||
this.setState({ isLoading: false })
|
||||
} catch (error) {
|
||||
Logger.log('error', error)
|
||||
this.setState({ isLoading: false, error: error.message })
|
||||
ReactGA.event({
|
||||
category: 'Purchase',
|
||||
action: 'purchaseAsset-error ' + error
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import AssetModel from '../../models/AssetModel'
|
||||
import { User } from '../../context/User'
|
||||
import Step from './Step'
|
||||
import Progress from './Progress'
|
||||
import ReactGA from 'react-ga'
|
||||
|
||||
import { steps } from '../../data/form-publish.json'
|
||||
|
||||
@ -90,6 +91,12 @@ class Publish extends Component<{}, PublishState> {
|
||||
|
||||
currentStep =
|
||||
currentStep >= totalSteps - 1 ? totalSteps : currentStep + 1
|
||||
|
||||
ReactGA.event({
|
||||
category: 'Publish',
|
||||
action: 'nextStep ' + currentStep
|
||||
})
|
||||
|
||||
this.setState({ currentStep })
|
||||
}
|
||||
|
||||
@ -242,6 +249,10 @@ class Publish extends Component<{}, PublishState> {
|
||||
|
||||
private registerAsset = async (event: FormEvent<HTMLFormElement>) => {
|
||||
event.preventDefault()
|
||||
ReactGA.event({
|
||||
category: 'Publish',
|
||||
action: 'registerAsset-start'
|
||||
});
|
||||
this.setState({
|
||||
publishingError: '',
|
||||
isPublishing: true
|
||||
@ -281,12 +292,20 @@ class Publish extends Component<{}, PublishState> {
|
||||
publishedDid: asset.id,
|
||||
isPublished: true
|
||||
})
|
||||
ReactGA.event({
|
||||
category: 'Publish',
|
||||
action: 'registerAsset-end' + asset.id
|
||||
})
|
||||
} catch (e) {
|
||||
// make readable errors
|
||||
Logger.log('error:', e)
|
||||
this.setState({
|
||||
publishingError: e
|
||||
})
|
||||
ReactGA.event({
|
||||
category: 'Publish',
|
||||
action: 'registerAsset-error' + e
|
||||
})
|
||||
}
|
||||
this.setState({
|
||||
isPublishing: false
|
||||
|
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');
|
||||
|
||||
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