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

Reinstate Posthog analytics PR fixing type definitions via installing dev dependencies #6532

Merged
merged 4 commits into from
Aug 4, 2021

Conversation

novocaine
Copy link
Contributor

@novocaine novocaine commented Aug 3, 2021

Part of the previous PR for posthog #6495 included overriding posthog's type definitions to remove references to transitive dependencies which we don't use and don't want to install. This was done via a paths entry in tsconfig.json.

This caused element-web linting to fail as EW's type linting descends into matrix-react-sdk but the override didn't apply to EW as no changes were made to its respective tsconfig.json. So I reverted the PR in #6531.

It wouldn't be great for every Typescript user of matrix-react-sdk to have to do that.

In this PR, I initially took a different approach suggested by @Palid - use patch-package to autopatch the library on postinstall. Unfortunately, as noted in the comments, we disable the postinstall hook in CI, and it would be awkward to work around that.

I considered forking the library, but we don't currently maintain any forked dependencies and it seems silly to start doing that now for this one.

So for the time being, we are just going to install the libraries referred to as dev dependencies. We will be using Sentry shortly anyway. Flagged with posthog maintainers at PostHog/posthog-js#252

@novocaine novocaine requested a review from a team August 3, 2021 11:02
@Palid
Copy link
Contributor

Palid commented Aug 3, 2021

@novocaine it seems that for some reason the CI does not patch the packages properly, or it's using a cached version.

@novocaine
Copy link
Contributor Author

It seems that because we run yarn install --ignore-scripts, the postinstall hook is not run. I think this is kind of intentional - we don't want third party packages executing scripts inside the CI.

yarnpkg/yarn#7338

@Palid
Copy link
Contributor

Palid commented Aug 3, 2021

@novocaine I guess we can just run it manually then?

@novocaine
Copy link
Contributor Author

We could, but then we're trusting patch-package itself to run inside our CI which I'm not quite sure about.

I considered just running patch -p1 < patches/posthog-js+1.12.2.patch which is all that's needed but I guess that will not work on windows.

This is neccessary to resolve re-exported types referred to by posthog-js' type definitions.

This isn't ideal, but

* We intend to start using sentry anyway
* Discussion with posthog maintainers about rrweb-snapshot at PostHog/posthog-js#252, perhaps we can find another solution soon
@novocaine
Copy link
Contributor Author

Giving up and adding them as dev dependencies in the interests of pragmatism.

As noted in the commit we will shortly be using sentry anyway, and I'm chasing up the posthog maintainers at PostHog/posthog-js#252

@novocaine novocaine changed the title Reinstate Posthog analytics PR using patch-package to patch Posthog's types Reinstate Posthog analytics PR fixing type definitions via installing dev dependencies Aug 4, 2021
@novocaine novocaine merged commit 57f5c30 into develop Aug 4, 2021
@novocaine novocaine deleted the posthog-analytics branch August 4, 2021 08:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants