update for Yandex.Metrika init model, disable Metrika for offstage clients
This commit is contained in:
parent
387295b357
commit
d6be338385
@ -32,10 +32,8 @@ export const sendLoginFormEmail = ({ email, password, dispatch }) =>
|
|||||||
.then((response) =>
|
.then((response) =>
|
||||||
{
|
{
|
||||||
//console.log("sendLoginFormEmail RESPONSE");
|
//console.log("sendLoginFormEmail RESPONSE");
|
||||||
|
|
||||||
//console.log(response.data);
|
//console.log(response.data);
|
||||||
|
|
||||||
|
|
||||||
if(response.data.status === "success")
|
if(response.data.status === "success")
|
||||||
{
|
{
|
||||||
const cookies = new Cookies();
|
const cookies = new Cookies();
|
||||||
@ -49,7 +47,8 @@ export const sendLoginFormEmail = ({ email, password, dispatch }) =>
|
|||||||
dispatch({ type: actionTypes.COMPANIES, data: { list: response.data.companies } });
|
dispatch({ type: actionTypes.COMPANIES, data: { list: response.data.companies } });
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
Router.push('/');
|
//Router.push('/');
|
||||||
|
window.location = "/";
|
||||||
})
|
})
|
||||||
.catch(() =>
|
.catch(() =>
|
||||||
{
|
{
|
||||||
@ -116,10 +115,8 @@ export const sendSmsCode = ({ dispatch, phone, code }) =>
|
|||||||
.then((response) =>
|
.then((response) =>
|
||||||
{
|
{
|
||||||
//console.log("sendSmsCode RESPONSE");
|
//console.log("sendSmsCode RESPONSE");
|
||||||
|
|
||||||
//console.log(response.data);
|
//console.log(response.data);
|
||||||
|
|
||||||
|
|
||||||
if(response.data.status === "success")
|
if(response.data.status === "success")
|
||||||
{
|
{
|
||||||
const cookies = new Cookies();
|
const cookies = new Cookies();
|
||||||
@ -132,7 +129,8 @@ export const sendSmsCode = ({ dispatch, phone, code }) =>
|
|||||||
dispatch({ type: actionTypes.USER, data: response.data.user });
|
dispatch({ type: actionTypes.USER, data: response.data.user });
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
Router.push('/');
|
//Router.push('/');
|
||||||
|
window.location = "/";
|
||||||
})
|
})
|
||||||
.catch(() =>
|
.catch(() =>
|
||||||
{
|
{
|
||||||
@ -176,7 +174,8 @@ export const logout = ({ dispatch, redirect = true }) =>
|
|||||||
resolve();
|
resolve();
|
||||||
if(redirect)
|
if(redirect)
|
||||||
{
|
{
|
||||||
Router.push('/');
|
//Router.push('/');
|
||||||
|
window.location = "/";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -210,7 +209,8 @@ export const sendOffstageToken = ({ token, dispatch }) =>
|
|||||||
dispatch({ type: actionTypes.COMPANIES, data: { list: response.data.companies } });
|
dispatch({ type: actionTypes.COMPANIES, data: { list: response.data.companies } });
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
Router.push('/');
|
//Router.push('/');
|
||||||
|
window.location = "/";
|
||||||
})
|
})
|
||||||
.catch(() =>
|
.catch(() =>
|
||||||
{
|
{
|
||||||
@ -265,7 +265,8 @@ export const sendSwitchAccount = ({ dispatch, acc_number }) =>
|
|||||||
.then(() =>
|
.then(() =>
|
||||||
{
|
{
|
||||||
resolve();
|
resolve();
|
||||||
Router.push('/');
|
//Router.push('/');
|
||||||
|
window.location = "/";
|
||||||
})
|
})
|
||||||
.catch(() =>
|
.catch(() =>
|
||||||
{
|
{
|
||||||
|
|||||||
@ -71,8 +71,11 @@ export default async function CRMRequestGet({ req, res, path, params, data = und
|
|||||||
res.status(200).json(crm_response.data);
|
res.status(200).json(crm_response.data);
|
||||||
})
|
})
|
||||||
.catch((error) =>
|
.catch((error) =>
|
||||||
|
{
|
||||||
|
if(log)
|
||||||
{
|
{
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
}
|
||||||
console.error("-".repeat(30), "error.response.data:");
|
console.error("-".repeat(30), "error.response.data:");
|
||||||
console.error(error.response.data);
|
console.error(error.response.data);
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
import { reduxWrapper } from '../store'
|
import { reduxWrapper } from '../store'
|
||||||
import numeral from 'numeral';
|
import numeral from 'numeral';
|
||||||
import '../css/style.css';
|
import Script from 'next/script';
|
||||||
|
|
||||||
//import DaData from 'dadata';
|
import '../css/style.css';
|
||||||
//global.dadata = new DaData(process.env.DADATA_API_KEY, process.env.DADATA_SECRET_KEY);
|
|
||||||
|
|
||||||
const m = Math.random();
|
const m = Math.random();
|
||||||
numeral.register('locale', `locale_${ m }`, {
|
numeral.register('locale', `locale_${ m }`, {
|
||||||
@ -23,11 +22,56 @@ numeral.register('locale', `locale_${ m }`, {
|
|||||||
});
|
});
|
||||||
numeral.locale(`locale_${ m }`);
|
numeral.locale(`locale_${ m }`);
|
||||||
|
|
||||||
const WrappedApp = ({ Component, pageProps }) =>
|
const WrappedApp = (props) =>
|
||||||
{
|
{
|
||||||
|
const { Component, pageProps, } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
|
{ props.observer && (
|
||||||
|
<>
|
||||||
|
<Script id="yandex-metrica" strategy={'afterInteractive'}>
|
||||||
|
{`
|
||||||
|
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
|
||||||
|
m[i].l=1*new Date();
|
||||||
|
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
|
||||||
|
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
|
||||||
|
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
|
||||||
|
|
||||||
|
ym(${ process.env.NEXT_PUBLIC_YANDEX_METRIKA_ID }, "init", { clickmap: true, trackLinks: true, accurateTrackBounce: true, webvisor: true });
|
||||||
|
console.log(ym, ${ process.env.NEXT_PUBLIC_YANDEX_METRIKA_ID });
|
||||||
|
`}
|
||||||
|
</Script>
|
||||||
|
<noscript>
|
||||||
|
<div>
|
||||||
|
<img src={`https://mc.yandex.ru/watch/${ process.env.NEXT_PUBLIC_YANDEX_METRIKA_ID }`} style={{ position:'absolute', left:'-9999px' }} alt=""/>
|
||||||
|
</div>
|
||||||
|
</noscript>
|
||||||
|
</>
|
||||||
|
) }
|
||||||
<Component {...pageProps} />
|
<Component {...pageProps} />
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WrappedApp.getInitialProps = async (props) =>
|
||||||
|
{
|
||||||
|
const { req } = props.ctx;
|
||||||
|
|
||||||
|
let observer = true;
|
||||||
|
if(req.url.indexOf("offstage") > -1)
|
||||||
|
{
|
||||||
|
observer = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(req.cookies !== undefined && req.cookies.observer !== undefined && req.cookies.observer === "true")
|
||||||
|
{
|
||||||
|
observer = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
observer,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default reduxWrapper.withRedux(WrappedApp);
|
export default reduxWrapper.withRedux(WrappedApp);
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import Document, { Html, Head, Main, NextScript } from 'next/document'
|
import Document, { Html, Head, Main, NextScript } from 'next/document';
|
||||||
|
|
||||||
class Doc extends Document
|
class Doc extends Document
|
||||||
{
|
{
|
||||||
@ -7,7 +7,6 @@ class Doc extends Document
|
|||||||
return (
|
return (
|
||||||
<Html lang="ru-RU">
|
<Html lang="ru-RU">
|
||||||
<Head>
|
<Head>
|
||||||
{/*<base href="http://claymorrow.myjino.ru/dev/evolution/" />*/}
|
|
||||||
<meta name="description" content="" />
|
<meta name="description" content="" />
|
||||||
<meta name="keywords" content="" />
|
<meta name="keywords" content="" />
|
||||||
|
|
||||||
@ -41,28 +40,6 @@ class Doc extends Document
|
|||||||
<body>
|
<body>
|
||||||
<Main/>
|
<Main/>
|
||||||
<NextScript />
|
<NextScript />
|
||||||
|
|
||||||
<script type="text/javascript" dangerouslySetInnerHTML={{
|
|
||||||
__html: `
|
|
||||||
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
|
|
||||||
m[i].l=1*new Date();
|
|
||||||
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
|
|
||||||
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
|
|
||||||
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
|
|
||||||
|
|
||||||
ym(${ process.env.YANDEX_METRIKA_ID }, "init", {
|
|
||||||
clickmap:true,
|
|
||||||
trackLinks:true,
|
|
||||||
accurateTrackBounce:true,
|
|
||||||
webvisor:true,
|
|
||||||
});
|
|
||||||
`, }}
|
|
||||||
/>
|
|
||||||
<noscript>
|
|
||||||
<div>
|
|
||||||
<img src={`https://mc.yandex.ru/watch/${ process.env.YANDEX_METRIKA_ID }`} style={{ position:'absolute', left:'-9999px' }} alt=""/>
|
|
||||||
</div>
|
|
||||||
</noscript>
|
|
||||||
</body>
|
</body>
|
||||||
</Html>
|
</Html>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -19,24 +19,33 @@ export default class AccountLayout extends React.Component
|
|||||||
window.addEventListener("_move", this._handle_onMove);
|
window.addEventListener("_move", this._handle_onMove);
|
||||||
window.addEventListener("_message", this._handle_onMessage);
|
window.addEventListener("_message", this._handle_onMessage);
|
||||||
|
|
||||||
|
setTimeout(() =>
|
||||||
|
{
|
||||||
const store = global.store.getState();
|
const store = global.store.getState();
|
||||||
const { company, user } = store;
|
const { company, user } = store;
|
||||||
|
|
||||||
console.log("LAYOUT", "CDM", { store });
|
//console.log("LAYOUT", "CDM", { store });
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
userID: user.email !== undefined && user.email !== null && user.email !== "" ? user.email : user.phone,
|
userID: user.email !== undefined && user.email !== null && user.email !== "" ? user.email : user.phone,
|
||||||
companyID: company.active,
|
companyID: company.active,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//console.log("LAYOUT", "CDM", { payload });
|
||||||
|
|
||||||
if(payload.companyID !== undefined && payload.companyID !== null && payload.companyID !== "")
|
if(payload.companyID !== undefined && payload.companyID !== null && payload.companyID !== "")
|
||||||
{
|
{
|
||||||
console.log("LAYOUT", "CDM", { payload });
|
//console.log("LAYOUT", "CDM", { payload });
|
||||||
ym(process.env.YANDEX_METRIKA_ID, 'userParams', payload);
|
//console.log("LAYOUT", "CDM", "CHECK YM");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("CDM", { state: this.state });
|
if(window.ym !== undefined)
|
||||||
|
{
|
||||||
|
console.log({ ym: window.ym, id: process.env.NEXT_PUBLIC_YANDEX_METRIKA_ID });
|
||||||
|
window.ym(process.env.NEXT_PUBLIC_YANDEX_METRIKA_ID, 'userParams', payload);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount()
|
componentWillUnmount()
|
||||||
@ -52,9 +61,12 @@ export default class AccountLayout extends React.Component
|
|||||||
_handle_onTrack = (event) =>
|
_handle_onTrack = (event) =>
|
||||||
{
|
{
|
||||||
//event.detail.path
|
//event.detail.path
|
||||||
console.log("LAYOUT", "_handle_onTrack", { event, props: this.props });
|
//console.log("LAYOUT", "_handle_onTrack", { event, props: this.props });
|
||||||
|
|
||||||
console.log({ ym });
|
if(window.ym !== undefined)
|
||||||
|
{
|
||||||
|
//console.log({ ym: window.ym });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_handle_onMove = (event) =>
|
_handle_onMove = (event) =>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user