diff --git a/frontend/app/components/Funnels/FunnelWidget/FunnelBar.tsx b/frontend/app/components/Funnels/FunnelWidget/FunnelBar.tsx
index b846ed94b..4d945b483 100644
--- a/frontend/app/components/Funnels/FunnelWidget/FunnelBar.tsx
+++ b/frontend/app/components/Funnels/FunnelWidget/FunnelBar.tsx
@@ -7,7 +7,7 @@ interface Props {
}
function FunnelBar(props: Props) {
const { filter } = props;
- const completedPercentage = calculatePercentage(filter.sessionsCount, filter.dropDueToIssues);
+ // const completedPercentage = calculatePercentage(filter.sessionsCount, filter.dropDueToIssues);
return (
diff --git a/frontend/app/mstore/dashboardStore.ts b/frontend/app/mstore/dashboardStore.ts
index 98e0c5e78..ba0e9ee83 100644
--- a/frontend/app/mstore/dashboardStore.ts
+++ b/frontend/app/mstore/dashboardStore.ts
@@ -8,6 +8,8 @@ import { getChartFormatter } from 'Types/dashboard/helper';
import Filter, { IFilter } from "./types/filter";
import Funnel from "./types/funnel";
import Session from "./types/session";
+import Error from "./types/error";
+import { FilterKey } from 'Types/filter/filterType';
export interface IDashboardSotre {
dashboards: IDashboard[]
@@ -132,7 +134,7 @@ export default class DashboardStore implements IDashboardSotre {
fetchMetricChartData: action
})
- const drillDownPeriod = Period({ rangeName: LAST_24_HOURS }).toTimestamps();
+ const drillDownPeriod = Period({ rangeName: LAST_30_DAYS }).toTimestamps();
this.drillDownFilter.updateKey('startTimestamp', drillDownPeriod.startTimestamp)
this.drillDownFilter.updateKey('endTimestamp', drillDownPeriod.endTimestamp)
}
@@ -459,8 +461,10 @@ export default class DashboardStore implements IDashboardSotre {
}
// TODO refactor to widget class
- if (metric.metricOf === 'SESSIONS') {
+ if (metric.metricOf === FilterKey.SESSIONS) {
_data['sessions'] = data.sessions.map((s: any) => new Session().fromJson(s))
+ } else if (metric.metricOf === FilterKey.ERRORS) {
+ _data['errors'] = data.errors.map((s: any) => new Error().fromJSON(s))
} else {
if (data.hasOwnProperty('chart')) {
_data['chart'] = getChartFormatter(this.period)(data.chart)
diff --git a/frontend/app/mstore/types/error.ts b/frontend/app/mstore/types/error.ts
index 7542aca4b..2f8b8fbec 100644
--- a/frontend/app/mstore/types/error.ts
+++ b/frontend/app/mstore/types/error.ts
@@ -2,7 +2,6 @@
export default class Error {
sessionId: string = ''
messageId: string = ''
- timestamp: string = ''
errorId: string = ''
projectId: string = ''
source: string = ''
@@ -11,6 +10,12 @@ export default class Error {
time: string = ''
function: string = '?'
stack0InfoString: string = ''
+
+ chart: any = []
+ sessions: number = 0
+ users: number = 0
+ lastOccurrence: string = ''
+ timestamp: string = ''
constructor() {
}
@@ -26,7 +31,10 @@ export default class Error {
this.message = json.message
this.time = json.time
this.function = json.function
+ this.chart = json.chart
this.stack0InfoString = getStck0InfoString(json.stack || [])
+ this.sessions = json.sessions
+ this.users = json.users
return this
}
}
diff --git a/frontend/app/mstore/types/funnel.ts b/frontend/app/mstore/types/funnel.ts
index 253fdb076..52b702d55 100644
--- a/frontend/app/mstore/types/funnel.ts
+++ b/frontend/app/mstore/types/funnel.ts
@@ -31,9 +31,9 @@ export default class Funnel implements IFunnel {
const firstStage = json.stages[0]
const lastStage = json.stages[json.stages.length - 1]
this.lostConversions = firstStage.sessionsCount - lastStage.sessionsCount
- this.lostConversionsPercentage = this.lostConversions / firstStage.sessionsCount * 100
+ this.lostConversionsPercentage = Math.round(this.lostConversions / firstStage.sessionsCount * 100)
this.totalConversions = lastStage.sessionsCount
- this.totalConversionsPercentage = this.totalConversions / firstStage.sessionsCount * 100
+ this.totalConversionsPercentage = Math.round(this.totalConversions / firstStage.sessionsCount * 100)
this.conversionImpact = this.lostConversions ? Math.round((this.lostConversions / firstStage.sessionsCount) * 100) : 0;
this.stages = json.stages ? json.stages.map((stage: any, index: number) => new FunnelStage().fromJSON(stage, firstStage.sessionsCount, index > 0 ? json.stages[index - 1].sessionsCount : stage.sessionsCount)) : []
this.affectedUsers = firstStage.usersCount ? firstStage.usersCount - lastStage.usersCount : 0;
diff --git a/frontend/app/mstore/types/widget.ts b/frontend/app/mstore/types/widget.ts
index de01ad834..d84a18efc 100644
--- a/frontend/app/mstore/types/widget.ts
+++ b/frontend/app/mstore/types/widget.ts
@@ -5,6 +5,7 @@ import { metricService } from "App/services";
import Session from "App/mstore/types/session";
import Funnelissue from 'App/mstore/types/funnelIssue';
import { issueOptions } from 'App/constants/filterOptions';
+import { FilterKey } from 'Types/filter/filterType';
export interface IWidget {
metricId: any
@@ -58,7 +59,7 @@ export default class Widget implements IWidget {
widgetId: any = undefined
name: string = "New Metric"
// metricType: string = "timeseries"
- metricType: string = "table"
+ metricType: string = "timeseries"
metricOf: string = "sessionCount"
metricValue: string = ""
viewType: string = "lineChart"
@@ -79,6 +80,8 @@ export default class Widget implements IWidget {
position: number = 0
data: any = {
+ sessions: [],
+ total: 0,
chart: [],
namesMap: {},
avg: 0,
@@ -93,7 +96,7 @@ export default class Widget implements IWidget {
constructor() {
makeAutoObservable(this, {
sessionsLoading: observable,
- data: observable.ref,
+ data: observable,
metricId: observable,
widgetId: observable,
name: observable,
@@ -183,7 +186,7 @@ export default class Widget implements IWidget {
series: this.series.map((series: any) => series.toJson()),
config: {
...this.config,
- col: this.metricType === 'funnel' ? 4 : this.config.col
+ col: this.metricType === 'funnel' || this.metricOf === FilterKey.ERRORS ? 4 : this.config.col
},
}
}
@@ -204,7 +207,7 @@ export default class Widget implements IWidget {
setData(data: any) {
runInAction(() => {
- Object.assign(this.data, data)
+ this.data = data;
})
}
@@ -236,8 +239,6 @@ export default class Widget implements IWidget {
fetchIssue(funnelId: any, issueId: any, params: any): Promise
{
return new Promise((resolve, reject) => {
metricService.fetchIssue(funnelId, issueId, params).then((response: any) => {
- response = response[0]
- console.log('response', response)
resolve({
issue: new Funnelissue().fromJSON(response.issue),
sessions: response.sessions.sessions.map((s: any) => new Session().fromJson(s)),
diff --git a/frontend/app/services/MetricService.ts b/frontend/app/services/MetricService.ts
index cfab5ae39..2696eec3b 100644
--- a/frontend/app/services/MetricService.ts
+++ b/frontend/app/services/MetricService.ts
@@ -89,7 +89,7 @@ export default class MetricService implements IMetricService {
getMetricChartData(metric: IWidget, data: any, isWidget: boolean = false): Promise {
const path = isWidget ? `/metrics/${metric.metricId}/chart` : `/metrics/try`;
return this.client.post(path, data)
- .then((response: { json: () => any; }) => response.json())
+ .then(fetchErrorCheck)
.then((response: { data: any; }) => response.data || {});
}