mirror of
https://github.com/Shopify/liquid.git
synced 2025-08-10 00:00:35 -04:00
Add usage tracking
This commit is contained in:
parent
806b2622da
commit
b316ff8413
@ -106,3 +106,9 @@ template = Liquid::Template.parse("{{x}} {{y}}")
|
||||
template.render!({ 'x' => 1}, { strict_variables: true })
|
||||
#=> Liquid::UndefinedVariable: Liquid error: undefined variable y
|
||||
```
|
||||
|
||||
### Usage tracking
|
||||
|
||||
To help determine if a feature or code path is used in production we have included opt-in usage tracking. To achieve this we provide an empty `Liquid::Usage.increment` method that can be implemented. This was designed to be paired with https://github.com/Shopify/statsd-instrument , however it's implementation is up to you.
|
||||
|
||||
Once you have enabled usage tracking we recommend reporting any logged events through Github Issues that your system may be reporting. It is highly likely this event has been added to consider deprecating or improving code specific to this event, so please raise any concerns.
|
||||
|
@ -421,6 +421,7 @@ module Liquid
|
||||
|
||||
def default(input, default_value = ''.freeze)
|
||||
if !input || input.respond_to?(:empty?) && input.empty?
|
||||
Usage.increment("liquid.default_filter_received_false_value") if input == false # See https://github.com/Shopify/liquid/issues/1127
|
||||
default_value
|
||||
else
|
||||
input
|
||||
|
6
lib/liquid/usage.rb
Normal file
6
lib/liquid/usage.rb
Normal file
@ -0,0 +1,6 @@
|
||||
module Liquid
|
||||
module Usage
|
||||
def self.increment(name, sample_rate: 0.1, tags: {})
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user