PostHog / posthog-php

MIT License
18 stars 19 forks source link

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

Open mbroadhead opened 10 months ago

mbroadhead commented 10 months ago

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.