@o3r/telemetry 10.0.0-prerelease.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright Amadeus SAS
2
+
3
+ Redistribution and use in source and binary forms, with or without modification,
4
+ are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this
7
+ list of conditions and the following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation and/or
11
+ other materials provided with the distribution.
12
+
13
+ 3. Neither the name of the copyright holder nor the names of its contributors
14
+ may be used to endorse or promote products derived from this software without
15
+ specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
21
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ <h1 align="center">Otter telemetry</h1>
2
+ <p align="center">
3
+ <img src="https://raw.githubusercontent.com/AmadeusITGroup/otter/main/assets/logo/otter.png" alt="Super cute Otter!" width="40%"/>
4
+ </p>
5
+
6
+ This package is an [Otter Framework Module](https://github.com/AmadeusITGroup/otter/tree/main/docs/core/MODULE.md).
7
+ <br />
8
+ <br />
9
+
10
+ ## Description
11
+
12
+ A set of helpers to retrieve tool usage metrics
13
+
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/angular/angular-cli/main/packages/angular_devkit/schematics/collection-schema.json",
3
+ "schematics": {
4
+ "ng-add": {
5
+ "description": "Add telemetry to project.",
6
+ "factory": "./schematics/ng-add/index#ngAdd",
7
+ "schema": "./schematics/ng-add/schema.json",
8
+ "aliases": ["install", "i"]
9
+ }
10
+ }
11
+ }
package/package.json ADDED
@@ -0,0 +1,136 @@
1
+ {
2
+ "name": "@o3r/telemetry",
3
+ "version": "10.0.0-prerelease.18",
4
+ "keywords": [
5
+ "otter-module"
6
+ ],
7
+ "scripts": {
8
+ "build": "yarn nx build telemetry",
9
+ "postbuild": "patch-package-json-main",
10
+ "prepare:build:builders": "yarn run cpy 'collection.json' dist && yarn run cpy 'schematics/**/*.json' dist/schematics",
11
+ "prepare:publish": "prepare-publish ./dist",
12
+ "build:builders": "tsc -b tsconfig.builders.json --pretty"
13
+ },
14
+ "dependencies": {
15
+ "tslib": "^2.5.3"
16
+ },
17
+ "peerDependencies": {
18
+ "@angular-devkit/architect": "~0.1700.3",
19
+ "@angular-devkit/core": "~17.0.3",
20
+ "@angular-devkit/schematics": "~17.0.3",
21
+ "rxjs": "^7.8.1"
22
+ },
23
+ "peerDependenciesMeta": {
24
+ "@angular-devkit/architect": {
25
+ "optional": true
26
+ }
27
+ },
28
+ "devDependencies": {
29
+ "@angular-devkit/architect": "~0.1700.3",
30
+ "@angular-devkit/core": "~17.0.3",
31
+ "@angular-devkit/schematics": "~17.0.3",
32
+ "@angular-eslint/eslint-plugin": "~17.2.0",
33
+ "@nx/eslint-plugin": "~17.2.0",
34
+ "@nx/jest": "~17.2.0",
35
+ "@nx/js": "~17.2.0",
36
+ "@o3r/eslint-plugin": "^10.0.0-prerelease.18",
37
+ "@types/jest": "~29.5.2",
38
+ "@types/node": "^20.0.0",
39
+ "@typescript-eslint/eslint-plugin": "^6.19.0",
40
+ "@typescript-eslint/parser": "^6.11.0",
41
+ "cpy-cli": "^5.0.0",
42
+ "eslint": "^8.42.0",
43
+ "eslint-import-resolver-node": "^0.3.4",
44
+ "eslint-plugin-jest": "~27.6.0",
45
+ "eslint-plugin-jsdoc": "~48.0.0",
46
+ "eslint-plugin-prefer-arrow": "~1.2.3",
47
+ "eslint-plugin-unicorn": "^50.0.0",
48
+ "jest": "~29.7.0",
49
+ "jest-junit": "~16.0.0",
50
+ "jsonc-eslint-parser": "~2.4.0",
51
+ "nx": "~17.2.0",
52
+ "rxjs": "^7.8.1",
53
+ "ts-jest": "~29.1.1",
54
+ "typescript": "~5.2.2"
55
+ },
56
+ "schematics": "./collection.json",
57
+ "engines": {
58
+ "node": ">=18.0.0"
59
+ },
60
+ "exports": {
61
+ ".": {
62
+ "default": "./src/public_api.js",
63
+ "typings": "./src/public_api.d.ts"
64
+ },
65
+ "./package.json": {
66
+ "default": "./package.json"
67
+ }
68
+ },
69
+ "main": "./src/public_api.js",
70
+ "type": "commonjs",
71
+ "contributors": [
72
+ {
73
+ "name": "Yannick Adam",
74
+ "url": "https://github.com/yannickadam",
75
+ "email": "yannickadam@users.noreply.github.com"
76
+ },
77
+ {
78
+ "name": "Kilian Panot",
79
+ "url": "https://github.com/kpanot",
80
+ "email": "kpanot@users.noreply.github.com"
81
+ },
82
+ {
83
+ "name": "Jeremy Bourgeois",
84
+ "url": "https://github.com/jbourgeois-1A",
85
+ "email": "jbourgeois-1A@users.noreply.github.com"
86
+ },
87
+ {
88
+ "name": "Pierre Henri Ginoux",
89
+ "url": "https://github.com/pginoux-1A",
90
+ "email": "pginoux-1A@users.noreply.github.com"
91
+ },
92
+ {
93
+ "name": "Mircea Vasile Rednic",
94
+ "url": "https://github.com/mrednic-1A",
95
+ "email": "mrednic-1A@users.noreply.github.com"
96
+ },
97
+ {
98
+ "name": "Stephane Dalle",
99
+ "email": "sdalle-1A@users.noreply.github.com"
100
+ },
101
+ {
102
+ "name": "Nicolas Hoffmann",
103
+ "url": "https://github.com/nhoffmann-1A",
104
+ "email": "nhoffmann-1A@users.noreply.github.com"
105
+ },
106
+ {
107
+ "name": "Victor Scaiceanu",
108
+ "url": "https://github.com/vscaiceanu-1a",
109
+ "email": "vscaiceanu-1A@users.noreply.github.com"
110
+ },
111
+ {
112
+ "name": "Florian Paul",
113
+ "url": "https://github.com/fpaul-1A",
114
+ "email": "fpaul-1A@users.noreply.github.com"
115
+ },
116
+ {
117
+ "name": "Corinne Paulve",
118
+ "url": "https://github.com/cpaulve-1A",
119
+ "email": "cpaulve-1A@users.noreply.github.com"
120
+ },
121
+ {
122
+ "name": "Matthieu Crouzet",
123
+ "url": "https://github.com/matthieu-crouzet",
124
+ "email": "matthieu-crouzet@users.noreply.github.com"
125
+ },
126
+ {
127
+ "name": "Salome Do",
128
+ "url": "https://github.com/sdo-1A",
129
+ "email": "sdo-1A@users.noreply.github.com"
130
+ }
131
+ ],
132
+ "bugs": "https://github.com/AmadeusITGroup/otter/issues",
133
+ "repository": "https://github.com/AmadeusITGroup/otter",
134
+ "license": "BSD-3-Clause",
135
+ "homepage": "https://amadeusitgroup.github.io/otter/"
136
+ }
@@ -0,0 +1,8 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ import type { NgAddSchematicsSchema } from './schema';
3
+ /**
4
+ * Add Otter telemetry to an Otter Project
5
+ * @param options
6
+ */
7
+ export declare function ngAdd(_options: NgAddSchematicsSchema): Rule;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtD;;;GAGG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,qBAAqB,GAAG,IAAI,CAE3D"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ngAdd = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ /**
6
+ * Add Otter telemetry to an Otter Project
7
+ * @param options
8
+ */
9
+ function ngAdd(_options) {
10
+ return (0, schematics_1.noop)();
11
+ }
12
+ exports.ngAdd = ngAdd;
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,5 @@
1
+ export interface NgAddSchematicsSchema {
2
+ /** Project name */
3
+ projectName?: string | undefined;
4
+ }
5
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/schema.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "ngAddSchematicsSchema",
4
+ "title": "Add telemetry project",
5
+ "description": "'ng add telemetry project",
6
+ "properties": {
7
+ "projectName": {
8
+ "type": "string",
9
+ "description": "Project name",
10
+ "$default": {
11
+ "$source": "projectName"
12
+ }
13
+ }
14
+ },
15
+ "additionalProperties": true,
16
+ "required": [
17
+ ]
18
+ }
@@ -0,0 +1,17 @@
1
+ import type { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
2
+ import { BuilderMetricData } from '../sender';
3
+ type BuilderWrapperFn<S, O extends BuilderOutput = BuilderOutput> = (opts: S, ctx: BuilderContext) => O | Promise<O>;
4
+ type SendDataFn = (data: BuilderMetricData, logger?: {
5
+ error: (msg: string) => void;
6
+ } | undefined) => Promise<void>;
7
+ /**
8
+ * Type of a function that wraps a builder
9
+ */
10
+ export type BuilderWrapper = <S, O extends BuilderOutput = BuilderOutput>(builderFn: BuilderWrapperFn<S, O>, sendData?: SendDataFn) => BuilderWrapperFn<S, O>;
11
+ /**
12
+ * Wrapper method of a builder to retrieve some metrics around the builder run
13
+ * @param builderFn
14
+ */
15
+ export declare const createBuilderWithMetrics: BuilderWrapper;
16
+ export {};
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/builders/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACd,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,iBAAiB,EAA+B,MAAM,WAAW,CAAC;AAE3E,KAAK,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,aAAa,GAAG,aAAa,IAC9D,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,cAAc,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAEnD,KAAK,UAAU,GAAG,CAAC,IAAI,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE;IAAE,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,GAAG,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEpH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,SAAS,aAAa,GAAG,aAAa,EACrE,SAAS,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,UAAU,KAAK,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEvF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,cA+CpC,CAAC"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createBuilderWithMetrics = void 0;
4
+ const index_1 = require("../environment/index");
5
+ const node_perf_hooks_1 = require("node:perf_hooks");
6
+ const sender_1 = require("../sender");
7
+ /**
8
+ * Wrapper method of a builder to retrieve some metrics around the builder run
9
+ * @param builderFn
10
+ */
11
+ const createBuilderWithMetrics = (builderFn, sendData = sender_1.sendData) => async (options, context) => {
12
+ const startTime = Math.floor(node_perf_hooks_1.performance.now());
13
+ let error;
14
+ try {
15
+ const result = await builderFn(options, context);
16
+ return result;
17
+ }
18
+ catch (e) {
19
+ const err = e instanceof Error ? e : new Error(error);
20
+ error = err.stack || err.toString();
21
+ throw err;
22
+ }
23
+ finally {
24
+ try {
25
+ const endTime = Math.floor(node_perf_hooks_1.performance.now());
26
+ const duration = endTime - startTime;
27
+ // context.builder.builderName does not contain the package name
28
+ const builderName = context.builder.name;
29
+ context.logger.info(`${builderName} run in ${duration}ms`);
30
+ const environment = (0, index_1.getEnvironmentInfo)();
31
+ const data = {
32
+ environment,
33
+ duration,
34
+ builder: {
35
+ name: builderName,
36
+ options,
37
+ ...(context.target
38
+ ? {
39
+ target: {
40
+ name: context.target.target,
41
+ projectName: context.target.project,
42
+ configuration: context.target.configuration
43
+ }
44
+ } : {})
45
+ },
46
+ error
47
+ };
48
+ context.logger.debug(JSON.stringify(data, null, 2));
49
+ await sendData(data, context.logger);
50
+ }
51
+ catch (e) {
52
+ // Do not throw error if we don't manage to collect data
53
+ const err = (e instanceof Error ? e : new Error(error));
54
+ context.logger.error(err.stack || err.toString());
55
+ }
56
+ }
57
+ };
58
+ exports.createBuilderWithMetrics = createBuilderWithMetrics;
59
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/builders/index.ts"],"names":[],"mappings":";;;AAIA,gDAA0D;AAC1D,qDAA8C;AAC9C,sCAA2E;AAa3E;;;GAGG;AACI,MAAM,wBAAwB,GAAmB,CAAC,SAAS,EAAE,QAAQ,GAAG,iBAAe,EAAE,EAAE,CAChG,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;IACzB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,6BAAW,CAAC,GAAG,EAAE,CAAC,CAAC;IAChD,IAAI,KAAK,CAAC;IACV,IAAI;QACF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACjD,OAAO,MAAM,CAAC;KACf;IACD,OAAO,CAAM,EAAE;QACb,MAAM,GAAG,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;QACtD,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;QACpC,MAAM,GAAG,CAAC;KACX;YACO;QACN,IAAI;YACF,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,6BAAW,CAAC,GAAG,EAAE,CAAC,CAAC;YAC9C,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;YACrC,gEAAgE;YAChE,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,IAAc,CAAC;YACnD,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,WAAW,WAAW,QAAQ,IAAI,CAAC,CAAC;YAC3D,MAAM,WAAW,GAAG,IAAA,0BAAkB,GAAE,CAAC;YACzC,MAAM,IAAI,GAAsB;gBAC9B,WAAW;gBACX,QAAQ;gBACR,OAAO,EAAE;oBACP,IAAI,EAAE,WAAW;oBACjB,OAAO;oBACP,GAAG,CAAC,OAAO,CAAC,MAAM;wBAChB,CAAC,CAAC;4BACA,MAAM,EAAE;gCACN,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM;gCAC3B,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO;gCACnC,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa;6BAC5C;yBACF,CAAC,CAAC,CAAC,EAAE,CACP;iBACF;gBACD,KAAK;aACN,CAAC;YACF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACpD,MAAM,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;SACtC;QAAC,OAAO,CAAM,EAAE;YACf,wDAAwD;YACxD,MAAM,GAAG,GAAG,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;YACxD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;SACnD;KACF;AACH,CAAC,CAAC;AA/CS,QAAA,wBAAwB,4BA+CjC"}
@@ -0,0 +1,66 @@
1
+ /** Support NPM package managers */
2
+ type SupportedPackageManagers = 'npm' | 'yarn';
3
+ interface PackageManagerInfo {
4
+ /** Name of the package manager used */
5
+ name: SupportedPackageManagers;
6
+ /** Version of the package manager */
7
+ version?: string;
8
+ }
9
+ /**
10
+ * Operation System information
11
+ */
12
+ interface OperatingSystemInfo {
13
+ /** Operating System CPU architecture */
14
+ architecture: string;
15
+ /** Operating System platform */
16
+ platform: string;
17
+ /** Operating System version */
18
+ version: string;
19
+ }
20
+ /**
21
+ * NodeJS information
22
+ */
23
+ interface NodeInfo {
24
+ /** Version of NodeJS */
25
+ version: string;
26
+ }
27
+ /**
28
+ * Otter information
29
+ */
30
+ interface OtterInfo {
31
+ /** Version of `@o3r/core` or `@o3r/telemetry` */
32
+ version?: string;
33
+ }
34
+ /**
35
+ * Project information
36
+ */
37
+ interface ProjectInfo {
38
+ /** Name of the project */
39
+ name: string;
40
+ }
41
+ export interface EnvironmentMetricData {
42
+ /** OS information */
43
+ os: OperatingSystemInfo;
44
+ /** NodeJS information */
45
+ node: NodeInfo;
46
+ /** Package manager information */
47
+ packageManager: PackageManagerInfo;
48
+ /** Otter information */
49
+ otter: OtterInfo;
50
+ /** Is process run in a CI */
51
+ ci: boolean;
52
+ /** Project information */
53
+ project?: ProjectInfo;
54
+ }
55
+ /**
56
+ * Get all environment information
57
+ * Could be useful for debugging issue
58
+ */
59
+ export declare const getEnvironmentInfo: () => EnvironmentMetricData;
60
+ /**
61
+ * Stringify the result of `getEnvironmentInfo`
62
+ * @see getEnvironmentInfo
63
+ */
64
+ export declare const getEnvironmentInfoStringify: () => string;
65
+ export {};
66
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/environment/index.ts"],"names":[],"mappings":"AAKA,mCAAmC;AACnC,KAAK,wBAAwB,GAAG,KAAK,GAAG,MAAM,CAAC;AA0C/C,UAAU,kBAAkB;IAC1B,uCAAuC;IACvC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAYD;;GAEG;AACH,UAAU,mBAAmB;IAC3B,wCAAwC;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,UAAU,QAAQ;IAChB,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,UAAU,SAAS;IACjB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,UAAU,WAAW;IACnB,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,qBAAqB;IACpC,qBAAqB;IACrB,EAAE,EAAE,mBAAmB,CAAC;IACxB,yBAAyB;IACzB,IAAI,EAAE,QAAQ,CAAC;IACf,kCAAkC;IAClC,cAAc,EAAE,kBAAkB,CAAC;IACnC,wBAAwB;IACxB,KAAK,EAAE,SAAS,CAAC;IACjB,6BAA6B;IAC7B,EAAE,EAAE,OAAO,CAAC;IACZ,0BAA0B;IAC1B,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAO,qBAsCrC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,2BAA2B,cAYvC,CAAC"}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEnvironmentInfoStringify = exports.getEnvironmentInfo = void 0;
4
+ const fs = require("node:fs");
5
+ const os = require("node:os");
6
+ const node_child_process_1 = require("node:child_process");
7
+ const path = require("node:path");
8
+ /**
9
+ * Determine if the given packager manager is supported
10
+ * @param name Name of the package manager
11
+ */
12
+ function isSupportedPackageManager(name) {
13
+ return name === 'yarn' || name === 'npm';
14
+ }
15
+ /**
16
+ * Get package manager used
17
+ */
18
+ function getPackageManager() {
19
+ if (isSupportedPackageManager(process.env?.ENFORCED_PACKAGE_MANAGER)) {
20
+ return process.env.ENFORCED_PACKAGE_MANAGER;
21
+ }
22
+ return (process.env?.npm_execpath?.includes('yarn') && 'yarn') || 'npm';
23
+ }
24
+ /**
25
+ * Get package manager version
26
+ */
27
+ function getPackageManagerVersion() {
28
+ try {
29
+ return (0, node_child_process_1.execSync)(`${getPackageManager()} --version`, {
30
+ encoding: 'utf8',
31
+ stdio: ['ignore', 'pipe', 'ignore'],
32
+ env: {
33
+ ...process.env,
34
+ // NPM updater notifier will prevents the child process from closing until it timeout after 3 minutes.
35
+ // eslint-disable-next-line @typescript-eslint/naming-convention
36
+ NO_UPDATE_NOTIFIER: '1',
37
+ // eslint-disable-next-line @typescript-eslint/naming-convention
38
+ NPM_CONFIG_UPDATE_NOTIFIER: 'false'
39
+ }
40
+ }).trim();
41
+ }
42
+ catch {
43
+ return undefined;
44
+ }
45
+ }
46
+ /**
47
+ * Get package manager information
48
+ */
49
+ function getPackageManagerInfo() {
50
+ return {
51
+ name: getPackageManager(),
52
+ version: getPackageManagerVersion()
53
+ };
54
+ }
55
+ /**
56
+ * Get all environment information
57
+ * Could be useful for debugging issue
58
+ */
59
+ const getEnvironmentInfo = () => {
60
+ const osInfo = {
61
+ architecture: os.arch(),
62
+ platform: os.platform(),
63
+ version: os.release()
64
+ };
65
+ const nodeInfo = {
66
+ version: process.version
67
+ };
68
+ const packageManagerInfo = getPackageManagerInfo();
69
+ let otterCorePackageJsonPath;
70
+ try {
71
+ otterCorePackageJsonPath = require.resolve('@o3r/core/package.json');
72
+ }
73
+ catch {
74
+ // Fallback to the @o3r/telemetry package version if @o3r/core is not found
75
+ otterCorePackageJsonPath = path.posix.join(__dirname, '..', '..', 'package.json');
76
+ }
77
+ const otterInfo = {
78
+ version: otterCorePackageJsonPath ? JSON.parse(fs.readFileSync(otterCorePackageJsonPath, { encoding: 'utf-8' })).version : undefined
79
+ };
80
+ const ci = typeof process.env.CI !== undefined && process.env.CI?.toLowerCase() !== 'false';
81
+ let projectName;
82
+ try {
83
+ projectName = JSON.parse(fs.readFileSync(path.posix.join(process.cwd(), 'package.json'), { encoding: 'utf-8' })).name;
84
+ }
85
+ catch { }
86
+ return {
87
+ os: osInfo,
88
+ node: nodeInfo,
89
+ packageManager: packageManagerInfo,
90
+ otter: otterInfo, ci,
91
+ ...(projectName ? { project: { name: projectName } } : {})
92
+ };
93
+ };
94
+ exports.getEnvironmentInfo = getEnvironmentInfo;
95
+ /**
96
+ * Stringify the result of `getEnvironmentInfo`
97
+ * @see getEnvironmentInfo
98
+ */
99
+ const getEnvironmentInfoStringify = () => {
100
+ const { os: osInfo, node: nodeInfo, packageManager: packageManagerInfo, otter: otterInfo, ci } = (0, exports.getEnvironmentInfo)();
101
+ return `
102
+ - User Agent Architecture: ${osInfo.architecture}
103
+ - User Agent Platform: ${osInfo.platform}
104
+ - User Agent Version: ${osInfo.version}
105
+ - Node Version: ${nodeInfo.version || 'undefined'}
106
+ - Package Manager Name: ${packageManagerInfo.name}
107
+ - Package Manager Version: ${packageManagerInfo.version || 'undefined'}
108
+ - Otter Version: ${otterInfo.version || 'undefined'}
109
+ - CI: ${ci}
110
+ `;
111
+ };
112
+ exports.getEnvironmentInfoStringify = getEnvironmentInfoStringify;
113
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/environment/index.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,5 @@
1
+ export * from './builders/index';
2
+ export * from './environment/index';
3
+ export * from './schematics/index';
4
+ export * from './sender/index';
5
+ //# sourceMappingURL=public_api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public_api.d.ts","sourceRoot":"","sources":["../../src/public_api.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./builders/index"), exports);
5
+ tslib_1.__exportStar(require("./environment/index"), exports);
6
+ tslib_1.__exportStar(require("./schematics/index"), exports);
7
+ tslib_1.__exportStar(require("./sender/index"), exports);
8
+ //# sourceMappingURL=public_api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public_api.js","sourceRoot":"","sources":["../../src/public_api.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,8DAAoC;AACpC,6DAAmC;AACnC,yDAA+B"}
@@ -0,0 +1,17 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ import { SchematicMetricData } from '../sender';
3
+ type SchematicWrapperFn<S> = (opts: S) => Rule;
4
+ type SendDataFn = (data: SchematicMetricData, logger?: {
5
+ error: (msg: string) => void;
6
+ } | undefined) => Promise<void>;
7
+ /**
8
+ * Type of a function that wraps a schematic
9
+ */
10
+ export type SchematicWrapper = <S>(schematicFn: SchematicWrapperFn<S>, sendData?: SendDataFn) => SchematicWrapperFn<S>;
11
+ /**
12
+ * Wrapper method of a schematic to retrieve some metrics around the schematic run
13
+ * @param schematicFn
14
+ */
15
+ export declare const createSchematicWithMetrics: SchematicWrapper;
16
+ export {};
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schematics/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAI5D,OAAO,EAA+B,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAE7E,KAAK,kBAAkB,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;AAE/C,KAAK,UAAU,GAAG,CAAC,IAAI,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE;IAAE,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,GAAG,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEtH;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,WAAW,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,UAAU,KAAK,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAEvH;;;GAGG;AACH,eAAO,MAAM,0BAA0B,EAAE,gBAqCtC,CAAC"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSchematicWithMetrics = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const node_perf_hooks_1 = require("node:perf_hooks");
6
+ const rxjs_1 = require("rxjs");
7
+ const index_1 = require("../environment/index");
8
+ const sender_1 = require("../sender");
9
+ /**
10
+ * Wrapper method of a schematic to retrieve some metrics around the schematic run
11
+ * @param schematicFn
12
+ */
13
+ const createSchematicWithMetrics = (schematicFn, sendData = sender_1.sendData) => (options) => async (tree, context) => {
14
+ const startTime = Math.floor(node_perf_hooks_1.performance.now());
15
+ let error;
16
+ try {
17
+ const rule = schematicFn(options);
18
+ await (0, rxjs_1.lastValueFrom)((0, schematics_1.callRule)(rule, tree, context));
19
+ }
20
+ catch (e) {
21
+ const err = e instanceof Error ? e : new Error(error);
22
+ error = err.stack || e.toString();
23
+ throw err;
24
+ }
25
+ finally {
26
+ try {
27
+ const endTime = Math.floor(node_perf_hooks_1.performance.now());
28
+ const duration = endTime - startTime;
29
+ const environment = (0, index_1.getEnvironmentInfo)();
30
+ const schematic = {
31
+ name: `${context.schematic.description.collection.name}:${context.schematic.description.name}`,
32
+ options,
33
+ interactive: context.interactive
34
+ };
35
+ const data = {
36
+ environment,
37
+ schematic,
38
+ duration,
39
+ error
40
+ };
41
+ context.logger.debug(JSON.stringify(data, null, 2));
42
+ await sendData(data, context.logger);
43
+ }
44
+ catch (e) {
45
+ // Do not throw error if we don't manage to collect data
46
+ const err = (e instanceof Error ? e : new Error(error));
47
+ context.logger.error(err.stack || err.toString());
48
+ }
49
+ }
50
+ };
51
+ exports.createSchematicWithMetrics = createSchematicWithMetrics;
52
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/schematics/index.ts"],"names":[],"mappings":";;;AAAA,2DAA4D;AAC5D,qDAA8C;AAC9C,+BAAqC;AACrC,gDAA0D;AAC1D,sCAA6E;AAW7E;;;GAGG;AACI,MAAM,0BAA0B,GACrC,CAAC,WAAW,EAAE,QAAQ,GAAG,iBAAe,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;IAChF,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,6BAAW,CAAC,GAAG,EAAE,CAAC,CAAC;IAChD,IAAI,KAAK,CAAC;IACV,IAAI;QACF,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QAClC,MAAM,IAAA,oBAAa,EAAC,IAAA,qBAAQ,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;KACpD;IACD,OAAO,CAAM,EAAE;QACb,MAAM,GAAG,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;QACtD,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;QAClC,MAAM,GAAG,CAAC;KACX;YACO;QACN,IAAI;YACF,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,6BAAW,CAAC,GAAG,EAAE,CAAC,CAAC;YAC9C,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;YACrC,MAAM,WAAW,GAAG,IAAA,0BAAkB,GAAE,CAAC;YACzC,MAAM,SAAS,GAAG;gBAChB,IAAI,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,IAAI,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE;gBAC9F,OAAO;gBACP,WAAW,EAAE,OAAO,CAAC,WAAW;aACjC,CAAC;YACF,MAAM,IAAI,GAAwB;gBAChC,WAAW;gBACX,SAAS;gBACT,QAAQ;gBACR,KAAK;aACN,CAAC;YACF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACpD,MAAM,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;SACtC;QAAC,OAAO,CAAM,EAAE;YACf,wDAAwD;YACxD,MAAM,GAAG,GAAG,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;YACxD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;SACnD;KACF;AACH,CAAC,CAAC;AArCS,QAAA,0BAA0B,8BAqCnC"}
@@ -0,0 +1,51 @@
1
+ import { EnvironmentMetricData } from '../environment';
2
+ export interface BaseMetricData {
3
+ /** Environment information */
4
+ environment: EnvironmentMetricData;
5
+ /** Time it takes to run */
6
+ duration: number;
7
+ /** Error message */
8
+ error?: string;
9
+ }
10
+ export interface BuilderMetricData extends BaseMetricData {
11
+ /** Builder information */
12
+ builder: {
13
+ /** Builder name */
14
+ name: string;
15
+ /** Builder options */
16
+ options?: any;
17
+ /** Target information */
18
+ target?: {
19
+ /** Target name */
20
+ name: string;
21
+ /** Target project name */
22
+ projectName: string;
23
+ /** Target configuration name */
24
+ configuration?: string;
25
+ };
26
+ };
27
+ }
28
+ export interface SchematicMetricData extends BaseMetricData {
29
+ /** Schematic information */
30
+ schematic: {
31
+ /** Schematic name format @pkg/name:schematic-name */
32
+ name: string;
33
+ /** Schematic options */
34
+ options?: any;
35
+ /** Is run in an interactive context */
36
+ interactive: boolean;
37
+ };
38
+ }
39
+ /**
40
+ * Different kinds of metrics
41
+ */
42
+ export type MetricData = BuilderMetricData | SchematicMetricData;
43
+ /**
44
+ * Send metric to a server
45
+ * @param data
46
+ * @param logger
47
+ */
48
+ export declare const sendData: (data: MetricData, logger?: {
49
+ error: (msg: string) => void;
50
+ } | undefined) => Promise<void>;
51
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sender/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,MAAM,WAAW,cAAc;IAC7B,8BAA8B;IAC9B,WAAW,EAAE,qBAAqB,CAAC;IACnC,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAkB,SAAQ,cAAc;IACvD,0BAA0B;IAC1B,OAAO,EAAE;QACP,mBAAmB;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,sBAAsB;QACtB,OAAO,CAAC,EAAE,GAAG,CAAC;QACd,yBAAyB;QACzB,MAAM,CAAC,EAAE;YACP,kBAAkB;YAClB,IAAI,EAAE,MAAM,CAAC;YACb,0BAA0B;YAC1B,WAAW,EAAE,MAAM,CAAC;YACpB,gCAAgC;YAChC,aAAa,CAAC,EAAE,MAAM,CAAC;SACxB,CAAC;KACH,CAAC;CACH;AAED,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACzD,4BAA4B;IAC5B,SAAS,EAAE;QACT,qDAAqD;QACrD,IAAI,EAAE,MAAM,CAAC;QACb,wBAAwB;QACxB,OAAO,CAAC,EAAE,GAAG,CAAC;QACd,uCAAuC;QACvC,WAAW,EAAE,OAAO,CAAC;KACtB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,iBAAiB,GAAG,mBAAmB,CAAC;AAEjE;;;;GAIG;AACH,eAAO,MAAM,QAAQ,SAAgB,UAAU;iBAA0B,MAAM,KAAK,IAAI;+BAmBvF,CAAC"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendData = void 0;
4
+ /**
5
+ * Send metric to a server
6
+ * @param data
7
+ * @param logger
8
+ */
9
+ const sendData = async (data, logger) => {
10
+ try {
11
+ const message = JSON.stringify(data);
12
+ const body = JSON.stringify({
13
+ messages: [{
14
+ applicationName: 'OTTER',
15
+ message
16
+ }]
17
+ });
18
+ await fetch('https://uat.digital-logging.saas.amadeus.com/postUILogs', {
19
+ method: 'POST',
20
+ body
21
+ });
22
+ }
23
+ catch (e) {
24
+ // Do not throw error if we don't manage to send data to a server
25
+ const err = e instanceof Error ? e : new Error(e);
26
+ // eslint-disable-next-line no-console
27
+ (logger || console).error(err.stack || err.toString());
28
+ }
29
+ };
30
+ exports.sendData = sendData;
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sender/index.ts"],"names":[],"mappings":";;;AA+CA;;;;GAIG;AACI,MAAM,QAAQ,GAAG,KAAK,EAAE,IAAgB,EAAE,MAAyC,EAAE,EAAE;IAC5F,IAAI;QACF,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;YAC1B,QAAQ,EAAE,CAAC;oBACT,eAAe,EAAE,OAAO;oBACxB,OAAO;iBACR,CAAC;SACH,CAAC,CAAC;QACH,MAAM,KAAK,CAAC,yDAAyD,EAAE;YACrE,MAAM,EAAE,MAAM;YACd,IAAI;SACL,CAAC,CAAC;KACJ;IAAC,OAAO,CAAM,EAAE;QACf,iEAAiE;QACjE,MAAM,GAAG,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;QAClD,sCAAsC;QACtC,CAAC,MAAM,IAAI,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;KACxD;AACH,CAAC,CAAC;AAnBW,QAAA,QAAQ,YAmBnB"}