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

Rework product analytics consent #1542

Merged
merged 15 commits into from
Oct 5, 2021

Conversation

OskarDamkjaer
Copy link
Contributor

@OskarDamkjaer OskarDamkjaer commented Oct 1, 2021

This PR reworks our product analytics consent settings, we now coalesce settings from Aura, Desktop, a new setting in neo4j.conf and a new setting in browser to determine if we can send user data and crash reports. To make it clear what setting takes prevalence and be confident that they are followed, I've created the util function usedTelemetrySettingSource.

The browser setting also shows where the to go to change the current settings (if not in browser) and shows a banner on the first five mounts, informing users of the new setting. Have also reached out to PM to get a review to test from the statistics end.

@OskarDamkjaer OskarDamkjaer changed the title Tracking consent Product analytics consent settings Oct 1, 2021
@OskarDamkjaer OskarDamkjaer changed the title Product analytics consent settings Rework product analytics consent Oct 1, 2021
@OskarDamkjaer OskarDamkjaer removed the request for review from oskarhane October 4, 2021 09:47
Copy link
Member

@oskarhane oskarhane left a comment

Choose a reason for hiding this comment

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

Great!
Is there a way to write more tests on this to make sure it's not broken in the future?

Either E2E tests (should be doable to fake an Aura env?), or maybe component tests on the settings sidebar with a fake store.
The :debug output might be useful in the E2E tests.

src/browser/modules/App/App.tsx Outdated Show resolved Hide resolved
Comment on lines 98 to 117
export function App(props: any) {
const [derivedTheme, setEnvironmentTheme] = useDerivedTheme(
props.theme,
LIGHT_THEME
)
// @ts-expect-error ts-migrate(7053) FIXME: No index signature with a parameter of type 'strin... Remove this comment to see the full error message
const themeData = themes[derivedTheme] || themes[LIGHT_THEME]
export class App extends React.Component<any, AppState> {
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason for moving to a class component here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The metrics data event handler is now dependent on the redux state to know if we can send event or not, since it was registered in a useEffect, the handler would need to be unregistered and reregistered on every mount state had changed. At first I wasn't confident that would work well with segment and moved to a class component where the callback reference could be reused, but looking at the final implementation we could have stayed as a function component.

src/browser/modules/App/App.tsx Outdated Show resolved Hide resolved
@@ -256,7 +288,7 @@ export function App(props: any) {
)
}

const mapStateToProps = (state: any) => {
const mapStateToProps = (state: GlobalState) => {
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

@oskarhane oskarhane left a comment

Choose a reason for hiding this comment

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

Looks good. I think you should make the CSS change I suggest below, but other than that 👍

@@ -697,6 +707,7 @@ export const serverConfigEpic = (some$: any, store: any) =>
return Rx.Observable.of(null)
})
})
.do(() => store.dispatch(update({ serverConfigDone: true })))
Copy link
Member

Choose a reason for hiding this comment

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

Not sure I'm a big fan of using this as a one-time thing - because this epic runs at an interval and the value can change between runs.
Using it like this kind of implies that it only runs once.
A name change might be good enough. serverConfigReads: Int maybe to really emphasize that it's a recurring thing?

I'm going to approve this anyway now, but give it a think and change if you want.

Copy link
Member

Choose a reason for hiding this comment

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

This new state opens up for browser to be in a pending state for other areas as well (all other configs just above this) rather than having a local default to fallback on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think serverConfigReads is a better implementation, good idea!

src/browser/modules/Main/styled.tsx Outdated Show resolved Hide resolved
Copy link
Member

@oskarhane oskarhane left a comment

Choose a reason for hiding this comment

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

🐝

@OskarDamkjaer OskarDamkjaer merged commit b6134fa into neo4j:master Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants