0.1.1 • Published 5 months ago

@pfeifferj/backstage-plugin-analytics-generic v0.1.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 months ago

Analytics Module: Generic

This plugin provides a generic implementation of the Backstage Analytics API for publishing events to POST endpoints such as knative sinks.

This module is made to work with backstage's built-in analytics plugin. The usage guide to start tracking analytics for your plugins can be found here: https://backstage.io/docs/plugins/analytics/

Installation

This plugin supports both traditional Backstage installation and Red Hat Developer Hub (RHDH) dynamic plugin deployment.

Traditional Backstage Installation

  1. Install the plugin package in your Backstage app:
# From your Backstage root directory
yarn add --cwd packages/app @pfeifferj/backstage-plugin-analytics-generic
  1. Wire up the API implementation to your App:
// packages/app/src/apis.ts
import {
  	AnyApiFactory,
  	createApiFactory,
  	discoveryApiRef,
	analyticsApiRef,
	configApiRef,
	errorApiRef,
	identityApiRef, // optional: if you want to add user-context to events
} from '@backstage/core-plugin-api';

import { GenericAnalyticsAPI } from '@pfeifferj/backstage-plugin-analytics-generic';
import { catalogApiRef } from '@backstage/plugin-catalog-react';

export const apis: AnyApiFactory[] = [
	...
	// Instantiate and register the Generic Analytics API Implementation.

  	createApiFactory({
    	api: analyticsApiRef,
    	deps: {
      		configApi: configApiRef,
      		errorApi: errorApiRef,
      		identityApi: identityApiRef,
      		catalogApi: catalogApiRef,
    	},
		factory: ({ configApi, errorApi, identityApi, catalogApi }) =>
      		GenericAnalyticsAPI.fromConfig(
        		configApi,
        		errorApi,
        		identityApi,
        		catalogApi,
			),
  	}),
	...
];
  1. Configure the plugin in your app-config.yaml:

The following is the minimum configuration required to start sending analytics events to a Knative sink. All that's needed is your Knative sink Host:

# app-config.yaml
app:
  analytics:
    generic:
      host: ${ANALYTICS_GENERIC_HOST}
      interval: ${ANALYTICS_GENERIC_INTERVAL} # interval in minutes to ship logs, set to 0 for instant streaming. default: 30 mins
      basicAuthToken: ${ANALYTICS_GENERIC_BASIC_AUTH} # basic auth token (optional)
      bearerAuthToken: ${ANALYTICS_GENERIC_BEARER_TOKEN} # bearer token for JWT/OAuth (optional)
      debug: true # logs events & debugging info in console & frontend. default: false (optional)
      includeTeamMetadata: true # include team metadata from catalog API. default: false (optional)

...
backend:
  cors:
    ...
	Access-Control-Allow-Origin: '*' # your endpoint

Authentication

The plugin supports two authentication methods for securing your analytics endpoint:

  • Basic Authentication: Set basicAuthToken to a base64-encoded username:password string
  • Bearer Token: Set bearerAuthToken to a JWT token or OAuth bearer token

If both are configured, basic authentication takes precedence. Choose the method that matches your endpoint's authentication requirements.

Red Hat Developer Hub (RHDH) Dynamic Plugin Installation

For RHDH deployments, you can install this plugin dynamically without rebuilding your application.

Using NPM Package

Add to your RHDH dynamic plugins configuration:

global:
  dynamic:
    plugins:
      - package: '@pfeifferj/backstage-plugin-analytics-generic-dynamic@latest'
        disabled: false
        pluginConfig:
          app:
            analytics:
              generic:
                host: ${ANALYTICS_GENERIC_HOST}
                interval: ${ANALYTICS_GENERIC_INTERVAL}
                basicAuthToken: ${ANALYTICS_GENERIC_BASIC_AUTH}
                bearerAuthToken: ${ANALYTICS_GENERIC_BEARER_TOKEN}
                debug: true
                includeTeamMetadata: true
0.1.0

5 months ago

0.1.1

5 months ago

0.0.37

1 year ago

0.0.38

1 year ago

0.0.39

1 year ago

0.0.33

1 year ago

0.0.34

1 year ago

0.0.35

1 year ago

0.0.36

1 year ago

0.0.31

2 years ago

0.0.30

2 years ago

0.0.26

2 years ago

0.0.27

2 years ago

0.0.28

2 years ago

0.0.29

2 years ago

0.0.25

2 years ago

0.0.20

2 years ago

0.0.21

2 years ago

0.0.22

2 years ago

0.0.23

2 years ago

0.0.24

2 years ago

0.0.19

2 years ago

0.0.17

2 years ago

0.0.18

2 years ago

0.0.15

2 years ago

0.0.16

2 years ago

0.0.14

2 years ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago