Skip to content

Commit

Permalink
rename statsigfeaturegate to statsigcheckgate, statsig_feature_gate t…
Browse files Browse the repository at this point in the history
…o statsig_check_gate. Remove incomplete middleware for now
  • Loading branch information
ziming committed Jul 8, 2023
1 parent 1f0f263 commit 0573cdb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 28 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Laravel Package for Statsig. A Feature Gate & A/B Testing Platform with a somewhat decent free tier.

This package is still very early in development & likely not ready for production use yet.
I have only just started using it in production on a small site 1st.
I have only just started using it in production on 2 small sites currently.

Use at your own risk if you want to try it now. But if you have used in production, it would be great to let me know :)

Expand All @@ -18,7 +18,7 @@ It is basically a wrapper around the [Statsig PHP SDK](https://docs.statsig.com/

The following features are being considered for the future. If any of it interest you, feel free to submit a PR.

- New Adaptors
- New Adapters
- New Middlewares
- Convenience Traits & Methods
- Octane/Vapor/Serverless Support (Probably far in the future)
Expand Down Expand Up @@ -129,9 +129,9 @@ It is confusingly named in all lowercase to match the official laravel naming co
Currently it can only be used if the user is logged in. Do not use it for your guest pages for now.

```blade
@statsigfeaturegate('gate_name')
@statsigcheckgate('gate_name')
<p>This is shown if this statsig gate return true</p>
@endstatsigfeaturegate
@endstatsigcheckgate
```

Lastly, a helper function is also provided if you want to be even more concise in your blade templates.
Expand All @@ -140,7 +140,7 @@ It is named in snake case, following laravel naming conventions for global helpe
Like the blade directive, currently it can only be used if the user is logged in.

```blade
<div class="{{ statsig_feature_gate('awesome_feature') ? 'border-green' : '' }}">
<div class="{{ statsig_check_gate('awesome_feature') ? 'border-green' : '' }}">
</div>
```
## Testing
Expand Down
4 changes: 4 additions & 0 deletions src/LaravelStatsig.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ public function flush(): void
*/
public function __call(string $name, array $arguments): mixed
{
if (isset($arguments[0]) && $arguments[0] instanceof Authenticatable) {
$arguments[0] = LaravelUserToStatsigUserConverter::convertLaravelUserToStatsigUser($arguments[0]);
}

return $this->statsigServer->$name(...$arguments);
}
}
2 changes: 1 addition & 1 deletion src/LaravelStatsigServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function configurePackage(Package $package): void

public function packageBooted(): void
{
Blade::if('statsigfeaturegate', function (string $gateName) {
Blade::if('statsigcheckgate', function (string $gateName) {
return LaravelStatsig::checkGate(Auth::user(), $gateName);
});
}
Expand Down
20 changes: 0 additions & 20 deletions src/Middleware/EnsureStatsigFeaturesAreActive.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Illuminate\Support\Facades\Auth;
use Ziming\LaravelStatsig\Facades\LaravelStatsig;

if (! function_exists('statsig_feature_gate')) {
function statsig_feature_gate(string $name): bool
if (! function_exists('statsig_check_gate')) {
function statsig_check_gate(string $name): bool
{
return LaravelStatsig::checkGate(Auth::user(), $name);
}
Expand Down

0 comments on commit 0573cdb

Please sign in to comment.