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: generate snippet methods #23663

Merged
merged 6 commits into from
Aug 20, 2024
Merged

feat: generate snippet methods #23663

merged 6 commits into from
Aug 20, 2024

Conversation

pauldambra
Copy link
Member

@pauldambra pauldambra commented Jul 11, 2024

we all either forget or don't know to add methods from posthog-js to the snippet as we add them to posthog-js

computers are good at not forgetting

lets generate the list of methods from the current posthog installed when the snippet loads

we can squash duplication in the front end side
but our layout.html we'll have to manually update since that'd be what is loading posthog for us to operate on


now we generate

['init', 'push', 'capture', 'register', 'register_once', 'register_for_session', 'unregister', 'unregister_for_session', 'getFeatureFlag', 'getFeatureFlagPayload', 'isFeatureEnabled', 'reloadFeatureFlags', 'updateEarlyAccessFeatureEnrollment', 'getEarlyAccessFeatures', 'on', 'onFeatureFlags', 'onSessionId', 'getSurveys', 'getActiveMatchingSurveys', 'getNextSurveyStep', 'identify', 'setPersonProperties', 'group', 'resetGroups', 'setPersonPropertiesForFlags', 'resetPersonPropertiesForFlags', 'setGroupPropertiesForFlags', 'resetGroupPropertiesForFlags', 'reset', 'get_distinct_id', 'getGroups', 'get_session_id', 'get_session_replay_url', 'alias', 'set_config', 'startSessionRecording', 'stopSessionRecording', 'sessionRecordingStarted', 'loadToolbar', 'get_property', 'getSessionProperty', 'createPersonProfile', 'opt_in_capturing', 'opt_out_capturing', 'has_opted_in_capturing', 'has_opted_out_capturing', 'clear_opt_in_out_capturing', 'debug']

we used to have fixed

[
  "capture", "identify", "alias", "people.set", "people.set_once", "set_config", "register", "register_once",
  "unregister", "opt_out_capturing", "has_opted_out_capturing", "opt_in_capturing", "reset", "isFeatureEnabled",
  "onFeatureFlags", "getFeatureFlag", "getFeatureFlagPayload", "reloadFeatureFlags", "group",
  "updateEarlyAccessFeatureEnrollment", "getEarlyAccessFeatures", "getActiveMatchingSurveys", "getSurveys",
  "getNextSurveyStep", "onSessionId", "setPersonProperties"
];

this adds missing methods

[
  'init', 'push', 'register_for_session', 'unregister_for_session', 'on', 'resetGroups', 'setPersonPropertiesForFlags',
  'resetPersonPropertiesForFlags', 'setGroupPropertiesForFlags', 'resetGroupPropertiesForFlags', 'get_distinct_id',
  'getGroups', 'get_session_id', 'get_session_replay_url', 'startSessionRecording', 'stopSessionRecording',
  'sessionRecordingStarted', 'loadToolbar', 'get_property', 'getSessionProperty', 'createPersonProfile',
  'has_opted_in_capturing', 'clear_opt_in_out_capturing', 'debug'
]

@pauldambra
Copy link
Member Author

pauldambra commented Jul 11, 2024

@neilkakkar i think you are the most diligent here... am i missing a trick?

(oh you're out! i missed that - ignore me 💖 )

Copy link
Contributor

github-actions bot commented Jul 11, 2024

Size Change: 0 B

Total Size: 1.08 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 1.08 MB

compressed-size-action

@posthog-bot
Copy link
Contributor

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 posthog-bot added stale and removed stale labels Jul 22, 2024
@posthog-bot
Copy link
Contributor

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. If you want to permanentely keep it open, use the waiting label.

@posthog-bot
Copy link
Contributor

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

@neilkakkar
Copy link
Collaborator

@pauldambra nope I just hear from customers very quickly when I don't add these 🙈 - your solution is much better than mine <3

@neilkakkar neilkakkar reopened this Aug 19, 2024
@posthog-bot posthog-bot removed the stale label Aug 19, 2024
@pauldambra pauldambra requested a review from a team August 19, 2024 08:15
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

4 snapshot changes in total. 0 added, 4 modified, 0 deleted:

  • chromium: 0 added, 4 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Collaborator

@neilkakkar neilkakkar left a comment

Choose a reason for hiding this comment

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

🚀

@pauldambra pauldambra merged commit 05210d6 into master Aug 20, 2024
93 checks passed
@pauldambra pauldambra deleted the feat/gen-snippet branch August 20, 2024 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants