Skip to content
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

Hotfix(metrics): CNX-9196 add object type event tracking for mixpanel in autocad, rhino, and revit #3257

Conversation

clairekuang
Copy link
Member

@clairekuang clairekuang commented Apr 3, 2024

Description & motivation

Adds two new events for mixpanel tracking: SendObjectReport and ReceiveObjectReport.
Attaches a dictionary containing each Speckle type found in the sent/received commit and their count, and tracks this event separately from send and receive events.

Added for AutoCAD, Rhino, and Revit.

@clairekuang clairekuang requested review from AlanRynne and teocomi April 3, 2024 12:52
Copy link
Contributor

@AlanRynne AlanRynne left a comment

Choose a reason for hiding this comment

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

Codewise, changes look good. We should make a pre-release to tripple check the metrics before going live

/// <summary>
/// Event triggered on send, capturing the object type counts of the sent commit
/// </summary>
SendObjectReport,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just make these without setup or do we need to setup on MixPanel side, presumably it's either automatic or we did the setup? Just asking? Also, do we know what part of our estate is release and what part is WIP?

Copy link
Member

@teocomi teocomi left a comment

Choose a reason for hiding this comment

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

I would not introduce two new events to track this; instead, we should attach this information to the existing Send and Receive events.

Also, I did not see any instance of SendObjectReport and ReceiveObjectReport in mixpanel. Has this code been tested? What's the payload like?

…mixpanel-for-AutoCAD-Rhino-and-Revit-on-send-and-receive
@clairekuang
Copy link
Member Author

I would not introduce two new events to track this; instead, we should attach this information to the existing Send and Receive events.

Since we are tracking this event from the connector binding (not DUI2), wouldn't this create 2 send events for every send then? Originally I introduced a new event to avoid this issue, but perhaps I'm misunderstanding how the send event is tracked

@clairekuang clairekuang requested a review from teocomi April 9, 2024 10:08
Copy link
Member

@teocomi teocomi left a comment

Choose a reason for hiding this comment

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

Checking your sample requests I can see that the object counts have been added as top level properties: https://eu.mixpanel.com/project/2605593/view/3144341/app/events#Q987uPpF8rvz

This will make it difficult to analyze the data in Mixpanel, I think they should instead be sent as nested object properties. This will make sure we keep our lexicon clean and data will be easier to parse.

Please also note the following limits:

  • Each event must be smaller than 1MB of uncompressed JSON.
  • Each event must have fewer than 255 properties.
  • All nested object properties must have fewer than 255 keys and max nesting depth is 3.
image

Copy link
Contributor

@BovineOx BovineOx left a comment

Choose a reason for hiding this comment

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

I'm okay with this but I think @teocomi needs the last word

@clairekuang clairekuang requested a review from teocomi April 10, 2024 15:19
@clairekuang
Copy link
Member Author

Just refactored the payload to be an array instead of a dictionary! Sample Mixpanel report below:
image

Copy link
Member

@JR-Morgan JR-Morgan left a comment

Choose a reason for hiding this comment

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

Were building up a fair bit of duplicate code.
I think @AlanRynne and @BovineOx were discussing consolidating the send + receive bindings into a shared project (so all connectors use the same) this would likely fix things here.
Not a blocker for this pr, but just extra fuel for us needing to re-consider where this lives.

.Select(o => new { TypeName = o.Key, Count = o.Value })
.OrderBy(pair => pair.Count)
.Reverse()
.Take(250);
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we can encode this value as a constant inside the Analytics class, just so we avoid having magic numbers

Copy link
Member

Choose a reason for hiding this comment

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

SInce the limit in mixpanel is 255, and we might be adding some other default props, I would lower it to 230 or so to be safe, maybe even 200.

Copy link
Member

@teocomi teocomi left a comment

Choose a reason for hiding this comment

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

Some minor comments

.Select(o => new { TypeName = o.Key, Count = o.Value })
.OrderBy(pair => pair.Count)
.Reverse()
.Take(250);
Copy link
Member

Choose a reason for hiding this comment

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

SInce the limit in mixpanel is 255, and we might be adding some other default props, I would lower it to 230 or so to be safe, maybe even 200.

Comment on lines 202 to 212
var typeCountArray = typeCountDict
.ToArray()
.Select(o => new { TypeName = o.Key, Count = o.Value })
.OrderBy(pair => pair.Count)
.Reverse()
.Take(250);

Analytics.TrackEvent(
Analytics.Events.ConvertToSpeckle,
new Dictionary<string, object>() { { "typeCount", typeCountArray } }
);
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if this could go in a helper function, but up to you guys...

@clairekuang clairekuang merged commit 118f6bb into main Apr 10, 2024
32 checks passed
@clairekuang clairekuang deleted the CNX-9196-Add-object-type-event-tracking-for-mixpanel-for-AutoCAD-Rhino-and-Revit-on-send-and-receive branch April 10, 2024 17:40
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.

5 participants