Analytics Module: Segment
This plugin provides an implementation of the Backstage Analytics API for
Segment. Once installed and configured, analytics events will be sent to
Segment as your users navigate and use your Backstage instance.
This plugin contains no other functionality.
Installation
-
Install the plugin package in your Backstage app:
yarn workspace app add @janus-idp/backstage-plugin-analytics-provider-segment
Configuration
-
Wire up the API implementation to your App in packages/app/src/apis.ts
:
import {
analyticsApiRef,
configApiRef,
identityApiRef,
} from '@backstage/core-plugin-api';
import { SegmentAnalytics } from '@janus-idp/backstage-plugin-analytics-provider-segment';
export const apis: AnyApiFactory[] = [
createApiFactory({
api: analyticsApiRef,
deps: { configApi: configApiRef, identityApi: identityApiRef },
factory: ({ configApi, identityApi }) =>
SegmentAnalytics.fromConfig(configApi, identityApi),
}),
];
-
Configure the plugin in your app-config.yaml
:
The following is the minimum configuration required to start sending analytics
events to Segment. All that's needed is your Segment Write Key
app:
analytics:
segment:
writeKey: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
maskIP: true
Debugging and Testing
In pre-production environments, you may wish to set additional configurations
to turn off reporting to Analytics. You can do so like this:
app:
analytics:
segment:
testMode: true
You might commonly set the above in an app-config.local.yaml
file, which is
normally gitignore
'd but loaded and merged in when Backstage is bootstrapped.