Skip to Content
ReferenceSDK Reference

SDK Reference

A quick lookup of the real public API, for developers who already understand the concepts. All examples assume $sdk is the object returned by Sdk::bootstrap().

Entry point: \Appneck\Sdk\Sdk (static)

Sdk::bootstrap( $api_key, $product_secret, $base_url, $plugin_file, ... )

The main entry point. Builds the signed client, wires all automatic hooks (activation, deactivation, heartbeat cron, consent, deactivation survey, announcement dismissal), and returns a Plugin object you keep.

$sdk = \Appneck\Sdk\Sdk::bootstrap( 'pk_your_product_key', 'sk_your_product_secret', 'https://appneck.com', __FILE__ );

Optional trailing arguments ($credentials, $transport, $logger, $queue) let you inject custom implementations — advanced, rarely needed.

Sdk::uninstall( $api_key, $product_secret, $base_url, ... )

For use inside uninstall.php only. Handles uninstall-time cleanup.

Sdk::client( $api_key, $product_secret, $base_url, ... )

Returns a low-level signed client without any lifecycle hooks. Use only if you need raw API access and are managing the lifecycle yourself.

Sdk::loaded_version()

Returns the version string of whichever bundled SDK copy actually won the loader race.

The Plugin object (what bootstrap() returns)

$sdk->track( $event_name, array $data = [] )

Queues a custom event locally (no immediate network call).

$sdk->track_error( $message, array $context = [] )

Queues an error event locally.

$sdk->flush()

Forces an immediate send of the queued events (this does call the API).

$sdk->is_registered(): bool

True once this site has enrolled with Appneck.

$sdk->may_contact_appneck(): bool

Whether the SDK may contact Appneck right now: always for a pro build ('is_premium' => true), and for a free build only once the site owner has clicked Allow & Continue. Every SDK request already obeys this.

$sdk->is_premium(): bool

Whether this build was bootstrapped with 'is_premium' => true.

Returns a read-only consent decision object:

MethodReturns
is_accepted()bool
is_rejected()bool
is_pending()bool (no decision yet)
status()raw status
decided_at()when decided
is_sync_pending()decided locally, not yet synced

The update-email decision: is_opted_in(), email(), name() (the admin who clicked Allow & Continue) and wording() (the exact text they agreed to).

The “change your mind” consent UI control: render_settings_section() draws two switches, Share usage data and Receive update emails. Also set_icon_url() for the opt-in card. Chainable:

$sdk->consent_notice() ->set_privacy_policy_url( 'https://example.com/privacy' ) ->render_settings_section();

$sdk->deactivation_survey()

The deactivation survey (auto-wired). You’d usually only call ->set_product_name( '...' ) on it if auto-detection of your product name fails.

$sdk->announcements()

Returns the raw announcements collection for custom rendering:

foreach ( $sdk->announcements()->visible() as $a ) { // render $a yourself }

$sdk->announcement_notices()

Returns the announcement notice renderer. Auto-rendered by bootstrap() via render_globally() — announcements already print on every wp-admin page, kept fresh in the background, with no code required. Call one of these only if you want the narrower, original behaviour instead (don’t call them in addition to the automatic default — that prints announcements twice on whichever screen they target):

  • render_on_screen( $screen_id ) — render on one specific admin screen only, no background refresh
  • render() — render here (call from your own admin callback), no background refresh

Escape hatches

$sdk->client(), $sdk->lifecycle(), $sdk->telemetry() expose the underlying objects for advanced use.

Filters (the only outward extension points)

There are exactly three filters and no outward do_action() hooks:

FilterPurpose
appneck_sdk_flush_intervalAdjust how often the event queue flushes
appneck_sdk_privacy_policy_versionSet your current privacy policy version
appneck_sdk_reprompt_on_policy_changeRe-ask consent when the policy version changes

Documented limitations (from the SDK itself)

  • PHP version not enforced at runtime despite the 7.2+ requirement.
  • Credential loss outside the short reclaim window needs an Appneck operator to resolve.
  • Deactivation survey relies on a JS/DOM intercept of the Plugins screen with no browser-test coverage — may break on major WP core changes.
  • Multisite network-wide deactivation is a known gap.

Requests under the hood (informational)

Every request the SDK sends is signed and includes headers identifying the Product, the installation, a timestamp (replay protection), and an HMAC signature. You never construct these yourself — this is only useful when debugging network traffic directly.