0.1.0 • Published 2 years ago

@twilio-labs/docusaurus-plugin-segment v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

docusaurus-plugin-segment

Send Docusaurus page view events to Segment. This opens up your analytics possibilities to the over 300 different integrations that Segment provides.

Installation

npm install --save @twilio-labs/docusaurus-plugin-segment

Or, if you prefer Yarn:

yarn add @twilio-labs/docusaurus-plugin-segment

Configuration

Accepted fields:

NameTypeDefaultDescription
writeKeystringRequiredThe Write Key for your Segment JavaScript source.
trackLocalSearchbooleanfalseWhether to track searches made with docusaurus-search-local
allowedInDevbooleanfalseWhether to allow tracking in development mode in addition to production.

To find your write key:

  1. Login to Segment
  2. Click on Connections
  3. Open your JavaScript source. (If you don't have one, click Add Source to add one.)
  4. Choose the Settings tab
  5. Click API Keys
  6. You will find the Write Key on this page.

Example configuration

docusaurus.config.js

  plugins: [
    [
      "@twilio-labs/docusaurus-plugin-segment",
      {
        writeKey: "3EBOWfRPv8qwertyZXCvbnMAsD2f1g0H",
        allowedInDev: false,
      },
    ],
  ],

Other features

Beyond sending page views to Segment, this plugin also supports sending search queries made using the docusaurus-search-local plugin.

It also supports identifying users on your system, should you have identity, by inspecting a cookie named client_id and expecting it to have the format of <unique id>|<email> (a unique identifier and email address, separated by the pipe character).

About Segment

This plugin is leveraging Segment's Analytics.js 2.0 JavaScript client (called a "source").