From e6e54620d2680c27689e2aa4d7040cc8b152102c Mon Sep 17 00:00:00 2001 From: Dmitry Romashov Date: Sat, 2 Feb 2019 11:57:40 +0300 Subject: [PATCH] add yandex-metric --- Izzy.Web/.gitignore | 1 + Izzy.Web/Client/package-lock.json | 5 +++++ Izzy.Web/Client/package.json | 1 + Izzy.Web/Client/src/YandexMetrica.tsx | 17 +++++++++++++++++ Izzy.Web/Client/src/index.tsx | 3 +++ 5 files changed, 27 insertions(+) create mode 100644 Izzy.Web/Client/src/YandexMetrica.tsx diff --git a/Izzy.Web/.gitignore b/Izzy.Web/.gitignore index 8f67a5b..c294aa7 100644 --- a/Izzy.Web/.gitignore +++ b/Izzy.Web/.gitignore @@ -23,6 +23,7 @@ bin/ Bin/ obj/ Obj/ +out/ # Visual Studio 2015 cache/options directory .vs/ diff --git a/Izzy.Web/Client/package-lock.json b/Izzy.Web/Client/package-lock.json index f9a00a1..f184394 100644 --- a/Izzy.Web/Client/package-lock.json +++ b/Izzy.Web/Client/package-lock.json @@ -14253,6 +14253,11 @@ "react-lifecycles-compat": "^3.0.4" } }, + "react-yandex-metrika": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/react-yandex-metrika/-/react-yandex-metrika-2.4.2.tgz", + "integrity": "sha512-UseTVfT6BFbJclauJy54avfoy1w4RyUZcAy3vk7Bz+ghosnfWsHIIhPg4z9U13tYqeHnYh8qMWeobYxOrdJgWw==" + }, "read-pkg": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", diff --git a/Izzy.Web/Client/package.json b/Izzy.Web/Client/package.json index 0aa008d..b8910b5 100644 --- a/Izzy.Web/Client/package.json +++ b/Izzy.Web/Client/package.json @@ -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" diff --git a/Izzy.Web/Client/src/YandexMetrica.tsx b/Izzy.Web/Client/src/YandexMetrica.tsx new file mode 100644 index 0000000..704b5b1 --- /dev/null +++ b/Izzy.Web/Client/src/YandexMetrica.tsx @@ -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 ( + + ) + } else { + return (
); + } +} diff --git a/Izzy.Web/Client/src/index.tsx b/Izzy.Web/Client/src/index.tsx index 132afc6..8b4abfc 100644 --- a/Izzy.Web/Client/src/index.tsx +++ b/Izzy.Web/Client/src/index.tsx @@ -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'; @@ -13,6 +15,7 @@ const store = configureStore(initialState); ReactDOM.render( + , document.getElementById('root') );