Skip to content

Commit 1a2521a

Browse files
authored
Disable telemetry in health checks (#2309)
* disable telemetry in health checks * handle in tests * handle in tests
1 parent 1d035b8 commit 1a2521a

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

.changeset/loud-dots-bathe.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.github/workflows/health_checks.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ on:
1919
- cron: '0 0,6,12,18 * * *'
2020
workflow_dispatch:
2121

22+
env:
23+
# Health checks can run on un-released code. Often work in progress.
24+
# Disable data from there.
25+
AMPLIFY_DISABLE_TELEMETRY: true
26+
2227
jobs:
2328
install:
2429
strategy:

packages/platform-core/src/usage-data/usage_data_emitter_factory.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import assert from 'node:assert';
2-
import { beforeEach, describe, it, mock } from 'node:test';
2+
import { after, before, beforeEach, describe, it, mock } from 'node:test';
33

44
import { UsageDataEmitterFactory } from './usage_data_emitter_factory';
55
import { DefaultUsageDataEmitter } from './usage_data_emitter';
@@ -21,6 +21,19 @@ void describe('UsageDataEmitterFactory', () => {
2121
() => mockedConfigController
2222
);
2323

24+
const originalAmplifyDisableTelemetry =
25+
process.env['AMPLIFY_DISABLE_TELEMETRY'];
26+
27+
before(() => {
28+
// Unset AMPLIFY_DISABLE_TELEMETRY. We may be setting this variable in GitHub workflows.
29+
delete process.env['AMPLIFY_DISABLE_TELEMETRY'];
30+
});
31+
32+
after(() => {
33+
// Restore original value after tests.
34+
process.env['AMPLIFY_DISABLE_TELEMETRY'] = originalAmplifyDisableTelemetry;
35+
});
36+
2437
beforeEach(() => {
2538
configControllerGet.mock.resetCalls();
2639
});

0 commit comments

Comments
 (0)