Skip to content

feat(eventfactory): Event Factory and UserEventFactory #174

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

Merged
merged 17 commits into from
Jul 15, 2019

Conversation

msohailhussain
Copy link
Contributor

Summary

  • UserEventFactory decouples ProjectConfig & provide the object to represent impression and conversion event.
  • EventFactory represents EventBatch after grouping imp/conv objects.

Test plan

  • Converted EventBuilder unit tests to EventFactory to make sure, all scenarios are covered to send payload to Server.

@msohailhussain msohailhussain requested review from mikeproeng37, aliabbasrizvi and a team July 11, 2019 17:32

public SnapshotEvent(string entityId, string uuid, string key, long timestamp, int? revenue, long? value, EventTags eventTags)
public SnapshotEvent(string entityId, string uuid, string key, long timestamp, int? revenue = null, float? value = null, EventTags eventTags = null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come SnapshotEvent doesn't get a Builder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, I will add builder for it, initially I decided not to have builder for simple classes but this class have same type of properties which may be interchanged. I actually missed it. Will add

/// <summary>
/// Helper to compute Unix time (i.e. since Jan 1, 1970)
/// </summary>
protected static long SecondsSince1970
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it could be a more global utility

@@ -0,0 +1,200 @@
/*
* Copyright 2017-2019, Optimizely
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only 2019

@@ -0,0 +1,200 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is a need for making things internal anymore. We want to be able to expose as much of the SDK as possible. Plus the class itself it public and not protected :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove it from Internals, just FYI, class should have internal attribute not to expose outside of assembly.

/// <summary>
/// UserEventFactory builds ImpressionEvent and ConversionEvent objects from a given UserEvent.
/// </summary>
public class UserEventFactory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a strong reason for making this a separate file? I was thinking a generic "Event" factory can create all these types of events

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a categorization between userevents which are impression and conversion and server event which is only LogEvent. Same in java. that's why I did it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok that is fine then.

Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@@ -0,0 +1,18 @@
using System;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be less generic. We can call it DateUtils

@mikeproeng37 mikeproeng37 merged commit 00af331 into master Jul 15, 2019
@msohailhussain msohailhussain deleted the mnoman/addedEventFactory branch September 24, 2019 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants