![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
firebase-metrics
Advanced tools
https://github.com/jemmyw/firebase-metrics
Sometimes you just want to get some metrics data before you're big enough to have a proper place for storing them. This library helps if your datastore is Firebase.
It also works nicely with frontend graphing libraries due to Firebase realtime nature.
npm install firebase
npm install firebase-metrics
Note that in these examples I've not verified the dates in the data below so it probably does not add up
First you need to decide some metric retention. For example, you want the data at 1 minute resolution for 7 days, then 1 hour resolution for 1 month, then daily resolution for 1 year:
const HOUR = 3600000;
const DAY = 86400000;
const resolutions = [
{
name: '1min',
t: 60 * 1000, // 1 minute
keep: 86400000 * 7 // 1 week
},
{
name: '1hour',
t: HOUR,
keep: DAY * 30
},
{
name: '1day',
t: DAY,
keep: DAY * 365
}
]
OK, so now we pass this into the background process:
const {startMetrics} = require('firebase-metrics');
const inRef = firebase.database().ref().child('metrics-in');
const outRef = firebase.database().ref().child('metrics');
startMetrics(inRef, outRef, resolutions);
This process will now wait for data to appear in metrics-in
and then record that as counts in metrics.
We can use the pushCount
helper to push a metric in:
const {pushCount} = require('firebase-metrics');
pushCount(inRef, 'my-tag', 2);
Now very soon you'll see the following structure in metrics:
"metrics": {
"tag:my-tag": {
"1474243200000": {
"1min": {
599: 2
},
"1hour": {
8: 2
},
"1day": {
0: 2
}
}
},
"resolutions": {
"1min": {
"buckets": 1440,
"days": {
1474243200000: 1474588800000
},
"keep": 604800000
}
}
}
OK, not that interesting, run it again and:
"metrics": {
"tag:my-tag": {
"1474243200000": {
"1min": {
599: 2,
600: 2
},
"1hour": {
8: 4
},
"1day": {
0: 4
}
}
}
}
So we can see what is happening. It puts the data into buckets in each resolution. It tracks the days that each resolution has data for, and the expiry for the day. When the day ticks over the server component will remove the expired buckets.
You can also pass in values that will be averaged in each time bucket using the helper pushMetric
. For example:
const {pushMetric} = require('firebase-metrics');
pushMetric(inRef, 'tag1', 23.33);
pushMetric(inRef, 'tag1', 10.78);
This produces the following:
"metrics": {
"tag:tag1": {
"1474243200000": {
"1min": {
599: {count:1, value: 23.33},
600: {count:1, value: 10.78}
},
"1hour": {
8: {count: 2, value: 17.055}
},
"1day": {
0: {count: 2, value: 17.055}
}
}
}
}
Note that you must be careful not to mix calls to pushCount
and pushMetric
as the data formats don't mix.
There is a non-working but viable example in the examples
directory. I pulled it straight out of a working dashboard, so it just requires some build (typescript and webpack).
Obviously both the startMetrics
and pushCount
processes require read/write access to the inRef and outRef (pushCount doesn't need any access to outRef).
If you see data building up in the inRef then the startMetrics
program isn't running.
The tests rely on a real Firebase database, which can be provisioned for free at firebase.google.com.
Read the instructions in src/test.ts, and then run the tests with npm test
FAQs
Use firebase a as place to store metric data
We found that firebase-metrics demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.