Era6 Capacitor Analytics
A capacitor plug-in that has enabled some features of Firebase Analytics
Android
npm install --save era6-capacitor-analytics
npx cap sync android
npx cap open android
- Add the Firebase service configuration file to the app's root folder (
android/app) - doc
- In your
MainActivity.java file add the lines:
import br.com.era6.capacitor.analytics.CapacitorAnalyticsPlugin;
...
add(CapacitorAnalyticsPlugin.class);
iOS
npm install --save era6-capacitor-analytics
npx cap sync ios
npx cap open ios
- Add the Firebase service configuration file to the app's root folder (
ios/App/App) - doc
API
reset(): Promise<void>
enable(): Promise<void>
disable(): Promise<void>
logEvent({ name: string; params?: object }): Promise<void>
setUserProp({ key: string; value: string }): Promise<void>
Usage
import { CapacitorAnalyticsPlugin } from 'era6-capacitor-analytics';
const analytics = new CapacitorAnalyticsPlugin();
analytics.setUserProp({
key: 'gender',
value: 'female'
});
analytics.logEvent({
name: 'page_view',
params: {
page_path: './test/'
}
});
analytics.reset();
analytics.enable();
analytics.disable();
Debug
Validate your Google Analytics configuration with DebugView
License
MIT