Skip to content

Commit 05feff6

Browse files
authored
Add a typecheck (#352)
1 parent 354f826 commit 05feff6

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

.github/workflows/docusaurus-build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
- name: Install dependencies
2727
run: npm ci
2828

29+
- name: TypeScript type check
30+
run: npm run typecheck
31+
2932
- name: Build site
3033
run: npm run build
3134
env:

src/components/PostHogProvider/index.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
import React, { useEffect, useState } from 'react';
1+
import React, { useEffect } from 'react';
22
import { hasConsent, onConsentChange } from '../../lib/analytics/consent-manager';
33

4+
// PostHog interface - define the methods we use
5+
interface PostHogInstance {
6+
opt_in_capturing(): void;
7+
opt_out_capturing(): void;
8+
startSessionRecording(): void;
9+
stopSessionRecording(): void;
10+
}
11+
412
declare global {
513
interface Window {
6-
posthog?: any;
14+
posthog?: PostHogInstance;
715
}
816
}
917

1018
export function PostHogProvider({ children }: { children: React.ReactNode }) {
11-
const [isPostHogEnabled, setIsPostHogEnabled] = useState(false);
12-
1319
useEffect(() => {
1420
// Check initial consent status
1521
const consentGiven = hasConsent();
16-
setIsPostHogEnabled(consentGiven);
1722

1823
if (consentGiven) {
1924
enablePostHog();
@@ -23,7 +28,6 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {
2328

2429
// Listen for consent changes
2530
const cleanup = onConsentChange((granted) => {
26-
setIsPostHogEnabled(granted);
2731
if (granted) {
2832
enablePostHog();
2933
} else {

0 commit comments

Comments
 (0)