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

chore: add analytics tracking to capture PlanningConstraints & PropertyInformation "overrides" #3510

Merged
merged 6 commits into from
Aug 14, 2024

Conversation

jessicamcinchak
Copy link
Member

@jessicamcinchak jessicamcinchak commented Aug 13, 2024

Adds new passport variables that we'll track via our analytics ALLOW_LIST:

  • propertyInformation.action with possible values "Accepted the property type" or "Changed the property type"
  • planningConstraints.action with possible values "Accepted all planning constraints" or "Reported at least one inaccurate planning constraint"
  • _overrides which is only defined if the user has changed the property type or reported inaccurate planning constraints and will include the specific details about what was changed/overrode
    • This data format can also be what we reference in the submissions payload to share override info with officers & back-office systems

Todo:

Testing:

  • Change your property type & override a constraint & confirm your passport is setting _overrides and the .action variables above as you'd expect !

@jessicamcinchak jessicamcinchak changed the title chore: add analytics tracking to capture PlanningConstraint & PropertyInformation "overrides" chore: add analytics tracking to capture PlanningConstraints & PropertyInformation "overrides" Aug 13, 2024
Copy link

github-actions bot commented Aug 13, 2024

Removed vultr server and associated DNS entries

@jessicamcinchak jessicamcinchak marked this pull request as ready for review August 14, 2024 11:59
@jessicamcinchak jessicamcinchak requested a review from a team August 14, 2024 11:59
Copy link
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

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

All looking good!

Tested manually and hit an issue I previously missed - if you remove all constraints you passports ends up with [] as the value for property.constraints.planning. As this is a truthy value it could cause some issues - more accurately this should be undefined (which I think will then get it stripped out by computePassport() and then match a journey of a user who had no constraints).

image

@@ -176,7 +178,13 @@ function Component(props: Props) {
if (data) _constraints.push(data as GISResponse["constraints"]);
}

const _overrides = inaccurateConstraints;
const hasInaccurateConstraints = inaccurateConstraints && Object.keys(inaccurateConstraints).length > 0;
const _overrides = hasInaccurateConstraints ? { ...priorOverrides, [props.fn]: inaccurateConstraints } : undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

An observation / pattern I didn't really notice last time round when inaccurateConstraints were added to this component.

This component has transitioned from being informational only, to now capturing data much like other components. This data is generally captured and validated using formik (unlike the useState() hook here for inaccurateConstraints).

This particular function is essentially handling the "back" behaviour usually managed by getPreviouslySubmittedData().

If / when we come back to handle using formik for the OverrideEntitiesModal instances, it likely makes sense that this state would live at this root component level to match the behaviour of other components as opposed to individual instances within each modal as I think I'd previously suggested.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for noting this here so we have record when coming back; will leave unresolved so stays expanded 👍

@@ -216,7 +216,7 @@ function Component(props: Props) {
_overrides,
"planningConstraints.action": userAction,
_nots: notsAfterOverrides,
...intersectingConstraintsAfterOverrides,
...(intersectingConstraintsAfterOverrides[props.fn]?.length === 0 ? undefined : intersectingConstraintsAfterOverrides),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

Copy link
Member Author

@jessicamcinchak jessicamcinchak Aug 14, 2024

Choose a reason for hiding this comment

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

Good catch with this one, thanks !

Copy link
Member Author

@jessicamcinchak jessicamcinchak Aug 14, 2024

Choose a reason for hiding this comment

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

Sorry @DafyddLlyr - actually second guessing this now - can you please test on this flow https://3510.planx.pizza/opensystemslab/digital-land-api-search-test/preview

When undefined instead of empty array (including for properties with no applicable constraints), then any future questions asking about property.constraints.planning (even if they have "none" / empty option) are NOT going to be automated because the passport doesn't have the key at all / thinks it's seeing it for the first time! I think previous behavior is intended / necessary?

Copy link
Member Author

@jessicamcinchak jessicamcinchak Aug 14, 2024

Choose a reason for hiding this comment

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

Okay sorry full circle here, disregard above comment, was totally my end-of-day confusion 🌀

Agree undefined is consistent with current prod behavior & what we want to keep 👍

Merging this since confident in handleOverrides test coverage and going to carve out some time tmrw morning to write more planning constraints tests for these wiggly/easy to confuse cases 👍

@jessicamcinchak jessicamcinchak merged commit 65c8f29 into main Aug 14, 2024
12 checks passed
@jessicamcinchak jessicamcinchak deleted the jess/planning-constraints-analytics branch August 14, 2024 16:35
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.

2 participants