Search by

mirafive / sdk-php

yk-sgr

MIRA FIVE server SDK for PHP: consent-aware events, revenue and touchpoints for revenue attribution

Package info

github.com/mirafive/sdk-php

Homepage

pkg:composer/mirafive/sdk-php

Statistics

Installs: 314

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

v2.3.1 2026-11-30 14:57 UTC

This package is auto-updated.

Last update: 2026-11-30 14:58:45 UTC


README

The server SDK of MIRA FIVE, revenue attribution and analytics by Cloo GmbH, compliant with GDPR and TDDDG. Send what only your server knows (a paid invoice, a plan change, a survey answer), revenue for the ledger, and backfills. The events join the browser's events on the MIRA server, where sessions, identity and attribution happen.

  • PHP 8.3 or newer. No required Composer dependencies; cURL is used when present, PHP streams otherwise, or your own PSR-18 client.
  • Consent-aware: every event says which consent it was collected under, and MIRA keeps what that consent tier allows.
  • Never throws from the event methods: problems go to onError or your PSR-3 logger.
  • Same wire format and semantics as the Node SDK (@mirafive/node), including eventIdFor(), so a conversion reported by PHP and by Node counts once.

Laravel or Symfony? Use mirafive/sdk-laravel or mirafive/sdk-symfony: they configure this client, flush after the response, add queues, the script tag and test fakes.

Install

composer require mirafive/sdk-php

Set the project's secret key (MIRA FIVE dashboard, Settings, Sources):

MIRAFIVE_SECRET_KEY=mira_sk_…

Quickstart

<?php

use MiraFive\Consent;
use MiraFive\Mira;

// Reads MIRAFIVE_SECRET_KEY and MIRAFIVE_HOST. Keep one client per request or process.
$mira = new Mira();

// Who the user is. PII traits (email, name, phone) are encrypted at rest by MIRA.
$mira->identify(
    userId: 'user_42',
    traits: ['email' => 'ada@example.com', 'plan' => 'pro'],
    externalIds: ['stripe_customer' => 'cus_123'], // so the Stripe connector links its money to this user
);

// Something the user did, with the consent your banner recorded.
$mira->track(
    event: 'report_exported',
    userId: 'user_42',
    properties: ['format' => 'csv'],
    consent: Consent::analyticsOnly(),
    context: ['ip' => $_SERVER['REMOTE_ADDR'] ?? null, 'userAgent' => $_SERVER['HTTP_USER_AGENT'] ?? null],
);

// Money, in integer minor units: 4900 is 49.00 EUR.
$mira->revenue(
    amount: 4900,
    currency: 'EUR',
    userId: 'user_42',
    entryId: 'stripe:in_123',                      // the same money from the Stripe connector counts once
    eventId: Mira::eventIdFor('order:123:paid'),   // a retried job counts once
);

// Events leave in batches when 100 are waiting, on flush(), and when the request ends.

That is all a plain PHP app needs: the client flushes in a shutdown function when the script ends. Under PHP-FPM, call fastcgi_finish_request() before that if the visitor should not wait for it (the flush never takes longer than flushDeadlineMs), or hand batches to a queue. In a long-running process (a worker, a daemon), call $mira->flush() after each unit of work and $mira->shutdown() before the process exits.

Environment

Variable Default Meaning
MIRAFIVE_SECRET_KEY (required to send) The project's secret key, mira_sk_…. Server only, never in a page
MIRAFIVE_HOST https://events.mirafive.io The ingest origin, for a self-hosted MIRA FIVE or a local one
MIRAFIVE_PUBLIC_KEY (none) The public key, mira_pk_…, for the browser script tag (ScriptTag)

Constructor arguments win over the environment. A public key (mira_pk_…) in place of the secret key is refused like a missing one: the client reports it once and sends nothing, and hands nothing to a queue either, as every MIRA FIVE server SDK does. Public keys belong in browsers. A host that is not an origin (https://events.mirafive.io/v1) is reported the same way; the constructor never throws, and checkConnection(), deliverPrepared() and deletePerson() throw that MiraError.

API reference

All methods take named arguments; the examples use them. Every event method also takes these common arguments:

Argument Type Meaning
userId ?string Your own id for the person. Never an email address
anonymousId ?string The browser's anonymous id, when you have it
eventId ?string A UUID; set it to report one fact from several places only once (see eventIdFor). Default: a UUIDv7
timestamp DateTimeInterface|int|string|null When it happened: a date, epoch milliseconds or an ISO 8601 string. Past dates are fine (backfills)
consent Consent|'not_applicable'|array|null The consent the event was collected under. Default not_applicable; see Consent tiers
context ?array What you know about the end user's request; see Context

new Mira(...)

Argument Default Meaning
secretKey MIRAFIVE_SECRET_KEY The project's secret key
host MIRAFIVE_HOST, else the cloud The ingest origin, https://… or http://…; anything else is reported and nothing is sent
flushAt 100 Send as soon as this many events are waiting (1 to 100, the ingest's batch limit)
timeoutMs 3000 Per request
connectTimeoutMs 1000 Per connection (cURL)
flushDeadlineMs 3000 What one flush may spend on attempts and waits together, so an outage cannot hold up your request
maxRetries 2 Retries per batch on network errors, timeouts, 408, 429 and 5xx
maxRetryAfterMs 3000 A longer Retry-After is not waited for; the batch is reported instead
onError null callable(MiraError): void; receives every problem
logger null A PSR-3 logger, used when there is no onError; else error_log()
cache null A PSR-16 cache that shares the delivery breaker between PHP-FPM workers
transport cURL, else streams Http\Psr18Transport wraps your PSR-18 client; Testing\RecordingTransport records
enabled true false: input is still checked, but nothing leaves the process and no key is needed
flushOnShutdown true false when your framework flushes after the response
handOff null Closure(string $payload): void; receives each batch instead of sending it (see Queues)
clock null A PSR-20 clock for default event times and sent_at

track(event, properties: [], …)

A custom event. Names starting with $ are reserved for MIRA; a name has at most 120 characters and no control characters. userId and anonymousId (and groupId) have at most 200 characters: a longer one is reported and the event dropped, never cut, since a shorter id is someone else's.

$mira->track(event: 'plan_changed', userId: 'user_42', properties: ['from' => 'basic', 'to' => 'pro']);

Properties are cleaned as every MIRA FIVE SDK cleans them: nested arrays and objects become dot keys (['plan' => ['name' => 'pro']] is plan.name) up to three levels, lists keep up to 50 scalars, strings are cut at 2048 characters and keys at 100, at most 64 properties are kept, and dates become ISO strings. Empty properties are sent as {}.

identify(userId, traits: [], externalIds: [], …)

Who the user is. PII traits (email, name, phone, address, …) are encrypted at rest; every other trait stays queryable.

externalIds are the person's ids in other systems, so connectors can link their money to this user: stripe_customer, revenuecat_app_user, shopify_customer, shopware_customer. Ids in systems of your own (a CRM, another billing provider) go in as custom: and a lowercase slug of up to 40 characters, at most 10 per event: ['custom:hubspot' => '123']. An unknown or malformed type is reported and dropped; an id over 200 characters is reported and dropped, never cut short.

group(groupId, userId: null, traits: [], …)

The company or account a user belongs to (B2B), with its traits: name, size, plan.

$mira->group(groupId: 'acme', userId: 'user_42', traits: ['name' => 'Acme GmbH', 'seats' => 12]);

revenue(amount, currency, …)

Money, as $revenue. Every call becomes one entry in the project's revenue ledger, keyed by entryId: sent twice, it counts once. Only secret keys may send revenue.

Argument Meaning
amount What the customer paid, VAT included, in integer minor units: cents for EUR and USD, yen for JPY. 1999 is 19.99 EUR. Negative for refunds
currency ISO 4217, for example EUR
entryId The provider object this money belongs to (stripe:in_123, crm:case-81)
entryKind charge (one-time, the default), subscription_payment (the default with subscription), refund (the default for a negative amount), dispute, dispute_won
refundOf For a refund or dispute: the entryId of the money it takes back
product The product or plan, for example premium_monthly
subscription ['id' => …, 'interval' => 'day'|'week'|'month'|'year', 'intervalCount' => 1..36, 'periodStart' => …, 'periodEnd' => …]
tax Order detail: the tax (VAT) included in amount, in minor units, 0 or more. amount stays what the customer paid
shipping Order detail: the shipping included in amount, in minor units, 0 or more
discount Order detail: the discount already taken off amount, in minor units, 0 or more
items Order detail: up to 100 lines, ['product' => 'SKU-1', 'variant' => 'L', 'quantity' => 2, 'price' => 2000]; price is one unit, tax included, before the discount
properties Your own properties
// A subscription payment (the first one and every renewal).
$mira->revenue(
    amount: 999,
    currency: 'EUR',
    userId: 'user_42',
    entryId: 'revenuecat:txn_1000000123',
    product: 'premium_monthly',
    subscription: ['id' => 'sub_42', 'interval' => 'month'], // pays from now for one month
);

// Quarterly billing, with an explicit period.
$mira->revenue(
    amount: 2700,
    currency: 'EUR',
    userId: 'user_42',
    entryId: 'stripe:in_456',
    subscription: [
        'id' => 'sub_43',
        'interval' => 'month',
        'intervalCount' => 3,
        'periodStart' => '2026-11-01T00:00:00Z',
        'periodEnd' => '2027-02-01T00:00:00Z',
    ],
);

// A refund takes the money back, and the credit of the channels that earned it.
$mira->revenue(
    amount: -999,
    currency: 'EUR',
    userId: 'user_42',
    entryKind: 'refund',
    entryId: 'revenuecat:txn_1000000123:refund',
    refundOf: 'revenuecat:txn_1000000123',
);

MRR comes from subscription payments and the period each pays for. A subscription payment inherits the attribution of the person's acquisition (their first conversion, sign-up, trial or first purchase, set per project), a refund that of the money it takes back.

A float amount is accepted only when it is a whole number (1999.0); 19.99 is reported and the event is dropped, because money is never rounded silently. Amounts go up to 10^15 either way. Order details are stored with the ledger entry; a broken one (a negative tax, a line without a product) is reported and the order details are dropped, while the money is still sent.

// A shop order: 54.90 EUR paid, of which 8.77 tax and 4.90 shipping.
$mira->revenue(
    amount: 5490,
    currency: 'EUR',
    userId: 'user_42',
    entryId: 'shop:order:1001',
    tax: 877,
    shipping: 490,
    items: [['product' => 'SKU-1', 'quantity' => 2, 'price' => 2500]],
);

touchpoint(kind, …)

A touchpoint that is not a visit, as $touchpoint: the answer to "How did you hear about us?", a trade fair contact, a redeemed code. The attribution models credit it like a visit. It needs a userId or an anonymousId, and a channel or a source. The fields are trimmed and cut to 200 characters (answer to 500), and always fit: your own properties make room for them within the 64.

Argument Meaning
kind survey, offline, code or custom
channel One of MIRA's channels (Mira::TOUCHPOINT_CHANNELS): paid_search, paid_social, affiliate, video, email, referral, …
source, medium, campaign Without a channel, these decide it like the UTMs of a link, the project's channel rules included
content The ad or creative, as utm_content names it for a visit
campaignId, adGroupId, adId Ids from the ad platform
code The discount or partner code
answer The survey answer as the person gave it. It passes MIRA's PII guard
externalRef Your record, such as a CRM contact (hubspot:123)
// "How did you hear about us?"
$mira->touchpoint(
    kind: 'survey',
    userId: 'user_42',
    source: 'podcast',
    answer: 'The Elternzeit podcast',
    eventId: Mira::eventIdFor('survey:response_77'), // a re-sent answer counts once
);

// A trade fair contact from your CRM.
$mira->touchpoint(kind: 'offline', userId: 'user_42', channel: 'referral', source: 'trade_fair_2026', externalRef: 'hubspot:123');

// A redeemed partner code.
$mira->touchpoint(kind: 'code', userId: 'user_42', channel: 'affiliate', source: 'partner_x', code: 'PARTNER20');

retract(eventId, reason: null)

Withdraws an event you sent before, as $retract: a lead your CRM deleted or marked as spam. Every report then reads as if the event was never sent. Give the event an eventId of your own when you send it, so you can name it later. reason is duplicate, spam, test or other.

$mira->retract(Mira::eventIdFor('lead:81'), 'spam');

with(userId: null, anonymousId: null, consent: null, context: null)

A client that fills in these values for every event; the call's own values win, and context is merged. It shares the buffer with the client it came from. Use it per request or per user:

$request = $mira->with(
    userId: (string) $user->id,
    consent: ['analytics' => $banner->analytics, 'marketing' => $banner->marketing],
    context: ['ip' => $_SERVER['REMOTE_ADDR'], 'userAgent' => $_SERVER['HTTP_USER_AGENT']],
);
$request->track(event: 'report_exported');

Mira::eventIdFor(string $key): string

A stable event id from your own key, such as order:123:paid. The same key always gives the same UUID, in PHP, Node and every other MIRA FIVE SDK (a UUIDv8 from the first 122 bits of SHA-256). A retried job, a backfill run twice, or the browser and the server reporting one conversion all count once.

flush(), shutdown()

flush() sends everything that is waiting, within flushDeadlineMs, and never throws. shutdown() flushes and refuses new events (reported as …: the client was shut down).

deliverPrepared(string $payload): BatchResult

Sends a batch that a handOff received, in a queue worker. See Queues.

checkConnection(): string

Proves that the secret key and host work, without sending an event: it asks the ingest's GET /v1/check, which stores and counts nothing. Returns the key's kind (secret). Throws a MiraError when the host cannot be reached or refuses the key.

deletePerson(string $userId): PersonErasure

Erases one person (GDPR Art. 17) with the same effect as the dashboard's People page: events, devices, traits, ids in other systems and touchpoints. Revenue stays in the totals, without the person. $userId is the id you send in events, exactly (never trimmed; an id over 200 characters is refused, not cut).

$proof = $mira->deletePerson('user_42');
$proof->requestId;  // the deletion request, listed in the project's privacy log
$proof->deleted;    // ['events' => 12, 'person_traits' => 3, …]
$proof->revenueKept;

Unlike the event methods it is synchronous and throws a MiraError instead of reporting: retryable is true for a busy or unreachable ingest (429, 5xx, network; it retries twice itself) and false for a wrong or public key (reason unknown_key, secret_key_required) or a bad id. It is idempotent: a person nothing is stored about, or one already erased, returns zero rows, so call it again after any failure, for example from a queued job. Events that name the person afterwards are refused for 30 days (onError reports them as rejected, reason erased): stop sending them from your side. Needs the secret key.

MiraError

What onError receives, a RuntimeException:

Property Meaning
status The HTTP status when the ingest answered (202 for rejected events), else null
eventIds The event_ids that were not delivered
retryable A network error, a timeout, 408, 429 or 5xx: trying later may work
retryAfterMs The ingest's Retry-After, in milliseconds
reason The ingest's error code: unknown_key, invalid_batch, rate_limited, …; config for a setup problem on your side (a bad host, a public key, a script tag option)

ScriptTag::render(publicKey, …)

The browser script tag, exactly as the dashboard shows it: a stub that queues calls made before the SDK has loaded, then the SDK from its current major version (https://cdn.mirafive.io/sdk/v2/mira.js, or {host}/sdk/v2/mira.js for another host), which gets fixes but never a breaking release. It never throws into the page: a secret key, an unknown option or a host that is not an origin prints nothing and goes to onError (else error_log()) as a MiraError with the reason config, so a misconfigured key never reaches a page and a typo never breaks one.

echo MiraFive\ScriptTag::render(
    publicKey: getenv('MIRAFIVE_PUBLIC_KEY') ?: '',
    consent: 'auto',                    // or granted, denied, analytics (analytics yes, marketing no), shopify
    autocapture: ['forms' => false],    // or false for none; parts: spa, engagement, outbound, downloads, forms
    nonce: $cspNonce,                   // optional
    onError: fn (MiraFive\MiraError $error) => $logger->error($error->getMessage()),
);

To pin one release, take its URL and integrity hash from the dashboard ("Pin this version") and pass both: src: 'https://cdn.mirafive.io/sdk/mira@2.5.0.js', integrity: 'sha384-…'. The tag then carries integrity and crossorigin, and the browser runs only those exact bytes. integrity without such a src is refused, since the moving URL serves new bytes with every release. consent: 'shopify' is for a Shopify storefront: the SDK follows Shopify's consent.

Context

Key Meaning
ip The end user's IP, for geo. Used at ingest and never stored
userAgent The end user's user agent, for the device
page ['url' => …, 'referrer' => …, 'title' => …]
app Your app's name, version, build and namespace, for events from an app backend
locale The end user's locale, de-DE
timezone The end user's IANA time zone, Europe/Berlin
location ['latitude' => …, 'longitude' => …]: only one your app already has, and only with analytics consent. MIRA rounds it to 2 decimals (about 1 km). An invalid location is dropped and reported; the event still goes out

Strings are cut to the ingest's limits (URLs 4096 characters, the user agent 1024, the locale 35, the time zone 64); an IP address over 45 characters is dropped and reported, since a cut one would be someone else's.

Consent tiers

Server events default to not_applicable: a paid invoice is a fact of your business, not something a visitor did. For events that describe what a visitor did, pass what your consent banner recorded: Consent::granted(), Consent::analyticsOnly(), Consent::denied(), Consent::of(analytics: true, marketing: false), or an array such as ['analytics' => true, 'marketing' => false] (booleans or granted, denied, unknown).

consent on the event Tier What MIRA keeps
not_applicable (default), no userId T1 The event, anonymous_id if given, geo from context.ip (the IP is discarded)
not_applicable with userId T2 Plus user_id, traits (PII traits encrypted at rest), revenue per person
{ analytics: 'granted' } T1 / T2 As above
{ analytics: 'granted', marketing: 'granted' } T3 Plus click ids, and later forwarding to ad platforms
{ analytics: 'denied' | 'unknown' } T0 No user_id, anonymous_id or session_id: the event counts, but is not linked to a person

Delivery

  • Batches: at most 100 events and about 500 kB per request to POST {host}/v1/batch, one batch at a time, so their order is kept.
  • Retries: network errors, timeouts, 408, 429 and 5xx are retried with exponential backoff and full jitter, never sooner than Retry-After, always with the same event ids. Other 4xx answers are final and reported.
  • Sequence numbers: every batch carries a random stream id per client and a seq from 1 (a retry keeps its number), so MIRA can count batches that never arrived.
  • Outages: a flush never takes longer than flushDeadlineMs. After a batch failed for good, the client skips the network for 30 s and reports the dropped events once, so an outage of the ingest cannot slow down every request. Pass a PSR-16 cache to share this between PHP-FPM workers.
  • Rejected events: the ingest validates each event on its own. A rejected event is reported with its id and reason; the rest of the batch is stored.

Queues

To keep the request free of network calls, hand batches to your queue and send them from a worker:

// In the web request: each batch payload goes to your queue. It carries no key.
$mira = new Mira(handOff: function (string $payload) use ($queue): void {
    $queue->push('mirafive', $payload);
});

// In the worker: send it with the worker's own key and the usual retries.
try {
    $mira->deliverPrepared($payload);
} catch (MiraFive\MiraError $error) {
    if ($error->retryable) {
        throw $error; // let the queue try again later: the same events and seq, counted once
    }
    $logger->warning($error->getMessage()); // final: the ingest refused the batch
}

sent_at is set when the worker sends, so a batch that waited in the queue keeps its events' times.

Testing

MiraFive\Testing\MiraFake is a real client on a recording transport. Input is checked exactly as in production, so an event the ingest would refuse fails the test the same way.

use MiraFive\Testing\MiraFake;

$fake = MiraFake::create();
(new Checkout($fake->mira))->complete($order);

$fake->assertRevenue(fn (array $event) => $event['revenue']['amount'] === 4900);
$fake->assertTracked('checkout_completed', 1);           // exactly once
$fake->assertIdentified('user_42');
$fake->assertTouchpoint(fn (array $event) => $event['properties']['source'] === 'podcast');
$fake->assertNotTracked('checkout_failed');
$fake->assertNoErrors();                                   // nothing was refused or dropped

Also: assertGrouped(), assertNothingTracked(), events(?name), errors(), clear(), and $fake->transport->answerNext(new MiraFive\Http\Response(503)) to test failures. Callbacks get the wire event, with snake_case keys (user_id, properties, revenue, traits, external_ids).

Troubleshooting

  • Nothing arrives. Run $mira->checkConnection() once, or pass onError: fn ($e) => error_log($e->getMessage()). Without a secret key the client reports no secret key once and drops events.
  • batch dropped: HTTP 401 unknown_key. The key is wrong, revoked, or from another MIRA FIVE host. Server code needs the secret key (mira_sk_…), not the public one.
  • 1 event(s) rejected: forbidden: $revenue needs a secret key. The client was given a public key.
  • revenue: amount must be an integer in minor units. Send cents: 1999, not 19.99.
  • Events from a worker or daemon arrive late or not at all. A long-running process never ends its request: call $mira->flush() after each job and $mira->shutdown() before it exits.
  • delivery failed recently; events are dropped …. The ingest could not be reached; the client waits 30 s before it tries again. Check outgoing HTTPS to MIRAFIVE_HOST.

Development

composer install
composer check                     # pint --test, phpstan (max, strict), pest
php tests/contract/emit.php        # the batches of a fixed scenario, for the wire schema check

License

MIT, Cloo GmbH. See LICENSE.

For AI coding assistants

How to add MIRA FIVE to a PHP app with this version of mirafive/sdk-php: the setup in order, then the rules that hold for every MIRA FIVE SDK. This is a server SDK; its only browser part is ScriptTag::render(), which prints the browser SDK's script tag. Every option and the full API are in this package's README.md.

Setup, in this order

  1. Install: composer require mirafive/sdk-php. It needs PHP 8.3 or later. In Laravel use mirafive/sdk-laravel, in Symfony mirafive/sdk-symfony instead: they configure this client and flush after the response.
  2. Keys: the secret key (mira_sk_…) is MIRAFIVE_SECRET_KEY in the server's environment, and the person puts it there: never ask for it in a conversation, and never write it into a template, a page, JavaScript or the repository. The public key (mira_pk_…) is MIRAFIVE_PUBLIC_KEY and is the only key a page may carry. The SDK refuses the wrong key in each place: a public key sends nothing, a secret key prints no tag. A host that MIRA FIVE's setup names is MIRAFIVE_HOST for the client and host: for the script tag; without one the default is right.
  3. Browser: this package covers the server only. Print the browser SDK once in the layout's <head>: echo MiraFive\ScriptTag::render(publicKey: getenv('MIRAFIVE_PUBLIC_KEY') ?: ''). Page views, route changes, engagement, outbound clicks, downloads and form submits are sent from then on; write no code for them. Pass nonce: when the site has a CSP.
  4. Consent: the script tag follows the site's consent banner by default (consent: 'auto'). Without consent it stores nothing on the device and still counts, so never load it behind consent yourself. A banner the site built itself calls mira("consent", { analytics: true, marketing: false }) in the page, from its accept and decline handlers. On the server, events about your business (a paid invoice) keep the default not_applicable. For what a visitor did, pass what the banner recorded: consent: Consent::analyticsOnly(), Consent::granted(), Consent::denied() or Consent::of(analytics: true, marketing: false). Never invent consent.
  5. Identify: $mira = new Mira(); reads the environment; keep one client per request or process. $mira->identify(userId: (string) $user->id, traits: ['plan' => $user->plan]) when a user signs in or changes. The id is the app's own user id, never an email; email, name and phone go into the traits, which MIRA FIVE encrypts at rest.
  6. Events: $mira->track(event: 'report_exported', userId: 'user_42', properties: ['format' => 'csv']) for what a person does that only the server sees. A result that must count exactly once (a sign-up, a lead, an order) gets a stable eventId, step 7. Which events count as conversions is set in MIRA FIVE, not in code.
  7. Revenue: only from the server, one call per payment: $mira->revenue(amount: 1999, currency: 'EUR', userId: 'user_42', entryId: 'stripe:in_123', eventId: Mira::eventIdFor('order:123:paid')). Refunds are negative amounts with refundOf: 'stripe:in_123'. A lead your CRM later drops is withdrawn with $mira->retract(Mira::eventIdFor('lead:81'), 'spam').
  8. Check: $mira->checkConnection() returns 'secret' or throws a MiraError that says what to fix; it sends no event. Pass onError: fn (MiraError $e) => error_log($e->getMessage()) to see every dropped event, and ScriptTag::render(..., debug: true) for the browser. MIRA FIVE then shows the source receiving: Sources in the dashboard, or get_source_health through MIRA FIVE's MCP server.

Rules

  • Money is sent only from the server: integer minor units plus an ISO 4217 currency (amount: 1999, currency: 'EUR' is 19.99 EUR), never floats like 19.99.
  • Count once: give money an entryId from the payment provider (stripe:in_123), so the Stripe connector and retries do not double it. Give business events a stable id: eventId: Mira::eventIdFor('order:123:paid'). The same key gives the same id in every SDK.
  • Personal data never goes into event names or properties.
  • Never block on analytics: event methods return nothing and never throw. Do not wrap them in try, and do not call flush() after every event. A plain PHP request flushes when it ends; in a worker or daemon call flush() after each job and shutdown() before the process exits.
  • Server events and visitors: pass the browser's mira.anonymousId to your server and set it as anonymousId on server events, so a purchase joins the visit and its source.