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

Add ability to enable only form_change, or form_submit, focus_form or any combination (close #371) #1065

Merged
merged 3 commits into from
Mar 23, 2022

Conversation

matus-tomlein
Copy link
Contributor

Issue #371

This PR adds ability to configure which of the three types of form events to track. It adds an option to the enableFormTracking call to list the events to be tracked.

API

enableFormTracking({
    options: {
        events: ['submit_form', 'focus_form', 'change_form']
    },
});

The events option is optional and, if not present, all three events are tracked.

Docs

Here is a PR in data-value-resources repo for the documentation changes.

Implementation

The list of subscribed events is checked in addFormListeners before adding event listeners to form fields (for focus and change) and the form (for submit).

I added an end-to-end test that checks that change events are not tracked if not subscribed to.

Also tried it out in a demo ReactJS app, but that's not part of this PR.

@snowplowcla
Copy link

Thanks for your pull request. Is this your first contribution to a Snowplow open source project? Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://docs.snowplowanalytics.com/docs/contributing/contributor-license-agreement/ to learn more and sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.

@snowplowcla snowplowcla added the cla:no [Auto generated] Snowplow Contributor License Agreement has not been signed. label Mar 15, 2022
Copy link
Contributor

@greg-el greg-el left a comment

Choose a reason for hiding this comment

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

LGTM! Tiny nitpick about the test description, but the code seems fine to me.

@@ -795,4 +804,36 @@ describe('Auto tracking', () => {
})
).toBe(false);
});

it('should only track focus_form and not change_form events events when focus_form events are filtered', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: duplicate 'events' in the test desc:
change_form events events when focus_form

@matus-tomlein matus-tomlein force-pushed the issue/371-form_tracking_configuration branch from 6af9daa to d4c84e5 Compare March 23, 2022 13:52
@matus-tomlein matus-tomlein merged commit 71eb444 into release/3.4.0 Mar 23, 2022
@matus-tomlein matus-tomlein deleted the issue/371-form_tracking_configuration branch March 23, 2022 14:16
matus-tomlein added a commit that referenced this pull request Mar 25, 2022
matus-tomlein added a commit that referenced this pull request Mar 29, 2022
matus-tomlein added a commit that referenced this pull request Apr 7, 2022
matus-tomlein added a commit that referenced this pull request Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:no [Auto generated] Snowplow Contributor License Agreement has not been signed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants