Skip to content

Commit

Permalink
Merge pull request #283 from fcoronelmakingsense/reports-unic-visits
Browse files Browse the repository at this point in the history
add: unique visits in reports
  • Loading branch information
fcoronelmakingsense authored Jul 2, 2019
2 parents 65a74a8 + 2f040f8 commit 5d8ba6e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class ReportsPageRanking extends React.Component {
{item.name}
</a>
<p className="text-ranking">
<strong>{item.totalVisits}</strong>{' '}
<strong>{item.totalVisitors}</strong>{' '}
<FormattedMessage id="reports_pageranking.total_visits" />
</p>
</div>
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ export default {
},
reports_pageranking: {
top_pages: `Most visited pages`,
top_pages_sub_head: `Sessions are the total number of registered visits during the period. If a user entered several times, all of them will be counted.`,
total_visits: `Sessions`,
total_visits: `Unique visitors`,
},
reports_title: `Doppler | Reports`,
signup: {
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ export default {
},
reports_pageranking: {
top_pages: `Páginas más visitadas`,
top_pages_sub_head: `Las Sesiones comprenden el número total de visitas registradas durante el periodo. Si un usuario ingresó varias veces, se contabilizarán todas.`,
total_visits: `Sesiones`,
total_visits: `Visitantes únicos`,
},
reports_title: `Doppler | Reportes`,
signup: {
Expand Down
14 changes: 7 additions & 7 deletions src/services/datahub-client.doubles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ const fakeData = [
const fakePagesData = [
{
name: '/email-marketing',
totalVisits: 10122,
totalVisitors: 10122,
},
{
name: '/precios',
totalVisits: 9000,
totalVisitors: 9000,
},
{
name: '/login',
totalVisits: 5001,
totalVisitors: 5001,
},
{
name: '/productos',
totalVisits: 3800,
totalVisitors: 3800,
},
{
name: '/servicios',
totalVisits: 1023,
totalVisitors: 1023,
},
];

Expand Down Expand Up @@ -72,12 +72,12 @@ export class HardcodedDatahubClient implements DatahubClient {
}: {
domainName: number;
dateFrom: Date;
}): Promise<{ name: string; totalVisits: number; url: string }[]> {
}): Promise<{ name: string; totalVisitors: number; url: string }[]> {
console.log('getPagesRankingByPeriod', { domainName, dateFrom });
await timeout(1500);
return fakePagesData.map((x) => ({
name: x.name,
totalVisits: x.totalVisits,
totalVisitors: x.totalVisitors,
url: `http://${domainName}${x.name}`,
}));
}
Expand Down
18 changes: 9 additions & 9 deletions src/services/datahub-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface DatahubClient {
getPagesRankingByPeriod(query: {
domainName: number;
dateFrom: Date;
}): Promise<{ name: string; totalVisits: number; url: string }[]>;
}): Promise<{ name: string; totalVisitors: number; url: string }[]>;
}

export class HttpDatahubClient implements DatahubClient {
Expand Down Expand Up @@ -101,21 +101,21 @@ export class HttpDatahubClient implements DatahubClient {
}: {
domainName: number;
dateFrom: Date;
}): Promise<{ name: string; totalVisits: number; url: string }[]> {
const response = await this.customerGet<{ items: { page: string; count: number }[] }>(
`domains/${domainName}/events/summarized-by-page`,
{
startDate: dateFrom.toISOString(),
},
);
}): Promise<{ name: string; totalVisitors: number; url: string }[]> {
const response = await this.customerGet<{
items: { page: string; visitorsQuantity: number }[];
}>(`domains/${domainName}/events/summarized-by-page`, {
startDate: dateFrom.toISOString(),
sortBy: 'visitors',
});

// By the moment we are hard-coding it because DataHub does not have this
// information. I am looking you Leo :P
const urlSchema = 'http://';

return response.data.items.map((x) => ({
name: x.page,
totalVisits: x.count,
totalVisitors: x.visitorsQuantity,
url: `${urlSchema}${domainName}${x.page}`,
}));
}
Expand Down

0 comments on commit 5d8ba6e

Please sign in to comment.