File tree Expand file tree Collapse file tree
plugins/analytics-module-segment Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,7 +17,25 @@ This plugin requires an active workspace with [Segment][segment]. Please referen
1717yarn --cwd packages/app add @segment/backstage-plugin-analytics-module-segment
1818```
1919
20- ### Wire up the API implementation to your App:
20+ ### New frontend system
21+
22+ Add the module to your app's frontend features:
23+
24+ ``` ts
25+ // packages/app/src/App.tsx
26+ import segmentAnalyticsModule from ' @segment/backstage-plugin-analytics-module-segment/alpha' ;
27+
28+ const app = createApp ({
29+ features: [segmentAnalyticsModule ],
30+ });
31+ ```
32+
33+ The module uses the configured Backstage identity when identifying users in
34+ Segment.
35+
36+ ### Legacy frontend system
37+
38+ Wire up the API implementation to your app:
2139
2240``` ts
2341// packages/app/src/apis.ts
Original file line number Diff line number Diff line change 1111 "main" : " dist/index.esm.js" ,
1212 "types" : " dist/index.d.ts"
1313 },
14+ "exports" : {
15+ "." : " ./src/index.ts" ,
16+ "./alpha" : " ./src/alpha.ts" ,
17+ "./package.json" : " ./package.json"
18+ },
19+ "typesVersions" : {
20+ "*" : {
21+ "alpha" : [
22+ " src/alpha.ts"
23+ ],
24+ "package.json" : [
25+ " package.json"
26+ ]
27+ }
28+ },
1429 "backstage" : {
1530 "role" : " frontend-plugin-module" ,
1631 "pluginId" : " app" ,
17- "pluginPackage" : " @backstage/plugin-app-backend "
32+ "pluginPackage" : " @backstage/plugin-app"
1833 },
1934 "repository" : {
2035 "type" : " git" ,
3247 "postpack" : " backstage-cli package postpack"
3348 },
3449 "dependencies" : {
50+ "@backstage/frontend-plugin-api" : " ^0.17.3" ,
51+ "@backstage/plugin-app-react" : " ^0.2.6" ,
3552 "@segment/analytics-next" : " ^1.72.1"
3653 },
3754 "peerDependencies" : {
4461 "@backstage/core-components" : " ^0.18.12" ,
4562 "@backstage/core-plugin-api" : " ^1.12.8" ,
4663 "@backstage/dev-utils" : " ^1.1.25" ,
47- "@backstage/frontend-plugin-api" : " ^0.17.3" ,
4864 "react" : " ^16.13.1 || ^17.0.0 || ^18.0.0"
4965 },
5066 "files" : [
Original file line number Diff line number Diff line change 1+ export { segmentAnalyticsModule as default } from './module' ;
Original file line number Diff line number Diff line change 1+ import segmentModule from './alpha' ;
2+ import { segmentAnalyticsModule } from './module' ;
3+
4+ describe ( 'segmentAnalyticsModule' , ( ) => {
5+ it ( 'provides an app frontend module through the alpha entry point' , ( ) => {
6+ expect ( segmentModule ) . toBe ( segmentAnalyticsModule ) ;
7+ expect ( segmentAnalyticsModule ) . toMatchObject ( {
8+ $$type : '@backstage/FrontendModule' ,
9+ pluginId : 'app' ,
10+ } ) ;
11+ } ) ;
12+ } ) ;
Original file line number Diff line number Diff line change 1+ import {
2+ configApiRef ,
3+ createFrontendModule ,
4+ identityApiRef ,
5+ } from '@backstage/frontend-plugin-api' ;
6+ import { AnalyticsImplementationBlueprint } from '@backstage/plugin-app-react' ;
7+
8+ import { SegmentAnalytics } from './apis' ;
9+
10+ const segmentAnalyticsImplementation = AnalyticsImplementationBlueprint . make ( {
11+ name : 'segment' ,
12+ params : defineParams =>
13+ defineParams ( {
14+ deps : { configApi : configApiRef , identityApi : identityApiRef } ,
15+ factory : ( { configApi, identityApi } ) =>
16+ SegmentAnalytics . fromConfig ( configApi , { identityApi } ) ,
17+ } ) ,
18+ } ) ;
19+
20+ /** @public */
21+ export const segmentAnalyticsModule = createFrontendModule ( {
22+ pluginId : 'app' ,
23+ extensions : [ segmentAnalyticsImplementation ] ,
24+ } ) ;
You can’t perform that action at this time.
0 commit comments