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

[Metrics] Use property session id generated each app session #1167

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/backend/metrics/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ function generateRandomId() {
return ethers.hexlify(ethers.randomBytes(24))
}

// using property based sessions instead of the default time based https://docs.mixpanel.com/docs/features/sessions#property-based-sessions
const session_id = generateRandomId()

/**
* An internal only function that adds context and global properties to the
* event payload before sending.
Expand All @@ -121,7 +124,8 @@ async function _trackEventPrivate(
[idFieldName]: id,
properties: {
...properties,
OS: getFormattedOsName()
OS: getFormattedOsName(),
session_id
},
context: {
app: {
Expand Down Expand Up @@ -167,7 +171,8 @@ export const trackScreen = async (name: string, properties?: apiObject) => {
name,
properties: {
...(properties ?? {}),
OS: getFormattedOsName()
OS: getFormattedOsName(),
session_id
},
context: {
app: {
Expand Down
Loading