From ab825d4626ba598df0b2e00b4635db41cc5b048d Mon Sep 17 00:00:00 2001 From: uonai Date: Sun, 16 Aug 2020 20:59:06 -0500 Subject: [PATCH] Analytics API integration --- node_common/constants.js | 1 + node_common/managers/analytics.js | 7 +++++-- pages/_/index.js | 7 ++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/node_common/constants.js b/node_common/constants.js index 4ec1ea87..c249efaf 100644 --- a/node_common/constants.js +++ b/node_common/constants.js @@ -2,6 +2,7 @@ export const POLLING_RATE = 5000; export const POWERGATE_HOST = "https://grpcweb.slate.textile.io"; export const FILE_STORAGE_URL = "./public/static/files/"; export const GITHUB_URL = "https://github.com/filecoin-project/slate"; +export const ANALYTICS_URL = "https://slate-stats-dev.azurewebsites.net/"; // NOTE(jim): 1 GB from Ignacio export const TEXTILE_ACCOUNT_BYTE_LIMIT = 1073741824; diff --git a/node_common/managers/analytics.js b/node_common/managers/analytics.js index 788c1be2..bb38f99f 100644 --- a/node_common/managers/analytics.js +++ b/node_common/managers/analytics.js @@ -4,8 +4,11 @@ import * as Powergate from "~/node_common/powergate"; import * as Constants from "~/node_common/constants"; export const get = async () => { - const analytics = {}; - + // Current endpoints available for consumption + // Endpoints: blocks, blockParents, blockRewards, blockMessages, receipts, messages + const endpoint = "blocks"; + const response = await fetch(Constants.ANALYTICS_URL + endpoint); + const analytics = response.json(); // TODO(colin): We can bind Analytics here on the server. return analytics; }; diff --git a/pages/_/index.js b/pages/_/index.js index ba3d52fd..6fbf6b98 100644 --- a/pages/_/index.js +++ b/pages/_/index.js @@ -10,6 +10,11 @@ export const getServerSideProps = async ({ query }) => { export default class ApplicationPage extends React.Component { render() { - return ; + return ( + + ); } }