Skip to content

DRAFT Telemetry PoC: not for reviews - #851

Draft
fateeand wants to merge 14 commits into
masterfrom
testrum
Draft

DRAFT Telemetry PoC: not for reviews#851
fateeand wants to merge 14 commits into
masterfrom
testrum

Conversation

@fateeand

@fateeand fateeand commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@fateeand
fateeand requested a balanced review from Copilot September 2, 2026 20:13
@fateeand fateeand changed the title DRAFT PoC: not for reviews DRAFT Telemetry PoC: not for reviews Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Coverage report for library

St.
Category Percentage Covered / Total
🟢 Statements 98.84% 7582/7671
🟢 Branches 93.87% 3902/4157
🟢 Functions 97.49% 1396/1432
🟢 Lines 99.34% 7034/7081

Test suite run success

3233 tests passing in 76 suites.

Report generated by 🧪jest coverage report action from e864056

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The broad telemetry, credential, routing, and cross-realm changes contain unresolved correctness and concurrency issues.

Pull request overview

Introduces a reusable Angular telemetry library and integrates it into the composition application for logging, scenarios, BI events, broadcast forwarding, and AWS RUM.

Changes:

  • Adds telemetry APIs, sinks, configuration, safety/redaction utilities, and tests.
  • Instruments composition navigation, demos, searches, uploads, themes, and diagnostics.
  • Adds routing, build, test, and CI support for telemetry.
