-
Notifications
You must be signed in to change notification settings - Fork 36
feat(eventprocessor): Datamodel for event processor #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
232f0a0
2320939
fbb5a68
8a5f531
c829fca
c3c9d46
23ab6ce
6474e98
d4f2c66
80b0963
071460a
900d96d
8fabcdb
a6ff8fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Copyright 2019, Optimizely | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Copyright 2019, Optimizely | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Copyright 2019 Optimizely | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| from .user_event import UserEvent | ||
|
|
||
|
|
||
| class ConversionEvent(UserEvent): | ||
| """ Class representing Conversion Event. """ | ||
|
|
||
| def __init__(self, event_context, event, user_id, visitor_attributes, event_tags, bot_filtering=None): | ||
| self.event_context = event_context | ||
| self.event = event | ||
| self.user_id = user_id | ||
| self.visitor_attributes = visitor_attributes | ||
| self.event_tags = event_tags | ||
| self.bot_filtering = bot_filtering |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Copyright 2019 Optimizely | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
|
|
||
| class Decision(object): | ||
| def __init__(self, compaign_id, experiment_id, variation_id): | ||
| self.campaign_id = compaign_id | ||
| self.experiment_id = experiment_id | ||
| self.variation_id = variation_id | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Copyright 2019 Optimizely | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
|
|
||
| class EventBatch(object): | ||
| def __init__(self, account_id, project_id, revision, client_name, client_version, | ||
| anonymize_ip, enrich_decisions, visitors=None): | ||
| self.account_id = account_id | ||
| self.project_id = project_id | ||
| self.revision = revision | ||
| self.client_name = client_name | ||
| self.client_version = client_version | ||
| self.anonymize_ip = anonymize_ip | ||
| self.enrich_decisions = enrich_decisions | ||
| self.visitors = visitors |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Copyright 2019 Optimizely | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| from .. import version | ||
|
||
|
|
||
| SDK_VERSION = 'python-sdk' | ||
|
||
|
|
||
|
|
||
| class EventContext(object): | ||
| """ Class respresenting Event Context. """ | ||
|
|
||
| def __init__(self, account_id, project_id, revision, anonymize_ip): | ||
| self.account_id = account_id | ||
| self.project_id = project_id | ||
| self.revision = revision | ||
| self.client_name = SDK_VERSION | ||
| self.client_version = version.__version__ | ||
| self.anonymize_ip = anonymize_ip | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Copyright 2019 Optimizely | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| from .user_event import UserEvent | ||
|
|
||
|
|
||
| class ImpressionEvent(UserEvent): | ||
|
||
| """ Class representing Impression Event. """ | ||
|
|
||
| def __init__(self, event_context, user_id, experiment, visitor_attributes, variation, bot_filtering=None): | ||
| self.event_context = event_context | ||
| self.user_id = user_id | ||
| self.experiment = experiment | ||
| self.visitor_attributes = visitor_attributes | ||
| self.variation = variation | ||
| self.bot_filtering = bot_filtering | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Copyright 2019 Optimizely | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
|
|
||
| class Snapshot(object): | ||
| def __init__(self, events, decisions=None): | ||
| self.events = events | ||
| self.decisions = decisions |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Copyright 2019 Optimizely | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
|
|
||
| class SnapshotEvent(object): | ||
| """ Class representing Snapshot Event. """ | ||
|
|
||
| def __init__(self, entity_id, uuid, key, timestamp, revenue=None, value=None, tags=None): | ||
| self.entity_id = entity_id | ||
| self.uuid = uuid | ||
| self.key = key | ||
| self.timestamp = timestamp | ||
| self.revenue = revenue | ||
| self.value = value | ||
| self.tags = tags |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Copyright 2019 Optimizely | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| import time | ||
| import uuid | ||
|
|
||
|
|
||
| class UserEvent(object): | ||
| """ Class respresenting Event Context. """ | ||
|
|
||
| def __init__(self, event_context): | ||
| self.event_context = event_context | ||
| self.uuid = self._get_uuid() | ||
| self.timestamp = self._get_time() | ||
|
|
||
| def _get_time(self): | ||
| return int(round(time.time() * 1000)) | ||
|
|
||
| def _get_uuid(self): | ||
| return str(uuid.uuid4()) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Copyright 2019 Optimizely | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
|
|
||
| class Visitor(object): | ||
| def __init__(self, snapshots, attributes, visitor_id): | ||
| self.snapshots = snapshots | ||
| self.attributes = attributes | ||
| self.visitor_id = visitor_id |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Copyright 2019 Optimizely | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
|
|
||
| class VisitorAttribute(object): | ||
| def __init__(self, entity_id, key, event_type, value): | ||
| self.entity_id = entity_id | ||
| self.key = key | ||
| self.type = event_type | ||
| self.value = value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would recommend putting all classes related to event payload in a single file. I would recommend calling the file
optimizely/event/payload.py or something.