@refraction-ui/astro 0.6.0 → 0.8.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,37 @@
1
+ import type { AnalyticsSink } from '../analytics/index.ts'
2
+ import {
3
+ createPostHogHttpSink,
4
+ type PostHogHttpSinkOptions,
5
+ } from './http-sink.js'
6
+ import {
7
+ createPostHogClientSdkSink,
8
+ type PostHogClientSdkSinkOptions,
9
+ } from './client-sdk-sink.js'
10
+
11
+ /** PostHog fan-out mode. `http` is the default (no browser library). */
12
+ export type PostHogSinkMode = 'http' | 'client-sdk'
13
+
14
+ export type PostHogSinkOptions =
15
+ | ({ mode?: 'http' } & PostHogHttpSinkOptions)
16
+ | ({ mode: 'client-sdk' } & PostHogClientSdkSinkOptions)
17
+
18
+ /**
19
+ * Create a PostHog `AnalyticsSink`.
20
+ *
21
+ * - `mode: 'http'` (DEFAULT) — pure protocol adapter against PostHog's
22
+ * `/capture` + `/batch` API. No `posthog-js`. Server-relay friendly.
23
+ * - `mode: 'client-sdk'` — OPTIONAL. Lazily dynamic-imports `posthog-js`
24
+ * for client-exclusive features. Only loaded if this mode is selected.
25
+ *
26
+ * Session replay is NOT configurable here — import the separate
27
+ * `@refraction-ui/analytics-sink-posthog/replay` module to opt in. It is
28
+ * never on the event path and tree-shakes away when unused.
29
+ */
30
+ export function createPostHogSink(
31
+ options: PostHogSinkOptions,
32
+ ): AnalyticsSink {
33
+ if (options.mode === 'client-sdk') {
34
+ return createPostHogClientSdkSink(options)
35
+ }
36
+ return createPostHogHttpSink(options)
37
+ }
@@ -47,3 +47,48 @@ export {
47
47
  type CreateMockSinkOptions,
48
48
  type Redactor,
49
49
  } from '../analytics/index.ts'
50
+
51
+ // Re-export vendor sink factories so consumers of the public meta can fan
52
+ // out to GA4 / Azure App Insights / PostHog. The sink packages stay private;
53
+ // they reach consumers only through this adapter (and the meta's `export *`).
54
+ // Named re-exports only — `export *` would collide on shared mapping helpers
55
+ // (each sink re-exports its own `mapEvent`). Mapping helpers are intentionally
56
+ // not surfaced here; only the sink factories + their option/type contracts.
57
+ export {
58
+ createGA4Sink,
59
+ createGA4HttpSink,
60
+ createGA4ClientSdkSink,
61
+ type GA4SinkOptions,
62
+ type GA4HttpOptions,
63
+ type GA4ClientSdkOptions,
64
+ type GA4ConsentBridge,
65
+ type ConsentState,
66
+ type GtagFn,
67
+ } from '../analytics-sink-ga4/index.ts'
68
+
69
+ export {
70
+ createAppInsightsSink,
71
+ type AppInsightsSinkOptions,
72
+ type AppInsightsSinkMode,
73
+ type ClientSdkOptions,
74
+ type HttpOptions,
75
+ type AppInsightsLike,
76
+ } from '../analytics-sink-app-insights/index.ts'
77
+
78
+ export {
79
+ createPostHogSink,
80
+ createPostHogHttpSink,
81
+ createPostHogClientSdkSink,
82
+ type PostHogSinkMode,
83
+ type PostHogSinkOptions,
84
+ type PostHogHttpSinkOptions,
85
+ type PostHogClientSdkSinkOptions,
86
+ } from '../analytics-sink-posthog/index.ts'
87
+
88
+ // Optional, lazy PostHog session replay (separate `./replay` entry point of
89
+ // the sink package — never on the event path, tree-shaken when unused).
90
+ export {
91
+ startSessionReplay,
92
+ type SessionReplayOptions,
93
+ type SessionReplayHandle,
94
+ } from '../analytics-sink-posthog/replay.ts'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@refraction-ui/astro",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "All Refraction UI Astro components in one package",
5
5
  "type": "module",
6
6
  "exports": {
@@ -10,8 +10,12 @@
10
10
  "dist"
11
11
  ],
12
12
  "scripts": {
13
- "build": "node build.mjs"
13
+ "build": "node build.mjs",
14
+ "test": "vitest run --passWithNoTests",
15
+ "test:watch": "vitest",
16
+ "test:coverage": "vitest run --coverage --passWithNoTests"
14
17
  },
18
+ "dependencies": {},
15
19
  "peerDependencies": {
16
20
  "astro": ">=4.0.0"
17
21
  },