File summaries
File Description
tsconfig.json Registers telemetry paths and project references.
projects/cps-telemetry/tsconfig.spec.json Configures telemetry tests.
projects/cps-telemetry/tsconfig.lib.prod.json Configures production compilation.
projects/cps-telemetry/tsconfig.lib.json Configures library compilation.
projects/cps-telemetry/src/public-api.ts Exposes the public telemetry API.
projects/cps-telemetry/src/lib/utils/cps-user-timings.util/cps-user-timings.util.ts Adds browser timing helpers.
projects/cps-telemetry/src/lib/utils/cps-user-timings.util/cps-user-timings.util.spec.ts Tests timing helpers.
projects/cps-telemetry/src/lib/utils/cps-telemetry-safe.util/cps-telemetry-safe.util.ts Adds fail-open utilities and identifiers.
projects/cps-telemetry/src/lib/utils/cps-telemetry-safe.util/cps-telemetry-safe.util.spec.ts Tests safety utilities.
projects/cps-telemetry/src/lib/utils/cps-debug-flag.util/cps-debug-flag.util.ts Adds runtime debug flags.
projects/cps-telemetry/src/lib/utils/cps-debug-flag.util/cps-debug-flag.util.spec.ts Tests debug flags.
projects/cps-telemetry/src/lib/sinks/cps-telemetry/cps-telemetry-abstract.sink/cps-telemetry-abstract.sink.ts Defines the sink contract.
projects/cps-telemetry/src/lib/sinks/cps-telemetry/cps-noop-telemetry.sink/cps-noop-telemetry.sink.ts Adds a no-op sink.
projects/cps-telemetry/src/lib/sinks/cps-telemetry/cps-noop-telemetry.sink/cps-noop-telemetry.sink.spec.ts Tests the no-op sink.
projects/cps-telemetry/src/lib/sinks/cps-rum/cps-rum-credentials/cps-rum-credentials.ts Defines RUM configuration and credentials.
projects/cps-telemetry/src/lib/sinks/cps-broadcast/cps-broadcast.messages.ts Defines broadcast protocol and validation.
projects/cps-telemetry/src/lib/sinks/cps-broadcast/cps-broadcast-telemetry.sink.ts Adds the follower broadcast sink.
projects/cps-telemetry/src/lib/sinks/cps-broadcast/cps-broadcast-host.service.ts Adds the broadcast host.
projects/cps-telemetry/src/lib/services/cps-scenario-telemetry.service/cps-scenario-telemetry.service.ts Manages scenario lifecycles.
projects/cps-telemetry/src/lib/services/cps-logger.service/cps-logger.service.ts Adds structured logging.
projects/cps-telemetry/src/lib/services/cps-bi-telemetry.service/cps-bi-telemetry.service.ts Adds BI event tracking and deduplication.
projects/cps-telemetry/src/lib/scenario/cps-scenario/cps-scenario.spec.ts Tests scenario behavior.
projects/cps-telemetry/src/lib/scenario/cps-scenario-operators/cps-scenario-operators.ts Adds an RxJS scenario operator.
projects/cps-telemetry/src/lib/scenario/cps-scenario-operators/cps-scenario-operators.spec.ts Tests the scenario operator.
projects/cps-telemetry/src/lib/providers/cps-telemetry-common.providers/cps-telemetry-common.providers.ts Adds telemetry provider functions.
projects/cps-telemetry/src/lib/providers/cps-log-api.provider/cps-log-api.provider.ts Defines the logging backend contract.
projects/cps-telemetry/src/lib/models/cps-telemetry-common.models/cps-telemetry-common.models.ts Defines shared telemetry models.
projects/cps-telemetry/src/lib/models/cps-telemetry-common.models/cps-telemetry-common.models.spec.ts Tests event-type generation.
projects/cps-telemetry/src/lib/models/cps-scenario.models/cps-scenario.models.ts Defines scenario models.
projects/cps-telemetry/src/lib/models/cps-log.models/cps-log.models.ts Defines logging models.
projects/cps-telemetry/src/lib/models/cps-bi.models/cps-bi.models.ts Defines BI event models.
projects/cps-telemetry/src/lib/config/cps-telemetry-common.config/cps-telemetry-common.config.ts Defines shared telemetry configuration.
projects/cps-telemetry/src/lib/config/cps-telemetry-common.config/cps-telemetry-common.config.spec.ts Tests shared defaults.
projects/cps-telemetry/src/lib/config/cps-scenario.config/cps-scenario.config.ts Defines scenario configuration.
projects/cps-telemetry/src/lib/config/cps-scenario.config/cps-scenario.config.spec.ts Tests scenario defaults.
projects/cps-telemetry/src/lib/config/cps-log.config/cps-log.config.ts Defines logging configuration.
projects/cps-telemetry/src/lib/config/cps-log.config/cps-log.config.spec.ts Tests logging defaults.
projects/cps-telemetry/src/lib/config/cps-bi.config/cps-bi.config.ts Defines BI configuration.
projects/cps-telemetry/src/lib/config/cps-bi.config/cps-bi.config.spec.ts Tests BI defaults.
projects/cps-telemetry/package.json Declares library metadata and peers.
projects/cps-telemetry/ng-package.json Configures telemetry packaging.
projects/composition/tsconfig.app.json Enables compilation with RUM dependencies.
projects/composition/src/app/services/telemetry.schema.ts Declares telemetry vocabularies.
projects/composition/src/app/services/rum-credentials.provider.ts Loads RUM bootstrap credentials.
projects/composition/src/app/services/rum-credentials.provider.spec.ts Tests credential loading.
projects/composition/src/app/services/app-telemetry.service.ts Instruments navigation and interactions.
projects/composition/src/app/services/app-telemetry.service.spec.ts Tests application telemetry.
projects/composition/src/app/services/app-log-api.provider.ts Adds an in-memory log provider.
projects/composition/src/app/services/app-log-api.provider.spec.ts Tests log storage and querying.
projects/composition/src/app/pages/table-page/table-page.component.ts Instruments lazy table loading.
projects/composition/src/app/pages/table-page/table-page.component.spec.ts Tests table scenarios.
projects/composition/src/app/pages/file-upload-page/file-upload-page.component.ts Instruments file processing.
projects/composition/src/app/pages/file-upload-page/file-upload-page.component.spec.ts Tests upload scenarios.
projects/composition/src/app/pages/autocomplete-page/autocomplete-page.component.ts Instruments search and validation.
projects/composition/src/app/pages/autocomplete-page/autocomplete-page.component.spec.ts Tests autocomplete scenarios.
projects/composition/src/app/guards/default-tab-redirect.guard.ts Redirects bare component routes.
projects/composition/src/app/guards/default-tab-redirect.guard.spec.ts Tests tab redirects.
projects/composition/src/app/components/viewer/viewer.component.ts Removes component-level redirecting.
projects/composition/src/app/components/viewer/viewer.component.spec.ts Updates viewer redirect expectations.
projects/composition/src/app/components/theme-toggle/theme-toggle.component.ts Tracks theme changes.
projects/composition/src/app/components/theme-toggle/theme-toggle.component.spec.ts Tests theme telemetry.
projects/composition/src/app/components/navigation-sidebar/navigation-sidebar.component.ts Tracks debounced searches.
projects/composition/src/app/components/navigation-sidebar/navigation-sidebar.component.spec.ts Tests search telemetry cleanup.
projects/composition/src/app/components/code-example/code-example.component.ts Adds logging and copy telemetry.
projects/composition/src/app/components/code-example/code-example.component.spec.ts Tests code-example diagnostics.
projects/composition/src/app/app.prefix-title-strategy.ts Logs missing route titles.
projects/composition/src/app/app.prefix-title-strategy.spec.ts Tests title diagnostics.
projects/composition/src/app/app.module.ts Registers telemetry and RUM providers.
projects/composition/src/app/app.component.ts Starts application telemetry.
projects/composition/src/app/app.component.spec.ts Adds telemetry test providers.
projects/composition/src/app/app-routing.module.ts Applies default-tab guards.
package.json Adds telemetry scripts and RUM dependency.
jest.config.js Maps the telemetry package in tests.
angular.json Registers telemetry build and test targets.
.gitignore Ignores generated telemetry traces.
.github/workflows/cps-shared-ui-checkers.yml Builds and tests telemetry in CI.
Review details
  • Files reviewed: 83/91 changed files
  • Comments generated: 16
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread projects/composition/src/app/app-routing.module.ts
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Playwright test results

