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

Add analytics to homepage #5278

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Conversation

Cloud11PL
Copy link
Member

What type of PR is this?

  • 💅 Refactor
  • 🌟 Feature
  • 🔥 Bug Fix
  • 🔩 Maintenance
  • 🛠 Workflow CI/CD changes

Related Issues or Documents

  • closes #

Usage Instructions, Screenshots, Recordings

Have you written tests?

  • Yes!
  • No... here is why: Writing tests are mandatory, please replace this text with why test are not included in this PR

[Optional] Description

Copy link

changeset-bot bot commented Nov 25, 2024

🦋 Changeset detected

Latest commit: 921efcb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
saleor-dashboard Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot temporarily deployed to pr-5278 November 25, 2024 15:43 Destroyed
@github-actions github-actions bot temporarily deployed to pr-5278 November 26, 2024 08:15 Destroyed
@github-actions github-actions bot temporarily deployed to pr-5278 November 26, 2024 08:39 Destroyed
@github-actions github-actions bot temporarily deployed to pr-5278 November 26, 2024 08:45 Destroyed
@github-actions github-actions bot temporarily deployed to pr-5278 November 26, 2024 08:51 Destroyed
@github-actions github-actions bot temporarily deployed to pr-5278 November 26, 2024 09:28 Destroyed
@github-actions github-actions bot temporarily deployed to pr-5278 November 26, 2024 10:02 Destroyed
@Cloud11PL Cloud11PL marked this pull request as ready for review November 26, 2024 10:12
@Cloud11PL Cloud11PL requested a review from a team as a code owner November 26, 2024 10:12
src/newHome/homeInfoTiles/TilesContainer.tsx Outdated Show resolved Hide resolved
src/newHome/homeOnboarding/useOnboardingData.tsx Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to pr-5278 November 26, 2024 11:30 Destroyed
@github-actions github-actions bot temporarily deployed to pr-5278 November 26, 2024 13:28 Destroyed
@github-actions github-actions bot temporarily deployed to pr-5278 November 26, 2024 13:36 Destroyed
"saleor-dashboard": patch
---

Environments created via Saleor Cloud now identify and report to PostHog. This means Dashboard now sends telemetry data regarding home page onboarding steps and links.
Copy link
Member

Choose a reason for hiding this comment

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

I dont see where exactly it checks if this is Saleor Cloud only?

This PR couples open source dashboard with a 3rd party vendor. For non-cloud builds it can't be opt out and the code is loaded to the bundle.

I suggest to write a simple facade pattern that will

  1. check for env variable like ENABLE_ANALYTICS or ENABLE_POSHOG. Perform no-op if not enabled
  2. If analytics enabled, dynamically load library, instead of bundling it eagerly
  3. Use custom methods and hooks and call posthog behind it, so the codebase is not tight coupled with posthog

you can consider this
https://github.com/DavidWells/analytics/tree/master

or at least get inspired (to run analytics.track() instead posthog.track()

Copy link
Member Author

@Cloud11PL Cloud11PL Nov 26, 2024

Choose a reason for hiding this comment

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

Dashboard has been coupled with Posthog for the past 9 months, it just wasn't (and still isn't) enabled. Posthog will be enabled when Dashboard is in a Cloud instance and has posthog api keys and host set in environment variables -> https://github.com/saleor/saleor-dashboard/blob/main/src/components/ProductAnalytics/index.tsx#L14, for non-cloud builds nothing has changed.

poulch
poulch previously approved these changes Nov 26, 2024
@github-actions github-actions bot temporarily deployed to pr-5278 November 27, 2024 07:33 Destroyed
@github-actions github-actions bot temporarily deployed to pr-5278 November 28, 2024 14:27 Destroyed
@github-actions github-actions bot temporarily deployed to pr-5278 November 28, 2024 15:07 Destroyed
poulch
poulch previously approved these changes Nov 28, 2024
@github-actions github-actions bot temporarily deployed to pr-5278 November 28, 2024 21:11 Destroyed
@github-actions github-actions bot temporarily deployed to pr-5278 November 29, 2024 07:28 Destroyed
andrzejewsky
andrzejewsky previously approved these changes Nov 29, 2024
@@ -22,10 +23,12 @@ const getStepsData = ({
intl,
isStepCompleted,
onStepComplete,
posthogCapture,
Copy link
Member

Choose a reason for hiding this comment

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

when you have abstraction, then you should not refer to the name "Posthog" anywhere apart the file where you build the abstraction

@@ -0,0 +1,28 @@
import { usePostHog } from "posthog-js/react";

export function useDashboardAnalytics() {
Copy link
Member

Choose a reason for hiding this comment

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

so perhaps just "useAnalytics" as the file name indicates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants