-
Notifications
You must be signed in to change notification settings - Fork 351
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
Add analytics events for browser preview #1984
Add analytics events for browser preview #1984
Conversation
42371f9
to
83eb87f
Compare
export const trackPreviewEpic: Epic<Action, GlobalState> = action$ => { | ||
return action$.ofType(PREVIEW_EVENT).map((action: any) => { | ||
return metricsEvent({ | ||
category: 'preview', | ||
label: action.label, | ||
data: action.data | ||
}) | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding this epic for tracking preview events here so that we can consume them in the existing subscriber in the App and dispatch to segment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this previewDuck module to create redux actions for our preview switch and page load events, containing logic for setting properties of each action
src/browser/modules/App/App.tsx
Outdated
useEffect(() => { | ||
const pageLoadAction = trackPageLoad() | ||
props.bus && props.bus.send(pageLoadAction.type, pageLoadAction) | ||
}, [props.bus, props.telemetrySettings.allowUserStats]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it shouldn't be a problem, but I still worry a little about this effect running extra times and giving us bad stats. I think we could be certain to avoid that if we run dispatch in dbMetaEpics
instead, in the section where the server configuration finishes. There's a comment: // side-effects
where it'd fit well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! I'll take a look
it seems that when dispatching from the dbMetaEpic
, props.telemetrySettings.allowUserStats
in App.tsx is still false :(
I'll see what we can do here
} | ||
|
||
export default withBus( | ||
connect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can just pass null here instead of a placeholder function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that works, thanks
@@ -546,6 +547,12 @@ export const serverConfigEpic = (some$: any, store: any) => | |||
store.dispatch(triggerCredentialsTimeout()) | |||
} | |||
|
|||
setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting that it works even with a timeout of 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed - it's where I start to get a bit iffy with the eventloop/callback queue - but I guess the callback just going to the back of the queue is enough for react's internals to finish and resolve props in the app
Adds a number of events to track page loads and UI switch actions for the browser preview.
When the browser app is loaded, we track a page load event with properties { previewUI: boolean, hasTriedPreviewUI: boolean }
hasTriedPreviewUI
is stored when we first switch to the preview UI.When we use the welcome tile to switch to the preview, we track an additional switched ui event with properties { switchedTo: 'browser' | 'preview'; timeSinceLastSwitch: number }.
We track timeSinceLastSwitch using a timestamp stored in localstorage, which we reset when switching between UIs.