passed  974 passed

Details

stats  974 tests across 35 suites
duration  33 minutes, 25 seconds
commit  e864056
info  For details, download the Playwright report

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Broadcast leadership, cancellation handling, credential caching, and telemetry delivery have unresolved correctness and security issues.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 84/92 changed files
  • Comments generated: 6
  • Review effort level: Balanced

Comment thread projects/cps-telemetry/src/lib/sinks/cps-broadcast/cps-broadcast.messages.ts Outdated
Comment thread projects/composition/src/app/services/rum-credentials.provider.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Successful upload scenarios can incorrectly remain active until timeout, alongside unresolved API and telemetry classification issues.

Review details

Suppressed comments (5)

Previously missed (5) — in code that hasn't changed since the last review.

projects/composition/src/app/app.module.ts:39

  • This labels telemetry from every build and deployment as production. The workspace has no environment replacement/config source, so local development or a non-production deployment that can reach /rum/init will contaminate production dimensions. Supply the deployment environment from runtime or build configuration instead of hard-coding it.
    projects/composition/src/app/pages/file-upload-page/file-upload-page.component.ts:94
  • The upload component wraps this callback in take(1) (cps-file-upload.component.ts:256). After the first value reaches that operator, it unsubscribes upstream before the source's complete notification reaches traceScenario, so a successful upload never calls scenario.complete; the map entry is then deleted and the scenario remains active until timeout. Settle the scenario in the successful next path before returning the value (and fail it in the error path) rather than relying on source completion here.
    projects/cps-telemetry/src/lib/services/cps-bi-telemetry.service/cps-bi-telemetry.service.ts:145
  • Updating an existing Map key does not refresh its insertion order. Consequently, a key re-emitted after its dedup window can have a fresh timestamp but still be selected as oldestKey at capacity; deleting it allows an immediate duplicate through. Refresh the insertion order whenever a non-duplicate key is recorded.
    projects/cps-telemetry/src/lib/sinks/cps-rum/cps-rum-credentials/cps-rum-credentials.ts:163
  • This callback type has the same strict-function-variance problem avoided by fetchFunction: a real SDK ClientBuilder with specific parameter types is not assignable to a function claiming it accepts arbitrary unknown arguments. Consumers therefore cannot use the documented escape hatch without a cast. Mirror the SDK's callable signature with local structural types (to keep the peer optional), or expose a type that accepts a typed function safely.
    projects/cps-telemetry/src/lib/sinks/cps-telemetry/cps-noop-telemetry.sink/cps-noop-telemetry.sink.ts:16
  • The concrete exported class narrows record, recordError, setUserId, and flush to zero-argument methods. Although TypeScript permits these implementations as overrides, consumers typed as CpsNoopTelemetrySink cannot call the normal sink API (for example, new CpsNoopTelemetrySink().record(type, payload) fails type checking). Preserve the abstract method parameters on each override.
  • Files reviewed: 83/92 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Scenario cancellation, noop identity retention, BI deduplication, and download cleanup contain unresolved behavioral defects.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (3)

Previously missed (3) — in code that hasn't changed since the last review.

