Socket
Socket
Sign inDemoInstall

@laxels/docusaurus-plugin-segment

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@laxels/docusaurus-plugin-segment

Segment API Analytics plugin for Docusaurus


Version published
Weekly downloads
728
increased by1.25%
Maintainers
1
Weekly downloads
 
Created
Source

docusaurus-plugin-segment

A Docusaurus plugin for Segment API Analytics based on prior work by Moesif

Disclaimer: This is a community plugin. It may not work. Use at your own risk.

How to install

  1. Install docusaurus-plugin-segment

npm install --save docusaurus-plugin-segment

  1. Add plugin to docusaurus.config.js

Method a: use themeConfig with Docusaurus v1

module.exports = {
  plugins: ['docusaurus-plugin-segment'],
  themeConfig: {
    segment: {
      apiKey: 'Your Segment Write API Key',
      // Add other options here.
    },
  },
};

Method b: use plugin options with Docusaurus v2

module.exports = {
  plugins: [
    'docusaurus-plugin-segment',
    {
      apiKey: 'Your Segment Write API Key'
      // Add other options here.
    }
  ]
}
  1. Test it works

Because the plugin is disabled when NODE_ENV is set to development, you'll want to create a production build:

npm run build

npm run serve

How to use

Any of the Segment browser APIs are accessible via window.analytics. The plugin tracks page views automatically but we also recommend identifying the user like so:

window.analytics.identify("97980cfea0067", {
  name: "Peter Gibbons",
  email: "peter@example.com",
  plan: "premium",
  logins: 5
});

Configuration Options

For full list of configuration options, see this page.

The page option defaults to false, and the plugin will use a hook to send page tracking events.

Keywords

FAQs

Package last updated on 03 Apr 2023

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