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

feat: Tidy initialisation with better warnings #768

Closed
wants to merge 18 commits into from

Conversation

benjackwhite
Copy link
Collaborator

@benjackwhite benjackwhite commented Aug 4, 2023

Changes

Needs #767

We get a lot of issues with people initialising PostHog incorrectly, sometimes due to think an env var is set when it isn't.
I started trying to add this and the spaghetti code of initialisation caused such a headache that I felt it was time we improved this.

Big change so we should validate this heavily but this:

  • Removes the multiple states that create a lib, instead using PostHog class as the basis and moving all initialisation into the two methods
  • Simplifies the global state side of things
  • Still keeps the snippet specific stuff but now it is relatively straightforward acting on the initialised PostHog instance rather than a hacked global override

TODO

  • Check the multiple paths
  • Check we have tests for these paths and they all pass
  • Ensure pre-loaded calls still work

Checklist

@github-actions
Copy link

github-actions bot commented Aug 4, 2023

Size Change: -3.36 kB (0%)

Total Size: 749 kB

Filename Size Change
dist/array.full.js 176 kB -880 B (0%)
dist/array.js 117 kB -869 B (-1%)
dist/es.js 117 kB -804 B (-1%)
dist/module.js 118 kB -804 B (-1%)
ℹ️ View Unchanged
Filename Size
dist/exception-autocapture.js 12 kB
dist/recorder-v2.js 104 kB
dist/recorder.js 58.4 kB
dist/surveys.js 46.8 kB

compressed-size-action

@benjackwhite benjackwhite changed the base branch from master to fix/optional-values August 4, 2023 08:40
@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@posthog-bot
Copy link
Collaborator

This PR was closed due to lack of activity. Feel free to reopen if it's still relevant.

@benjackwhite benjackwhite removed the stale label Sep 4, 2023
@benjackwhite benjackwhite reopened this Sep 4, 2023
Base automatically changed from fix/optional-values to master September 7, 2023 10:15
Copy link
Member

@pauldambra pauldambra left a comment

Choose a reason for hiding this comment

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

looks good to me...

fixed a couple of linting issues, but when I ran yalc publish loads of tests failed :'(

@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@posthog-bot
Copy link
Collaborator

This PR was closed due to lack of activity. Feel free to reopen if it's still relevant.

@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

# Conflicts:
#	src/__tests__/posthog-core.identify.js
#	src/__tests__/posthog-core.js
#	src/extensions/sessionrecording.ts
#	src/posthog-core.ts
#	src/posthog-featureflags.ts
#	src/posthog-surveys.ts
@benjackwhite benjackwhite removed the stale label Jan 2, 2024
@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@posthog-bot
Copy link
Collaborator

This PR was closed due to lack of activity. Feel free to reopen if it's still relevant.

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

Successfully merging this pull request may close these issues.

3 participants