feat(surveys): add active matching surveys subscription - #4794
Open
AyobamiH wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes #1498.
getActiveMatchingSurveysis intentionally a one-shot query. For API surveys targeted by an event or action, the matching set can change after the query returns, but consumers currently have no push-based way to observe that change.Changes
posthog.onActiveMatchingSurveysChanged(callback), which returns an unsubscribe function.getActiveMatchingSurveysone-shot to avoid changing existing callback semantics.posthog-js,@posthog/types, and the production property-preservation list.Test evidence
corepack pnpm --filter posthog-js test:unit: 6,060 passed, 8 skipped.corepack pnpm --filter posthog-js test:functional: 10 passed.corepack pnpm --filter posthog-js typecheckcorepack pnpm --filter posthog-js lintcorepack pnpm --filter posthog-js format:checkcorepack pnpm --filter posthog-js buildcorepack pnpm --filter posthog-js bundle-size:array upstream/main: +1.54 KiB minified, +0.30 KiB gzip, +0.18 KiB Brotli.corepack pnpm --filter @posthog/types test:unitcorepack pnpm --filter @posthog/types lintcorepack pnpm --filter @posthog/types buildcorepack pnpm formatcorepack pnpm lint:oxlintcorepack pnpm check:public-apiRelease info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
AyobamiH directed the issue selection, implementation, and maintainer-style review. Codex in ChatGPT Work Mode assisted with repository investigation, implementation, and verification.
The separate subscription API follows the maintainer's recommendation and preserves the existing getter's one-shot behavior. During review, the regression was strengthened to use an API survey and the real
SurveyManagermatching path without manually registering trigger definitions. A second regression preserves initial-notification ordering when an existingonSurveysLoadedcallback captures the activating event.