DES CAS D’USAGE D’IA À REPRENDRE.Édition française · Particuliers, indépendants, TPE
PostHog

Installation de PostHog dans une base de code

installing-posthog-in-a-codebase

En bref

Installez et configurez un SDK PostH Friday dans un dépôt que vous pouvez lire et modifier, en suivant les documents de PostHog pour le framework. Utiliser lorsqu'un utilisateur travaillant dans sa base de codes demande d'ajouter, d'installer ou de configurer PostHog, l'analyse de produit, le replay de session ou un SDK PostHog. Couvre trouver la bonne page de docs, installer le dernier paquet, obtenir le jeton de projet et l'hôte d'ingestion du projet-get, les garder dans le fichier env, configuration côté serveur, identifier les utilisateurs, et vérifier le changement. Si vous ne pouvez pas accéder au code de l'utilisateur, comme c'est le cas dans ChatGPT sur le web ou Claude sur le web, utilisez plutôt l'installation-posthog-from-chat.

Ce que ça fait

  • 1. Trouvez le cadre et lisez ses documents
  • 2. Installez le dernier SDK
  • 3. Obtenez le jeton et l'hôte

Pour qui, et un exemple

Personnes dont la tâche correspond : Installez et configurez un SDK PostHog dans un dépôt que vous pouvez lire et modifier, en suivant les documents de PostHog pour le framework.

Exemple de demande : « Installation de PostHog dans une base de code : Installez et configurez un SDK PostH Friday dans un dépôt que vous pouvez lire et modifier, en suivant les documents de PostHog pour le framework. »

Installez et configurez un SDK PostH Friday dans un dépôt que vous pouvez lire et modifier, en suivant les documents de PostHog pour le framework. Exemple rédigé par iadujour.fr à partir du SKILL.md, non testé.

Installer

Claude Code : /plugin marketplace add PostHog/skills, puis /plugin install posthog-all@posthog-skills (README).

/plugin marketplace add PostHog/skills
/plugin install posthog-all@posthog-skills

Fonctionne avec

  • Claude Code

Source : README : marketplace Claude Code `/plugin marketplace add PostHog/skills`. D’autres agents ne sont pas nommés.

Niveau : Avancé

S’adresse à un usage avancé (sécurité, production, architecture ou réglages fins) décrit dans le SKILL.md.

À savoir

Dépôt officiel PostHog (github.com/PostHog/skills). Skills pour l’analytique produit, les indicateurs de fonctionnalité, le suivi d’erreurs et les workflows d’équipe.

Extrait du SKILL.md

La description d’origine, celle que l’agent lit pour décider de charger la skill (en anglais) :

Install and configure a PostHog SDK in a repository you can read and edit, following PostHog's docs for the framework. Use when a user working in their codebase asks to add, install, or set up PostHog, product analytics, session replay, or […]

Citée depuis le SKILL.md au commit 445764b .

Le SKILL.md compte 98 lignes et 7 sections principales :

  • 1. Find the framework and read its docs
  • 2. Install the latest SDK
  • 3. Get the token and host
  • 4. Initialize as the docs show
  • 5. Identify users
  • 6. Verify
  • 7. Mention transactional emails if the app sends them

Licence : MIT

Consultée le 13 novembre 2026 : fichier de licence du dépôt.

La licence autorise la reprise : le texte intégral du SKILL.md est reproduit ci-dessous, sans modification, avec sa mention de licence.

Texte intégral du SKILL.md

Reproduit sans modification depuis PostHog/skills (commit 445764b) , © PostHog, sous licence MIT (fichier de licence d’origine ).

Afficher le SKILL.md original (98 lignes, en anglais)
---
name: installing-posthog-in-a-codebase
description: >-
  Install and configure a PostHog SDK in a repository you can read and edit, following PostHog's docs for
  the framework. Use when a user working in their codebase asks to add, install, or set up PostHog, product
  analytics, session replay, or a PostHog SDK. Covers finding the right docs page, installing the latest
  package, getting the project token and ingestion host from project-get, keeping them in the env file,
  server-side setup, identifying users, and verifying the change. If you can't access the user's code, as is
  common in ChatGPT on the web or Claude on the web, use installing-posthog-from-chat instead.
---

# Installing PostHog in a codebase

Use this skill when you can read and edit the user's code.
If you can't access their code, as is common in ChatGPT on the web or Claude on the web, use `installing-posthog-from-chat`.

PostHog's docs are the source of truth for each SDK's setup.
Init options, file locations and recommended settings change between SDK releases, so read the docs page for the framework before you write code, and follow it rather than what you remember.

## 1. Find the framework and read its docs

Detect the framework from the manifest files (`package.json`, `pyproject.toml`, `requirements.txt`, `Gemfile`, `composer.json`, `go.mod`, and so on) and the app's entry points.
A web app with its own backend usually needs a client SDK and a server SDK, so read both pages.

| Framework                      | Docs page                                            |
| ------------------------------ | ---------------------------------------------------- |
| JavaScript web (any framework) | https://posthog.com/docs/libraries/js.md             |
| React, including Vite apps     | https://posthog.com/docs/libraries/react.md          |
| Next.js                        | https://posthog.com/docs/libraries/next-js.md        |
| Vue.js                         | https://posthog.com/docs/libraries/vue-js.md         |
| Nuxt                           | https://posthog.com/docs/libraries/nuxt-js.md        |
| Svelte and SvelteKit           | https://posthog.com/docs/libraries/svelte.md         |
| Angular                        | https://posthog.com/docs/libraries/angular.md        |
| Astro                          | https://posthog.com/docs/libraries/astro.md          |
| Remix                          | https://posthog.com/docs/libraries/remix.md          |
| React Router                   | https://posthog.com/docs/libraries/react-router.md   |
| TanStack Start                 | https://posthog.com/docs/libraries/tanstack-start.md |
| Node.js, including Express     | https://posthog.com/docs/libraries/node.md           |
| Python, including FastAPI      | https://posthog.com/docs/libraries/python.md         |
| Django                         | https://posthog.com/docs/libraries/django.md         |
| Flask                          | https://posthog.com/docs/libraries/flask.md          |
| Ruby                           | https://posthog.com/docs/libraries/ruby.md           |
| Ruby on Rails                  | https://posthog.com/docs/libraries/ruby-on-rails.md  |
| PHP                            | https://posthog.com/docs/libraries/php.md            |
| Laravel                        | https://posthog.com/docs/libraries/laravel.md        |
| Go                             | https://posthog.com/docs/libraries/go.md             |
| Java                           | https://posthog.com/docs/libraries/java.md           |
| .NET                           | https://posthog.com/docs/libraries/dotnet.md         |
| Elixir                         | https://posthog.com/docs/libraries/elixir.md         |
| Rust                           | https://posthog.com/docs/libraries/rust.md           |
| React Native                   | https://posthog.com/docs/libraries/react-native.md   |
| Flutter                        | https://posthog.com/docs/libraries/flutter.md        |
| iOS                            | https://posthog.com/docs/libraries/ios.md            |
| Android                        | https://posthog.com/docs/libraries/android.md        |

For a framework that isn't listed, call `docs-search` with the framework name.

## 2. Install the latest SDK

Add each package with the project's own package manager and no version, for example `npm install posthog-js`, `pnpm add posthog-node`, `uv add posthog` or `bundle add posthog-ruby`.
That resolves the newest release.
Don't type a version into the manifest from memory, because that pins an old release.

In a monorepo, install into the package that runs the app, not the workspace root.

## 3. Get the token and host

Call `project-get` without an ID.
Use `api_token` as the project token and `api_host` as the SDK's host option.

- Read both from environment variables in code, using the names the docs page uses (for example `NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN` and `NEXT_PUBLIC_POSTHOG_HOST`).
- Write the real values to the env file the framework loads, such as `.env.local` or `.env`. If the project has an example env file, add the variable names there with empty values.
- Never hard-code the token or the host in source files, and never use them as fallback defaults in code.

## 4. Initialize as the docs show

- Initialize the SDK once, in the place the docs page names. Don't add a second initialization elsewhere.
- For `posthog-js`, set `defaults` to the date the docs page shows. It selects the newest set of recommended settings, so don't take a date from memory.
- For a backend SDK in a long-running server, create one client for the process, reuse it, and shut it down when the process exits. Don't create a client per request.
- In serverless or edge handlers (for example Next.js route handlers on Vercel, or AWS Lambda), the runtime can freeze as soon as the response is sent, so queued events are lost. Flush before the handler returns: await `flush()` on a reused client, or use the platform's `waitUntil`, as the docs page describes.
- For a server-rendered app (Django, Rails, Laravel and similar), add the server SDK as well as the browser snippet.

## 5. Identify users

If the app has login, call `identify` after login with a stable user ID from the auth system, such as the database ID, not an email address or display name.
Call `reset()` on logout.
Send server-side events with the same distinct ID, so client and server events land on the same person.

## 6. Verify

Run the project's build, type check or tests, and fix anything your change broke.
If you can run the app, load a page and check that events arrive with `read-data-schema` or `execute-sql`.
Tell the user which environment variables to add in their hosting provider before they deploy.

## 7. Mention transactional emails if the app sends them

If the manifest has an email sending package, such as `resend`, `@sendgrid/mail`, `postmark`, `mailgun.js`, `@aws-sdk/client-ses`, `@aws-sdk/client-sesv2`, `nodemailer`, `sendgrid`, or `boto3` code that calls SES, tell the user once, after setup, that PostHog can send those emails too. Use the `sending-transactional-emails` skill if they want to set it up.
Source. Fiche rédigée par iadujour.fr à partir de : Frontmatter, sections et corps du SKILL.md, README du dépôt. Consultée le 13 novembre 2026. PostHog/skills .
MÊME ÉDITEUR

Autres skills PostHog : Observabilité et supervision

Toute la catégorie
PostHogObservabilité et supervision

Ajouter le suivi des erreurs PostHog

instrument-error-tracking

Ajouter le suivi des erreurs PostHog pour capturer et surveiller les exceptions.

Outils : Claude CodeNiveau : Avancémàj 12/11/2026
PostHogObservabilité et supervision

Ajouter PostHog AI Observability

instrument-llm-analytics

Ajouter PostHog AI Observability pour suivre l'utilisation du modèle AI.

Outils : Claude CodeNiveau : Avancémàj 12/11/2026
PostHogObservabilité et supervision

Ajouter une capture de journal PostHog

instrument-logs

Ajouter la capture de journal PostHog pour suivre les journaux d'application.

Outils : Claude CodeNiveau : Intermédiairemàj 12/11/2026
ÉCHANGES

Commentaires.

Un retour d’expérience, une question, une précision sur cette skill ? Les commentaires sont relus avant publication.

Commentaires publiés

Chargement des commentaires…

    Laisser un commentaire

    Charte de modération. Chaque commentaire est relu avant publication. Sont refusés : l’incitation à la haine, les propos injurieux ou discriminatoires, la publicité, le spam et les liens promotionnels, le hors-sujet et les données personnelles d’autrui.