Steps to Add a New Service

LaunchIt uses a cookie banner to manage user consent for tracking services. Only if a user consents to a service, the corresponding tracking script is loaded.

You can disable the complete behavior in the appConfig.tsx file. However, if you want to add a new service, follow these steps:

Choose an existing group or add a new entry to the COOKIE_GROUPS:

web/lib/cookies/types.ts
export const COOKIE_GROUPS: CookieGroup[] = [
  // Existing groups
  {
    id: 'socialMedia',
    name: 'cookies.groups.socialMedia.name',
    description: 'cookies.groups.socialMedia.description',
    component: SocialMediaTracking, // Component for the service
  },
];

2. Create or modify the Component

Modify your chosen component in web/components/cookies/groups/ or create the new one.

web/components/cookies/groups/socialMediaTracking.tsx
'use client';

import { useEffect } from 'react';
import { appConfig } from '@/appConfig';
import { initSocialMediaService, SocialMediaService } from '@/lib/analytics/social-media';

export function SocialMediaTracking({ children }: { children?: React.ReactNode }) {
  useEffect(() => {
    if (appConfig.services.socialMedia) {
      initSocialMediaService(); // Initialize the service here
    }
  }, []);

  return (
  <>
    // and / or here
    <SocialMediaService />
    {children}
    </>
);
}

3. Implement the Service Logic

Create the service initialization and shutdown logic in web/lib/analytics/:

web/lib/analytics/social-media.tsx
'use client';

import { appConfig } from '@/appConfig';

export function initSocialMediaService() {
  // Initialize social media tracking service
}

export function SocialMediaService({ children }: ProviderProps) {
  if (appConfig.services.socialMedia) {
    return <SocialMediaProvider props={...}>{children}</SocialMediaProvider>;
  }
  return <>{children}</>;
}

4. Update appConfig

Include the new service in the services:

web/appConfig.tsx
export const appConfig: AppConfig = {
  // Other configurations
  services: {
    posthog: true,
    plausible: true,
    googleAnalytics: false,
    socialMedia: true,
  },
};

5. Set Environment Variables

Ensure that any necessary environment variables are set, such as API keys for the new service.