Skip to content

PostHog::alias() returns a different type depending on batch_size #57

@mbroadhead

Description

@mbroadhead

It seems a bit inconsistent that when batch_size=1, PostHog::alias() returns a raw JSON string, while when batch_size > 1 PostHog::alias() returns a boolean. Is this expected behavior?

Example:

# When batch_size > 1
use Str;
use PostHog\PostHog;
$uuid = Str::uuid();
$key = config('services.posthog.api_key');
$host = config('services.posthog.api_host');
PostHog::init($key, ['host' => $host, 'batch_size' => 7]);
var_dump(PostHog::alias(["distinctId" => "user-$uuid", "alias" => "guest-$uuid"]));

bool(true)

# When batch_size == 1
use Str;
use PostHog\PostHog;
$uuid = Str::uuid();
$key = config('services.posthog.api_key');
$host = config('services.posthog.api_host');
PostHog::init($key, ['host' => $host, 'batch_size' => 1]);
var_dump(PostHog::alias(["distinctId" => "user-$uuid", "alias" => "guest-$uuid"]));

string(13) "{"status": 1}"

I'm using posthog-php version 3.0.8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions