imbi-plugin-posthog 2.60.0__py3-none-any.whl

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,11 @@
1
+ """Imbi PostHog plugin: receive PostHog webhook deliveries."""
2
+
3
+ from importlib import metadata
4
+
5
+ from imbi.plugins.posthog.plugin import PostHogPlugin, PostHogWebhookActions
6
+
7
+ #: Discovered by the imbi-common registry's convention scan.
8
+ PLUGIN = PostHogPlugin
9
+
10
+ version = metadata.version('imbi-plugin-posthog')
11
+ __all__ = ['PLUGIN', 'PostHogPlugin', 'PostHogWebhookActions', 'version']
@@ -0,0 +1,76 @@
1
+ """The PostHog plugin (Plugin Architecture v3).
2
+
3
+ A PostHog *webhook destination* posts one request for each event that
4
+ passes its filters. The destination's body template is::
5
+
6
+ {"event": "{event}", "person": "{person}"}
7
+
8
+ so a delivery is ``{"event": {...}, "person": {...}}``, where ``event``
9
+ carries ``uuid``, ``event``, ``distinct_id``, ``properties``,
10
+ ``timestamp``, and ``url``, and ``person`` carries ``id``, ``name``,
11
+ ``url``, and ``properties``.
12
+
13
+ The gateway's built-in event recording captures each delivery, driven by
14
+ the Webhook's selectors (identifier, event type, user subject), so this
15
+ plugin declares an empty action catalog. It exists so a PostHog webhook
16
+ can be bound to an Integration and its deliveries verified: PostHog
17
+ signs each request per the `Standard Webhooks
18
+ <https://www.standardwebhooks.com/>`_ specification, keyed by the
19
+ ``Webhook.secret``.
20
+ """
21
+
22
+ from imbi.common import plugins
23
+ from imbi.common.plugins.base import WebhookSignature
24
+
25
+ #: The Standard Webhooks signature header, lower case.
26
+ SIGNATURE_HEADER = 'webhook-signature'
27
+ #: The prefix of each symmetric (HMAC-SHA256) Standard Webhooks token.
28
+ SIGNATURE_PREFIX = 'v1,'
29
+
30
+
31
+ class PostHogWebhookActions(plugins.WebhookActionsCapability):
32
+ """Webhook-actions capability for PostHog; it has no actions."""
33
+
34
+ @classmethod
35
+ def actions(cls) -> list[plugins.ActionDescriptor]:
36
+ return []
37
+
38
+ @classmethod
39
+ def signature(cls) -> WebhookSignature:
40
+ # Standard Webhooks: base64 HMAC-SHA256 of
41
+ # ``<webhook-id>.<webhook-timestamp>.<body>``, keyed by the
42
+ # ``whsec_`` secret the destination shows, stored as the
43
+ # Webhook.secret.
44
+ return WebhookSignature(
45
+ header=SIGNATURE_HEADER,
46
+ prefix=SIGNATURE_PREFIX,
47
+ secret='webhook',
48
+ scheme='standard-webhooks',
49
+ )
50
+
51
+
52
+ class PostHogPlugin(plugins.Plugin):
53
+ """PostHog Integration: receive webhook deliveries."""
54
+
55
+ manifest = plugins.PluginManifest(
56
+ slug='posthog',
57
+ name='PostHog',
58
+ icon='si-posthog',
59
+ description=(
60
+ 'Receive PostHog webhook destination deliveries, verify their '
61
+ 'signature, and record each event against its project.'
62
+ ),
63
+ auth_type='none',
64
+ capabilities=[
65
+ plugins.Capability(
66
+ kind='webhook-actions',
67
+ label='Webhook actions',
68
+ description=(
69
+ 'Receives PostHog webhook deliveries. The gateway '
70
+ 'records each as an event; the capability advertises '
71
+ 'no actions.'
72
+ ),
73
+ handler=PostHogWebhookActions,
74
+ )
75
+ ],
76
+ )
File without changes
@@ -0,0 +1,102 @@
1
+ Metadata-Version: 2.5
2
+ Name: imbi-plugin-posthog
3
+ Version: 2.60.0
4
+ Summary: PostHog webhook plugin for Imbi
5
+ Author-email: Dave Shawley <daves@aweber.com>
6
+ License-Expression: BSD-3-Clause
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Natural Language :: English
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Requires-Python: >=3.14
14
+ Requires-Dist: imbi-common==2.60.0
15
+ Requires-Dist: pydantic>=2
16
+ Description-Content-Type: text/markdown
17
+
18
+ # imbi-plugin-posthog
19
+
20
+ The PostHog plugin for the [Imbi](https://github.com/AWeber-Imbi)
21
+ platform, distributed as a single Python package (`imbi.plugins.posthog`)
22
+ exposing one Integration (`posthog`) with one capability:
23
+
24
+ - **`webhook-actions`** — receives deliveries from a PostHog webhook
25
+ destination. imbi-gateway verifies the signature, finds the project,
26
+ and records each delivery as an event. The capability advertises no
27
+ custom actions.
28
+
29
+ The Imbi host discovers the package by scanning `imbi.plugins.*` and
30
+ reads the module-level `PLUGIN` attribute; there are no entry points.
31
+ All plugin base classes come from `imbi.common.plugins`.
32
+
33
+ ## The delivery
34
+
35
+ Configure the PostHog webhook destination with this JSON body:
36
+
37
+ ```json
38
+ {
39
+ "event": "{event}",
40
+ "person": "{person}"
41
+ }
42
+ ```
43
+
44
+ PostHog expands `{event}` and `{person}` to objects, so a delivery is:
45
+
46
+ ```json
47
+ {
48
+ "event": {
49
+ "uuid": "...",
50
+ "event": "$pageview",
51
+ "distinct_id": "...",
52
+ "properties": {},
53
+ "timestamp": "...",
54
+ "url": "https://us.posthog.com/project/1/events/..."
55
+ },
56
+ "person": {
57
+ "id": "...",
58
+ "name": "...",
59
+ "url": "https://us.posthog.com/project/1/person/...",
60
+ "properties": {}
61
+ }
62
+ }
63
+ ```
64
+
65
+ ## Signature
66
+
67
+ PostHog signs each request per the
68
+ [Standard Webhooks](https://www.standardwebhooks.com/) specification. The
69
+ destination sends three headers:
70
+
71
+ | Header | Value |
72
+ |---|---|
73
+ | `Webhook-Id` | The unique id of the message |
74
+ | `Webhook-Timestamp` | The send time, as integer seconds since the epoch |
75
+ | `Webhook-Signature` | Space-separated `v1,<base64>` tokens |
76
+
77
+ Each token is the base64 HMAC-SHA256 of
78
+ `<webhook-id>.<webhook-timestamp>.<body>`, keyed by the signing secret.
79
+ PostHog signs only when the destination's **Signing secret** is set, so
80
+ generate a Standard Webhooks key (a base64 string, optionally prefixed
81
+ with `whsec_`), enter it as the **Signing secret** of the PostHog
82
+ destination with **Signature format** set to **Standard Webhooks**, and
83
+ put the same key in the **Secret** field of the Imbi webhook. The
84
+ gateway drops a delivery whose signature is missing or does not match,
85
+ and a delivery whose timestamp is more than five minutes from the
86
+ gateway clock.
87
+ The header name and prefix are the `SIGNATURE_HEADER` and
88
+ `SIGNATURE_PREFIX` constants in `imbi.plugins.posthog.plugin`.
89
+
90
+ ## Development
91
+
92
+ ```bash
93
+ moon run root:setup # uv sync + pre-commit hooks
94
+ moon run posthog:test # coverage (fails under 85%)
95
+ moon run posthog:lint posthog:typecheck posthog:format # ruff + basedpyright + format check
96
+ ```
97
+
98
+ The plugin needs no credentials (`auth_type='none'`): it only receives.
99
+
100
+ ## License
101
+
102
+ BSD-3-Clause.
@@ -0,0 +1,6 @@
1
+ imbi/plugins/posthog/__init__.py,sha256=6xoPxlL7TpKO0HyB7a8vGkRaLif_IzRHsDGafBrmmbA,383
2
+ imbi/plugins/posthog/plugin.py,sha256=GfCfz2P6w1loIbWYWqmAUtL0_0aCOlGCjSbQ2nZTisQ,2702
3
+ imbi/plugins/posthog/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ imbi_plugin_posthog-2.60.0.dist-info/METADATA,sha256=iHYt_XsBflq3CmofKaiyTyPFap9mE8dk87LDcm0iqtQ,3227
5
+ imbi_plugin_posthog-2.60.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
6
+ imbi_plugin_posthog-2.60.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any