@ms-cloudpack/external-telemetry 0.1.20 → 0.1.22

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.
@@ -1,2 +1,2 @@
1
- export declare function getAppName(): Promise<string | undefined>;
1
+ export declare function getAppName(appPath: string): Promise<string | undefined>;
2
2
  //# sourceMappingURL=getAppName.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getAppName.d.ts","sourceRoot":"","sources":["../src/getAppName.ts"],"names":[],"mappings":"AAEA,wBAAsB,UAAU,gCAS/B"}
1
+ {"version":3,"file":"getAppName.d.ts","sourceRoot":"","sources":["../src/getAppName.ts"],"names":[],"mappings":"AAEA,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,+BAQ/C"}
package/lib/getAppName.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { PackageDefinitions } from '@ms-cloudpack/package-utilities';
2
- export async function getAppName() {
3
- const appPath = process.cwd();
2
+ export async function getAppName(appPath) {
4
3
  const definition = await PackageDefinitions.getInstance().get(appPath);
5
4
  if (!definition) {
6
5
  throw new Error(`There was no package.json located at "${appPath}".`);
@@ -1 +1 @@
1
- {"version":3,"file":"getAppName.js","sourceRoot":"","sources":["../src/getAppName.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC9B,MAAM,UAAU,GAAG,MAAM,kBAAkB,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAEvE,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,IAAI,KAAK,CAAC,yCAAyC,OAAO,IAAI,CAAC,CAAC;KACvE;IAED,OAAO,UAAU,CAAC,IAAI,CAAC;AACzB,CAAC","sourcesContent":["import { PackageDefinitions } from '@ms-cloudpack/package-utilities';\n\nexport async function getAppName() {\n const appPath = process.cwd();\n const definition = await PackageDefinitions.getInstance().get(appPath);\n\n if (!definition) {\n throw new Error(`There was no package.json located at \"${appPath}\".`);\n }\n\n return definition.name;\n}\n"]}
1
+ {"version":3,"file":"getAppName.js","sourceRoot":"","sources":["../src/getAppName.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAe;IAC9C,MAAM,UAAU,GAAG,MAAM,kBAAkB,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAEvE,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,IAAI,KAAK,CAAC,yCAAyC,OAAO,IAAI,CAAC,CAAC;KACvE;IAED,OAAO,UAAU,CAAC,IAAI,CAAC;AACzB,CAAC","sourcesContent":["import { PackageDefinitions } from '@ms-cloudpack/package-utilities';\n\nexport async function getAppName(appPath: string) {\n const definition = await PackageDefinitions.getInstance().get(appPath);\n\n if (!definition) {\n throw new Error(`There was no package.json located at \"${appPath}\".`);\n }\n\n return definition.name;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"reportExternalTelemetryEvent.d.ts","sourceRoot":"","sources":["../src/reportExternalTelemetryEvent.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAIhF;;;GAGG;AACH,wBAAsB,4BAA4B,CAAC,OAAO,EAAE,sBAAsB,iBAqBjF"}
1
+ {"version":3,"file":"reportExternalTelemetryEvent.d.ts","sourceRoot":"","sources":["../src/reportExternalTelemetryEvent.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAIhF;;;GAGG;AACH,wBAAsB,4BAA4B,CAAC,OAAO,EAAE,sBAAsB,iBAwBjF"}
@@ -8,7 +8,7 @@ const external = 'EXTERNAL';
8
8
  * @param options - The options for reporting the event.
9
9
  */
10
10
  export async function reportExternalTelemetryEvent(options) {
11
- const { telemetry } = await readConfig();
11
+ const { telemetry } = await readConfig(options.appPath);
12
12
  const instrumentationKey = telemetry?.instrumentationKey || process.env.CLOUDPACK_TELEMETRY_INSTRUMENTATION_KEY;
13
13
  const telemetryClient = await createTelemetryClient({
14
14
  productVersion: getVersion(import.meta.url),
@@ -17,7 +17,7 @@ export async function reportExternalTelemetryEvent(options) {
17
17
  instrumentationKey: instrumentationKey,
18
18
  logLevel: options.logLevel,
19
19
  });
20
- telemetryClient.setSharedSpanAttribute('appName', options.appName || (await getAppName()) || '<unknown>');
20
+ telemetryClient.setSharedSpanAttribute('appName', options.appName || (await getAppName(options.appPath)) || '<unknown>');
21
21
  const externalTelemetrySpan = telemetryClient.getTracer().startSpan(external);
22
22
  externalTelemetrySpan.addEvent(`${external}-${options.eventName}`, options.attributes);
23
23
  externalTelemetrySpan.end();
@@ -1 +1 @@
1
- {"version":3,"file":"reportExternalTelemetryEvent.js","sourceRoot":"","sources":["../src/reportExternalTelemetryEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,MAAM,QAAQ,GAAG,UAAU,CAAC;AAE5B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,OAA+B;IAChF,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,UAAU,EAAE,CAAC;IACzC,MAAM,kBAAkB,GAAG,SAAS,EAAE,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC;IAEhH,MAAM,eAAe,GAAG,MAAM,qBAAqB,CAAC;QAClD,cAAc,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QAC3C,WAAW,EAAE,oBAAoB;QACjC,gBAAgB,EAAE,WAAW;QAC7B,kBAAkB,EAAE,kBAAkB;QACtC,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC,CAAC;IAEH,eAAe,CAAC,sBAAsB,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,IAAI,CAAC,MAAM,UAAU,EAAE,CAAC,IAAI,WAAW,CAAC,CAAC;IAE1G,MAAM,qBAAqB,GAAG,eAAe,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAE9E,qBAAqB,CAAC,QAAQ,CAAC,GAAG,QAAQ,IAAI,OAAO,CAAC,SAAS,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAEvF,qBAAqB,CAAC,GAAG,EAAE,CAAC;IAE5B,MAAM,eAAe,CAAC,QAAQ,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import { readConfig } from '@ms-cloudpack/config';\nimport { createTelemetryClient } from '@ms-cloudpack/telemetry';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\nimport { getAppName } from './getAppName.js';\nimport type { ReportTelemetryOptions } from './types/ReportTelemetryOptions.js';\n\nconst external = 'EXTERNAL';\n\n/**\n * Report an external telemetry event to the CloudPack telemetry service.\n * @param options - The options for reporting the event.\n */\nexport async function reportExternalTelemetryEvent(options: ReportTelemetryOptions) {\n const { telemetry } = await readConfig();\n const instrumentationKey = telemetry?.instrumentationKey || process.env.CLOUDPACK_TELEMETRY_INSTRUMENTATION_KEY;\n\n const telemetryClient = await createTelemetryClient({\n productVersion: getVersion(import.meta.url),\n serviceName: 'external-telemetry',\n serviceNamespace: 'cloudpack',\n instrumentationKey: instrumentationKey,\n logLevel: options.logLevel,\n });\n\n telemetryClient.setSharedSpanAttribute('appName', options.appName || (await getAppName()) || '<unknown>');\n\n const externalTelemetrySpan = telemetryClient.getTracer().startSpan(external);\n\n externalTelemetrySpan.addEvent(`${external}-${options.eventName}`, options.attributes);\n\n externalTelemetrySpan.end();\n\n await telemetryClient.shutdown();\n}\n"]}
1
+ {"version":3,"file":"reportExternalTelemetryEvent.js","sourceRoot":"","sources":["../src/reportExternalTelemetryEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,MAAM,QAAQ,GAAG,UAAU,CAAC;AAE5B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,OAA+B;IAChF,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACxD,MAAM,kBAAkB,GAAG,SAAS,EAAE,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC;IAEhH,MAAM,eAAe,GAAG,MAAM,qBAAqB,CAAC;QAClD,cAAc,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QAC3C,WAAW,EAAE,oBAAoB;QACjC,gBAAgB,EAAE,WAAW;QAC7B,kBAAkB,EAAE,kBAAkB;QACtC,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC,CAAC;IAEH,eAAe,CAAC,sBAAsB,CACpC,SAAS,EACT,OAAO,CAAC,OAAO,IAAI,CAAC,MAAM,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,WAAW,CACtE,CAAC;IAEF,MAAM,qBAAqB,GAAG,eAAe,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAE9E,qBAAqB,CAAC,QAAQ,CAAC,GAAG,QAAQ,IAAI,OAAO,CAAC,SAAS,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAEvF,qBAAqB,CAAC,GAAG,EAAE,CAAC;IAE5B,MAAM,eAAe,CAAC,QAAQ,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import { readConfig } from '@ms-cloudpack/config';\nimport { createTelemetryClient } from '@ms-cloudpack/telemetry';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\nimport { getAppName } from './getAppName.js';\nimport type { ReportTelemetryOptions } from './types/ReportTelemetryOptions.js';\n\nconst external = 'EXTERNAL';\n\n/**\n * Report an external telemetry event to the CloudPack telemetry service.\n * @param options - The options for reporting the event.\n */\nexport async function reportExternalTelemetryEvent(options: ReportTelemetryOptions) {\n const { telemetry } = await readConfig(options.appPath);\n const instrumentationKey = telemetry?.instrumentationKey || process.env.CLOUDPACK_TELEMETRY_INSTRUMENTATION_KEY;\n\n const telemetryClient = await createTelemetryClient({\n productVersion: getVersion(import.meta.url),\n serviceName: 'external-telemetry',\n serviceNamespace: 'cloudpack',\n instrumentationKey: instrumentationKey,\n logLevel: options.logLevel,\n });\n\n telemetryClient.setSharedSpanAttribute(\n 'appName',\n options.appName || (await getAppName(options.appPath)) || '<unknown>',\n );\n\n const externalTelemetrySpan = telemetryClient.getTracer().startSpan(external);\n\n externalTelemetrySpan.addEvent(`${external}-${options.eventName}`, options.attributes);\n\n externalTelemetrySpan.end();\n\n await telemetryClient.shutdown();\n}\n"]}
@@ -8,6 +8,10 @@ export interface ReportTelemetryOptions {
8
8
  * "EXTERNAL-" prefix will be added by cloudpack.
9
9
  */
10
10
  eventName: string;
11
+ /**
12
+ * Path to the app being run or bundled in cloudpack.
13
+ */
14
+ appPath: string;
11
15
  /**
12
16
  * Application name to be reported into application insights.
13
17
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ReportTelemetryOptions.d.ts","sourceRoot":"","sources":["../../src/types/ReportTelemetryOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD;;GAEG;AAEH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB"}
1
+ {"version":3,"file":"ReportTelemetryOptions.d.ts","sourceRoot":"","sources":["../../src/types/ReportTelemetryOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD;;GAEG;AAEH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"ReportTelemetryOptions.js","sourceRoot":"","sources":["../../src/types/ReportTelemetryOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { LogLevel } from '@ms-cloudpack/telemetry';\n\n/**\n * Options for external telemetry.\n */\n\nexport interface ReportTelemetryOptions {\n /**\n * Event name to be reported into application insights.\n * \"EXTERNAL-\" prefix will be added by cloudpack.\n */\n eventName: string;\n\n /**\n * Application name to be reported into application insights.\n */\n appName?: string;\n\n /**\n * Additional attributes to be reported into application insights.\n */\n attributes?: Record<string, string>;\n\n /**\n * Log level to be used by application insights.\n */\n logLevel?: LogLevel;\n}\n"]}
1
+ {"version":3,"file":"ReportTelemetryOptions.js","sourceRoot":"","sources":["../../src/types/ReportTelemetryOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { LogLevel } from '@ms-cloudpack/telemetry';\n\n/**\n * Options for external telemetry.\n */\n\nexport interface ReportTelemetryOptions {\n /**\n * Event name to be reported into application insights.\n * \"EXTERNAL-\" prefix will be added by cloudpack.\n */\n eventName: string;\n\n /**\n * Path to the app being run or bundled in cloudpack.\n */\n appPath: string;\n\n /**\n * Application name to be reported into application insights.\n */\n appName?: string;\n\n /**\n * Additional attributes to be reported into application insights.\n */\n attributes?: Record<string, string>;\n\n /**\n * Log level to be used by application insights.\n */\n logLevel?: LogLevel;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/external-telemetry",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
4
4
  "description": "Reporting external telemetry which is not about of cloudpack internals.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -13,8 +13,8 @@
13
13
  }
14
14
  },
15
15
  "dependencies": {
16
- "@ms-cloudpack/telemetry": "^0.3.3",
17
- "@ms-cloudpack/config": "^0.7.4",
16
+ "@ms-cloudpack/telemetry": "^0.3.4",
17
+ "@ms-cloudpack/config": "^0.7.5",
18
18
  "@ms-cloudpack/package-utilities": "^3.1.5",
19
19
  "@ms-cloudpack/path-utilities": "^2.3.0",
20
20
  "@ms-cloudpack/json-utilities": "^0.0.6",