Set up Backstage in minutes with Roadie
Focus on using Backstage, rather than building and maintaining it.
Installation steps
Install the plugin
yarn --cwd packages/app add @segment backstage-plugin-analytics-module-segment
Import it into your Backstage application
// packages/app/src/apis.ts
import {
analyticsApiRef,
configApiRef,
identityApiRef,
} from '@backstage/core-plugin-api';
import { SegmentAnalytics } from '@segment/backstage-plugin-analytics-module-segment';
export const apis: AnyApiFactory[] = [
// Instantiate and register the SegmentAnalytics API Implementation.
createApiFactory({
api: analyticsApiRef,
deps: { configApi: configApiRef, identityApi: identityApiRef },
factory: ({ configApi, identityApi }) =>
SegmentAnalytics.fromConfig(configApi, {
identityApi,
}),
}),
];
Optionally configure user anonymization (by default, this analytics plugin identifies the user taking actions as the logged in Backstage User's entity reference string)
// packages/app/src/apis.ts
import {
analyticsApiRef,
configApiRef,
identityApiRef,
} from '@backstage/core-plugin-api';
import { SegmentAnalytics } from '@segment/backstage-plugin-analytics-module-segment';
export const apis: AnyApiFactory[] = [
// Instantiate and register the SegmentAnalytics API Implementation.
createApiFactory({
api: analyticsApiRef,
deps: { configApi: configApiRef, identityApi: identityApiRef },
factory: ({ configApi, identityApi }) =>
SegmentAnalytics.fromConfig(configApi, {
identityApi,
userIdTransform: 'sha-256',
}),
}),
];
Configure the plugin
// app-config.yaml
app:
analytics:
segment:
writeKey: abcABCfooBARtestKEY
Found a mistake? Update these instructions.
Things to know
Things to know
- This plugin requires an active workspace with Segment.
- This plugin uses Analytics.js Source.
- You’ll need a Segment Write Key to use this plugin.
Useful links
Set up Backstage in minutes with Roadie
Focus on using Backstage, rather than building and maintaining it.