projects/composition/src/app/services/app-log-api.provider.ts:102

  • If anchor.click() throws, anchor.remove() is skipped and the temporary download link remains in document.body; the existing failure-path test only checks URL revocation. Create the anchor before the try and remove it in finally together with the object URL cleanup.
    projects/cps-telemetry/src/lib/scenario/cps-scenario-operators/cps-scenario-operators.ts:74
  • Unsubscription never reaches either callback here. Common cancellation paths such as switchMap, takeUntilDestroyed, or a manual unsubscribe therefore leave the scenario active until its timeout, recording a cancellation as a timeout. Add teardown handling (for example, the tap observer's unsubscribe hook) that cancels an otherwise-unsettled scenario, and cover that path with a test.
    projects/cps-telemetry/src/lib/services/cps-bi-telemetry.service/cps-bi-telemetry.service.ts:122
  • The delimiter-based key is ambiguous: for example, eventType: 'x|y', feature: 'z' produces the same key as eventType: 'x', feature: 'y|z'. Those are different emitted events, but the second is incorrectly dropped during the dedup window. Encode the fields structurally (for example, as a JSON array) instead of concatenating them.
  • Files reviewed: 83/95 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The cross-cutting telemetry architecture still has unresolved packaging, test-configuration, and timestamp-filtering issues.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

projects/composition/src/app/services/app-log-api.provider.ts:54

  • Lexicographic comparison is only chronological when both timestamps use the same canonical offset. CpsLogQuery accepts general ISO-8601 bounds, so a valid offset such as 2024-01-02T01:00:00+02:00 incorrectly excludes a record at 2024-01-02T00:00:00Z, even though the record is later. Parse the bounds and record timestamps before comparing them.
  • Files reviewed: 82/95 changed files
  • Comments generated: 2
  • Review effort level: Balanced

@fateeand
fateeand requested a balanced review from Copilot September 3, 2026 17:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Scenario snapshots, credential transitions, and fail-open error handling contain unresolved correctness issues.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 88/103 changed files
  • Comments generated: 5
  • Review effort level: Balanced

Comment thread projects/composition/src/app/services/rum-credentials.provider.ts Outdated
Comment thread projects/cps-telemetry/src/lib/scenario/cps-scenario/cps-scenario.ts Outdated
Comment thread projects/cps-telemetry/src/lib/scenario/cps-scenario/cps-scenario.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Settled scenario metrics, error redaction, RUM failure state, and a public RUM callback contract remain incorrect.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (3)

Previously missed (2) — in code that hasn't changed since the last review.

projects/cps-telemetry/src/lib/scenario/cps-scenario/cps-scenario.ts:596

  • An aggregate left open when the scenario settles keeps using the current cpsNow() on every later toRecord() call. The supposedly settled record therefore continues to gain duration and is no longer a stable snapshot. Clamp an open aggregate to the scenario's settlement time once isSettled is true.
    projects/cps-telemetry/rum/src/lib/cps-rum-credentials/cps-rum-credentials.ts:164
  • The public callback type omits the credentials and compression-strategy arguments that the adjacent documentation says the SDK supplies. Consumers therefore get no contextual types for half of this advanced API and must invent or cast those parameters, despite this interface claiming to mirror the SDK field-for-field. Mirror the complete callback signature in the hand-written type.

projects/cps-telemetry/rum/src/lib/cps-rum-telemetry.sink/cps-rum-telemetry.sink.ts:178

  • The failure message says monitoring is disabled, but this path never sets disabled. Since initPromise is already resolved and cannot retry, every subsequent event is instead buffered indefinitely (up to the cap), and unload reports the misleading “before RUM finished initializing” warning. Transition to the same disabled state as a declined bootstrap and clear queued items.
  • Files reviewed: 88/103 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

AWS RUM remains active after revocation or teardown, and route telemetry can expose matrix-parameter values.

Review details

Suppressed comments (4)

Previously missed (3) — in code that hasn't changed since the last review.

projects/composition/src/app/services/app-telemetry.service.ts:195

  • Static Angular routes can still carry matrix parameters (for example, /button;customerId=123). This only strips query strings and fragments, so those resolved values become the route metric dimension and can leak identifiers or create unbounded cardinality. Strip each segment's matrix parameters as well.
    projects/cps-telemetry/rum/src/lib/cps-rum-telemetry.sink/cps-rum-telemetry.sink.ts:332
  • Destroying the Angular sink only clears the credential timer; the AWS RUM instance continues running its event listeners, plugins, cache, and dispatch timer. This can keep collecting after teardown and duplicate telemetry if the app is bootstrapped again in the same page. Disable the client during destruction.
    projects/cps-telemetry/rum/src/lib/cps-rum-credentials/cps-rum-credentials.ts:159
  • This description is incorrect for aws-rum-web 3.2.1: credentials supplied through setAwsCredentials are used to sign requests even without an identityPoolId. Telling consumers this option has no effect can lead them to disable signing and receive 403 responses. Document that it should remain enabled for broker-supplied credentials, and is disabled only when another transport/proxy handles signing.

projects/cps-telemetry/rum/src/lib/cps-rum-telemetry.sink/cps-rum-telemetry.sink.ts:488

  • Dropping this reference does not disable the already-created AWS RUM client: its automatic plugins and dispatch timer remain active, so a provider returning null does not actually revoke monitoring as promised. Call the SDK's disable() method before clearing the reference.
  • Files reviewed: 88/103 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Cross-tab attribution and redaction gaps can produce inaccurate telemetry and retain unsanitized data.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

projects/composition/src/app/services/app-telemetry.service.ts:176

  • This JSDoc describes navigationStartedAt, but the routeTemplate JSDoc immediately following it detaches it from that method. Move this block directly above navigationStartedAt so generated documentation and editor hovers describe the intended function.
  • Files reviewed: 88/103 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment on lines +122 to +127
const key = JSON.stringify([
eventName,
detail?.scenarioId ?? '',
detail?.eventType ?? '',
detail?.feature ?? '',
this.metadataKey(metadata)
Comment on lines +133 to +136
try {
locks
.request(
`cps-telemetry-host:${channelName}`,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants