diff --git a/packages/@o3r/extractors/src/core/comparator/metadata-files.helper.spec.ts b/packages/@o3r/extractors/src/core/comparator/metadata-files.helper.spec.ts index 88d86dfa33..e27fa31e44 100644 --- a/packages/@o3r/extractors/src/core/comparator/metadata-files.helper.spec.ts +++ b/packages/@o3r/extractors/src/core/comparator/metadata-files.helper.spec.ts @@ -85,8 +85,8 @@ describe('metadata files helpers', () => { const major = 1; const minor = 3; mockCoerce.mockReturnValue({ major, minor}); - await expect(getVersionRangeFromLatestVersion(`${major}.${minor}.14`, 'major')).resolves.toBe(`<${major}.0.0`); - await expect(getVersionRangeFromLatestVersion(`${major}.${minor}.14`, 'minor')).resolves.toBe(`<${major}.${minor}.0`); + await expect(getVersionRangeFromLatestVersion(`${major}.${minor}.14`, 'major')).resolves.toBe(`<${major}.0.0-a`); + await expect(getVersionRangeFromLatestVersion(`${major}.${minor}.14`, 'minor')).resolves.toBe(`<${major}.${minor}.0-a`); }); }); diff --git a/packages/@o3r/extractors/src/core/comparator/metadata-files.helper.ts b/packages/@o3r/extractors/src/core/comparator/metadata-files.helper.ts index d763f490bd..1388285b41 100644 --- a/packages/@o3r/extractors/src/core/comparator/metadata-files.helper.ts +++ b/packages/@o3r/extractors/src/core/comparator/metadata-files.helper.ts @@ -54,5 +54,5 @@ export async function getVersionRangeFromLatestVersion(latestMigrationVersion: s if (!semver) { throw new O3rCliError(`${latestMigrationVersion} is not a valid version.`); } - return `<${semver.major}.${granularity === 'minor' ? semver.minor : 0}.0`; + return `<${semver.major}.${granularity === 'minor' ? semver.minor : 0}.0-a`; } diff --git a/packages/@o3r/telemetry/src/sender/index.ts b/packages/@o3r/telemetry/src/sender/index.ts index fe4d185528..e97f5b92d6 100644 --- a/packages/@o3r/telemetry/src/sender/index.ts +++ b/packages/@o3r/telemetry/src/sender/index.ts @@ -66,19 +66,32 @@ export type SendDataFn = (data: MetricData, logger?: { error: (msg: string) => v /** * Send metric to a Amadeus Log Server * @param data Metrics to report - * @param _logger Optional logger to provide to the function - * @param _logger.error + * @param logger Optional logger to provide to the function */ -export const sendData: SendDataFn = async (data: MetricData, _logger?: { error: (msg: string) => void }) => { - const message = JSON.stringify(data); - const body = JSON.stringify({ - messages: [{ - applicationName: 'OTTER', - message - }] - }); - await fetch('https://uat.digital-logging.saas.amadeus.com/postUILogs', { - method: 'POST', - body - }); +export const sendData: SendDataFn = (data, logger) => { + let body!: string; + try { + const message = JSON.stringify(data); + body = JSON.stringify({ + messages: [{ + applicationName: 'OTTER', + message + }] + }); + } catch (e: any) { + return Promise.reject(e); + } + + setTimeout(() => { + void fetch('https://uat.digital-logging.saas.amadeus.com/postUILogs', { + method: 'POST', + body + }).catch((e) => { + const err = (e instanceof Error ? e : new Error(e)); + logger?.error(err.stack || err.toString()); + }); + }, 1).unref(); + + return Promise.resolve(); }; +