PHP SDK
Consent
The default is off, and off means nothing leaves the site — not registration, not a snapshot, not an event. The SDK has no opinion about how you ask; it owns the decision and its provenance.
// The owner ticked your unticked-by-default checkbox:
$insights->consent()->grant('1');
// Is telemetry currently on?
$insights->consent()->isGranted();
// What they accepted, and when (ISO-8601 UTC), or null:
$insights->consent()->version();
$insights->consent()->acceptedAt();
Turning it off goes through the facade, not Consent directly, so the held event queue is emptied and the recorded onboarding steps are deleted too:
$insights->revokeConsent();
Spec 9.3 replaces the automatic “consent revoked” event with an unticked checkbox inside your own revocation UI — “Also let Plugie know you stopped (sends only your install ID)” — so that switching telemetry off can never itself cause a network request. If the owner ticks it:
$insights->revokeConsent(true); // sends consent_revoked FIRST, then closes the gate
Renewal
When you change what you collect, raise consent_version in init(). The SDK does not go silent — it keeps sending everything except inventory, which it holds back until the owner accepts the new version, and that includes anything it collects that the old notice may not name, such as onboarding steps — but reports that the owner should be asked again:
if ($insights->needsConsentRenewal()) {
// show the notice again; on acceptance:
$insights->consent()->grant('2');
}
This is true when your consent_version differs from the accepted one or when the server has answered that a newer version is required (requiredConsentVersion() tells you which). Comparison is by equality, never ordering — a version is a free string and 'initial' → 'expanded' is a valid scheme. A site that has never granted consent answers false: it is asked, not asked again.
Share plugin and theme inventory
Off by default (SDK-10). Turning it on lets your dashboard’s Ecosystem screen show which other plugins, and which themes, run on your users’ sites:
Insights::init([
// ...your existing options...
'plugin_file' => __FILE__, // required for the plugin list: it is how your own plugin is left out
'consent_version' => '3', // raised in the SAME release
'inventory' => ['plugins' => true, 'theme' => true],
]);
What is sent: slugs only, no versions. plugins.active and plugins.inactive are the folder names of the other plugins, and theme.slug is the parent theme (get_template()), not a child theme.
Your consent notice must name it. Add a sentence for each half you turn on:
- “the slugs (short names) of the other plugins installed on this site, and whether each is active”
- “the slug of this site’s theme (its parent theme, when a child theme is active)”
Then raise consent_version. A site whose owner accepted an older version keeps sending everything else, and no inventory, until they accept the new notice. The server holds to the same rule: a snapshot whose consent version is not the one your plugin currently requires is stored without plugins or theme. needsConsentRenewal() tells you when to ask. The preview (preview()) shows inventory to an owner who has not decided yet, because that is what opting in would send. It does not show inventory to an owner whose accepted version is behind — the owner you are asking to renew — because nothing sends it until they accept. In a renewal dialog, show your new notice’s text naming the inventory rather than relying on preview().
Without plugin_file the plugin list is never sent, and errors() says why. The theme half does not need it.