Commit c107758b authored by David Björkheim's avatar David Björkheim
Browse files

DEICH-5759 Deichman.no: add tracking for login flow

parent 79c728c4
import React, { Fragment } from "react";
import React from "react";
import autoBind from "auto-bind";
import PropTypes from "prop-types";
import { connect } from "react-redux";
......@@ -19,6 +19,7 @@ import Form from "./Form";
import { Block, Button } from "@digibib/deichman-ui";
import "./styles.css";
import { trackPageView } from "../../utilities/analytics";
let recaptchaInstance;
......@@ -36,6 +37,7 @@ class LoginComponent extends React.Component {
script.src = "https://www.google.com/recaptcha/api.js";
script.async = true;
document.body.appendChild(script);
trackPageView("/virt/login/landing");
}
componentWillUpdate(nextProps) {
......@@ -47,13 +49,20 @@ class LoginComponent extends React.Component {
}
handleLogin(data) {
const { preventRedirect, fetchFavouritesOnLogin, fetchKohaBranchesOnLogin, loginApi } = this.props;
const {
preventRedirect,
fetchFavouritesOnLogin,
fetchKohaBranchesOnLogin,
loginApi
} = this.props;
const postData = {
...data,
captchaResponse: loginApi.captchaResponse
};
trackPageView("/virt/login/local/start");
this.props.login(postData, preventRedirect).then(() => {
trackPageView("/virt/login/local/completed");
if (fetchFavouritesOnLogin) {
this.props.getFavourites();
}
......@@ -71,9 +80,9 @@ class LoginComponent extends React.Component {
if (!isEmpty(redirectModalData) && checkStoreAvailable()) {
saveVariable("initialModalData", JSON.stringify(redirectModalData));
}
// Go to authUrl
trackPageView("/virt/login/idporten/start");
window.location.href = authUrl;
// Go to authUrl
}
render() {
......
......@@ -105,6 +105,7 @@ class MyApp extends App {
// Show initial modal if params exist
const { idPortenLoginSuccess = false } = this.props.queryParams;
if (idPortenLoginSuccess) {
trackPageView("/virt/login/idporten/completed");
const initialModalData = readVariable("initialModalData");
if (initialModalData) {
this.props.reduxStore.dispatch(
......
......@@ -26,6 +26,7 @@ class MyDocument extends Document {
window.__deichmanTriggerMessage=window.__deichmanTriggerMessage||function(message){__deichmanTriggerMessage.m=message};
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', '${CONFIG.ANALYTICS.CODE}', 'auto');
ga('set', 'transport', 'beacon');
ga('send', 'pageview');
`
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment