UNPKG

3.63 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google Inc. 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 */
8import { analytics } from '@angular-devkit/core';
9export declare const AnalyticsProperties: {
10 AngularCliProd: string;
11 AngularCliStaging: string;
12 readonly AngularCliDefault: string;
13};
14/**
15 * This is the ultimate safelist for checking if a package name is safe to report to analytics.
16 */
17export declare const analyticsPackageSafelist: (string | RegExp)[];
18export declare function isPackageNameSafeForAnalytics(name: string): boolean;
19/**
20 * Implementation of the Analytics interface for using `universal-analytics` package.
21 */
22export declare class UniversalAnalytics implements analytics.Analytics {
23 private _ua;
24 private _dirty;
25 private _metrics;
26 private _dimensions;
27 /**
28 * @param trackingId The Google Analytics ID.
29 * @param uid A User ID.
30 */
31 constructor(trackingId: string, uid: string);
32 /**
33 * Creates the dimension and metrics variables to pass to universal-analytics.
34 * @private
35 */
36 private _customVariables;
37 event(ec: string, ea: string, options?: analytics.EventOptions): void;
38 screenview(cd: string, an: string, options?: analytics.ScreenviewOptions): void;
39 pageview(dp: string, options?: analytics.PageviewOptions): void;
40 timing(utc: string, utv: string, utt: string | number, options?: analytics.TimingOptions): void;
41 flush(): Promise<void>;
42}
43/**
44 * Set analytics settings. This does not work if the user is not inside a project.
45 * @param level Which config to use. "global" for user-level, and "local" for project-level.
46 * @param value Either a user ID, true to generate a new User ID, or false to disable analytics.
47 */
48export declare function setAnalyticsConfig(level: 'global' | 'local', value: string | boolean): void;
49/**
50 * Prompt the user for usage gathering permission.
51 * @param force Whether to ask regardless of whether or not the user is using an interactive shell.
52 * @return Whether or not the user was shown a prompt.
53 */
54export declare function promptGlobalAnalytics(force?: boolean): Promise<boolean>;
55/**
56 * Prompt the user for usage gathering permission for the local project. Fails if there is no
57 * local workspace.
58 * @param force Whether to ask regardless of whether or not the user is using an interactive shell.
59 * @return Whether or not the user was shown a prompt.
60 */
61export declare function promptProjectAnalytics(force?: boolean): Promise<boolean>;
62export declare function hasGlobalAnalyticsConfiguration(): Promise<boolean>;
63/**
64 * Get the global analytics object for the user. This returns an instance of UniversalAnalytics,
65 * or undefined if analytics are disabled.
66 *
67 * If any problem happens, it is considered the user has been opting out of analytics.
68 */
69export declare function getGlobalAnalytics(): Promise<UniversalAnalytics | undefined>;
70export declare function hasWorkspaceAnalyticsConfiguration(): Promise<boolean>;
71/**
72 * Get the workspace analytics object for the user. This returns an instance of UniversalAnalytics,
73 * or undefined if analytics are disabled.
74 *
75 * If any problem happens, it is considered the user has been opting out of analytics.
76 */
77export declare function getWorkspaceAnalytics(): Promise<UniversalAnalytics | undefined>;
78/**
79 * Return the usage analytics sharing setting, which is either a property string (GA-XXXXXXX-XX),
80 * or undefined if no sharing.
81 */
82export declare function getSharedAnalytics(): Promise<UniversalAnalytics | undefined>;