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

Support for posthog super properties #2579

Closed
wants to merge 1 commit into from

Conversation

BillCarsonFr
Copy link
Member

Pull Request Checklist

A quick PR to add super properties to captured event. Super properties are added to every captured event.
In this case I added on super property for cryptoSDK, we used this property as a filter on $screen events (as well as E2E errors). It allows to build a ratio of errors for all different clients just using this filter.

Let me know if ok

UI changes have been tested with:

  • iPhone and iPad simulators in portrait and landscape orientations.
  • Dark mode enabled and disabled.
  • Various sizes of dynamic type.
  • Voiceover enabled.

@BillCarsonFr BillCarsonFr requested a review from a team as a code owner March 15, 2024 15:38
@BillCarsonFr BillCarsonFr requested review from stefanceriu and removed request for a team March 15, 2024 15:38
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

Warnings
⚠️ Please add a changelog.
⚠️ Some of the commits are missing ticket numbers. Please consider squashing all commits that don't have a tracking number.
⚠️ Please add a sign-off to either the PR description or to the commits themselves.

Generated by 🚫 Danger Swift against 24c858e

/// Super Properties are properties associated with events that are set once and then sent with every capture call, be it a $screen, an autocaptured button click, or anything else.
/// It is different from user properties that will be attached to the user and not events.
/// Not persisted for now, should be set on start.
private var superProperties: [String: Any] = [:]
Copy link
Member

Choose a reason for hiding this comment

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

Why don't we define and type these similar to AnalyticsEvent.UserProperties?

Copy link
Member Author

Choose a reason for hiding this comment

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

We need this property in Screen events to have common filters for each platforms. Screen events are built in, and not defined in the analytics repo

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh I see, just define a blank object in the repo


// Add super property cryptoSDK to the captured events, to allow easy
// filtering of events across different client by using same filter.
superProperties["cryptoSDK"] = "Rust"
Copy link
Member

Choose a reason for hiding this comment

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

.. would make this less.. stringy

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, we shouldn't be sending anything to PostHog that isn't coming from the schema.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can't define that in the schema (properties added to build in events)

Copy link
Member

Choose a reason for hiding this comment

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

It should be possible to make a SuperProperties event and attach it's .properties to the event's that we're sending instead of an untyped dictionary though?

Copy link
Member Author

Choose a reason for hiding this comment

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

}

func screen(_ event: AnalyticsScreenProtocol) {
guard isRunning else { return }
postHog?.screen(event.screenName.rawValue, properties: attachUserProperties(to: event.properties))
postHog?.screen(event.screenName.rawValue, properties: attachUserProperties(to: attachSuperProperties(to: event.properties)))
Copy link
Member

Choose a reason for hiding this comment

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

This is not the most straightforward thing, some tests are in order. Please see UnitTests/AnalyticsTests, especiall the *UserProperties part

@stefanceriu
Copy link
Member

@BillCarsonFr planning on coming back to this PR at some point or can we close it?

@BillCarsonFr
Copy link
Member Author

Closing in favour of #2774

@stefanceriu stefanceriu deleted the valere/posthog_super_properties branch July 23, 2024 09: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.

3 participants