Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Report crypto sdk in posthog #11834

Merged
merged 7 commits into from
Nov 13, 2023
Merged

Report crypto sdk in posthog #11834

merged 7 commits into from
Nov 13, 2023

Conversation

BillCarsonFr
Copy link
Member

@BillCarsonFr BillCarsonFr commented Nov 8, 2023

Fixes element-hq/element-web#26449

Checklist

  • Tests written for new code (and old code if feasible)
  • Linter and other CI checks pass
  • Sign-off given on the changes (see CONTRIBUTING.md)

This change is marked as an internal change (Task), so will not be included in the changelog.

@BillCarsonFr BillCarsonFr added the T-Task Refactoring, enabling or disabling functionality, other engineering tasks label Nov 8, 2023
// Update super property for cryptoSDK in posthog.
// This property will be subsequently passed in every event.
const value = this.getCryptoSDKPropertyValue();
this.registerSuperProperties({ cryptoSDK: value });
Copy link
Member

Choose a reason for hiding this comment

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

Don't these clobber between sessions of the same account?

Copy link
Member Author

Choose a reason for hiding this comment

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

No I tested (same users with a rust and a legacy "device")
image

As per doc

However, please note that this does not store properties against the User, only against their events.

It's technically stored in a cookie:

Setting Super Properties creates a cookie on the client with the respective properties and their values.

There is a thing maybe annoying: if you switch to rust stack and we do PageView per unique user, the same user will report in both Legacy and Rust for some time. However for web insights we can use per Unique Session that could be better for us

Copy link
Member

Choose a reason for hiding this comment

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

Setting Super Properties creates a cookie on the client with the respective properties and their values.

Then we can't use it without updating the cookie policy.

Copy link
Member Author

Choose a reason for hiding this comment

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

Setting Super Properties creates a cookie on the client with the respective properties and their values.

Then we can't use it without updating the cookie policy.

We are already using superProperties for appVersion and appPlatform. So the cookie policy is already outdated?

// Temporary flag until we can switch to the Rust SDK without restarting the app.
// Currently, you have to set up the flag then logout and login again to switch.
// On login the matrixClient is passed to the analytics object, and we can check the crypto backend version.
private hasLoggedInWithRustCrypto = false;
Copy link
Member Author

@BillCarsonFr BillCarsonFr Nov 9, 2023

Choose a reason for hiding this comment

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

Note for reviewer: Ideally we should just listen to the feature_rust_crypto settings, and this is what we will do when we will have migration in place. But until then you need to enable that feature then logout and login, that's why there is this flag.

It will be set when the current MatrixClient is passed to the analytics object (on login / page load / ...), the trick is to look at the crypto version.

I am not sure if it's right to listen to the setting now as it's not yet working. Maybe it should for now just check the crypto version from matrix client for now, and then later when we have migration we use the setting?
Let me know and I will update

Update: Simplified, will now just check the actual crypto version

src/PosthogAnalytics.ts Outdated Show resolved Hide resolved
Comment on lines 208 to 210
if (["feature_rust_crypto"].includes(settingsPayload.settingName)) {
this.updateCryptoSuperProperty();
}
Copy link
Member

Choose a reason for hiding this comment

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

This code will never fire, no? Given the feature is not runtime mutable and must be set via config.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I simplified all, it will probably not be fully live ever. Just using the matrixClient passed on load/login/account data and read the crypto version

@BillCarsonFr BillCarsonFr added this pull request to the merge queue Nov 13, 2023
Merged via the queue into develop with commit 9595dbb Nov 13, 2023
85 checks passed
@BillCarsonFr BillCarsonFr deleted the valere/element-r/posthog branch November 13, 2023 15:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T-Task Refactoring, enabling or disabling functionality, other engineering tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Report to Posthog about which crypto stack is in use
2 participants