{"version":3,"sources":["webpack://uconn-today-plugin/./src/js/Apollo/cache.js","webpack://uconn-today-plugin/./src/js/Components/ListLoader.jsx","webpack://uconn-today-plugin/./src/js/Apollo/link.js","webpack://uconn-today-plugin/./src/js/Apollo/client.js","webpack://uconn-today-plugin/./src/js/index.js","webpack://uconn-today-plugin/./src/js/utils/analytics.js"],"names":["cache","InMemoryCache","typePolicies","Query","fields","post","_","args","toReference","__typename","id","posts","keyArgs","__","context","variables","categorySlug","number","Array","map","index","key","className","from","HttpLink","uri","fetch","ApolloClient","link","ArticleList","React","app_containers","document","querySelectorAll","App","props","state","client","loaded","this","setState","apolloClient","ApolloProvider","instance","analytics","Suspense","fallback","ListLoader","category","numPosts","columns","Component","forEach","ac","dataset","id_string","render","getElementById","isProdHost","some","substring","window","location","hostname","includes","analyticsConfig","trackingId","anonymizeIp","host","instanceName","plugins","googleAnalytics","Analytics","app","debug","trackPage","tracker","postData","title","uctodayPostData","siteTitle","url","href","path","trackEvent","data","eventName","trackerOpts","label","hasOwnProperty","value"],"mappings":"iKAEaA,EAAQ,I,QAAIC,IAAc,CACrCC,aAAc,CACZC,MAAO,CACLC,OAAQ,CAaNC,KAbM,SAaDC,EAbC,GAayB,IAArBC,EAAqB,EAArBA,KACR,OAAOC,EADsB,EAAfA,aACK,CACjBC,WAAY,OACZC,GAAIH,EAAKG,MAGbC,MAAO,CAWLC,QAAS,SAAEC,EAAIC,GACb,OAAOA,EAAQC,UAAUC,qB,0JCpBrC,IAdmB,SAAC,GAAe,I,EAAbC,EAAa,EAAbA,OACpB,OACE,uBAAKP,GAAG,qB,EAGAQ,MAAMD,G,+lBAASE,KAAI,SAACb,EAAGc,GAAJ,OACnB,uBAAKC,IAAKD,EAAOE,UAAU,2B,4MCEvC,GAPaC,UAAK,CAChB,IAAIC,WAAS,CACXC,IAAK,4CACLC,cCIJ,EALqB,IAAIC,KAAa,CACpCC,OACA5B,Y,2zBCaF,IAAM6B,EAAcC,QAAW,kBAAM,yDAK/BC,EA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gBAAgBC,UAFzB,cAEwCH,EAASC,OAFjD,gBACHjB,OAAOkB,gBAAgBC,UADpB,cACmCH,EAASC,OAE1DF,EAAQ,CACNE,QACAG,IAAKpB,OAAOC,SAASoB,KACrBC,KAAMN,EAASpD,OASN2D,EAAa,SAACR,EAASS,GAClC,IAAMC,EAAa5B,EAAD,gBAEP2B,EAAKC,WAFE,qBACFD,EAAKC,WAWfC,EAAc,CAClBvC,SATgBU,EAAD,qBAED2B,EAAKrC,UAFJ,gBACNqC,EAAKrC,UASdwC,MANa9B,EAAD,qBAEE2B,EAAKG,OAFP,gBACHH,EAAKG,QAQZH,EAAKI,eAAe,WACtBF,EAAYG,MAAQL,EAAKK,OAG3Bd,EAAQU,EAAWC,M","file":"main.js","sourcesContent":["import { InMemoryCache, defaultDataIdFromObject } from '@apollo/client/core';\n\nexport const cache = new InMemoryCache({\n typePolicies: {\n Query: {\n fields: {\n /**\n * \n * We don't want to make a separate request to the server for post data after the initial GET_POSTS request. Rather, we want to return the Post object referenced by the ID passed to the client. This is `post` referenced in the POST_QUERY graphql request. It only exists in the client.\n * \n * See the following link for info on the `toReference` function - https://www.apollographql.com/docs/react/caching/advanced-topics/#cache-redirects-using-field-policy-read-functions\n * \n * @param {*} _ \n * @param object args from the query and the toReference function from apollo\n * \n * @returns Object the post from the apollo cache\n * \n */\n post(_, { args, toReference }) {\n return toReference({\n __typename: 'Post',\n id: args.id\n })\n },\n posts: {\n /**\n * See - https://www.apollographql.com/docs/react/caching/cache-field-behavior/#specifying-key-arguments\n * \n * Needed to assist with pagination and being able to use multiple instances of the shortcode.\n * \n * @param args not used\n * @param object context - includes the variables passed to the query\n * \n * @returns string the category slug\n */\n keyArgs: ( __, context ) => {\n return context.variables.categorySlug\n },\n },\n },\n },\n }\n})","import React from 'react'\n\nconst ListLoader = ({ number }) => {\n return (\n
\n {\n // creates an array of variable length based on the number of articles to expect\n [...Array(number)].map((_, index) => (\n
\n )\n )\n }\n
\n )\n}\n\nexport default ListLoader","import { HttpLink, from } from '@apollo/client'\nimport fetch from 'unfetch'\n\nconst link = from([\n new HttpLink({ \n uri: 'https://today.uconn.edu/wordpress/graphql', \n fetch \n })\n])\n\nexport default link","import { ApolloClient } from '@apollo/client/core'\n\nimport { cache } from './cache'\nimport link from './link'\n\nconst apolloClient = new ApolloClient({\n link,\n cache\n})\n\nexport default apolloClient","// polyfill stuff...\nimport 'core-js/es/object/assign'\nimport 'core-js/es/array/from'\nimport 'core-js/es/array/includes'\nimport 'core-js/es/promise'\nimport 'regenerator-runtime/runtime'\n\nimport React, { Component, Suspense } from 'react'\nimport { render } from 'react-dom'\nimport { ApolloProvider } from '@apollo/client'\nimport { AnalyticsProvider } from 'use-analytics'\n\nimport apolloClient from './Apollo/client'\nimport { analytics } from './utils/analytics'\n\n// creates the JS app styles\nimport '../sass/app-styles.scss'\nimport ListLoader from './Components/ListLoader'\n\n// lazy load the actual list component. this way if it's further down the page, it won't be needed until called\nconst ArticleList = React.lazy(() => import(\n /* webpackChunkName: \"uct-article-list\" */\n './Components/ArticleList'\n))\n\nconst app_containers = document.querySelectorAll('.uctoday-plugin-app-container');\n\nclass App extends Component {\n constructor(props) {\n super(props)\n this.state = {\n client: null,\n loaded: false,\n props: props\n }\n }\n\n componentDidMount() {\n this.setState({\n client: apolloClient,\n loaded: true\n })\n }\n\n render() {\n\n const { client, loaded, props } = this.state\n\n if (!loaded) {\n return \n }\n\n return (\n \n \n }>\n \n \n \n \n )\n }\n}\n\n// support multiple instances of the shortcode being used\napp_containers.forEach(ac => {\n if ( ac.dataset.category ) {\n const id_string = 'uctoday-plugin-app-' + ac.dataset.category;\n if ( !ac.dataset.numPosts ) {\n ac.dataset.numPosts = \"4\";\n }\n render(, document.getElementById(id_string));\n }\n});","// analytics provided by - https://getanalytics.io/\n\nimport Analytics from 'analytics'\nimport googleAnalytics from '@analytics/google-analytics'\n\nconst isProd = process.env.NODE_ENV === 'production' ? true : false\n\nconst debug = !isProd ? true : false\n\nconst nonProdHosts = [\n 'localhost',\n 'dev',\n 'test'\n]\n\nconst isProdHost = nonProdHosts.some(substring => window.location.hostname.includes(substring))\n\n// creates a config for the analytics with the hardcoded value of the UCToday GA container\nconst analyticsConfig = {\n trackingId: 'UA-1427009-15',\n anonymizeIp: true,\n}\n\n// allow multiple analytics configuration for production\n// https://getanalytics.io/plugins/google-analytics/#using-multiple-instances\nif (window.location.host !== 'localhost') {\n analyticsConfig.instanceName = 'uctodayReaderInstance'\n}\n\n\nconst plugins = [\n // send analytics to google\n googleAnalytics(analyticsConfig)\n]\n\nexport const analytics = new Analytics({\n app: 'uct-gql-test',\n debug,\n plugins\n})\n\n/**\n * \n * @param function tracker analytics hook to be used as a closure\n * @param object postData\n */\nexport const trackPage = (tracker, postData = {}) => {\n const title = !isProdHost ?\n `Test: ${window.uctodayPostData.siteTitle} - ${postData.title}` :\n `UCTPlugin: ${window.uctodayPostData.siteTitle} - ${postData.title}`\n tracker({\n title,\n url: window.location.href,\n path: postData.uri\n })\n}\n\n/**\n *\n * @param function tracker analytics hook to be used as a closure\n * @param object event data \n */\nexport const trackEvent = (tracker, data) => {\n const eventName = !isProdHost ?\n `test-event-${data.eventName}` :\n `event-${data.eventName}`\n \n const category = !isProdHost ?\n `Test: ${data.category}` :\n `UCTPlugin: ${data.category}`\n\n const label = !isProdHost ?\n `Test: ${data.label}` :\n `UCTPlugin: ${data.label}`\n\n const trackerOpts = {\n category,\n label,\n }\n\n if (data.hasOwnProperty('value')) {\n trackerOpts.value = data.value\n }\n\n tracker(eventName, trackerOpts)\n}"],"sourceRoot":""}