More standard installation method/instructions.

Signed-off-by: Eric Peterson <ericpeterson@spotify.com>
This commit is contained in:
Eric Peterson
2021-09-16 22:32:10 +02:00
parent 0bf2112f9d
commit b9e3a03f9c
4 changed files with 37 additions and 19 deletions
+17 -5
View File
@@ -4,16 +4,28 @@ This plugin provides an opinionated implementation of the Backstage Analytics
API for Google Analytics. Once installed and configured, analytics events will
be sent to GA as your users navigate and use your Backstage instance.
This plugin contains no (and will never contain any) other functionality.
This plugin contains no other functionality.
## Installation
1. Install this plugin in your Backstage app:
`cd packages/app && yarn add @backstage/plugin-analytics-module-ga`
2. Register the plugin with your App. In most instances of Backstage, this is
as simple as adding `export { analyticsModuleGA } from '@backstage/plugin-analytics-module-ga';`
to your `packages/app/src/plugins.ts` file.
3. Configure the plugin (see below).
2. Add the API implementation to your App and configure the plugin (see below).
```tsx
// packages/app/src/apis.ts
import { analyticsApiRef, configApiRef } from '@backstage/core-plugin-api';
import { GoogleAnalytics } from '@backstage/plugin-analytics-module-ga';
export const apis: AnyApiFactory[] = [
// Instantiate and register the GA Analytics API Implementation.
createApiFactory({
api: analyticsApiRef,
deps: { configApi: configApiRef },
factory: ({ configApi }) => GoogleAnalytics.fromConfig(configApi),
}),
];
```
## Configuration
+17
View File
@@ -3,12 +3,29 @@
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
import { AnalyticsApi } from '@backstage/core-plugin-api';
import { AnalyticsEvent } from '@backstage/core-plugin-api';
import { BackstagePlugin } from '@backstage/core-plugin-api';
import { Config } from '@backstage/config';
// Warning: (ae-missing-release-tag) "analyticsModuleGA" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const analyticsModuleGA: BackstagePlugin<{}, {}>;
// Warning: (ae-missing-release-tag) "GoogleAnalytics" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export class GoogleAnalytics implements AnalyticsApi {
captureEvent({
context,
action,
subject,
value,
attributes,
}: AnalyticsEvent): void;
static fromConfig(config: Config): GoogleAnalytics;
}
// (No @packageDocumentation comment for this package)
```
+2
View File
@@ -13,4 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { analyticsModuleGA } from './plugin';
export { GoogleAnalytics } from './apis/implementations/AnalyticsApi';
+1 -14
View File
@@ -13,21 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
analyticsApiRef,
configApiRef,
createApiFactory,
createPlugin,
} from '@backstage/core-plugin-api';
import { GoogleAnalytics } from './apis/implementations/AnalyticsApi';
import { createPlugin } from '@backstage/core-plugin-api';
export const analyticsModuleGA = createPlugin({
id: 'analytics-provider-ga',
apis: [
createApiFactory({
api: analyticsApiRef,
deps: { config: configApiRef },
factory: ({ config }) => GoogleAnalytics.fromConfig(config),
}),
],
});