UNPKG

1.91 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8export interface CustomDimensionsAndMetricsOptions {
9 dimensions?: (boolean | number | string)[];
10 metrics?: (boolean | number | string)[];
11}
12export interface EventOptions extends CustomDimensionsAndMetricsOptions {
13 label?: string;
14 value?: string;
15}
16export interface ScreenviewOptions extends CustomDimensionsAndMetricsOptions {
17 appVersion?: string;
18 appId?: string;
19 appInstallerId?: string;
20}
21export interface PageviewOptions extends CustomDimensionsAndMetricsOptions {
22 hostname?: string;
23 title?: string;
24}
25export interface TimingOptions extends CustomDimensionsAndMetricsOptions {
26 label?: string;
27}
28/**
29 * Interface for managing analytics. This is highly platform dependent, and mostly matches
30 * Google Analytics. The reason the interface is here is to remove the dependency to an
31 * implementation from most other places.
32 *
33 * The methods exported from this interface more or less match those needed by us in the
34 * universal analytics package, see https://unpkg.com/@types/universal-analytics@0.4.2/index.d.ts
35 * for typings. We mostly named arguments to make it easier to follow, but didn't change or
36 * add any semantics to those methods. They're mapping GA and u-a one for one.
37 *
38 * The Angular CLI (or any other kind of backend) should forward it to some compatible backend.
39 */
40export interface Analytics {
41 event(category: string, action: string, options?: EventOptions): void;
42 screenview(screenName: string, appName: string, options?: ScreenviewOptions): void;
43 pageview(path: string, options?: PageviewOptions): void;
44 timing(category: string, variable: string, time: string | number, options?: TimingOptions): void;
45 flush(): Promise<void>;
46}