Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@capacitor-community/firebase-analytics

Package Overview
Dependencies
Maintainers
7
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capacitor-community/firebase-analytics

A native plugin for firebase analytics.

  • 0.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16K
increased by12.88%
Maintainers
7
Weekly downloads
 
Created
Source

Capacitor Firebase Analytics Plugin

Capacitory community plugin for firebase analytics.

Maintainers

MaintainerGitHubSocialSponsoring Company
Priyank Patelpriyankpat@priyankpat_Ionic

Mainteinance Status: Actively Maintained

Installation

To use npm

npm install @capacitor/firebase-analytics

To use yarn

yarn add @capacitor/firebase-analytics

Sync native files

npx cap sync

On iOS, no further steps are needed.

On Android, register the plugin in your main activity:

import com.getcapacitor.community.firebaseanalytics.FirebaseAnalytics;

public class MainActivity extends BridgeActivity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initializes the Bridge
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      // Additional plugins you've installed go here
      // Ex: add(TotallyAwesomePlugin.class);
      add(FirebaseAnalytics.class);
    }});
  }
}

Configuration

No configuration required for this plugin.

Supported methods

NameAndroidiOSWeb
setUserId
setUserProperty
getAppInstanceId
setScreenName
reset
logEvent

Usage

// Must import the package once to make sure the web support initializes
import '@capacitor-community/http';

import { Plugins } from '@capacitor/core';

const { FirebaseAnalytics } = Plugins;

/**
 * This method will allow you to set user id.
 * @param userId - unique identifier of a user
 * @returns void
 * https://firebase.google.com/docs/analytics/userid
 */
FirebaseAnalytics.setUserId({
  userId: 'john_doe_123',
});

/**
 * This method will allow you to set user property.
 * @param userId - unique identifier of a user
 * @returns void
 * https://firebase.google.com/docs/analytics/user-properties
 */
FirebaseAnalytics.setUserProperty({
  name: 'favorite_food',
  value: 'pizza',
});

/**
 * This method will allow you to set user id.
 * @param none
 * @returns instanceId - individual instance id value
 * https://firebase.google.com/docs/analytics/user-properties
 */
FirebaseAnalytics.getAppInstanceId();

/**
 * This method will allow you to track screens.
 * @param screenName - name of the current screen to track
 *        nameOverride - name of the screen class to override
 * @returns instanceId - individual instance id value
 * https://firebase.google.com/docs/analytics/screenviews
 */
FirebaseAnalytics.setScreenName({
  screenName: 'login',
  nameOverride: 'LoginScreen',
});

/**
 * This method will clear all analytics data and reset the app instance id.
 * @param none
 * @returns void
 */
FirebaseAnalytics.reset();

/**
 * This method will log an app event.
 * @param name - name of the event to log
 *        params - key/value pairs of properties (25 maximum per event)
 * @returns void
 */
FirebaseAnalytics.logEvent({
  name: 'select_content',
  params: {
    content_type: 'image',
    content_id: 'P12453',
    items: [{ name: 'Kittens' }]
  },
});

Keywords

FAQs

Package last updated on 24 Jun 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc