Skip to content

Commit

Permalink
Merge pull request #378 from nulib/preview/5199-ga-primary-affiliation
Browse files Browse the repository at this point in the history
Add user primary affiliation to data layer.
  • Loading branch information
mathewjordan authored Aug 30, 2024
2 parents f01b829 + 8b7e669 commit 315d2b0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions context/user-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ const UserProvider = ({ children }: { children: ReactNode }) => {
isLoggedIn = false,
isReadingRoom = false,
name,
primaryAffiliation,
sub,
} = result;
setUser({
email,
isLoggedIn,
isReadingRoom,
name,
primaryAffiliation,
sub,
});
});
Expand Down
2 changes: 1 addition & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import Head from "next/head";
import { ObjectLiteral } from "@/types";
import React from "react";
import { SearchProvider } from "@/context/search-context";
import Transition from "@/components/Transition";
import { User } from "@/types/context/user";
import { UserProvider } from "@/context/user-context";
import { defaultOpenGraphData } from "@/lib/open-graph";
Expand Down Expand Up @@ -56,6 +55,7 @@ function MyApp({ Component, pageProps }: MyAppProps) {
...pageProps.dataLayer,
isLoggedIn: user?.isLoggedIn,
isUsingAI: isUsingAI && user?.isLoggedIn,
userPrimaryAffiliation: user?.primaryAffiliation,
};

// "VirtualPageView" is a custom event that we use to track page views.
Expand Down
1 change: 1 addition & 0 deletions types/context/user.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export type User = {
sub: string;
name: string;
primaryAffiliation: string;
email: string;
isLoggedIn: boolean;
isReadingRoom: boolean;
Expand Down

0 comments on commit 315d2b0

Please sign in to comment.