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

DEICH-5591 Deichman.no: Add reserve tracking funnel

parent a6c3010f
......@@ -7,8 +7,12 @@ import ModalPortal from "../ModalPortal/ModalPortal";
export default function LoginButton(props) {
const children = props.children;
const onClick = props.onClick || Function.prototype;
const butttonsProps = { ...props };
delete butttonsProps.children;
delete butttonsProps.onClick;
const [showLoginModal, setShowLoginModal] = useState(false);
const [showDelayedModal, setShowDelayedModal] = useState(false);
......@@ -49,7 +53,13 @@ export default function LoginButton(props) {
</FocusTrap>
</ModalPortal>
)}
<Button {...butttonsProps} onClick={() => setShowLoginModal(true)}>
<Button
{...butttonsProps}
onClick={() => {
setShowLoginModal(true);
onClick();
}}
>
{children}
</Button>
</>
......
......@@ -2,6 +2,7 @@ import React, { Fragment } from "react";
import PropTypes from "prop-types";
import { Block, Button, Input, Hr } from "@digibib/deichman-ui";
import { trackConfirmed, trackRemoteReserve } from "../tracker/Reserve";
const RemoteReservationForm = ({
onSubmit,
......@@ -14,6 +15,16 @@ const RemoteReservationForm = ({
numHolds,
publication = {}
}) => {
useEffect(
() => {
if (completed) {
trackConfirmed();
} else {
trackRemoteReserve();
}
},
[completed]
);
// Return success or error message if reservation completed
if (completed) {
const header = error
......
import React from "react";
import React, { useEffect } from "react";
import PropTypes from "prop-types";
import { Block, Button, Select, Hr } from "@digibib/deichman-ui";
import { translations as TRANSLATIONS } from "../../constants/translations";
......@@ -7,6 +7,7 @@ import { getWaitingPeriodText } from "../../utilities/datetime";
import { sortBy } from "lodash";
import "./styles.css";
import { trackConfirmed, trackReserve } from "../tracker/Reserve";
export default function ReservationForm({
allBranches,
......@@ -22,6 +23,16 @@ export default function ReservationForm({
reservationWork,
onRedirectClose
}) {
useEffect(
() => {
if (completed) {
trackConfirmed();
} else {
trackReserve();
}
},
[completed]
);
// Return success message if reservation completed
if (completed && !error) {
const { mainTitle, mediaType, sellingPoint, imageObj } = publication;
......
import { Block } from "@digibib/deichman-ui";
import React from "react";
import React, { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { toggleFavourites } from "../../store/application";
import ReserveButton from "../PublicationCard/ReserveButton/ReserveButton";
import PublicationList from "../PublicationList";
import { trackSelectPublication } from "../tracker/Reserve";
export default function ReservationSelector({
publications,
......@@ -19,6 +20,8 @@ export default function ReservationSelector({
state => state.application.urls.tjenestekatalog
);
useEffect(trackSelectPublication, [publications]);
const ReserveComponent = ({ publication, copies }) => {
const { formats, recordId } = publication;
const copiesInfo = copies[publication.recordId] || {};
......
......@@ -40,6 +40,7 @@ import { useEffect } from "react";
import { useSelector } from "react-redux";
import LoginButton from "../LoginButton/LoginButton";
import PublicationDetailsButton from "../PublicationDetailsButton/PublicationDetailsButton";
import { trackLogin } from "../tracker/Reserve";
export default function ReservePublicationWidget({
publications,
......@@ -179,7 +180,9 @@ export default function ReservePublicationWidget({
<h3>{title}</h3>
{!isLoggedIn && (
<div>
<LoginButton primary>Logg inn og bestill</LoginButton>
<LoginButton onClick={trackLogin} primary>
Logg inn og bestill
</LoginButton>
</div>
)}
{isLoggedIn && (
......
import { trackPageView } from "../../utilities/analytics";
export {
trackLogin,
trackSelectPublication,
trackReserve,
trackRemoteReserve,
trackConfirmed
};
function trackLogin() {
trackPageView("/virt/reservation/login");
}
function trackSelectPublication() {
trackPageView("/virt/reservation/publication_selection");
}
function trackReserve() {
trackPageView("/virt/reservation/pickup_location");
}
function trackRemoteReserve() {
trackPageView("/virt/reservation/remote");
}
function trackConfirmed() {
trackPageView("/virt/reservation/confirmation");
}
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