You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Detailed-README.md
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -110,6 +110,42 @@ except TimeoutException:
110
110
sys.exit()
111
111
```
112
112
113
+
## Impression Listener
114
+
Split SDKs send impression data back to Split servers periodically and as a result of evaluating splits. In order to additionally send this information to a location of your choice, you could define and attach an Impression Listener. For that purpose, SDK's options have a parameter called `impressionListener` where an implementation of `ImpressionListener` could be added. This implementation **must** define the `log_impression` method and it will receive data in the following schema:
115
+
116
+
| Name | Type | Description |
117
+
| --- | --- | --- |
118
+
| impression | Impression | Impression object that has the feature_name, treatment result, label, etc. |
119
+
| attributes | Array | A list of attributes passed by the client. |
120
+
| instance-id | String | Corresponds to the IP of the machine where the SDK is running. |
121
+
| sdk-language-version | String | Indicates the version of the sdk. In this case the language will be python plus the version of it. |
122
+
123
+
### Implementing custom Impression Listener
124
+
Below you could find an example of how implement a custom Impression Listener:
125
+
```python
126
+
# Import ImpressionListener interface
127
+
from splitio.impressions import ImpressionListener
128
+
129
+
# Implementation Sample for a Custom Impression Listener
130
+
classCustomImpressionListener(ImpressionListener)
131
+
{
132
+
deflog_impression(self, data):
133
+
# Custom behavior
134
+
}
135
+
```
136
+
137
+
### Attaching custom Impression Listener
138
+
```python
139
+
factory = get_factory(
140
+
'YOUR_API_KEY',
141
+
config={
142
+
# ...
143
+
'impressionListener': CustomImpressionListener()
144
+
},
145
+
# ...
146
+
)
147
+
split = factory.client()
148
+
113
149
## Additional information
114
150
115
151
You can get more information on how to use this package in the included documentation.
0 commit comments