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

Recording interactions with TCF notices #4161

Merged
merged 27 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9739820
First pass
galvana Sep 26, 2023
7865a6a
Hard-coding values for TcfOverlay useConsentServed
galvana Sep 27, 2023
f6e1644
Merge branch 'main' into PROD-914-recording-interactions-with-tcf-not…
galvana Sep 27, 2023
3d20547
Merge branch 'main' into PROD-914-recording-interactions-with-tcf-not…
galvana Sep 28, 2023
66a9966
Making distinction between banner and tcf_banner
galvana Sep 28, 2023
aa36a5e
Merge branch 'main' into PROD-914-recording-interactions-with-tcf-not…
galvana Sep 29, 2023
2f72a39
Removing unused imports
galvana Sep 29, 2023
36c495c
Merge branch 'main' into PROD-914-recording-interactions-with-tcf-not…
galvana Oct 6, 2023
f575144
Fixing merge conflict resolution issues
galvana Oct 6, 2023
101bd42
Adding new TCF mappings
galvana Oct 9, 2023
104ccfd
Fixing typo
galvana Oct 10, 2023
fc63ef8
Served notice cleanup
galvana Oct 10, 2023
157a44d
Merge branch 'main' into PROD-914-recording-interactions-with-tcf-not…
galvana Oct 10, 2023
c3209ba
Updating tests and raising bundle size
galvana Oct 10, 2023
ba83ca6
Updating TCF tests
galvana Oct 12, 2023
28e0335
Merge branch 'main' into PROD-914-recording-interactions-with-tcf-not…
galvana Oct 12, 2023
cc6bc37
Merge branch 'main' into PROD-914-recording-interactions-with-tcf-not…
galvana Oct 12, 2023
b50987c
Merge branch 'main' into PROD-914-recording-interactions-with-tcf-not…
galvana Oct 12, 2023
fa39dae
Merge branch 'main' into PROD-914-recording-interactions-with-tcf-not…
galvana Oct 14, 2023
ec6e6ba
Refactoring updateConsentPreferences call for NoticeOverlay
galvana Oct 14, 2023
e47ae05
Lint fix
galvana Oct 14, 2023
4ccaea3
Additional lint fixes
galvana Oct 14, 2023
11c51a3
Merge branch 'main' into PROD-914-recording-interactions-with-tcf-not…
galvana Oct 25, 2023
cbe77bf
Increasing allowed bundle size
galvana Oct 25, 2023
9a00147
Updating conditions to trigger a notices served API call
galvana Oct 25, 2023
e2775d9
Updating change log
galvana Oct 25, 2023
4c6f008
Merge branch 'main' into PROD-914-recording-interactions-with-tcf-not…
galvana Oct 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The types of changes are:
- Access and erasure support for SparkPost [#4328](https://github.com/ethyca/fides/pull/4238)
- Access and erasure support for Iterate [#4332](https://github.com/ethyca/fides/pull/4332)
- SSH Support for MySQL connections [#4310](https://github.com/ethyca/fides/pull/4310)
- Added served notice history IDs to the TCF privacy preference API calls [#4161](https://github.com/ethyca/fides/pull/4161)

### Fixed
- Cleans up CSS for fidesEmbed mode [#4306](https://github.com/ethyca/fides/pull/4306)
Expand Down
2 changes: 1 addition & 1 deletion clients/fides-js/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import postcss from "rollup-plugin-postcss";

const NAME = "fides";
const IS_DEV = process.env.NODE_ENV === "development";
const GZIP_SIZE_ERROR_KB = 22; // fail build if bundle size exceeds this
const GZIP_SIZE_ERROR_KB = 24; // fail build if bundle size exceeds this
const GZIP_SIZE_WARN_KB = 15; // log a warning if bundle size exceeds this

// TCF
Expand Down
10 changes: 10 additions & 0 deletions clients/fides-js/src/components/ConsentBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { h, FunctionComponent, ComponentChildren, VNode } from "preact";
import { useEffect } from "react";
import { getConsentContext } from "../lib/consent-context";
import { ExperienceConfig } from "../lib/consent-types";
import CloseButton from "./CloseButton";
Expand All @@ -7,6 +8,7 @@ import ExperienceDescription from "./ExperienceDescription";

interface BannerProps {
experience: ExperienceConfig;
onOpen: () => void;
onClose: () => void;
bannerIsOpen: boolean;
/**
Expand All @@ -20,13 +22,21 @@ interface BannerProps {

const ConsentBanner: FunctionComponent<BannerProps> = ({
experience,
onOpen,
onClose,
bannerIsOpen,
children,
onVendorPageClick,
buttonGroup,
}) => {
const showGpcBadge = getConsentContext().globalPrivacyControl;

useEffect(() => {
if (bannerIsOpen) {
onOpen();
}
}, [bannerIsOpen]);

return (
<div
id="fides-banner-container"
Expand Down
21 changes: 4 additions & 17 deletions clients/fides-js/src/components/Overlay.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { h, FunctionComponent, VNode } from "preact";
import { useEffect, useState, useCallback, useMemo } from "preact/hooks";
import {
FidesOptions,
PrivacyExperience,
ServingComponent,
} from "../lib/consent-types";
import { FidesOptions, PrivacyExperience } from "../lib/consent-types";

import { debugLog, hasActionNeededNotices } from "../lib/consent-utils";

Expand All @@ -30,6 +26,7 @@ interface Props {
options: FidesOptions;
experience: PrivacyExperience;
cookie: FidesCookie;
onOpen: () => void;
renderBanner: (props: RenderBannerProps) => VNode | null;
renderModalContent: (props: RenderModalContent) => VNode;
onVendorPageClick?: () => void;
Expand All @@ -39,6 +36,7 @@ const Overlay: FunctionComponent<Props> = ({
experience,
options,
cookie,
onOpen,
renderBanner,
renderModalContent,
onVendorPageClick,
Expand All @@ -63,9 +61,7 @@ const Overlay: FunctionComponent<Props> = ({
const handleOpenModal = useCallback(() => {
if (instance) {
instance.show();
dispatchFidesEvent("FidesUIShown", cookie, options.debug, {
servingComponent: ServingComponent.OVERLAY,
});
onOpen();
}
}, [instance, cookie, options.debug]);

Expand Down Expand Up @@ -122,15 +118,6 @@ const Overlay: FunctionComponent<Props> = ({
[experience, options]
);

useEffect(() => {
const eventCookie = cookie;
if (showBanner && bannerIsOpen) {
dispatchFidesEvent("FidesUIShown", eventCookie, options.debug, {
servingComponent: ServingComponent.BANNER,
});
}
}, [showBanner, cookie, options.debug, bannerIsOpen]);

const handleManagePreferencesClick = (): void => {
handleOpenModal();
setBannerIsOpen(false);
Expand Down
59 changes: 50 additions & 9 deletions clients/fides-js/src/components/notices/NoticeOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { useState, useCallback, useMemo } from "preact/hooks";
import {
ConsentMechanism,
ConsentMethod,
LastServedConsentSchema,
PrivacyNotice,
SaveConsentPreference,
ServingComponent,
} from "../../lib/consent-types";
import ConsentBanner from "../ConsentBanner";

Expand Down Expand Up @@ -59,26 +61,51 @@ const NoticeOverlay: FunctionComponent<OverlayProps> = ({
options,
userGeography: fidesRegionString,
acknowledgeMode: isAllNoticeOnly,
privacyExperienceId: experience.id,
privacyExperience: experience,
});

const createConsentPreferencesToSave = (
privacyNoticeList: PrivacyNotice[],
enabledPrivacyNoticeKeys: string[],
servedNoticeList: LastServedConsentSchema[]
): SaveConsentPreference[] => {
const servedNoticeMap = Object.fromEntries(
servedNoticeList
.filter((notice) => notice.privacy_notice_history?.id !== undefined)
.map((notice) => [
notice.privacy_notice_history?.id,
notice.served_notice_history_id,
])
);

return privacyNoticeList.map((notice) => {
const userPreference = transformConsentToFidesUserPreference(
enabledPrivacyNoticeKeys.includes(notice.notice_key),
notice.consent_mechanism
);
return new SaveConsentPreference(
notice,
userPreference,
servedNoticeMap[notice.privacy_notice_history_id]
);
});
};

const handleUpdatePreferences = useCallback(
(enabledPrivacyNoticeKeys: Array<PrivacyNotice["notice_key"]>) => {
const consentPreferencesToSave = privacyNotices.map((notice) => {
const userPreference = transformConsentToFidesUserPreference(
enabledPrivacyNoticeKeys.includes(notice.notice_key),
notice.consent_mechanism
);
return new SaveConsentPreference(notice, userPreference);
});
const consentPreferencesToSave = createConsentPreferencesToSave(
privacyNotices,
enabledPrivacyNoticeKeys,
servedNotices
);

updateConsentPreferences({
consentPreferencesToSave,
experience,
consentMethod: ConsentMethod.button,
options,
userLocationString: fidesRegionString,
cookie,
servedNotices,
updateCookie: (oldCookie) =>
updateCookieFromNoticePreferences(
oldCookie,
Expand All @@ -104,15 +131,29 @@ const NoticeOverlay: FunctionComponent<OverlayProps> = ({
}
const experienceConfig = experience.experience_config;

const dispatchOpenBannerEvent = () => {
dispatchFidesEvent("FidesUIShown", cookie, options.debug, {
servingComponent: ServingComponent.BANNER,
});
};

const dispatchOpenOverlayEvent = () => {
dispatchFidesEvent("FidesUIShown", cookie, options.debug, {
servingComponent: ServingComponent.OVERLAY,
});
};

return (
<Overlay
options={options}
experience={experience}
cookie={cookie}
onOpen={dispatchOpenOverlayEvent}
renderBanner={({ isOpen, onClose, onSave, onManagePreferencesClick }) =>
showBanner ? (
<ConsentBanner
bannerIsOpen={isOpen}
onOpen={dispatchOpenBannerEvent}
onClose={onClose}
experience={experienceConfig}
buttonGroup={
Expand Down
Loading