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 onFidesEvent method for an alternative way to subscribe to Fides events #5297

Merged
merged 4 commits into from
Sep 23, 2024

Conversation

guncha
Copy link
Contributor

@guncha guncha commented Sep 18, 2024

Description Of Changes

This PR adds an onFidesEvent method to the global Fides object that subscribes the callback to Fides events. This is equivalent to calling window.addEventListener(...) yourself, except that the callback receives the FidesEventDetail object instead of a CustomEvent. This is needed for the Google Tag Manager template integration as it doesn't allow usage of APIs like addEventListener and also doesn't support CustomEvent or, really, any other non-primitive type.

See this Slack thread for the rationale.

Code Changes

  • Add onFidesEvent method to fides.ts and fides-tcf.ts

Steps to Confirm

  • Load the new fides.js version on a page
  • Make sure Fides.onFidesEvent is available
  • Call it with a handler (e.g. console.log), trigger the event and verify that the handler was called

Pre-Merge Checklist

  • All CI Pipelines Succeeded
  • Update CHANGELOG.md

Copy link

vercel bot commented Sep 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
fides-plus-nightly ⬜️ Ignored (Inspect) Visit Preview Sep 23, 2024 5:48pm

Copy link

cypress bot commented Sep 18, 2024

fides    Run #10059

Run Properties:  status check passed Passed #10059  •  git commit bb3ca1465c ℹ️: Merge a2dace0e50eee92b7fa379d0a0214f5b51790c07 into b4e014f2001d57284659a686651e...
Project fides
Branch Review refs/pull/5297/merge
Run status status check passed Passed #10059
Run duration 00m 38s
Commit git commit bb3ca1465c ℹ️: Merge a2dace0e50eee92b7fa379d0a0214f5b51790c07 into b4e014f2001d57284659a686651e...
Committer Guntars Ašmanis-Graham
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 4
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.
View all changes introduced in this branch ↗︎

@guncha
Copy link
Contributor Author

guncha commented Sep 20, 2024

Btw, there's an issue with typedoc where adding a @returns tag will remove the description so I opted to keep it instead.

Copy link
Contributor

@eastandwestwind eastandwestwind left a comment

Choose a reason for hiding this comment

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

Small change request but nothing blocking. Manually tested this and was able to get the event details surfaced using the new onFidesEvent method.

Thanks @guncha !

clients/fides-js/src/lib/events.ts Show resolved Hide resolved
@guncha guncha merged commit 5b706ea into main Sep 23, 2024
13 checks passed
@guncha guncha deleted the ga-events-api branch September 23, 2024 18:59
Copy link

cypress bot commented Sep 23, 2024

fides    Run #10064

Run Properties:  status check passed Passed #10064  •  git commit 5b706eae82: Add onFidesEvent method for an alternative way to subscribe to Fides events (#52...
Project fides
Branch Review main
Run status status check passed Passed #10064
Run duration 00m 37s
Commit git commit 5b706eae82: Add onFidesEvent method for an alternative way to subscribe to Fides events (#52...
Committer Guntars Ašmanis-Graham
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 4
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.
View all changes introduced in this branch ↗︎

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