@allstak/angular 0.1.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"allstak-angular.mjs","sources":["../../src/version.ts","../../src/init.ts","../../src/error-handler.ts","../../src/http-interceptor.ts","../../src/trace-service.ts","../../src/trace-directive.ts","../../src/trace-decorators.ts","../../src/providers.ts","../../src/module.ts","../../public-api.ts","../../allstak-angular.ts"],"sourcesContent":["// AUTO-GENERATED by scripts/gen-version.mjs — do not edit by hand.\nexport const SDK_NAME = 'allstak-angular';\nexport const SDK_VERSION = \"0.1.0\";\n","import { AllStak } from '@allstak/js';\nimport type { AllStakConfig } from '@allstak/js';\nimport { SDK_NAME, SDK_VERSION } from './version';\n\n/**\n * The core client instance returned by `AllStak.init`. `@allstak/js` does\n * not export the `AllStakClient` class by name, so we derive the type from\n * the value. This keeps the emitted declaration referential (no inlining of\n * the core class's private members, which would trip TS4094).\n */\nexport type AllStakClientInstance = ReturnType<typeof AllStak.init>;\n\n/**\n * Initialize the AllStak SDK for an Angular application.\n *\n * This is a thin shim over `AllStak.init` from `@allstak/js` that stamps the\n * wrapper identity (`sdkName: 'allstak-angular'`, `sdkVersion`) so the backend\n * can tell Angular traffic apart from plain JS traffic. Everything else —\n * buffering, sampling, session health, offline queue, PII scrubbing — is\n * delegated to the underlying core client.\n *\n * Call this once at app boot in `main.ts`, BEFORE `bootstrapApplication(...)`\n * (standalone) or `platformBrowserDynamic().bootstrapModule(...)` (NgModule),\n * so the global `ErrorHandler` and router instrumentation see a live client:\n *\n * import { init } from '@allstak/angular';\n *\n * init({\n * apiKey: environment.allstakApiKey,\n * environment: environment.production ? 'production' : 'development',\n * });\n *\n * bootstrapApplication(AppComponent, appConfig);\n */\nexport function init(config: AllStakConfig): AllStakClientInstance {\n return AllStak.init({\n ...config,\n sdkName: config.sdkName ?? SDK_NAME,\n sdkVersion: config.sdkVersion ?? SDK_VERSION,\n });\n}\n","import { ErrorHandler, Injectable } from '@angular/core';\nimport { AllStak } from '@allstak/js';\n\n/**\n * Options accepted by {@link createErrorHandler} / {@link AllStakErrorHandler}.\n *\n * Mirrors the shape host apps expect from a framework error-handler factory:\n * a logging toggle and an `extractor` escape hatch so the host can customise\n * how a thrown value is unwrapped before we hand it to `captureException`.\n */\nexport interface ErrorHandlerOptions {\n /**\n * Also `console.error` the original error after capturing it. Default:\n * `true` — preserving Angular's default behaviour of surfacing errors to\n * the console so local development is not silenced.\n */\n logErrors?: boolean;\n\n /**\n * Customise how the thrown value is reduced to the `Error` we capture.\n * Receives the raw value Angular handed to `handleError` plus the SDK's\n * `defaultExtractor`, so a host can fall back to default behaviour for\n * cases it does not care about.\n *\n * createErrorHandler({\n * extractor: (error, defaultExtractor) =>\n * error?.customCause ?? defaultExtractor(error),\n * });\n */\n extractor?: (error: unknown, defaultExtractor: (error: unknown) => unknown) => unknown;\n}\n\nconst DEFAULT_OPTIONS: Required<Pick<ErrorHandlerOptions, 'logErrors'>> = {\n logErrors: true,\n};\n\n/**\n * Unwrap the common Angular/zone.js error envelopes so we capture the real\n * underlying error rather than the wrapper:\n *\n * - Angular wraps errors thrown during change detection as\n * `{ ngOriginalError }` / `{ originalError }`.\n * - `HttpErrorResponse` carries the server payload on `.error`.\n * - DOM `ErrorEvent` carries the real error on `.error`.\n * - Rejected promises may surface as `{ rejection }`.\n */\nfunction defaultExtractor(error: unknown): unknown {\n if (error && typeof error === 'object') {\n const candidate = error as Record<string, unknown>;\n // PromiseRejectionEvent-style wrapping from zone.js.\n if ('rejection' in candidate && candidate['rejection'] != null) {\n return defaultExtractor(candidate['rejection']);\n }\n // Angular wraps the thrown value during change detection.\n if ('ngOriginalError' in candidate && candidate['ngOriginalError'] != null) {\n return defaultExtractor(candidate['ngOriginalError']);\n }\n if ('originalError' in candidate && candidate['originalError'] != null) {\n return defaultExtractor(candidate['originalError']);\n }\n // DOM ErrorEvent / HttpErrorResponse expose the real error on `.error`.\n if ('error' in candidate && candidate['error'] instanceof Error) {\n return candidate['error'];\n }\n }\n return error;\n}\n\n/** Coerce any extracted value into an `Error` so `captureException` is happy. */\nfunction toError(value: unknown): Error {\n if (value instanceof Error) return value;\n if (typeof value === 'string') return new Error(value);\n try {\n return new Error(JSON.stringify(value));\n } catch {\n return new Error(String(value));\n }\n}\n\n/**\n * AllStak's implementation of Angular's `ErrorHandler`. Captures every error\n * routed through Angular's global error handling — uncaught render/lifecycle\n * errors, change-detection errors, and (when zone.js is present) unhandled\n * promise rejections.\n *\n * Wired manually as `{ provide: ErrorHandler, useValue: createErrorHandler() }`\n * or via {@link provideAllStakErrorHandler}.\n */\n@Injectable()\nexport class AllStakErrorHandler implements ErrorHandler {\n private readonly options: ErrorHandlerOptions;\n\n constructor(options: ErrorHandlerOptions = {}) {\n this.options = { ...DEFAULT_OPTIONS, ...options };\n }\n\n handleError(error: unknown): void {\n const extracted = this.options.extractor\n ? this.options.extractor(error, defaultExtractor)\n : defaultExtractor(error);\n\n const err = toError(extracted);\n\n try {\n AllStak.captureException(err, { framework: 'angular' });\n } catch {\n // Never let our handler break the host's error path.\n }\n\n if (this.options.logErrors !== false) {\n // Preserve Angular's default of surfacing the original (pre-unwrap)\n // value so stack traces and zone context stay intact in the console.\n // eslint-disable-next-line no-console\n console.error(error);\n }\n }\n}\n\n/**\n * Factory returning an Angular `ErrorHandler` that forwards to\n * `AllStak.captureException`.\n *\n * Standalone (`app.config.ts`):\n *\n * import { ErrorHandler } from '@angular/core';\n * import { createErrorHandler } from '@allstak/angular';\n *\n * export const appConfig = {\n * providers: [{ provide: ErrorHandler, useValue: createErrorHandler() }],\n * };\n *\n * NgModule (`AppModule`):\n *\n * @NgModule({\n * providers: [{ provide: ErrorHandler, useValue: createErrorHandler() }],\n * })\n * export class AppModule {}\n */\nexport function createErrorHandler(options?: ErrorHandlerOptions): ErrorHandler {\n return new AllStakErrorHandler(options);\n}\n","import { Injectable } from '@angular/core';\nimport type {\n HttpEvent,\n HttpHandler,\n HttpInterceptor,\n HttpHandlerFn,\n HttpRequest,\n} from '@angular/common/http';\nimport { HttpResponse, HttpErrorResponse } from '@angular/common/http';\nimport { Observable } from 'rxjs';\nimport { AllStak } from '@allstak/js';\nimport type { HttpRequestItem, Span } from '@allstak/js';\n\n/** HTTP verbs the core `HttpRequestItem` accepts. */\ntype HttpMethod = HttpRequestItem['method'];\n\nconst KNOWN_METHODS: ReadonlySet<string> = new Set([\n 'GET',\n 'POST',\n 'PUT',\n 'DELETE',\n 'PATCH',\n 'HEAD',\n 'OPTIONS',\n]);\n\n/** Normalise an Angular request method into the core method union. */\nfunction normalizeMethod(method: string): HttpMethod {\n const upper = method.toUpperCase();\n return (KNOWN_METHODS.has(upper) ? upper : 'GET') as HttpMethod;\n}\n\n/** Split an outbound URL into `host` + `path`, tolerating relative URLs. */\nfunction splitUrl(url: string): { host: string; path: string } {\n try {\n const base =\n typeof window !== 'undefined' && window.location\n ? window.location.origin\n : 'http://localhost';\n const parsed = new URL(url, base);\n return { host: parsed.host, path: parsed.pathname + parsed.search };\n } catch {\n return { host: '', path: url };\n }\n}\n\n/**\n * Open a span + record an outbound request for a single `HttpRequest`, and\n * return the lifecycle hooks the interceptor (class or functional) uses to\n * finish it. Shared so the class-based and functional interceptors stay\n * behaviourally identical.\n */\nfunction instrumentRequest(req: HttpRequest<unknown>): {\n onResponse: (status: number) => void;\n onError: (error: unknown) => void;\n} {\n const startedAt = Date.now();\n const method = normalizeMethod(req.method);\n const { host, path } = splitUrl(req.urlWithParams);\n let span: Span | null = null;\n\n try {\n span = AllStak.startSpan('http.client', {\n op: 'http.client',\n description: `${req.method} ${req.urlWithParams}`,\n attributes: {\n 'allstak.origin': 'auto.http.angular',\n 'http.method': req.method,\n 'http.url': req.urlWithParams,\n },\n });\n } catch {\n // Never block the request on observability errors.\n }\n\n const finish = (statusCode: number, status: 'ok' | 'error') => {\n const durationMs = Date.now() - startedAt;\n try {\n span?.setMeasurement('http.duration_ms', durationMs);\n span?.finish(status);\n } catch {\n // ignore — span may already be finished\n }\n try {\n const item: HttpRequestItem = {\n direction: 'outbound',\n method,\n host,\n path,\n statusCode,\n durationMs,\n };\n AllStak.captureRequest(item);\n } catch {\n // ignore — request recording is best-effort\n }\n };\n\n return {\n onResponse(statusCode: number) {\n finish(statusCode, statusCode >= 400 ? 'error' : 'ok');\n },\n onError(error: unknown) {\n const statusCode = error instanceof HttpErrorResponse ? error.status : 0;\n finish(statusCode, 'error');\n },\n };\n}\n\n/**\n * Class-based `HttpInterceptor` that records every outbound HTTP request and\n * opens a `http.client` span around it. Register in the DI-token style used by\n * NgModule apps and standalone apps that opt into `withInterceptorsFromDi()`:\n *\n * import { HTTP_INTERCEPTORS } from '@angular/common/http';\n * import { AllStakHttpInterceptor } from '@allstak/angular';\n *\n * providers: [\n * { provide: HTTP_INTERCEPTORS, useClass: AllStakHttpInterceptor, multi: true },\n * ]\n *\n * The interceptor never mutates the request and never swallows errors — it\n * only observes the stream.\n */\n@Injectable()\nexport class AllStakHttpInterceptor implements HttpInterceptor {\n intercept(\n req: HttpRequest<unknown>,\n next: HttpHandler,\n ): Observable<HttpEvent<unknown>> {\n const hooks = instrumentRequest(req);\n\n return new Observable<HttpEvent<unknown>>((subscriber) => {\n const sub = next.handle(req).subscribe({\n next: (event) => {\n if (event instanceof HttpResponse) {\n hooks.onResponse(event.status);\n }\n subscriber.next(event);\n },\n error: (error) => {\n hooks.onError(error);\n subscriber.error(error);\n },\n complete: () => subscriber.complete(),\n });\n return () => sub.unsubscribe();\n });\n }\n}\n\n/**\n * Functional `HttpInterceptor` for standalone apps using\n * `provideHttpClient(withInterceptors([allStakHttpInterceptor]))`.\n *\n * Behaviourally identical to {@link AllStakHttpInterceptor}.\n */\nexport function allStakHttpInterceptor(\n req: HttpRequest<unknown>,\n next: HttpHandlerFn,\n): Observable<HttpEvent<unknown>> {\n const hooks = instrumentRequest(req);\n\n return new Observable<HttpEvent<unknown>>((subscriber) => {\n const sub = next(req).subscribe({\n next: (event) => {\n if (event instanceof HttpResponse) {\n hooks.onResponse(event.status);\n }\n subscriber.next(event);\n },\n error: (error) => {\n hooks.onError(error);\n subscriber.error(error);\n },\n complete: () => subscriber.complete(),\n });\n return () => sub.unsubscribe();\n });\n}\n","import { Injectable, OnDestroy, Optional } from '@angular/core';\nimport {\n Router,\n NavigationStart,\n NavigationEnd,\n NavigationCancel,\n NavigationError,\n} from '@angular/router';\nimport type { Event as RouterEvent } from '@angular/router';\nimport type { Subscription } from 'rxjs';\nimport { AllStak } from '@allstak/js';\nimport type { Span } from '@allstak/js';\n\n/**\n * Router-aware navigation instrumentation.\n *\n * `TraceService` subscribes to Angular `Router` events and opens a\n * `navigation` span per route change — `NavigationStart` opens it,\n * `NavigationEnd` finishes it `ok`, and `NavigationCancel` / `NavigationError`\n * finish it `error`. A navigation breadcrumb is recorded alongside each span.\n *\n * Because Angular only constructs a service when something injects it, the\n * service must be *force-instantiated* for its Router subscription to run.\n * Use {@link provideAllStakRouterInstrumentation} (standalone) or inject it in\n * your `AppComponent` constructor (NgModule) — see those helpers for wiring.\n *\n * `Router` is `@Optional()` so apps without `@angular/router` (which is an\n * optional peer dependency) can still construct the service without error; it\n * simply becomes a no-op.\n */\n@Injectable({ providedIn: 'root' })\nexport class TraceService implements OnDestroy {\n private activeNavSpan: Span | null = null;\n private readonly subscription: Subscription | null = null;\n\n constructor(@Optional() private readonly router: Router | null) {\n if (!this.router) return;\n this.subscription = this.router.events.subscribe((event: RouterEvent) => {\n this.handleEvent(event);\n });\n }\n\n private handleEvent(event: RouterEvent): void {\n try {\n if (event instanceof NavigationStart) {\n this.onNavigationStart(event.url);\n } else if (event instanceof NavigationEnd) {\n this.finishActive('ok');\n } else if (\n event instanceof NavigationCancel ||\n event instanceof NavigationError\n ) {\n this.finishActive('error');\n if (event instanceof NavigationError) {\n AllStak.captureException(\n event.error instanceof Error\n ? event.error\n : new Error(String(event.error)),\n { framework: 'angular', source: '@angular/router' },\n );\n }\n }\n } catch {\n // ignore — never block navigation on observability errors\n }\n }\n\n private onNavigationStart(url: string): void {\n // A new navigation supersedes any span still open from a redirect chain.\n this.finishActive('ok');\n\n AllStak.addBreadcrumb({\n type: 'navigation',\n message: url,\n level: 'info',\n data: { url },\n });\n\n this.activeNavSpan = AllStak.startSpan('navigation', {\n op: 'navigation',\n description: url,\n attributes: {\n 'allstak.origin': 'auto.navigation.angular',\n 'route.url': url,\n },\n });\n }\n\n private finishActive(status: 'ok' | 'error'): void {\n if (!this.activeNavSpan) return;\n try {\n this.activeNavSpan.finish(status);\n } catch {\n // ignore — span may already be finished\n } finally {\n this.activeNavSpan = null;\n }\n }\n\n ngOnDestroy(): void {\n this.subscription?.unsubscribe();\n this.finishActive('ok');\n }\n}\n","import {\n Directive,\n Input,\n OnInit,\n AfterViewInit,\n} from '@angular/core';\nimport { AllStak } from '@allstak/js';\nimport type { Span } from '@allstak/js';\n\n/**\n * `[trace]` template directive for component render timing.\n *\n * <app-checkout trace=\"checkout\"></app-checkout>\n *\n * Opens a `ui.angular.init` span when the host component initialises\n * (`ngOnInit`) and finishes it once the component's view has been fully\n * initialised (`ngAfterViewInit`). The span is named after the directive's\n * `trace` value — required, because component class names are not reliable in\n * minified production builds.\n *\n * Standalone components import the directive directly; module-based apps get\n * it via {@link AllStakTraceModule}.\n */\n@Directive({\n selector: '[trace]',\n standalone: true,\n})\nexport class TraceDirective implements OnInit, AfterViewInit {\n /**\n * Human-readable name for the traced component. Used as the span\n * description. Required so spans stay meaningful after minification.\n */\n @Input('trace') componentName = '';\n\n private span: Span | null = null;\n\n ngOnInit(): void {\n const name = this.componentName || 'unnamed';\n try {\n this.span = AllStak.startSpan('ui.angular.init', {\n op: 'ui.angular.init',\n description: name,\n attributes: {\n 'allstak.origin': 'auto.ui.angular',\n 'angular.component': name,\n },\n });\n } catch {\n // Never let render tracing break a component.\n }\n }\n\n ngAfterViewInit(): void {\n try {\n this.span?.finish('ok');\n } catch {\n // ignore — span may already be finished\n } finally {\n this.span = null;\n }\n }\n}\n","import { AllStak } from '@allstak/js';\nimport type { Span } from '@allstak/js';\n\n/**\n * Options for {@link TraceClassDecorator} / {@link TraceMethodDecorator}.\n *\n * `name` is required because Angular component/class names are mangled in\n * minified production builds — the span would otherwise be unidentifiable.\n */\nexport interface TraceDecoratorOptions {\n name: string;\n}\n\n/**\n * Class decorator that instruments a component's init lifecycle. Wraps\n * `ngOnInit` so a `ui.angular.init` span is opened on init and finished on\n * `ngAfterViewInit` (or immediately after `ngOnInit` if the component has no\n * `ngAfterViewInit`).\n *\n * @TraceClassDecorator({ name: 'CheckoutComponent' })\n * @Component({ ... })\n * export class CheckoutComponent implements OnInit {}\n */\nexport function TraceClassDecorator(options: TraceDecoratorOptions) {\n return function <T extends { new (...args: any[]): object }>(target: T): T {\n const proto = target.prototype as Record<string, unknown> & {\n ngOnInit?: () => void;\n ngAfterViewInit?: () => void;\n };\n const SPAN_KEY = '__allstak_trace_class_span__';\n const originalOnInit = proto.ngOnInit;\n const originalAfterViewInit = proto.ngAfterViewInit;\n\n proto.ngOnInit = function (this: Record<string, unknown>) {\n try {\n this[SPAN_KEY] = AllStak.startSpan('ui.angular.init', {\n op: 'ui.angular.init',\n description: options.name,\n attributes: {\n 'allstak.origin': 'auto.ui.angular',\n 'angular.component': options.name,\n },\n });\n } catch {\n // ignore\n }\n originalOnInit?.call(this);\n // If there is no ngAfterViewInit, close the span right after init.\n if (!originalAfterViewInit && !proto.ngAfterViewInit) {\n finishSpan(this[SPAN_KEY]);\n this[SPAN_KEY] = undefined;\n }\n };\n\n proto.ngAfterViewInit = function (this: Record<string, unknown>) {\n originalAfterViewInit?.call(this);\n finishSpan(this[SPAN_KEY]);\n this[SPAN_KEY] = undefined;\n };\n\n return target;\n };\n}\n\n/** Alias for the alternate naming. */\nexport const TraceClass = TraceClassDecorator;\n\n/**\n * Method decorator emitting a point-in-time `ui.angular.[hook]` span around a\n * single lifecycle method (e.g. `ngOnInit`, `ngOnChanges`, `ngAfterViewInit`).\n *\n * class Foo {\n * @TraceMethodDecorator({ name: 'Foo.ngOnInit' })\n * ngOnInit() {}\n * }\n */\nexport function TraceMethodDecorator(options: TraceDecoratorOptions) {\n return function (\n _target: object,\n propertyKey: string,\n descriptor: PropertyDescriptor,\n ): PropertyDescriptor {\n const original = descriptor.value as ((...args: unknown[]) => unknown) | undefined;\n descriptor.value = function (this: unknown, ...args: unknown[]) {\n let span: Span | null = null;\n try {\n span = AllStak.startSpan(`ui.angular.${propertyKey}`, {\n op: `ui.angular.${propertyKey}`,\n description: options.name,\n attributes: {\n 'allstak.origin': 'auto.ui.angular',\n 'angular.hook': propertyKey,\n },\n });\n } catch {\n // ignore\n }\n try {\n return original?.apply(this, args);\n } finally {\n finishSpan(span ?? undefined);\n }\n };\n return descriptor;\n };\n}\n\n/** Alias for the alternate naming. */\nexport const TraceMethod = TraceMethodDecorator;\n\nfunction finishSpan(span: unknown): void {\n try {\n (span as Span | undefined)?.finish('ok');\n } catch {\n // ignore — span may already be finished\n }\n}\n","import {\n APP_INITIALIZER,\n ENVIRONMENT_INITIALIZER,\n ErrorHandler,\n inject,\n makeEnvironmentProviders,\n} from '@angular/core';\nimport type { EnvironmentProviders, Provider } from '@angular/core';\nimport type { AllStakConfig } from '@allstak/js';\nimport { init } from './init';\nimport { createErrorHandler } from './error-handler';\nimport type { ErrorHandlerOptions } from './error-handler';\nimport { TraceService } from './trace-service';\n\n/**\n * Bootstrap the AllStak SDK from a standalone app's `appConfig.providers`.\n *\n * import { provideAllStak } from '@allstak/angular';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideAllStak({ apiKey: environment.allstakApiKey }),\n * ],\n * };\n *\n * This calls {@link init} during DI bootstrap. For the global `ErrorHandler`\n * to catch errors thrown *during bootstrap itself*, prefer calling `init(...)`\n * directly in `main.ts` before `bootstrapApplication`; this provider is the\n * convenient alternative for apps that initialise inside the DI graph.\n */\nexport function provideAllStak(config: AllStakConfig): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useValue: () => {\n init(config);\n },\n },\n ]);\n}\n\n/**\n * Provide the AllStak `ErrorHandler` (overriding Angular's default) so every\n * error routed through Angular's global error handling is captured.\n *\n * providers: [provideAllStakErrorHandler()]\n *\n * Equivalent to `{ provide: ErrorHandler, useValue: createErrorHandler() }`.\n */\nexport function provideAllStakErrorHandler(\n options?: ErrorHandlerOptions,\n): Provider {\n return { provide: ErrorHandler, useValue: createErrorHandler(options) };\n}\n\n/**\n * Register and force-instantiate {@link TraceService} so its Router\n * subscription runs and a navigation span opens per route change.\n *\n * providers: [provideRouter(routes), provideAllStakRouterInstrumentation()]\n *\n * `TraceService` is `providedIn: 'root'`, but Angular only constructs a\n * service when something injects it. The `APP_INITIALIZER` below injects it\n * during bootstrap, guaranteeing the subscription is live before the first\n * navigation completes.\n */\nexport function provideAllStakRouterInstrumentation(): EnvironmentProviders {\n return makeEnvironmentProviders([\n TraceService,\n {\n provide: APP_INITIALIZER,\n multi: true,\n useFactory: () => {\n // Force-instantiate the service; the factory itself is a no-op.\n inject(TraceService);\n return () => undefined;\n },\n },\n ]);\n}\n","import {\n APP_INITIALIZER,\n ErrorHandler,\n InjectionToken,\n NgModule,\n Optional,\n} from '@angular/core';\nimport type { ModuleWithProviders } from '@angular/core';\nimport type { AllStakConfig } from '@allstak/js';\nimport { init } from './init';\nimport { createErrorHandler } from './error-handler';\nimport { TraceService } from './trace-service';\nimport { TraceDirective } from './trace-directive';\n\n/** DI token carrying the config passed to {@link AllStakModule.forRoot}. */\nexport const ALLSTAK_CONFIG = new InjectionToken<AllStakConfig>('ALLSTAK_CONFIG');\n\n/**\n * NgModule that exposes {@link TraceDirective} for module-based apps (or\n * standalone components that prefer NgModule-style `imports`):\n *\n * @NgModule({ imports: [AllStakTraceModule] })\n * export class AppModule {}\n *\n * <app-checkout trace=\"checkout\"></app-checkout>\n *\n * `TraceDirective` is a standalone directive, so it is imported (not declared)\n * and re-exported.\n */\n@NgModule({\n imports: [TraceDirective],\n exports: [TraceDirective],\n})\nexport class AllStakTraceModule {}\n\n/**\n * Root NgModule for module-based Angular apps.\n *\n * import { AllStakModule } from '@allstak/angular';\n *\n * @NgModule({\n * imports: [\n * BrowserModule,\n * AllStakModule.forRoot({ apiKey: environment.allstakApiKey }),\n * ],\n * })\n * export class AppModule {}\n *\n * `forRoot(config)`:\n * - calls {@link init} during bootstrap (via `APP_INITIALIZER`);\n * - overrides the global `ErrorHandler` with the AllStak handler;\n * - force-instantiates {@link TraceService} so router navigation spans open;\n * - exposes {@link TraceDirective} via {@link AllStakTraceModule}.\n *\n * Call `forRoot` exactly once, in your root module. Feature modules that only\n * need the `[trace]` directive can import {@link AllStakTraceModule} directly.\n */\n@NgModule({\n imports: [AllStakTraceModule],\n exports: [AllStakTraceModule],\n})\nexport class AllStakModule {\n // Inject TraceService here so importing the module force-instantiates it and\n // its Router subscription runs. `@Optional` keeps router-less apps working.\n constructor(@Optional() _trace: TraceService | null) {}\n\n static forRoot(config: AllStakConfig): ModuleWithProviders<AllStakModule> {\n return {\n ngModule: AllStakModule,\n providers: [\n { provide: ALLSTAK_CONFIG, useValue: config },\n { provide: ErrorHandler, useValue: createErrorHandler() },\n TraceService,\n {\n provide: APP_INITIALIZER,\n multi: true,\n useFactory: appInitializerFactory,\n deps: [ALLSTAK_CONFIG, TraceService],\n },\n ],\n };\n }\n}\n\n/**\n * `APP_INITIALIZER` factory: initialises the SDK from the injected config and\n * touches `TraceService` so it is constructed (its constructor wires the\n * Router subscription). Declared as a named function so ng-packagr's partial\n * compiler can statically reference it (no arrow-in-decorator-metadata error).\n */\nexport function appInitializerFactory(\n config: AllStakConfig,\n // TraceService is injected via `deps` purely to force its construction.\n _trace: TraceService,\n): () => void {\n return () => {\n init(config);\n };\n}\n","/**\n * AllStak for Angular.\n *\n * Public surface:\n * - `init` — bootstrap (delegates to @allstak/js with Angular tagging)\n * - `createErrorHandler` / `AllStakErrorHandler` — Angular `ErrorHandler` forwarding to captureException\n * - `AllStakHttpInterceptor` / `allStakHttpInterceptor` — records outbound requests + opens spans\n * - `TraceService` — Router-aware navigation span instrumentation\n * - `TraceDirective` / `AllStakTraceModule` — `[trace]` component render-timing directive\n * - `TraceClassDecorator` / `TraceMethodDecorator` — lifecycle-span decorators\n * - `provideAllStak` / `provideAllStakErrorHandler` / `provideAllStakRouterInstrumentation`\n * — standalone provider functions\n * - `AllStakModule.forRoot(config)` — NgModule registration for module-based apps\n * - re-exports — every top-level @allstak/js export\n */\n\n// Bootstrap.\nexport { init } from './src/init';\nexport type { AllStakClientInstance } from './src/init';\n\n// Error handling.\nexport {\n createErrorHandler,\n AllStakErrorHandler,\n} from './src/error-handler';\nexport type { ErrorHandlerOptions } from './src/error-handler';\n\n// HTTP instrumentation.\nexport {\n AllStakHttpInterceptor,\n allStakHttpInterceptor,\n} from './src/http-interceptor';\n\n// Router / navigation instrumentation.\nexport { TraceService } from './src/trace-service';\n\n// Component render-timing directive + module.\nexport { TraceDirective } from './src/trace-directive';\n\n// Lifecycle-span decorators.\nexport {\n TraceClass,\n TraceClassDecorator,\n TraceMethod,\n TraceMethodDecorator,\n} from './src/trace-decorators';\nexport type { TraceDecoratorOptions } from './src/trace-decorators';\n\n// Standalone provider functions.\nexport {\n provideAllStak,\n provideAllStakErrorHandler,\n provideAllStakRouterInstrumentation,\n} from './src/providers';\n\n// NgModule registration for module-based apps.\nexport {\n AllStakModule,\n AllStakTraceModule,\n ALLSTAK_CONFIG,\n appInitializerFactory,\n} from './src/module';\n\n// Wrapper identity.\nexport { SDK_NAME, SDK_VERSION } from './src/version';\n\n// ---------------------------------------------------------------------------\n// Mirror the @allstak/js public surface so consumers can pull the entire\n// observability API from a single namespaced import:\n// import * as AllStakAngular from '@allstak/angular';\n// ---------------------------------------------------------------------------\nexport {\n AllStak,\n Scope,\n Session,\n SessionTracker,\n Span,\n WebVitalsModule,\n isWebVitalsSupported,\n defineIntegration,\n dedupeIntegration,\n consoleIntegration,\n httpClientIntegration,\n databaseIntegration,\n eventFiltersIntegration,\n inboundFiltersIntegration,\n} from '@allstak/js';\n\nexport type {\n AllStakConfig,\n AllStakIntegration,\n Breadcrumb,\n ErrorEvent,\n ErrorEventProcessor,\n LogEvent,\n LogLevel,\n HttpRequestItem,\n HeartbeatOptions,\n SpanData,\n SpanOptions,\n SpanProcessor,\n TracesSampler,\n SamplingContext,\n WebVitalsContext,\n DbQueryItem,\n SessionStatus,\n} from '@allstak/js';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.TraceService"],"mappings":";;;;;;;;;AAAA;AACO,MAAM,QAAQ,GAAG;AACjB,MAAM,WAAW,GAAG;;ACU3B;;;;;;;;;;;;;;;;;;;;;AAqBG;AACG,SAAU,IAAI,CAAC,MAAqB,EAAA;IACxC,OAAO,OAAO,CAAC,IAAI,CAAC;AAClB,QAAA,GAAG,MAAM;AACT,QAAA,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,QAAQ;AACnC,QAAA,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,WAAW;AAC7C,KAAA,CAAC;AACJ;;ACRA,MAAM,eAAe,GAAqD;AACxE,IAAA,SAAS,EAAE,IAAI;CAChB;AAED;;;;;;;;;AASG;AACH,SAAS,gBAAgB,CAAC,KAAc,EAAA;AACtC,IAAA,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACtC,MAAM,SAAS,GAAG,KAAgC;;QAElD,IAAI,WAAW,IAAI,SAAS,IAAI,SAAS,CAAC,WAAW,CAAC,IAAI,IAAI,EAAE;AAC9D,YAAA,OAAO,gBAAgB,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QACjD;;QAEA,IAAI,iBAAiB,IAAI,SAAS,IAAI,SAAS,CAAC,iBAAiB,CAAC,IAAI,IAAI,EAAE;AAC1E,YAAA,OAAO,gBAAgB,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;QACvD;QACA,IAAI,eAAe,IAAI,SAAS,IAAI,S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A,EAAA,CAHd,kBAAkB,EAzBjB,kBAAkB,CAAA,EAAA,CAAA;;4FA4BlB,aAAa,EAAA,UAAA,EAAA,CAAA;kBAJzB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,OAAO,EAAE,CAAC,kBAAkB,CAAC;oBAC7B,OAAO,EAAE,CAAC,kBAAkB,CAAC;AAC9B,iBAAA;;0BAIc;;AAoBf;;;;;AAKG;AACG,SAAU,qBAAqB,CACnC,MAAqB;AACrB;AACA,MAAoB,EAAA;AAEpB,IAAA,OAAO,MAAK;QACV,IAAI,CAAC,MAAM,CAAC;AACd,IAAA,CAAC;AACH;;AClGA;;;;;;;;;;;;;;AAcG;AAEH;;AChBA;;AAEG;;;;"}
package/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ /// <amd-module name="@allstak/angular" />
5
+ export * from './public-api';
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@allstak/angular",
3
+ "version": "0.1.0",
4
+ "description": "Official AllStak SDK for Angular — error tracking, structured logs, distributed tracing, and observability for Angular applications.",
5
+ "keywords": [
6
+ "angular",
7
+ "observability",
8
+ "error-tracking",
9
+ "logging",
10
+ "monitoring",
11
+ "tracing",
12
+ "allstak"
13
+ ],
14
+ "homepage": "https://allstak.sa",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/AllStak/allstak-angular.git"
18
+ },
19
+ "bugs": "https://github.com/AllStak/allstak-angular/issues",
20
+ "license": "MIT",
21
+ "author": "AllStak <sdk@allstak.sa>",
22
+ "sideEffects": false,
23
+ "peerDependencies": {
24
+ "@angular/common": ">=14.0.0 <19.0.0",
25
+ "@angular/core": ">=14.0.0 <19.0.0",
26
+ "@angular/router": ">=14.0.0 <19.0.0",
27
+ "rxjs": "^6.5.5 || ^7.0.0"
28
+ },
29
+ "peerDependenciesMeta": {
30
+ "@angular/router": {
31
+ "optional": true
32
+ }
33
+ },
34
+ "dependencies": {
35
+ "@allstak/js": "^0.3.0",
36
+ "tslib": "^2.3.0"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public",
40
+ "provenance": true,
41
+ "registry": "https://registry.npmjs.org/"
42
+ },
43
+ "module": "fesm2022/allstak-angular.mjs",
44
+ "typings": "index.d.ts",
45
+ "exports": {
46
+ "./package.json": {
47
+ "default": "./package.json"
48
+ },
49
+ ".": {
50
+ "types": "./index.d.ts",
51
+ "esm2022": "./esm2022/allstak-angular.mjs",
52
+ "esm": "./esm2022/allstak-angular.mjs",
53
+ "default": "./fesm2022/allstak-angular.mjs"
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * AllStak for Angular.
3
+ *
4
+ * Public surface:
5
+ * - `init` — bootstrap (delegates to @allstak/js with Angular tagging)
6
+ * - `createErrorHandler` / `AllStakErrorHandler` — Angular `ErrorHandler` forwarding to captureException
7
+ * - `AllStakHttpInterceptor` / `allStakHttpInterceptor` — records outbound requests + opens spans
8
+ * - `TraceService` — Router-aware navigation span instrumentation
9
+ * - `TraceDirective` / `AllStakTraceModule` — `[trace]` component render-timing directive
10
+ * - `TraceClassDecorator` / `TraceMethodDecorator` — lifecycle-span decorators
11
+ * - `provideAllStak` / `provideAllStakErrorHandler` / `provideAllStakRouterInstrumentation`
12
+ * — standalone provider functions
13
+ * - `AllStakModule.forRoot(config)` — NgModule registration for module-based apps
14
+ * - re-exports — every top-level @allstak/js export
15
+ */
16
+ export { init } from './src/init';
17
+ export type { AllStakClientInstance } from './src/init';
18
+ export { createErrorHandler, AllStakErrorHandler, } from './src/error-handler';
19
+ export type { ErrorHandlerOptions } from './src/error-handler';
20
+ export { AllStakHttpInterceptor, allStakHttpInterceptor, } from './src/http-interceptor';
21
+ export { TraceService } from './src/trace-service';
22
+ export { TraceDirective } from './src/trace-directive';
23
+ export { TraceClass, TraceClassDecorator, TraceMethod, TraceMethodDecorator, } from './src/trace-decorators';
24
+ export type { TraceDecoratorOptions } from './src/trace-decorators';
25
+ export { provideAllStak, provideAllStakErrorHandler, provideAllStakRouterInstrumentation, } from './src/providers';
26
+ export { AllStakModule, AllStakTraceModule, ALLSTAK_CONFIG, appInitializerFactory, } from './src/module';
27
+ export { SDK_NAME, SDK_VERSION } from './src/version';
28
+ export { AllStak, Scope, Session, SessionTracker, Span, WebVitalsModule, isWebVitalsSupported, defineIntegration, dedupeIntegration, consoleIntegration, httpClientIntegration, databaseIntegration, eventFiltersIntegration, inboundFiltersIntegration, } from '@allstak/js';
29
+ export type { AllStakConfig, AllStakIntegration, Breadcrumb, ErrorEvent, ErrorEventProcessor, LogEvent, LogLevel, HttpRequestItem, HeartbeatOptions, SpanData, SpanOptions, SpanProcessor, TracesSampler, SamplingContext, WebVitalsContext, DbQueryItem, SessionStatus, } from '@allstak/js';
@@ -0,0 +1,66 @@
1
+ import { ErrorHandler } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Options accepted by {@link createErrorHandler} / {@link AllStakErrorHandler}.
5
+ *
6
+ * Mirrors the shape host apps expect from a framework error-handler factory:
7
+ * a logging toggle and an `extractor` escape hatch so the host can customise
8
+ * how a thrown value is unwrapped before we hand it to `captureException`.
9
+ */
10
+ export interface ErrorHandlerOptions {
11
+ /**
12
+ * Also `console.error` the original error after capturing it. Default:
13
+ * `true` — preserving Angular's default behaviour of surfacing errors to
14
+ * the console so local development is not silenced.
15
+ */
16
+ logErrors?: boolean;
17
+ /**
18
+ * Customise how the thrown value is reduced to the `Error` we capture.
19
+ * Receives the raw value Angular handed to `handleError` plus the SDK's
20
+ * `defaultExtractor`, so a host can fall back to default behaviour for
21
+ * cases it does not care about.
22
+ *
23
+ * createErrorHandler({
24
+ * extractor: (error, defaultExtractor) =>
25
+ * error?.customCause ?? defaultExtractor(error),
26
+ * });
27
+ */
28
+ extractor?: (error: unknown, defaultExtractor: (error: unknown) => unknown) => unknown;
29
+ }
30
+ /**
31
+ * AllStak's implementation of Angular's `ErrorHandler`. Captures every error
32
+ * routed through Angular's global error handling — uncaught render/lifecycle
33
+ * errors, change-detection errors, and (when zone.js is present) unhandled
34
+ * promise rejections.
35
+ *
36
+ * Wired manually as `{ provide: ErrorHandler, useValue: createErrorHandler() }`
37
+ * or via {@link provideAllStakErrorHandler}.
38
+ */
39
+ export declare class AllStakErrorHandler implements ErrorHandler {
40
+ private readonly options;
41
+ constructor(options?: ErrorHandlerOptions);
42
+ handleError(error: unknown): void;
43
+ static ɵfac: i0.ɵɵFactoryDeclaration<AllStakErrorHandler, never>;
44
+ static ɵprov: i0.ɵɵInjectableDeclaration<AllStakErrorHandler>;
45
+ }
46
+ /**
47
+ * Factory returning an Angular `ErrorHandler` that forwards to
48
+ * `AllStak.captureException`.
49
+ *
50
+ * Standalone (`app.config.ts`):
51
+ *
52
+ * import { ErrorHandler } from '@angular/core';
53
+ * import { createErrorHandler } from '@allstak/angular';
54
+ *
55
+ * export const appConfig = {
56
+ * providers: [{ provide: ErrorHandler, useValue: createErrorHandler() }],
57
+ * };
58
+ *
59
+ * NgModule (`AppModule`):
60
+ *
61
+ * @NgModule({
62
+ * providers: [{ provide: ErrorHandler, useValue: createErrorHandler() }],
63
+ * })
64
+ * export class AppModule {}
65
+ */
66
+ export declare function createErrorHandler(options?: ErrorHandlerOptions): ErrorHandler;
@@ -0,0 +1,30 @@
1
+ import type { HttpEvent, HttpHandler, HttpInterceptor, HttpHandlerFn, HttpRequest } from '@angular/common/http';
2
+ import { Observable } from 'rxjs';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * Class-based `HttpInterceptor` that records every outbound HTTP request and
6
+ * opens a `http.client` span around it. Register in the DI-token style used by
7
+ * NgModule apps and standalone apps that opt into `withInterceptorsFromDi()`:
8
+ *
9
+ * import { HTTP_INTERCEPTORS } from '@angular/common/http';
10
+ * import { AllStakHttpInterceptor } from '@allstak/angular';
11
+ *
12
+ * providers: [
13
+ * { provide: HTTP_INTERCEPTORS, useClass: AllStakHttpInterceptor, multi: true },
14
+ * ]
15
+ *
16
+ * The interceptor never mutates the request and never swallows errors — it
17
+ * only observes the stream.
18
+ */
19
+ export declare class AllStakHttpInterceptor implements HttpInterceptor {
20
+ intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>>;
21
+ static ɵfac: i0.ɵɵFactoryDeclaration<AllStakHttpInterceptor, never>;
22
+ static ɵprov: i0.ɵɵInjectableDeclaration<AllStakHttpInterceptor>;
23
+ }
24
+ /**
25
+ * Functional `HttpInterceptor` for standalone apps using
26
+ * `provideHttpClient(withInterceptors([allStakHttpInterceptor]))`.
27
+ *
28
+ * Behaviourally identical to {@link AllStakHttpInterceptor}.
29
+ */
30
+ export declare function allStakHttpInterceptor(req: HttpRequest<unknown>, next: HttpHandlerFn): Observable<HttpEvent<unknown>>;
package/src/init.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ import { AllStak } from '@allstak/js';
2
+ import type { AllStakConfig } from '@allstak/js';
3
+ /**
4
+ * The core client instance returned by `AllStak.init`. `@allstak/js` does
5
+ * not export the `AllStakClient` class by name, so we derive the type from
6
+ * the value. This keeps the emitted declaration referential (no inlining of
7
+ * the core class's private members, which would trip TS4094).
8
+ */
9
+ export type AllStakClientInstance = ReturnType<typeof AllStak.init>;
10
+ /**
11
+ * Initialize the AllStak SDK for an Angular application.
12
+ *
13
+ * This is a thin shim over `AllStak.init` from `@allstak/js` that stamps the
14
+ * wrapper identity (`sdkName: 'allstak-angular'`, `sdkVersion`) so the backend
15
+ * can tell Angular traffic apart from plain JS traffic. Everything else —
16
+ * buffering, sampling, session health, offline queue, PII scrubbing — is
17
+ * delegated to the underlying core client.
18
+ *
19
+ * Call this once at app boot in `main.ts`, BEFORE `bootstrapApplication(...)`
20
+ * (standalone) or `platformBrowserDynamic().bootstrapModule(...)` (NgModule),
21
+ * so the global `ErrorHandler` and router instrumentation see a live client:
22
+ *
23
+ * import { init } from '@allstak/angular';
24
+ *
25
+ * init({
26
+ * apiKey: environment.allstakApiKey,
27
+ * environment: environment.production ? 'production' : 'development',
28
+ * });
29
+ *
30
+ * bootstrapApplication(AppComponent, appConfig);
31
+ */
32
+ export declare function init(config: AllStakConfig): AllStakClientInstance;
@@ -0,0 +1,61 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import type { ModuleWithProviders } from '@angular/core';
3
+ import type { AllStakConfig } from '@allstak/js';
4
+ import { TraceService } from './trace-service';
5
+ import * as i0 from "@angular/core";
6
+ import * as i1 from "./trace-directive";
7
+ /** DI token carrying the config passed to {@link AllStakModule.forRoot}. */
8
+ export declare const ALLSTAK_CONFIG: InjectionToken<AllStakConfig>;
9
+ /**
10
+ * NgModule that exposes {@link TraceDirective} for module-based apps (or
11
+ * standalone components that prefer NgModule-style `imports`):
12
+ *
13
+ * @NgModule({ imports: [AllStakTraceModule] })
14
+ * export class AppModule {}
15
+ *
16
+ * <app-checkout trace="checkout"></app-checkout>
17
+ *
18
+ * `TraceDirective` is a standalone directive, so it is imported (not declared)
19
+ * and re-exported.
20
+ */
21
+ export declare class AllStakTraceModule {
22
+ static ɵfac: i0.ɵɵFactoryDeclaration<AllStakTraceModule, never>;
23
+ static ɵmod: i0.ɵɵNgModuleDeclaration<AllStakTraceModule, never, [typeof i1.TraceDirective], [typeof i1.TraceDirective]>;
24
+ static ɵinj: i0.ɵɵInjectorDeclaration<AllStakTraceModule>;
25
+ }
26
+ /**
27
+ * Root NgModule for module-based Angular apps.
28
+ *
29
+ * import { AllStakModule } from '@allstak/angular';
30
+ *
31
+ * @NgModule({
32
+ * imports: [
33
+ * BrowserModule,
34
+ * AllStakModule.forRoot({ apiKey: environment.allstakApiKey }),
35
+ * ],
36
+ * })
37
+ * export class AppModule {}
38
+ *
39
+ * `forRoot(config)`:
40
+ * - calls {@link init} during bootstrap (via `APP_INITIALIZER`);
41
+ * - overrides the global `ErrorHandler` with the AllStak handler;
42
+ * - force-instantiates {@link TraceService} so router navigation spans open;
43
+ * - exposes {@link TraceDirective} via {@link AllStakTraceModule}.
44
+ *
45
+ * Call `forRoot` exactly once, in your root module. Feature modules that only
46
+ * need the `[trace]` directive can import {@link AllStakTraceModule} directly.
47
+ */
48
+ export declare class AllStakModule {
49
+ constructor(_trace: TraceService | null);
50
+ static forRoot(config: AllStakConfig): ModuleWithProviders<AllStakModule>;
51
+ static ɵfac: i0.ɵɵFactoryDeclaration<AllStakModule, [{ optional: true; }]>;
52
+ static ɵmod: i0.ɵɵNgModuleDeclaration<AllStakModule, never, [typeof AllStakTraceModule], [typeof AllStakTraceModule]>;
53
+ static ɵinj: i0.ɵɵInjectorDeclaration<AllStakModule>;
54
+ }
55
+ /**
56
+ * `APP_INITIALIZER` factory: initialises the SDK from the injected config and
57
+ * touches `TraceService` so it is constructed (its constructor wires the
58
+ * Router subscription). Declared as a named function so ng-packagr's partial
59
+ * compiler can statically reference it (no arrow-in-decorator-metadata error).
60
+ */
61
+ export declare function appInitializerFactory(config: AllStakConfig, _trace: TraceService): () => void;
@@ -0,0 +1,41 @@
1
+ import type { EnvironmentProviders, Provider } from '@angular/core';
2
+ import type { AllStakConfig } from '@allstak/js';
3
+ import type { ErrorHandlerOptions } from './error-handler';
4
+ /**
5
+ * Bootstrap the AllStak SDK from a standalone app's `appConfig.providers`.
6
+ *
7
+ * import { provideAllStak } from '@allstak/angular';
8
+ *
9
+ * export const appConfig: ApplicationConfig = {
10
+ * providers: [
11
+ * provideAllStak({ apiKey: environment.allstakApiKey }),
12
+ * ],
13
+ * };
14
+ *
15
+ * This calls {@link init} during DI bootstrap. For the global `ErrorHandler`
16
+ * to catch errors thrown *during bootstrap itself*, prefer calling `init(...)`
17
+ * directly in `main.ts` before `bootstrapApplication`; this provider is the
18
+ * convenient alternative for apps that initialise inside the DI graph.
19
+ */
20
+ export declare function provideAllStak(config: AllStakConfig): EnvironmentProviders;
21
+ /**
22
+ * Provide the AllStak `ErrorHandler` (overriding Angular's default) so every
23
+ * error routed through Angular's global error handling is captured.
24
+ *
25
+ * providers: [provideAllStakErrorHandler()]
26
+ *
27
+ * Equivalent to `{ provide: ErrorHandler, useValue: createErrorHandler() }`.
28
+ */
29
+ export declare function provideAllStakErrorHandler(options?: ErrorHandlerOptions): Provider;
30
+ /**
31
+ * Register and force-instantiate {@link TraceService} so its Router
32
+ * subscription runs and a navigation span opens per route change.
33
+ *
34
+ * providers: [provideRouter(routes), provideAllStakRouterInstrumentation()]
35
+ *
36
+ * `TraceService` is `providedIn: 'root'`, but Angular only constructs a
37
+ * service when something injects it. The `APP_INITIALIZER` below injects it
38
+ * during bootstrap, guaranteeing the subscription is live before the first
39
+ * navigation completes.
40
+ */
41
+ export declare function provideAllStakRouterInstrumentation(): EnvironmentProviders;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Options for {@link TraceClassDecorator} / {@link TraceMethodDecorator}.
3
+ *
4
+ * `name` is required because Angular component/class names are mangled in
5
+ * minified production builds — the span would otherwise be unidentifiable.
6
+ */
7
+ export interface TraceDecoratorOptions {
8
+ name: string;
9
+ }
10
+ /**
11
+ * Class decorator that instruments a component's init lifecycle. Wraps
12
+ * `ngOnInit` so a `ui.angular.init` span is opened on init and finished on
13
+ * `ngAfterViewInit` (or immediately after `ngOnInit` if the component has no
14
+ * `ngAfterViewInit`).
15
+ *
16
+ * @TraceClassDecorator({ name: 'CheckoutComponent' })
17
+ * @Component({ ... })
18
+ * export class CheckoutComponent implements OnInit {}
19
+ */
20
+ export declare function TraceClassDecorator(options: TraceDecoratorOptions): <T extends {
21
+ new (...args: any[]): object;
22
+ }>(target: T) => T;
23
+ /** Alias for the alternate naming. */
24
+ export declare const TraceClass: typeof TraceClassDecorator;
25
+ /**
26
+ * Method decorator emitting a point-in-time `ui.angular.[hook]` span around a
27
+ * single lifecycle method (e.g. `ngOnInit`, `ngOnChanges`, `ngAfterViewInit`).
28
+ *
29
+ * class Foo {
30
+ * @TraceMethodDecorator({ name: 'Foo.ngOnInit' })
31
+ * ngOnInit() {}
32
+ * }
33
+ */
34
+ export declare function TraceMethodDecorator(options: TraceDecoratorOptions): (_target: object, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
35
+ /** Alias for the alternate naming. */
36
+ export declare const TraceMethod: typeof TraceMethodDecorator;
@@ -0,0 +1,28 @@
1
+ import { OnInit, AfterViewInit } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * `[trace]` template directive for component render timing.
5
+ *
6
+ * <app-checkout trace="checkout"></app-checkout>
7
+ *
8
+ * Opens a `ui.angular.init` span when the host component initialises
9
+ * (`ngOnInit`) and finishes it once the component's view has been fully
10
+ * initialised (`ngAfterViewInit`). The span is named after the directive's
11
+ * `trace` value — required, because component class names are not reliable in
12
+ * minified production builds.
13
+ *
14
+ * Standalone components import the directive directly; module-based apps get
15
+ * it via {@link AllStakTraceModule}.
16
+ */
17
+ export declare class TraceDirective implements OnInit, AfterViewInit {
18
+ /**
19
+ * Human-readable name for the traced component. Used as the span
20
+ * description. Required so spans stay meaningful after minification.
21
+ */
22
+ componentName: string;
23
+ private span;
24
+ ngOnInit(): void;
25
+ ngAfterViewInit(): void;
26
+ static ɵfac: i0.ɵɵFactoryDeclaration<TraceDirective, never>;
27
+ static ɵdir: i0.ɵɵDirectiveDeclaration<TraceDirective, "[trace]", never, { "componentName": { "alias": "trace"; "required": false; }; }, {}, never, never, true, never>;
28
+ }
@@ -0,0 +1,32 @@
1
+ import { OnDestroy } from '@angular/core';
2
+ import { Router } from '@angular/router';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * Router-aware navigation instrumentation.
6
+ *
7
+ * `TraceService` subscribes to Angular `Router` events and opens a
8
+ * `navigation` span per route change — `NavigationStart` opens it,
9
+ * `NavigationEnd` finishes it `ok`, and `NavigationCancel` / `NavigationError`
10
+ * finish it `error`. A navigation breadcrumb is recorded alongside each span.
11
+ *
12
+ * Because Angular only constructs a service when something injects it, the
13
+ * service must be *force-instantiated* for its Router subscription to run.
14
+ * Use {@link provideAllStakRouterInstrumentation} (standalone) or inject it in
15
+ * your `AppComponent` constructor (NgModule) — see those helpers for wiring.
16
+ *
17
+ * `Router` is `@Optional()` so apps without `@angular/router` (which is an
18
+ * optional peer dependency) can still construct the service without error; it
19
+ * simply becomes a no-op.
20
+ */
21
+ export declare class TraceService implements OnDestroy {
22
+ private readonly router;
23
+ private activeNavSpan;
24
+ private readonly subscription;
25
+ constructor(router: Router | null);
26
+ private handleEvent;
27
+ private onNavigationStart;
28
+ private finishActive;
29
+ ngOnDestroy(): void;
30
+ static ɵfac: i0.ɵɵFactoryDeclaration<TraceService, [{ optional: true; }]>;
31
+ static ɵprov: i0.ɵɵInjectableDeclaration<TraceService>;
32
+ }
@@ -0,0 +1,2 @@
1
+ export declare const SDK_NAME = "allstak-angular";
2
+ export declare const SDK_VERSION = "0.1.0";