-
Notifications
You must be signed in to change notification settings - Fork 2
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
1355 tunnel de conversion de bout en bout juin 2023 #95
Merged
baptou12
merged 3 commits into
main
from
1355-tunnel-de-conversion-de-bout-en-bout-juin-2023
Aug 17, 2023
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from "react" | ||
import { ResponsiveBar } from "@nivo/bar" | ||
|
||
const xAxisKey = "label" | ||
|
||
function findKeysFromData(data) { | ||
return data.reduce((keys, row) => { | ||
Object.keys(row).forEach((key) => { | ||
if (key !== xAxisKey && !keys.includes(key)) { | ||
keys.push(key) | ||
} | ||
}) | ||
return keys | ||
}, []) | ||
} | ||
|
||
export const DefaultFunnelChart = ({ data, dataTestid }) => { | ||
const keys = findKeysFromData(data) | ||
|
||
return ( | ||
<div className="responsive-chart" data-testid={dataTestid}> | ||
<ResponsiveBar | ||
data={data} | ||
indexBy={xAxisKey} | ||
keys={keys} | ||
groupMode="stacked" | ||
margin={{ top: 15, right: 10, bottom: 150, left: 60 }} | ||
padding={0.1} | ||
animate={false} | ||
colors={["#a4c4eb", "#d62728", "#ff7f0e"]} | ||
axisBottom={{ | ||
tickSize: 5, | ||
tickPadding: 5, | ||
tickRotation: -45, | ||
legendOffset: 32, | ||
}} | ||
/> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { interceptAidesJeunesStatistics } from "../support/utils.js" | ||
|
||
describe("Funnel Page", () => { | ||
beforeEach(() => { | ||
const interceptIdentifier = interceptAidesJeunesStatistics() | ||
cy.visitFromHome("/funnel") | ||
cy.wait(interceptIdentifier) | ||
}) | ||
|
||
it("displays the menu and title", () => { | ||
cy.checkMenu() | ||
cy.checkTitle() | ||
}) | ||
|
||
it("displays funnel results chart", () => { | ||
cy.get(".responsive-chart").should("be.visible") | ||
cy.checkGraph("funnel-visits", "Visites", "125821") | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { Component } from "react" | ||
|
||
import { fetchFunnelData } from "../services/funnelService.js" | ||
import { DefaultFunnelChart } from "../components/defaultFunnelChart.js" | ||
|
||
class Funnel extends Component { | ||
state = { | ||
chartsData: null, | ||
loading: true, | ||
selectedMonth: null, | ||
} | ||
|
||
async componentDidMount() { | ||
await this.fetchData() | ||
} | ||
|
||
async fetchData() { | ||
const { availableMonths, chartsData } = await fetchFunnelData() | ||
|
||
const selectedMonth = availableMonths[0] | ||
|
||
this.setState({ | ||
chartsData, | ||
selectedMonth, | ||
loading: false, | ||
}) | ||
} | ||
|
||
render() { | ||
const { loading, selectedMonth, chartsData } = this.state | ||
|
||
if (loading) { | ||
return <p>Chargement...</p> | ||
} | ||
|
||
const { visitToRecap, surveyData, accompanimentData } = | ||
chartsData[selectedMonth] | ||
|
||
return ( | ||
<> | ||
<h1 data-testid="title">Metriques de parcours {selectedMonth}</h1> | ||
|
||
<> | ||
<div className="funnel-charts"> | ||
<div className="funnel-chart"> | ||
<h2>Visites - Emails Récapitulatifs</h2> | ||
{visitToRecap && ( | ||
<DefaultFunnelChart | ||
data={visitToRecap} | ||
dataTestid="funnel-visits" | ||
/> | ||
)} | ||
</div> | ||
|
||
<div className="funnel-chart"> | ||
<h2>Sondages Envoyés - Répondus</h2> | ||
{surveyData && <DefaultFunnelChart data={surveyData} />} | ||
</div> | ||
|
||
<div className="funnel-chart"> | ||
<h2>Accompagnement</h2> | ||
{accompanimentData && ( | ||
<DefaultFunnelChart data={accompanimentData} /> | ||
)} | ||
</div> | ||
</div> | ||
</> | ||
</> | ||
) | ||
} | ||
} | ||
|
||
export default Funnel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Fetch from "./fetch" | ||
|
||
import configuration from "../next.config.js" | ||
|
||
function formatFunnelData(data) { | ||
return { | ||
visitToRecap: [ | ||
{ label: "Visites", total: data.visits }, | ||
{ label: "Visites Uniques", total: data.nbUniqVisitors }, | ||
{ label: "Simulations terminées", total: data.simulationCount }, | ||
{ | ||
label: "Emails de recap envoyés", | ||
"Avec recontact": data.followupWithOptinCount, | ||
"Sans recontact": data.followupWithoutOptinCount, | ||
}, | ||
], | ||
surveyData: [ | ||
{ | ||
label: "Email de sondage envoyés", | ||
total: data.followupWithSurveyCount, | ||
}, | ||
{ | ||
label: "Sondages répondus", | ||
total: data.followupWithSurveyRepliedCount, | ||
}, | ||
], | ||
accompanimentData: [ | ||
{ label: "RDV affiché", total: data.showAccompanimentCount }, | ||
{ label: "RDV cliqué", total: data.clickAccompanimentCount }, | ||
], | ||
} | ||
} | ||
|
||
export const fetchFunnelData = async () => { | ||
const statsResponse = await Fetch.getJSON( | ||
configuration.env.aidesJeunesStatisticsURL, | ||
) | ||
|
||
const funnelData = statsResponse.funnel | ||
const chartsData = {} | ||
for (const [month, data] of Object.entries(funnelData)) { | ||
chartsData[month] = formatFunnelData(data) | ||
} | ||
|
||
return { | ||
availableMonths: Object.keys(funnelData), | ||
chartsData, | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pour tester, j'ai remplacé le fetch ici par un objet en dur car actuellement l'objet renvoyé par https://mes-aides.1jeune1solution.beta.gouv.fr/documents/stats.json n'a pas encore la clef
funnel
. Tu as testé avec un lien en pré-prod ou objet hébergé ailleurs j'imagine ?