analytics.js
fetchAnalyticsData() {
this.loading.today = true;
this.loading.daily = true;
const metrics = ['VISITS', 'PAGE VIEWS', 'CONVERSION RATE', 'BOUNCE RATE'];
const analyticsModules = [
{ endpoint: '', parameters: { to: format(TODAY, DATE_FORMAT).toString(), from: format(TODAY, DATE_FORMAT).toString() } },
{
endpoint: 'traffic-source',
parameters: { to: format(TODAY, DATE_FORMAT).toString(), from: format(TODAY, DATE_FORMAT).toString() }
},
{
endpoint: 'user-demographics',
parameters: {
to: format(endOfWeek(TODAY), DATE_FORMAT).toString(),
from: format(startOfWeek(TODAY), DATE_FORMAT).toString()
}
},
{
endpoint: 'engagement-metrics',
parameters: {
to: format(endOfWeek(TODAY), DATE_FORMAT).toString(),
from: format(startOfWeek(TODAY), DATE_FORMAT).toString()
}
}
];
}
How do I invoke the fetchAnalyticsData function in my dashboard.js?
I am looking to execute the fetchAnalyticsData function in the dashboard.js file.
For instance, within my dashboard.js, I have a method called
updateChart() { ... } where I wish to trigger the fetchAnalyticsData function from analytics.js