Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(frontend): tag feedback form in matomo #360

Merged
merged 2 commits into from
Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/code-du-travail-frontend/src/common/Answer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import Head from "next/head";
import { Container, Alert, Article, NoAnswer, Button } from "@cdt/ui";
import { withRouter } from "next/router";

import ReactPiwik from "react-piwik";
import Disclaimer from "../common/Disclaimer";
import Html from "../common/Html";
import Search from "../search/Search";
Expand All @@ -20,12 +20,19 @@ class Answer extends React.Component {
};

onValidate = () => {
console.log("👍");
ReactPiwik.push(["trackEvent", this.props.sourceType, "feedback", "👍"]);
};
showModal = () => {
ReactPiwik.push(["trackEvent", this.props.sourceType, "feedback", "👎"]);
this.setState({ modalVisible: true });
};
closeModal = () => {
ReactPiwik.push([
"trackEvent",
this.props.sourceType,
"feedback",
"close modal"
]);
this.setState({ modalVisible: false });
};
setResults = searchResults => {
Expand Down
4 changes: 3 additions & 1 deletion packages/code-du-travail-frontend/test/jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ jest.mock("next/config", () => () => ({
API_URL: "api.url"
}
}));

jest.mock("react-piwik", () => ({
push: jest.fn()
}));
// trick to prevent @reach-modal warning if styles are not imported
// jsdom doesn"t support it for now @see https://github.com/jsdom/jsdom/issues/1895
document.documentElement.style.setProperty("--reach-modal", "1");