-
Notifications
You must be signed in to change notification settings - Fork 28
feat(epmodel): Event Processor datamodel #184
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 all commits
53deab0
76b0e85
0d5be25
f3df881
13bcf55
20b7226
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,39 @@ | ||
# frozen_string_literal: true | ||
|
||
# | ||
# Copyright 2019, Optimizely and contributors | ||
# | ||
# 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. | ||
# | ||
require_relative 'user_event' | ||
module Optimizely | ||
class ConversionEvent < UserEvent | ||
attr_reader :event_context, :event, :user_id, :visitor_attributes, :tags, :bot_filtering | ||
|
||
def initialize( | ||
event_context, | ||
event, | ||
user_id, | ||
visitor_attributes, | ||
tags, | ||
bot_filtering = nil | ||
) | ||
@event_context = event_context | ||
@event = event | ||
@user_id = user_id | ||
@visitor_attributes = visitor_attributes | ||
@tags = tags | ||
@bot_filtering = bot_filtering | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
# | ||
# Copyright 2019, Optimizely and contributors | ||
# | ||
# 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. | ||
# | ||
module Optimizely | ||
class Decision | ||
attr_reader :campaign_id, :experiment_id, :variation_id | ||
|
||
def initialize(campaign_id, experiment_id, variation_id) | ||
@campaign_id = campaign_id | ||
@experiment_id = experiment_id | ||
@variation_id = variation_id | ||
end | ||
|
||
def as_json | ||
{ | ||
campaign_id: @campaign_id, | ||
experiment_id: @experiment_id, | ||
variation_id: @variation_id | ||
} | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# frozen_string_literal: true | ||
|
||
# | ||
# Copyright 2019, Optimizely and contributors | ||
# | ||
# 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. | ||
# | ||
module Optimizely | ||
class EventBatch | ||
attr_accessor :account_id, :project_id, :revision, :client_name, :client_version, | ||
:anonymize_ip, :enrich_decisions, :visitors | ||
|
||
def as_json | ||
{ | ||
account_id: @account_id, | ||
project_id: @project_id, | ||
revision: @revision, | ||
client_name: @client_name, | ||
client_version: @client_version, | ||
anonymize_ip: @anonymize_ip, | ||
enrich_decisions: @enrich_decisions, | ||
visitors: @visitors | ||
} | ||
end | ||
|
||
class Builder | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we really need builder classes in ruby ? |
||
attr_reader :account_id, :project_id, :revision, :client_name, :client_version, | ||
:anonymize_ip, :enrich_decisions, :visitors | ||
|
||
def build | ||
event_batch = EventBatch.new | ||
event_batch.account_id = @account_id | ||
event_batch.project_id = @project_id | ||
event_batch.revision = @revision | ||
event_batch.client_name = @client_name | ||
event_batch.client_version = @client_version | ||
event_batch.anonymize_ip = @anonymize_ip | ||
event_batch.enrich_decisions = @enrich_decisions | ||
event_batch.visitors = @visitors | ||
event_batch | ||
end | ||
|
||
def with_account_id(account_id) | ||
@account_id = account_id | ||
end | ||
|
||
def with_project_id(project_id) | ||
@project_id = project_id | ||
end | ||
|
||
def with_revision(revision) | ||
@revision = revision | ||
end | ||
|
||
def with_client_name(client_name) | ||
@client_name = client_name | ||
end | ||
|
||
def with_client_version(client_version) | ||
@client_version = client_version | ||
end | ||
|
||
def with_anonymize_ip(anonymize_ip) | ||
@anonymize_ip = anonymize_ip | ||
end | ||
|
||
def with_enrich_decisions(enrich_decisions) | ||
@enrich_decisions = enrich_decisions | ||
end | ||
|
||
def with_visitors(visitors) | ||
@visitors = visitors | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# frozen_string_literal: true | ||
|
||
# | ||
# Copyright 2019, Optimizely and contributors | ||
# | ||
# 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. | ||
# | ||
module Optimizely | ||
class EventContext | ||
attr_reader :account_id, :project_id, :revision, :client_name, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how you will set these values? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. initialized |
||
:client_version, :anonymize_ip | ||
def initialize( | ||
account_id, | ||
project_id, | ||
revision, | ||
client_name, | ||
client_version, | ||
anonymize_ip | ||
) | ||
@account_id = account_id | ||
@project_id = project_id | ||
@revision = revision | ||
@client_name = client_name | ||
@client_version = client_version | ||
@anonymize_ip = anonymize_ip | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
# | ||
# Copyright 2019, Optimizely and contributors | ||
# | ||
# 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. | ||
# | ||
require_relative 'user_event' | ||
module Optimizely | ||
class ImpressionEvent < UserEvent | ||
attr_reader :event_context, :user_id, :experiment, :variation, :visitor_attributes, | ||
:bot_filtering | ||
|
||
def initialize( | ||
event_context, | ||
user_id, | ||
experiment, | ||
variation, | ||
visitor_attributes, | ||
bot_filtering | ||
) | ||
@event_context = event_context | ||
@user_id = user_id | ||
@experiment = experiment | ||
@variation = variation | ||
@visitor_attributes = visitor_attributes | ||
@bot_filtering = bot_filtering | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
# | ||
# Copyright 2019, Optimizely and contributors | ||
# | ||
# 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. | ||
# | ||
module Optimizely | ||
class Snapshot | ||
attr_reader :decisions, :events | ||
|
||
def initialize(events, decisions = nil) | ||
@decisions = decisions | ||
@events = events | ||
end | ||
|
||
def as_json | ||
hash = { | ||
events: @events, | ||
decisions: @decisions | ||
} | ||
hash.delete_if { |_key, value| value.nil? } | ||
hash | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# frozen_string_literal: true | ||
|
||
# | ||
# Copyright 2019, Optimizely and contributors | ||
# | ||
# 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. | ||
# | ||
module Optimizely | ||
class SnapshotEvent | ||
attr_reader :entity_id, :uuid, :key, :timestamp, :revenue, :value, :tags | ||
|
||
def initialize( | ||
entity_id: nil, | ||
uuid: nil, | ||
key: nil, | ||
timestamp: nil, | ||
revenue: nil, | ||
value: nil, | ||
tags: nil | ||
) | ||
@entity_id = entity_id | ||
@uuid = uuid | ||
@key = key | ||
@timestamp = timestamp | ||
@revenue = revenue | ||
@value = value | ||
@tags = tags | ||
end | ||
|
||
def as_json | ||
hash = { | ||
entity_id: @entity_id, | ||
uuid: @uuid, | ||
key: @key, | ||
timestamp: @timestamp, | ||
revenue: @revenue, | ||
value: @value, | ||
tags: @tags | ||
} | ||
hash.delete_if { |_key, value| value.nil? } | ||
hash | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
# | ||
# Copyright 2019, Optimizely and contributors | ||
# | ||
# 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. | ||
# | ||
module Optimizely | ||
class UserEvent | ||
attr_reader :event_context, :uuid, :timestamp | ||
end | ||
end |
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.
where are other attributes?
bot filter?