From efb1cba2164df8dfc1ca47aa66302284138b0d82 Mon Sep 17 00:00:00 2001 From: anatolykopyl Date: Tue, 5 Jul 2022 14:49:12 +0300 Subject: [PATCH] Remove metrika id from env --- .drone.yml | 3 --- app/.env.local.example | 1 - app/components/WithYandexMetrika.js | 10 ++++------ 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.drone.yml b/.drone.yml index 4460a29..1bffb44 100644 --- a/.drone.yml +++ b/.drone.yml @@ -41,9 +41,6 @@ steps: from_secret: ssh_private_key MONGODB_URI: from_secret: MONGODB_URI - YA_METRIKA_ID: - from_secret: YA_METRIKA_ID - NODE_ENV: production commands: - git clone -b monorepo https://git.radner.ru/anatolykopyl/warframe-center.git - cd warframe-center diff --git a/app/.env.local.example b/app/.env.local.example index 32e425e..1929839 100644 --- a/app/.env.local.example +++ b/app/.env.local.example @@ -1,2 +1 @@ MONGODB_URI= -YA_METRIKA_ID= diff --git a/app/components/WithYandexMetrika.js b/app/components/WithYandexMetrika.js index 07c2b48..fa2783f 100644 --- a/app/components/WithYandexMetrika.js +++ b/app/components/WithYandexMetrika.js @@ -2,20 +2,18 @@ import Router from 'next/router' import React, { useCallback, useEffect } from 'react' import ym, { YMInitializer } from 'react-yandex-metrika' -const enabled = - process.env.NODE_ENV === 'production' && - process.env.YA_METRIKA_ID - const WithYandexMetrika = (props) => { const { children } = props + const enabled = process.env.NODE_ENV !== 'development' + const hit = useCallback((url) => { if (enabled) { ym('hit', url) } else { console.log('%c[YandexMetrika](HIT)', 'color: orange', url) } - }, []) + }, [enabled]) useEffect(() => { hit(window.location.pathname + window.location.search) @@ -26,7 +24,7 @@ const WithYandexMetrika = (props) => { <> {enabled && (