This is the
Dev Log
aboutPerfAnalytics
project!
This documentation keeps my research and ideas.
Written by @hasantezcan
-
Created figma project workflow!
https://www.figma.com/file/zKuVBxuDzzYsNfSERA5Vxn/PerfAnalytics?node-id=0%3A1
-
Researched analytics terms:
1. Measuring Web Performance in 2021: The Definitive Guide (BLOG)
https://requestmetrics.com/web-performance/measure-web-performance
- The old performance measure way is Page Load Time
- The new way is The Core Web Vitals (In 2019)
You can reach whole value with
this API.
-
First Contentful Paint (FCP)
-
Largest Contentful Paint (LCP)
Warning: This code shows how to log largest-contentful-paint entries to the console, but measuring LCP in JavaScript is more complicated. See below for details:
web.dev suggest to use web vital lib instead of measure manually
-
Cumulative Layout Shift (CLS)
-
First Input Delay (FID)
-
Time to First Byte (TTFB) - Reduce server response times
-
Time to Interactive (TTI)
-
Total Blocking Time (TBT)
-
Speed Index
2. Measure performance with the RAIL model!
What is the RAIL model that?
User-centric performance model. We care about humans and design the sites for humans. So we set the performance values according to humans react while building websites. RAIL name comes from Response, Animation, Idle, Load
!NOTE: The important thing; the response times table shows us How the human being reacts to the latency!
!NOTE: Human react can be variable according to device or internet connection value.
3. Analyze runtime performance
https://developer.chrome.com/docs/devtools/evaluate-performance/
- In this articale your will learn how to use performance tab in chrome dev tools
4. Optimize website speed
https://developer.chrome.com/docs/devtools/speed/get-started/
- In this article you will learn the basic of performance terms and basic usage!
❓ Question:
Can I use directly the web vitals package to get performance parameters?
⁉️ ISSUE:
I have an issue with the web vitals package console logs. Did not shows on the console. They are coming as a second and disappears immediately!
<script src="https://unpkg.com/web-vitals/dist/web-vitals.iife.js"></script>
<script>
const { getCLS, getFID, getLCP, getTTFB } = webVitals;
getCLS(console.log);
getFID(console.log);
getLCP((metric) => {
console.log("test");
console.log(`getLCP metric`, metric.value);
});
getTTFB((metric) => {
// Calculate the request time by subtracting from TTFB
// everything that happened prior to the request starting.
const requestTime = metric.value - metric.entries[0].requestStart;
console.log("Request time:", requestTime);
});
</script>
⁉️ ISSUE:
- The TTFB value show like a TTFB time: 2.9349999967962503
- but my manual value is Manual TTFB time: 1
I want like a web vitals TTFB value!
✅ SOLVED:
with the performance.getEntriesByType()
- PerformanceTiming.responseStart is deprecated! therefore I prefer to use performance.getEntriesByType()
✍️ NOTE:
The Performance interface provide the performance.getEntriesByType()
Inspired from here
✍️ NOTE:
I found an API named PerformanceNavigationTiming but this is not working. I think the reason was not working may be that feature is still being Experimental feature.
⁉️ ISSUE:
What is the DOM load value? I calculated as 0
or 500ms
. I have to learn it!
🌟 Usefull paper:
Reading performance data with JavaScript.
- This blog post gives essancial information about
Performance API v1
andPerformance API v2
- The performance information that I need is almost ready.
- I am not sure about some values validation but I am working on it.
- I decided to move on google sheets and google scripts while building API.
I have just started to build API with nodejs and MongoDB. Why I didn't continue with google sheets and google scripts because I realized I couldn't have an opportunity to test my code and also I build the whole API side to the Cloud therefore I can't commit my changes in this repository. Maybe that was a cool idea but for this case, I will stay with nodeJs and mongo DB.
- Refactored whole project directories
- Started to the API with NodeJs and Mongo DB
Yesterday I started to build API with JS but after that, I thought I can go with typescript. I spend a little resource time learning usage typescript on the server-side. And voilà! 🎉 I created the metrics post request today. From now on, I will connect the nodejs package with API.
- Rebuild api with typescript
- Build
post api/metrics
endpoint - Connect API with Mongo DB
Today I connected PerfAnalytics JS with PerfAnalytics API. Also made some improvements PerfAnalytics JS side.
Today I start to build PerfAnalytics.Dashboard with react-typescript.
I will move on with antDesign for fast development.
Which graph chart ?
I made a little search for decided which one is best option for me.
I found couple of blog post about that topic.[0]
I liked chartjs but this has not a React support. Actually, it was but now deprecated.
So I decided to move on with the other option "recharts"
❓ Question:
What is uv, pv, amt?
{name: 'Page A', uv: 400, pv: 2400, amt: 2400}
I see these values inside of the reCharts graph data.
Q: What is uv and pv? #171 Q: What is the 'amt' property being used in all example data sets ? #467
amt = amount
pv = PageView
uv = UniqueVisitor
My database metrics recored with this format
createdAt: 2021-07-15T07:16:27.715+00:00
updatedAt: 2021-07-15T07:16:27.715+00:00
When this metrics is recored db my local time is 10:16
. Mongo db use global timze zone gmt 000 or you can say utc
And this format name is ISO 8601
// Current local timestampt with vanillaJs
const start = new Date(`${date} ${startTime}`).getTime()
const end = new Date(`${date} ${endTime}`).getTime()
// Current local timestampt with momentJs
const end = moment(`${date} ${startTime}`).format("x")
const end = moment(`${date} ${endTime}`).format("x")
// Create ISO 8601 time format with momentJs
const start = moment(`${date} ${startTime}`).toISOString()
const end = moment(`${date} ${endTime}`).toISOString()
// Create ISO 8601 time format with vanillaJS
new Date().toISOString() // "2017-08-26T16:31:02.349Z"
Source :
- Not worked
https://khalilstemmler.com/blogs/typescript/node-starter-project/#Create-a-tsconfigjson
TrendyolCase-HasanTezcan (REPO)
- PerfAnalytics.API
- PerfAnalytics.Dashboard
- PerfAnalytics.Js
All projects inside in one repo! How can I handle that? Is that the proper way to work like that? While I developing this application sometimes I thought "I need a fresh new paper" just like a quiz in university. :)
When shown two lines the graph is dividing into two! And shows empty half of it!
- Exploring Recharts: different ways of accessing data
- two lines with different data sources
- recharts cannot draw two independent lines
✅ SOLVED:
Solved with this resource: recharts/recharts#956
Update windowLoad time measure method with this approach.
- Mongoose Mixed schema types
- Each record in table should have a unique key prop,or set rowKey to an unique primary key.
- Support striped rows in tables
I move subprojects to separate repositories created by mine. In the main repository given by Trendyol, I don't have any access to add secret keys so I cant build GitHub actions in a proper way.
I created 3 repositories for API, Web Client, and JS package with my whole commit history.
After that, every single sub-project will maintain from its own repository.
https://codeburst.io/deploying-a-react-app-using-github-pages-and-github-actions-7fc14d380796