Skip to content

Commit 0573cdb

Browse files
author
ziming
committed
rename statsigfeaturegate to statsigcheckgate, statsig_feature_gate to statsig_check_gate. Remove incomplete middleware for now
1 parent 1f0f263 commit 0573cdb

File tree

5 files changed

+12
-28
lines changed

5 files changed

+12
-28
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Laravel Package for Statsig. A Feature Gate & A/B Testing Platform with a somewhat decent free tier.
99

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

1313
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 :)
1414

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

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

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

131131
```blade
132-
@statsigfeaturegate('gate_name')
132+
@statsigcheckgate('gate_name')
133133
<p>This is shown if this statsig gate return true</p>
134-
@endstatsigfeaturegate
134+
@endstatsigcheckgate
135135
```
136136

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

142142
```blade
143-
<div class="{{ statsig_feature_gate('awesome_feature') ? 'border-green' : '' }}">
143+
<div class="{{ statsig_check_gate('awesome_feature') ? 'border-green' : '' }}">
144144
</div>
145145
```
146146
## Testing

src/LaravelStatsig.php

+4
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ public function flush(): void
141141
*/
142142
public function __call(string $name, array $arguments): mixed
143143
{
144+
if (isset($arguments[0]) && $arguments[0] instanceof Authenticatable) {
145+
$arguments[0] = LaravelUserToStatsigUserConverter::convertLaravelUserToStatsigUser($arguments[0]);
146+
}
147+
144148
return $this->statsigServer->$name(...$arguments);
145149
}
146150
}

src/LaravelStatsigServiceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function configurePackage(Package $package): void
3232

3333
public function packageBooted(): void
3434
{
35-
Blade::if('statsigfeaturegate', function (string $gateName) {
35+
Blade::if('statsigcheckgate', function (string $gateName) {
3636
return LaravelStatsig::checkGate(Auth::user(), $gateName);
3737
});
3838
}

src/Middleware/EnsureStatsigFeaturesAreActive.php

-20
This file was deleted.

src/helpers.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
use Illuminate\Support\Facades\Auth;
66
use Ziming\LaravelStatsig\Facades\LaravelStatsig;
77

8-
if (! function_exists('statsig_feature_gate')) {
9-
function statsig_feature_gate(string $name): bool
8+
if (! function_exists('statsig_check_gate')) {
9+
function statsig_check_gate(string $name): bool
1010
{
1111
return LaravelStatsig::checkGate(Auth::user(), $name);
1212
}

0 commit comments

Comments
 (0)