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

feat(frontend): integrate config settings with API #2108

Merged
merged 7 commits into from
Mar 10, 2023

Conversation

jorgeepc
Copy link
Contributor

@jorgeepc jorgeepc commented Mar 3, 2023

This PR integrates analytics (config) settings with the resources API.

Changes

  • Integrate web UI with resources API
  • Consume analyticsEnabled flag from API to trigger web events

Fixes

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

@jorgeepc jorgeepc self-assigned this Mar 3, 2023
@jorgeepc jorgeepc force-pushed the 2100-integrate-config-api branch 2 times, most recently from 1cadfdf to 44849b7 Compare March 7, 2023 21:11
@@ -0,0 +1,30 @@
import {EResourceType, TListResponse, TResource} from 'types/Settings.types';

export type TRawConfig = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should replace these types with the OpenAPI generated types

@jorgeepc jorgeepc marked this pull request as ready for review March 7, 2023 21:46
@jorgeepc jorgeepc requested a review from xoscar March 7, 2023 21:46
@jorgeepc jorgeepc force-pushed the 2100-integrate-config-api branch from 44849b7 to 8599ba3 Compare March 8, 2023 15:50
Copy link
Contributor

@xoscar xoscar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean job dude! I left a quick non-blocking question 😄

// Config
const {data: config = Config()} = useGetConfigQuery({});

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, but let's make sure we don't forget this provider and this side effect is the one handling the analytics switch

analytics.load(window.ENV.measurementId);
}}();
}
!function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}analytics.load=function(key,e){var t=document.createElement("script");t.type="text/javascript";t.async=!0;t.src="https://cdn.segment.com/analytics.js/v1/" + key + "/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n);analytics._loadOptions=e};analytics._writeKey="X2vwYODI1vb8g6QpzL9OBxuv5vK7dGan";analytics.SNIPPET_VERSION="4.15.3";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QQ do we know for sure that by just loading the script we are not sending any telemetry data?

I want to clarify if the user updates the flag but still after a refresh this scripts sends something we don't want/expect

Copy link
Contributor

@xoscar xoscar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job doing the analytics lib changes dude!

@jorgeepc jorgeepc merged commit 6389d60 into main Mar 10, 2023
@jorgeepc jorgeepc deleted the 2100-integrate-config-api branch March 10, 2023 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants