Skip to content

Commit

Permalink
Merge pull request #5 from FrameBassman/dev
Browse files Browse the repository at this point in the history
add yandex-metric
  • Loading branch information
framebassman committed Feb 2, 2019
2 parents e64b3d4 + e6e5462 commit 5efdfbc
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions Izzy.Web/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ bin/
Bin/
obj/
Obj/
out/

# Visual Studio 2015 cache/options directory
.vs/
Expand Down
5 changes: 5 additions & 0 deletions Izzy.Web/Client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Izzy.Web/Client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"react-dom": "^16.7.0",
"react-redux": "^6.0.0",
"react-scripts": "2.1.3",
"react-yandex-metrika": "^2.4.2",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0",
"typescript": "3.2.2"
Expand Down
17 changes: 17 additions & 0 deletions Izzy.Web/Client/src/YandexMetrica.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { YMInitializer } from 'react-yandex-metrika';

function isProd(): boolean {
return process.env.ASPNETCORE_ENVIRONMENT === 'production'
|| process.env.NODE_ENV === 'production';
}

export const YandexMetrica = (props: any) => {
if (isProd()) {
return (
<YMInitializer accounts={props.accounts}/>
)
} else {
return (<div/>);
}
}
3 changes: 3 additions & 0 deletions Izzy.Web/Client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Provider } from 'react-redux';

import './index.css';
import App from './App';
import { YandexMetrica } from './YandexMetrica';
import { YMInitializer } from 'react-yandex-metrika';
import * as serviceWorker from './serviceWorker';
import configureStore from './store/configureStore';

Expand All @@ -13,6 +15,7 @@ const store = configureStore(initialState);
ReactDOM.render(
<Provider store={store}>
<App/>
<YandexMetrica accounts={[52190806]} />
</Provider>,
document.getElementById('root')
);
Expand Down

0 comments on commit 5efdfbc

Please sign in to comment.