Skip to content

Commit

Permalink
feat: add property.type to analytics allow list answers (#2671)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak authored Jan 17, 2024
1 parent 9abbe36 commit cd66a69
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Operation } from "../sanitiseApplicationData/types";
const ALLOW_LIST = [
"proposal.projectType",
"application.declaration.connection",
"property.type",
];

export const getAnalyzeSessionOperations = (): Operation[] => [
Expand Down
16 changes: 8 additions & 8 deletions editor.planx.uk/src/pages/FlowEditor/lib/analyticsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type AnalyticsLogDirection =
const ALLOW_LIST = [
"proposal.projectType",
"application.declaration.connection",
"property.type",
] as const;

export type HelpClickMetadata = Record<string, string>;
Expand Down Expand Up @@ -108,7 +109,7 @@ export const AnalyticsProvider: React.FC<{ children: React.ReactNode }> = ({

const trackVisibilityChange = () => {
if (shouldSkipTracking()) return;

switch (document.visibilityState) {
case "hidden":
send(
Expand Down Expand Up @@ -287,12 +288,12 @@ export const AnalyticsProvider: React.FC<{ children: React.ReactNode }> = ({
}

function shouldSkipTracking() {
return (!shouldTrackAnalytics || !lastVisibleNodeAnalyticsLogId)
return !shouldTrackAnalytics || !lastVisibleNodeAnalyticsLogId;
}

async function trackHelpClick(metadata?: HelpClickMetadata) {
if (shouldSkipTracking()) return;

await publicClient.mutate({
mutation: gql`
mutation UpdateHasClickedHelp($id: bigint!, $metadata: jsonb = {}) {
Expand All @@ -314,7 +315,7 @@ export const AnalyticsProvider: React.FC<{ children: React.ReactNode }> = ({

async function trackNextStepsLinkClick(metadata?: SelectedUrlsMetadata) {
if (shouldSkipTracking()) return;

await publicClient.mutate({
mutation: gql`
mutation UpdateHasClickNextStepsLink(
Expand All @@ -340,7 +341,7 @@ export const AnalyticsProvider: React.FC<{ children: React.ReactNode }> = ({
flowDirection: AnalyticsLogDirection,
) {
if (shouldSkipTracking()) return;

await publicClient.mutate({
mutation: gql`
mutation UpdateFlowDirection($id: bigint!, $flow_direction: String) {
Expand All @@ -364,7 +365,7 @@ export const AnalyticsProvider: React.FC<{ children: React.ReactNode }> = ({
nodeId?: string,
) {
if (shouldSkipTracking()) return;

const targetNodeMetadata = nodeId ? getTargetNodeDataFromFlow(nodeId) : {};
const metadata: Record<string, NodeMetadata> = {};
metadata[`${initiator}`] = targetNodeMetadata;
Expand Down Expand Up @@ -430,7 +431,6 @@ export const AnalyticsProvider: React.FC<{ children: React.ReactNode }> = ({

async function updateLastVisibleNodeLogWithAllowListAnswers(nodeId: string) {
if (shouldSkipTracking()) return;


const allowListAnswers = getAllowListAnswers(nodeId);
if (!allowListAnswers) return;
Expand Down Expand Up @@ -510,7 +510,7 @@ export const AnalyticsProvider: React.FC<{ children: React.ReactNode }> = ({
*/
async function trackInputErrors(error: string) {
if (shouldSkipTracking()) return;

await publicClient.mutate({
mutation: gql`
mutation TrackInputErrors($id: bigint!, $error: jsonb) {
Expand Down

0 comments on commit cd66a69

Please sign in to comment.