![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
@hadx/analytics
Advanced tools
This is a lightweight analytics library to track and report React Native app's usage using Firebase's firestore. Supporting real time mobile notification using One Signal.
Why not use Firebase Analytics?
You can have access to all the data programmatically since it's hosted on your firebase firestore. Hadex Analytics also provides functions to read, filter and analyse those data. No need to export to BigQuery which is not free.
Create a new project on firebase console (ex: AppsAnalytics)
Create Firestore database with Rules
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
yarn add @hadx/analytics
Add a Web App to the project
In your React Native app that you want to track:
import Analytics from '@hadx/analytics';
export default class App extends React.Component {
constructor(props: Props) {
super(props);
Analytics.initialize({
debug: __DEV__,
appID: THIS_APP_ID,
firebaseAuth: {email: ..., password: ...}, // created earlier
firebaseConfig: ..., // copied above
}).then(() => {
Analytics.logEvent('openApp'); // example event
});
}
}
In your Report website or app:
import Analytics from '@hadx/analytics';
Analytics.initialize({
debug: __DEV__,
firebaseAuth: {email: ..., password: ...}, // created earlier
firebaseConfig: ..., // copied above
}).then(() => {
// newUnit is an event that is logged automatically by Hadex Analytics
Analytics.getAppEvents('myappID', [["id", '==', 'newUnit']]).then(events => {
console.log('Total users: ' + events.length)
});
});
Want to receive real time notification with your mobile app when an user buy your in-app-purchase? (or whatever event you want to subscribe to)
In the app you want to track:
Analytics.initialize({
..., // just like example in Basic Usage
notificationConfig: {apiKey: ..., appID: ...}, // copied above
});
In your private app that receives notifications:
import OneSignal from 'react-native-one-signal';
Analytics.initialize({
..., // just like example in Basic Usage
notificationConfig: {
apiKey: ..., // copied above
appID: ..., // copied above
oneSignalModule: OneSignal
},
});
You can set the notification content and heading for each event type with dynamic values
Analytics.updateEventType('myAppID', 'newUnit', {
'notification.heading': 'New user',
'notification.content': 'There is a new user from {countryCode}'
});
// Notificaiton receive: 'There is a new user from US'
Available dynamic values are fields from the Event interface (See documentation for detail) and values from data when you log your event. For example:
// In the tracked app
Analytics.logEvent('newUnit', {name: 'Arthur'});
// In the report app
Analytics.updateEventType('myAppID', 'newUnit', {
'notification.content': 'There is a new user {name}'
});
/*
* When the 'newUnit' event is logged,
* the report app will recieve:
* 'There is a new user Arthur'
*/
These events below are logged automatically for you
Event ID | When | Data |
---|---|---|
newUnit | a new user installs your app | deviceID |
This library is pratically free for small and medium size app. (the library itself is free ofcourse) It uses the free plan of 2 main services:
One Signal: shoutout to One Signal for their great free plan. The features used by this library is unlimited on One Signal.
So if you usage of firebase firestore is more than what the free plan allowed, you can easily scale up with their paid plan. The price is pretty reasonable. When this happens, usually you should have gain more money with ads (or whatever your bussiness model is) than what you have to pay for firebase.
FAQs
Hadex's analytics service to track and report app's usage
We found that @hadx/analytics 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.