7
7
8
8
Laravel Package for Statsig. A Feature Gate & A/B Testing Platform with a somewhat decent free tier
9
9
10
- This package is still very early in development, but I have used it on a few small production sites for a while already .
10
+ This package is still very early in development, but I have used it on a few small production sites for a while.
11
11
12
- If you have used in production, it would be great to let me know any feedback :)
12
+ If you have used in production, it would be great to let me know :)
13
13
14
14
It is basically a wrapper around the [ Statsig PHP SDK] ( https://docs.statsig.com/server/phpSDK )
15
15
16
16
## Support us
17
17
18
- The following features are being considered for the future. If any of it interest you, feel free to submit a PR.
18
+ The following features are being considered for the future. Feel free to suggest or PR others
19
+ feel free to submit a PR.
19
20
20
- - New Adapters
21
- - New Middlewares
21
+ - Custom IDs Support
22
22
- More Convenience Traits & Methods
23
23
- HTTP & Console API support
24
- - Octane/Vapor/Serverless Support (Probably far in the future )
24
+ - Octane/Vapor/Serverless Support (It probably already works but it is not confirmed )
25
25
26
26
Donations are welcomed too as an alternative. Anything goes.
27
27
@@ -74,13 +74,17 @@ return [
74
74
'secret' => env('STATSIG_SECRET_KEY'),
75
75
76
76
'data_adapter' => LocalFileDataAdapter::class,
77
+
78
+ // arguments to the Data Adapter class constructor
77
79
'data_adapter_arguments' => [
78
- // '/tmp/statsig/', leave blank for the default directory
80
+ // '/tmp/statsig/', // empty array for the default directory for the default Data Adapter
79
81
],
80
82
81
83
'logging_adapter' => LocalFileLoggingAdapter::class,
84
+
85
+ // arguments to the Logging Adapter class constructor
82
86
'logging_adapter_arguments' => [
83
- // '/tmp/statsig.logs', leave blank for the default file path
87
+ // '/tmp/statsig.logs', // empty array for the default file path for the default Logging Adapter
84
88
],
85
89
];
86
90
```
@@ -123,6 +127,14 @@ LaravelStatsigUserConfiguration::setConversionCallable(function (User $laravelUs
123
127
124
128
$statsigEvent = new LaravelStatsigEvent('event_name');
125
129
130
+ // Giving it a value is optional
131
+ $statsigEvent->setValue('string-or-float-or-int-or-whatever-primitive-type');
132
+
133
+ // Extra event metadata is optional too. See the official Statsig docs on how many you can send
134
+ $statsigEvent->setMetadata([
135
+ 'key' => 'value'
136
+ ]);
137
+
126
138
// You can also use this convenience method
127
139
LaravelStatsig::logEventWithAuthUser($statsigEvent);
128
140
@@ -135,11 +147,17 @@ A handy blade directive is also provided to check against Statsig Feature Gates
135
147
136
148
It is confusingly named in all lowercase to match the official laravel naming conventions for blade directives.
137
149
138
- Currently it can only be used if the user is logged in. Do not use it for your guest pages for now.
139
-
140
150
``` blade
141
151
@statsigcheckgate('gate_name')
142
- <p>This is shown if this statsig gate return true</p>
152
+ <p>This is shown if this statsig gate return true for the authenticated user</p>
153
+ @endstatsigcheckgate
154
+
155
+ @statsigcheckgate('gate_name', 'user-identifier')
156
+ <p>This is usually used for guest user but can be ur authenticated user identifier too</p>
157
+ @endstatsigcheckgate
158
+
159
+ @statsigcheckgate('gate_name', $user)
160
+ <p>$user can be a StatsigUser or a laravel user instance</p>
143
161
@endstatsigcheckgate
144
162
```
145
163
@@ -149,15 +167,26 @@ It is named in snake case, following laravel naming conventions for global helpe
149
167
Like the blade directive, currently it can only be used if the user is logged in.
150
168
151
169
``` blade
152
- <div class="{{ statsig_check_gate('awesome_feature') ? 'border-green' : '' }}">
170
+ <div class="{{ statsig_check_gate('gate_name') ? 'border-red' : '' }}">
171
+ The Authenticated user will be used to check if it passes this gate
172
+ </div>
173
+
174
+ <div class="{{ statsig_check_gate('gate_name', 'user-identifier') ? 'border-red' : '' }}">
175
+ This is usually used for guest user but can be ur authenticated user identifier too
176
+ </div>
177
+
178
+ <div class="{{ statsig_check_gate('gate_name', $user) ? 'border-red' : '' }}">
179
+ Use this is you want to pass in a statsig user or laravel user instance
153
180
</div>
154
181
```
155
182
## Testing
156
183
184
+ No tests currently, feel free to PR
185
+
157
186
``` bash
158
187
composer test
159
188
```
160
- ## Userful References
189
+ ## Useful References
161
190
162
191
Below are links to some good reads that I think would benefit you in getting started:
163
192
0 commit comments