Skip to content

WarreH/analytics-plugin-planhat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Analytics plugin Planhat

This adds support for Planhat for the Analytics package.

Installation

npm install analytics analytics-plugin-planhat --save

Usage

Browser (Vue, React, Angular)

import { Analytics } from "analytics"
import planhatPlugin from "analytics-plugin-planhat"

const analytics = Analytics({
  app: "[your app name]",
  plugins: [
    planhatPlugin({
      tenantUUID: "[your tenantUUID]",
    }),
  ],
})

Example

Node

CommonJS

const { Analytics } = require('analytics')
// or const Analytics = require('analytics').default
const planhatPlugin  = require('analytics-plugin-planhat')

const analytics = Analytics({
  app: "[your app name]",
  plugins: [
    planhatPlugin({
      tenantUUID: "[your tenantUUID]",
    }),
  ],
})

Example

ES6 Modules

import { Analytics } from 'analytics'
import planhatPlugin  from 'analytics-plugin-planhat'

const analytics = Analytics({
  app: "[your app name]",
  plugins: [
    planhatPlugin({
      tenantUUID: "[your tenantUUID]",
    }),
  ],
})

Example

Methods

analytics.identify

Identify an user for which activities will be tracked.

analytics.identify([userId], {
  firstName: "[firstName]"",
  lastName: "[lastName]"",
  email: "[email]",
  companyExternalId:"[companyId]"
})
Argument Description
userId Id for the Planhat user.
If you want to identify users by mail pass null
email Email of the user.
Either userId or email is required to identify the user.
Provide an email if the userId is null.
firstName Firstname of the Planhat user
lastName Lastname of the Planhat user
companyExternalId ExternalId of a company in Planhat, the company must exist in Planhat.
Is required for the auto-creation of users.

analytics.track

Track an user activity for the identified user.

analytics.track([activity name], {
  [extraAttribute]: [value],
  ...
})
Argument Description
activity name Name of the tracked user activity
extraAttribute Add additional information about the user activity

If you only want to use this plugin:

analytics.track([activity name], 
  {
    [extraAttribute]:[value]
  },
  {
    plugins: {
      all: false,
      planhat: true
    }
  }
);

More

More information about the usage of the methods and additional options can be found at the original analytics package:

Planhat Webplatform

The tracked user activities can be found in the following locations:

  • On a company page under the usage tab

  • On a user page under the usage tab

About PlanHat API

In order to track an activity of an user it must exist in Planhat. When an user is identified but doesn't exist in Planhat, it will be created automatically provided all the required info is passed in the request.

Planhat will still repsond with status code 200 if not all information is passed correctly. Errors can be found in the Planhat webplatform.

  • API errors
  • Errors with tracking an user activity can be found under metrics

More information can be found in their API documentation.

Development

Go to the folder plugin.

Install dependenies

npm install

Build package

nmp run build

Powered By

About

Planhat integration for 'analytics' module for browser & node

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published