* Skip google analytics when ga_tracking_id is nil
This commit involves short-circuiting Google Analytics calls when the
Forem has not configured a `Settings::General.ga_tracking_id`. Note,
depending on your local `.env` file (or configured ENV variables) you
may have a `GA_TRACKING_ID` value set; I did, it was set to "Optional"
which overrode the database setting.
We set the HTML data properites in two places: [admin.html.erb][1] and
[application.html.erb][2].
In addition, I'm short-circuiting the local fallback analytics call (via
[Stacato][https://github.com/tpitale/staccato]). My understanding of
Stacato, based on a cursory read, requires a Google Analytics Tracking
ID to work.
And last, we have a one off of javascript for Google Analytics tracking.
This closes#15962.
[1]:528bd2baa6/app/views/layouts/admin.html.erb (L31)
[2]:528bd2baa6/app/views/layouts/application.html.erb (L55)
How to test?
- Check your .env file to see if you have set GA_TRACKING_ID. If so,
unset it.
- Start with a fresh Forem instance.
- Open your browser and open the developer tools to inspect the Network
activity.
- Open the homepage of your local Forem instance (http://localhost:3000)
- Filter your Network results for analytics. You shouldn't see any.
Also, make sure you're disabling any blockers you might have as that
influences things.
* Commenting out GA_TRACKING_ID
Related to https://github.com/forem/forem/pull/15967
* Favor empty GA_TRACKING_ID env variable
Prior to this commit, we had a couple of references to magic strings
regarding DisplayAdEvent objects. This commit seeks to consolidate that
behavior.
In a handful of cases we had javascript variables, but as these JS files
are `erb` templates, we can inject the constant as well. This reduces
repetition of knowledge.
* wip
* Removed reference to cached_tag_list as the feed enpoint only returns tag_list now.
* Removed reference to cached_properties.
* Updated <CommentsCount /> and <TagList /> to support additinal className
* wip
* wip
* Undid init scrolling for Algolia articles
* Converted homePageFeed.jsx to an ERB template to access Sprockets.
* Now the homePageFeed.jsx files is an ERB so it can load Sprockets assets.
* wip
* Removed accidental commit of debugger statement in ERB.
* Now different feed time frames are loaded based on the homepage feed tab clicked.
* Prevent default Algolia paging when on the homepage.
* Added a tiny comment about feed time frame.
* Now feed loads properly for each time frame on home page.
* prop name refactor.
* Reneabled default Algolia scrolling.
* On the homepage, we no longer overwrite article HTML with Algolia data for initial articles.
* Assumption is the proper URL for main_image of featured article will be sent in the feed.
* Fixed Google Analytics for featured article.
* No longer need the new-feed ID for checking if we're on the homepage.
* Trying to make codeclimate happy.
* wip
* Removed reference to cached_tag_list as the feed enpoint only returns tag_list now.
* Removed reference to cached_properties.
* Updated <CommentsCount /> and <TagList /> to support additinal className
* wip
* wip
* Undid init scrolling for Algolia articles
* Converted homePageFeed.jsx to an ERB template to access Sprockets.
* Now the homePageFeed.jsx files is an ERB so it can load Sprockets assets.
* wip
* Removed accidental commit of debugger statement in ERB.
* Now different feed time frames are loaded based on the homepage feed tab clicked.
* Prevent default Algolia paging when on the homepage.
* Added a tiny comment about feed time frame.
* Now feed loads properly for each time frame on home page.
* prop name refactor.
* Reneabled default Algolia scrolling.
* On the homepage, we no longer overwrite article HTML with Algolia data for initial articles.
* Assumption is the proper URL for main_image of featured article will be sent in the feed.
* Fixed Google Analytics for featured article.
* No longer need the new-feed ID for checking if we're on the homepage.
* Added postcst episodes to <Feed /> state.
* Breaking up Article.jsx to make codeclimate happy.
* wip
* Created the <TodaysPodcastEpisodes /> and <PodcastEpisode /> components.
* Fixed issues with some components that were updated for the <FeaturedArticle />
* Added tests for <FeaturedArticle />
* Barreled up <FeaturedArticle />
* Added Storybook stories for <FeaturedArticle />
* Featured articles don't display org, so removed that test.
* Added proper today's podcasts components to feed.
* Converted some leftover ERB + removed pro checkmark as it doesn't exist yet.
* Now logic is same as master for feed timeframe.
* Updated <FeaturedArticle /> snapshots.
* On frontpage, bookmark button state is managed by Preact components now.
* bookmarkedFeedItems is now a prop on <Feed />.
* Fixed logic check for initializing reading list icons.
* Now <Article /> and <FeaturedArticle /> receive a bookmarkClick prop.
* Removed beginnings of scroll handler in <Feed /> as we're using what's there already for now.
* Removed logic to not show main image on other time frame feeds as it was not correct.
* Fixed issue with 0 rendering when no podcast episodes in feed.
* Converted <SaveButton /> to a stateful component.
* wip - <Feed /> render prop now passes bookmarked feed item ID set and a click event.
* Moved FEED_ICONS to an export so it's easier to use JSX/JS in <Feed />
* Moved <Feed /> into article components.
* Now reading list save buttons work properly in Preact components.
* Fixed issue with Save buttons in Algolia paging/<Feed />
* Updated snapshots.
* Took <Feed /> out of articles barrel file as jest was trying to import FEED_ICONs which is an ERB template.
* Now the Preact feed is dynamically imported.
* Now the Preact <Feed /> only loads for a logged on user.
* Fixed <FeaturedArticle /> so that the save button behaves properly now.
* Updated article stories for Storybook.
* Putting this back to the order it was because I've removed my code changes for this block.
* Fixed when renderFeed is imported for a logged on user.
* Add podcasts to feed and render home from server
* Add padding to feature laoding div
* Update tests
* Add more loading articles
* Fix conflicts
* Add readinglist javascript to initscrolling
* Ensure first article is one with image
* Organize feed items outside of feed instead of in it
Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
Co-authored-by: Josh Puetz <josh@grorichpuetz.com>
* Add HTML variants for cta optimization and other nav bar adjustments
* Fix 1==1 non-random mistake
* Spruce up org call-to-action
* Change default text color
* Add html variant trial and success request specs
* Fix article sidebar caching issue
* One line adjustment
* Modify schema
* Add include ActionView::Helpers::TagHelper to user_tag_spec
* Modify follow_button to remove session context
* Dummy commit
* Change Edit Article to Edit Post
* Dummy commit
* Fix rubocop concerns
* Fix rubocop style
* Modify sample_application.yml and write test
* Add ahrefs verification
* Add some tests around model validations
* Indent an end
* Add a few tests
* Add tests and reserved words
* Fix live articles spec typo
* Modify ga_events_controller
* Add Algolia to search and add Only My Posts filter
* Actually fix Algolia index possible issue
* Fix search issue
* Make minor adjustments to sponsorship sidebar
* Make submission rules headsup html allowed and remove devise trackable
* Remove devise_trackable from application_controller
* Adjust login CTA for /new
* Adjust string in test to reflect changes
* Quick fix for internal navigatioon draft caching issue
* Add ID to internal/articles
* Fix auth with Twitter in two places
* Added comments to algolia and modified design
* Update sidebar styles and make other small adjustments
* Clean up tag styling and other small improvements
* Finalize design adjustments
* Add indexing condition for comments
* Fix Algolia typo
* Fix Algolia indexing on comment