Mirror of https://github.com/roostorg/coop
github.com/roostorg/coop
1import type {
2 IAnalyticsAdapter,
3} from '../IAnalyticsAdapter.js';
4import type {
5 AnalyticsEventInput,
6 AnalyticsQueryResult,
7 AnalyticsWriteOptions,
8} from '../types.js';
9
10/**
11 * No-op adapter useful for tests or environments where analytics are disabled.
12 */
13export class NoOpAnalyticsAdapter implements IAnalyticsAdapter {
14 readonly name = 'noop-analytics';
15
16 async writeEvents(
17 _table: string,
18 _events: readonly AnalyticsEventInput[],
19 _options?: AnalyticsWriteOptions,
20 ): Promise<void> {
21 // Intentionally empty.
22 }
23
24 async query<T = AnalyticsQueryResult>(
25 _sql: string,
26 _params: readonly unknown[] = [],
27 ): Promise<readonly T[]> {
28 return [];
29 }
30
31 async flush(): Promise<void> {
32 // Nothing buffered.
33 }
34
35 async close(): Promise<void> {
36 // Nothing to tear down.
37 }
38
39 supportsCDC(): boolean {
40 return false;
41 }
42}