Gathering detailed insights and metrics for @capacitor-community/firebase-analytics
Gathering detailed insights and metrics for @capacitor-community/firebase-analytics
Gathering detailed insights and metrics for @capacitor-community/firebase-analytics
Gathering detailed insights and metrics for @capacitor-community/firebase-analytics
@capacitor-firebase/analytics
Capacitor plugin for Firebase Analytics.
@firebase/analytics
A analytics package for new firebase packages
@firebase/analytics-compat
This is the compatibility layer for the Firebase Analytics component of the Firebase JS SDK.
@firebase/analytics-types
@firebase/analytics Types
npm install @capacitor-community/firebase-analytics
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
162 Stars
189 Commits
64 Forks
17 Watching
7 Branches
34 Contributors
Updated on 09 Oct 2024
Java (39.88%)
TypeScript (31.95%)
Swift (19.63%)
Objective-C (3.7%)
Ruby (3.39%)
JavaScript (1.45%)
Cumulative downloads
Total Downloads
Last day
5.3%
3,039
Compared to previous day
Last week
4.5%
14,794
Compared to previous week
Last month
6%
61,186
Compared to previous month
Last year
-4.7%
773,622
Compared to previous year
1
@capacitor-community/firebase-analytics
Capacitor community plugin for native Firebase Analytics.
✏️✏️ This plugin now supports Capacitor 6 only. For Capacitor 5 and 4 please use version listed below ✏️✏️
Capacitor version | Plugin version |
---|---|
6.x | 6.x |
5.x | 5.0.1 |
4.x | 1.0.1 |
Maintainer | GitHub | Social |
---|---|---|
mesur.io | mesur-io | @mesur_io |
Using npm:
1npm install @capacitor-community/firebase-analytics@latest
Using yarn:
1yarn add @capacitor-community/firebase-analytics@latest
Sync native files:
1# Update the native plugins and dependencies referenced in package.json 2npx cap sync
Note: You may also need to run File > Sync Project with Gradle Files in order for Android Studio to recognize the import.
No configuration is required for this plugin.
Click here for an example on how to implement this plugin.
You can also clone the repository:
1git clone https://github.com/jcesarmobile/capacitor-firebase-analytics-example
Name | Android | iOS | Web |
---|---|---|---|
setUserId | ✅ | ✅ | ✅ |
setUserProperty | ✅ | ✅ | ✅ |
getAppInstanceId | ✅ | ✅ | ❌ |
setScreenName | ✅ | ✅ | ❌ |
reset | ✅ | ✅ | ❌ |
logEvent | ✅ | ✅ | ✅ |
setCollectionEnabled | ✅ | ✅ | ✅ |
setSessionTimeoutDuration | ✅ | ✅ | ✅ |
enable | ✅ | ✅ | ✅ |
disable | ✅ | ✅ | ✅ |
1import { FirebaseAnalytics } from "@capacitor-community/firebase-analytics"; 2 3/** 4 * Platform: Web 5 * Configure and initialize the firebase app. 6 * @param options - firebase web app configuration options 7 * */ 8FirebaseAnalytics.initializeFirebase({ 9 apiKey: "...", 10 authDomain: "...", 11 databaseURL: "...", 12 projectId: "...", 13 storageBucket: "...", 14 messagingSenderId: "...", 15 appId: "...", 16 measurementId: "...", 17}); 18 19/** 20 * Platform: Web/Android/iOS 21 * Sets the user ID property. 22 * @param userId - unique identifier of a user 23 * @returns void 24 * https://firebase.google.com/docs/analytics/userid 25 */ 26FirebaseAnalytics.setUserId({ 27 userId: "john_doe_123", 28}); 29 30/** 31 * Platform: Web/Android/iOS 32 * Sets a user property to a given value. 33 * @param options - property name and value to set 34 * @returns void 35 * https://firebase.google.com/docs/analytics/user-properties 36 */ 37FirebaseAnalytics.setUserProperty({ 38 name: "favorite_food", 39 value: "pizza", 40}); 41 42/** 43 * Platform: Android/iOS 44 * Retrieves the app instance id from the service. 45 * @param none 46 * @returns instanceId - individual instance id value 47 * https://firebase.google.com/docs/analytics/user-properties 48 */ 49FirebaseAnalytics.getAppInstanceId(); 50 51/** 52 * Platform: Android/iOS 53 * Sets the current screen name, which specifies the current visual context in your app. 54 * @param screenName - name of the current screen to track 55 * nameOverride - name of the screen class to override 56 * @returns instanceId - individual instance id value 57 * https://firebase.google.com/docs/analytics/screenviews 58 */ 59FirebaseAnalytics.setScreenName({ 60 screenName: "login", 61 nameOverride: "LoginScreen", 62}); 63 64/** 65 * Platform: Web/Android/iOS 66 * Clears all analytics data for this app from the device and resets the app instance id. 67 * @param none 68 * @returns void 69 */ 70FirebaseAnalytics.reset(); 71 72/** 73 * Platform: Web/Android/iOS 74 * Logs an app event. 75 * @param name - name of the event to log 76 * params - key/value pairs of properties (25 maximum per event) 77 * @returns void 78 */ 79FirebaseAnalytics.logEvent({ 80 name: "select_content", 81 params: { 82 content_type: "image", 83 content_id: "P12453", 84 items: [{ name: "Kittens" }], 85 }, 86}); 87 88/** 89 * Platform: Web/Android/iOS 90 * Sets whether analytics collection is enabled for this app on this device. 91 * @param name - enabled - boolean true/false 92 * @returns void 93 */ 94FirebaseAnalytics.setCollectionEnabled({ 95 enabled: false, 96}); 97 98/** 99 * Platform: Web/Android/iOS 100 * Deprecated - use setCollectionEnabled() instead 101 * Enable analytics collection for this app on this device. 102 * @param none 103 * @returns void 104 */ 105FirebaseAnalytics.enable(); 106 107/** 108 * Platform: Web/Android/iOS 109 * Deprecated - use setCollectionEnabled() instead 110 * Disable analytics collection for this app on this device. 111 * @param none 112 * @returns void 113 */ 114FirebaseAnalytics.disable(); 115 116/** 117 * Platform: Web/Android/iOS 118 * Sets the duration of inactivity that terminates the current session. 119 * @param duration - duration in seconds (default - 18000) 120 * @returns void 121 */ 122FirebaseAnalytics.setSessionTimeoutDuration({ 123 duration: 10000, 124});
Navigate to the project settings page for your app on Firebase.
Download the GoogleService-Info.plist
file. In Xcode right-click on the yellow folder named "App" and select the Add files to "App"
.
Tip: if you drag and drop your file to this location, Xcode may not be able to find it.
Download the google-services.json
file and copy it to android/app/
directory of your capacitor project.
This plugin will use the following project variables (defined in your app’s variables.gradle
file):
$firebaseAnalyticsVersion
version of com.google.firebase:firebase-analytics
(default: 21.2.2
)ionic start my-cap-app --capacitor
cd my-cap-app
npm install --save @capacitor-community/firebase-analytics
mkdir www && touch www/index.html
sudo gem install cocoapods
(only once)npx cap add ios
npx cap sync ios
(every time you run npm install
)npx cap open ios
GoogleService-Info.plist
to the app folder in xcode-FIRAnalyticsDebugEnabled
Tip: every time you change a native code you may need to clean up the cache (Product > Clean build folder) and then run the app again.
ionic start my-cap-app --capacitor
cd my-cap-app
npm install --save @capacitor-community/firebase-analytics
mkdir www && touch www/index.html
npx cap add android
npx cap sync android
(every time you run npm install
)npx cap open android
google-services.json
to your android/app
folderNow you should be set to go. Try to run your client using ionic cap run android --livereload --address=0.0.0.0
.
Tip: every time you change a native code you may need to clean up the cache (Build > Clean Project | Build > Rebuild Project) and then run the app again.
For existing projects you can upgrade all capacitor related packages (including this plugin) with this single command
npx npm-upgrade '*capacitor*' && npm install
If you were previously using the capacitor-analytics
package from npm
Update NPM package:
1npm uninstall --save capacitor-analytics 2npm install --save-prod @capacitor-community/firebase-analytics@latest
Update the plugin initialization in Android's MainActivity.java
Remove the old plugin import:
1-import io.stewan.capacitor.analytics.AnalyticsPlugin;
Update the init()
call to remove the old plugin import. You may be able to remove the entire init()
call if there is nothing else in there.
1// Initializes the Bridge 2this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{ 3 // Additional plugins you've installed go here 4 // Ex: add(TotallyAwesomePlugin.class); 5- add(AnalyticsPlugin.class); 6}});
Public API changes:
instance()
has been renamed to getAppInstanceId()
setScreen()
has been renamed to setScreenName()
setUserID()
has been renamed to setUserId()
setUserProp()
has been renamed to setUserProperty()
enable()
has been deprecated in favor of setCollectionEnabled()
disable()
has been deprecated in favor of setCollectionEnabled()
Thanks goes to these wonderful people (emoji key):
Chris Abernethy 🚧 | Priyank Patel 💻 | stewwan 💻 | Karmjit Singh ⚠️ 🐛 | Michel Roca 🐛 | Matthias 👀 | Tobi 💻 |
Nicholas Norris 🐛 | gabrielscarvalho 🐛 💻 | ptmkenny 🐛 💻 📖 | vkyeswa 🐛 | losciur ⚠️ 🐛 | wyattades 💻 | losciur 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
5 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
Found 4/29 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More