Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,31 @@ module.exports = {
]
}
},
{
// The core's AWS RUM entry point: aws-rum-web, and still no framework.
files: ['projects/ui-watchtower/rum/**/*.ts'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'@angular/*',
'zone.js',
'@absaoss-cps/ngx-ui-watchtower',
'@absaoss-cps/ngx-ui-watchtower/*',
'rxjs',
'rxjs/*'
],
message:
'The core is framework-independent, and this entry point loads no other optional peer.'
}
]
}
]
}
},
{
// The core's RxJS entry point: RxJS, and still no framework.
files: ['projects/ui-watchtower/rxjs/**/*.ts'],
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ How it is designed: [projects/ngx-ui-watchtower/DESIGN.md](projects/ngx-ui-watch
projects/ui-watchtower/
src/ @absaoss-cps/ui-watchtower — the framework-independent engine
rxjs/ secondary entry point — @absaoss-cps/ui-watchtower/rxjs
rum/ secondary entry point — @absaoss-cps/ui-watchtower/rum
type-tests/ consumer type tests, without a framework
README.md usage guide, published to npm
package.json the published package's manifest
Expand Down
7 changes: 6 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module.exports = {
'<rootDir>/projects/ui-watchtower/src/public-api.ts',
'^@absaoss-cps/ui-watchtower/rxjs$':
'<rootDir>/projects/ui-watchtower/rxjs/src/public-api.ts',
'^@absaoss-cps/ui-watchtower/rum$':
'<rootDir>/projects/ui-watchtower/rum/src/public-api.ts',
'^@absaoss-cps/ngx-ui-watchtower$':
'<rootDir>/projects/ngx-ui-watchtower/src/public-api.ts',
'^@absaoss-cps/ngx-ui-watchtower/rum$':
Expand Down Expand Up @@ -34,5 +36,8 @@ module.exports = {
'!projects/**/public-api.ts',
// Compiled by the typecheck, never run.
'!projects/**/type-tests/**'
]
],
coverageThreshold: {
global: { statements: 90, branches: 90, functions: 90, lines: 90 }
}
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lint": "eslint \"**/*.ts\" --max-warnings=0",
"format": "prettier --write \"**/*.{ts,mjs,html}\"",
"format:check": "prettier --check \"**/*.{ts,mjs,html}\"",
"typecheck": "tsc -p projects/ui-watchtower/tsconfig.lib.json --noEmit && tsc -p projects/ui-watchtower/rxjs/tsconfig.lib.json --noEmit && tsc -p projects/ui-watchtower/tsconfig.spec.json --noEmit && tsc -p projects/ui-watchtower/type-tests/tsconfig.json && tsc -p projects/ui-watchtower/type-tests/tsconfig.augmented.json && ng build --configuration=production --project=ui-watchtower && tsc -p projects/ngx-ui-watchtower/tsconfig.lib.json --noEmit && tsc -p projects/ngx-ui-watchtower/tsconfig.spec.json --noEmit && tsc -p projects/ngx-ui-watchtower/rum/tsconfig.lib.json --noEmit && tsc -p projects/ngx-ui-watchtower/rum/tsconfig.spec.json --noEmit && ngc -p projects/ngx-ui-watchtower/type-tests/tsconfig.json && ngc -p projects/ngx-ui-watchtower/type-tests/tsconfig.augmented.json",
"typecheck": "tsc -p projects/ui-watchtower/tsconfig.lib.json --noEmit && tsc -p projects/ui-watchtower/rxjs/tsconfig.lib.json --noEmit && tsc -p projects/ui-watchtower/rum/tsconfig.lib.json --noEmit && tsc -p projects/ui-watchtower/tsconfig.spec.json --noEmit && tsc -p projects/ui-watchtower/type-tests/tsconfig.json && tsc -p projects/ui-watchtower/type-tests/tsconfig.augmented.json && ng build --configuration=production --project=ui-watchtower && tsc -p projects/ngx-ui-watchtower/tsconfig.lib.json --noEmit && tsc -p projects/ngx-ui-watchtower/tsconfig.spec.json --noEmit && tsc -p projects/ngx-ui-watchtower/rum/tsconfig.lib.json --noEmit && tsc -p projects/ngx-ui-watchtower/rum/tsconfig.spec.json --noEmit && ngc -p projects/ngx-ui-watchtower/type-tests/tsconfig.json && ngc -p projects/ngx-ui-watchtower/type-tests/tsconfig.augmented.json",
"api:check": "npm run build && node scripts/api-snapshot.mjs",
"api:update": "npm run build && node scripts/api-snapshot.mjs --update"
},
Expand Down
21 changes: 15 additions & 6 deletions projects/ngx-ui-watchtower/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,16 @@ providers: [
broadcast plumbing stay internal so they can change freely. Redaction is
the exception: a custom sink needs `uwtRedactMetadata`,
`uwtNormalizeError`, `uwtScrubString` and `uwtRedactConfigFor`.
- **The RUM sink is the core's too.** Its logic — the lazy `aws-rum-web`
import, startup retries, credential refresh, the pre-init buffer, the
settings check — lives in `@absaoss-cps/ui-watchtower/rum`. This package's
`/rum` keeps `UWT_RUM_CREDENTIALS_PROVIDER`, `provideUwtTelemetryRumSink()`
and `UwtRumTelemetrySink`, an injectable subclass of the core's.
- **The secondary entry keeps private copies of a few utilities.** ng-packagr
fixes each entry point's `rootDir` to its own `src`, so
`@absaoss-cps/ngx-ui-watchtower/rum` can't import the main entry's
internals by relative path and carries small copies of what it needs.
internals by relative path and carries small copies of what it needs: its
Angular helpers and the reporter.
- **Test doubles live in the specs that use them**, declared inline, never in
a shared file and never exported. The one browser gap needing a stub is
`BroadcastChannel`, which jsdom doesn't implement.
Expand Down Expand Up @@ -1608,12 +1614,15 @@ convention, for an application that wants the pre-fallback behavior back.
## 11. Error handling and performance

- **Telemetry never breaks the application.** Every public entry point is
wrapped and never rethrows. The core prints nothing by itself: it hands a
suppressed error, or data it had to drop, to the `UwtReporter` it is
given. This package gives it one that writes to the console, prefixed
wrapped and never rethrows. The core hands a suppressed error (`'error'`),
or data it had to drop (`'warn'`), to the `UwtReporter` it is given. This
package gives it one that writes to the console, prefixed
`[ngx-ui-watchtower]`, in development mode only, so bugs surface in
development and production stays silent. Even a broken `console.error`
cannot turn a suppressed failure into a throw.
development and production stays silent. What cannot work as configured
(`'config'`) — a second broadcast host, a host in a forwarding realm, RUM
settings of the wrong type — is printed in production too, as it always
was; without a reporter, the core prints it itself. Even a broken
`console.error` cannot turn a suppressed failure into a throw.
- **Fail-open.** A broker outage, expired credentials or an SDK throw all
leave the application behaving exactly as with healthy telemetry. A failed
broker request at startup is retried with backoff for five minutes. A
Expand Down
1 change: 1 addition & 0 deletions projects/ngx-ui-watchtower/public-api.snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@
"UwtRumTelemetrySink": [
"class",
"new (): UwtRumTelemetrySink",
"dispose(): void",
"flush(beacon?: boolean | undefined): void",
"getSessionId(): string | undefined",
"getUserId(): string | undefined",
Expand Down
Loading
Loading