Skip to content

Commit

Permalink
Refactor current usage of Amplitude (browser)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadorequest committed Jun 22, 2021
1 parent 8cdeeac commit 2442d2f
Show file tree
Hide file tree
Showing 19 changed files with 275 additions and 178 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy-vercel-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ jobs:
with:
node-version: '14.x' # Use the same node.js version as the one Vercel's uses (currently node14.x)

# Starts a Vercel deployment, using the production configuration file of the default institution
# The default institution is the one defined in the `vercel.json` file (which is a symlink to the actual file)
# Starts a Vercel deployment, using the production configuration file of the default customer
# The default customer is the one defined in the `vercel.json` file (which is a symlink to the actual file)
# N.B: It's Vercel that will perform the actual deployment
start-production-deployment:
name: Starts Vercel deployment (production) (Ubuntu 18.04)
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-vercel-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ jobs:
with:
node-version: '14.x' # Use the same node.js version as the one Vercel's uses (currently node14.x)

# Starts a Vercel deployment, using the staging configuration file of the default institution
# The default institution is the one defined in the `vercel.json` file (which is a symlink to the actual file)
# Starts a Vercel deployment, using the staging configuration file of the default customer
# The default customer is the one defined in the `vercel.json` file (which is a symlink to the actual file)
# N.B: It's Vercel that will perform the actual deployment
start-staging-deployment:
name: Starts Vercel deployment (staging) (Ubuntu 18.04)
Expand Down
9 changes: 7 additions & 2 deletions src/app/components/BrowserPageBootstrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import {
getClientNetworkConnectionType,
getClientNetworkInformationSpeed,
} from '@/modules/core/networkInformation/networkInformation';
import { configureSentryUser } from '@/modules/core/sentry/sentry';
import {
configureSentryBrowserMetadata,
configureSentryUserMetadata,
} from '@/modules/core/sentry/sentry';
import { cypressContext } from '@/modules/core/testing/contexts/cypressContext';
import {
CYPRESS_WINDOW_NS,
Expand Down Expand Up @@ -91,7 +94,9 @@ const BrowserPageBootstrap = (props: BrowserPageBootstrapProps): JSX.Element =>
const networkConnectionType: ClientNetworkConnectionType = getClientNetworkConnectionType();

// Configure Sentry user and track navigation through breadcrumb
configureSentryUser(userSession);
configureSentryUserMetadata(userSession);
configureSentryBrowserMetadata(networkSpeed, networkConnectionType, isInIframe, iframeReferrer);

Sentry.addBreadcrumb({ // See https://docs.sentry.io/enriching-error-data/breadcrumbs
category: fileLabel,
message: `Rendering ${fileLabel}`,
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/ServerPageBootstrap.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MultiversalPageProps } from '@/layouts/core/types/MultiversalPageProps';
import { OnlyServerPageProps } from '@/layouts/core/types/OnlyServerPageProps';
import { createLogger } from '@/modules/core/logging/logger';
import { configureSentryUser } from '@/modules/core/sentry/sentry';
import { configureSentryUserMetadata } from '@/modules/core/sentry/sentry';
import { userSessionContext } from '@/modules/core/userSession/userSessionContext';
import * as Sentry from '@sentry/node';
import React from 'react';
Expand Down Expand Up @@ -35,7 +35,7 @@ const ServerPageBootstrap = (props: ServerPageBootstrapProps): JSX.Element => {
} = pageProps;

// Configure Sentry user and track navigation through breadcrumb
configureSentryUser(userSession);
configureSentryUserMetadata(userSession);
Sentry.addBreadcrumb({ // See https://docs.sentry.io/enriching-error-data/breadcrumbs
category: fileLabel,
message: `Rendering ${fileLabel}`,
Expand Down
13 changes: 10 additions & 3 deletions src/layouts/demo/components/DemoNav.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Tooltip from '@/components/dataDisplay/Tooltip';
import AirtableAsset from '@/modules/core/airtable/components/AirtableAsset';
import { AMPLITUDE_ACTIONS } from '@/modules/core/amplitude/events';
import { LogEvent } from '@/modules/core/amplitude/types/Amplitude';
import { AirtableAttachment } from '@/modules/core/data/types/AirtableAttachment';
import { Asset } from '@/modules/core/data/types/Asset';
Expand Down Expand Up @@ -284,7 +285,9 @@ const DemoNav: React.FunctionComponent<Props> = () => {
target={'_blank'}
rel={'noopener'}
onClick={(): void => {
logEvent('open-github-doc');
logEvent('open-github-doc', {
action: AMPLITUDE_ACTIONS.CLICK,
});
}}
>
<FontAwesomeIcon icon={['fas', 'book']} />
Expand All @@ -307,7 +310,9 @@ const DemoNav: React.FunctionComponent<Props> = () => {
target={'_blank'}
rel={'noopener'}
onClick={(): void => {
logEvent('open-github');
logEvent('open-github', {
action: AMPLITUDE_ACTIONS.CLICK,
});
}}
title={''}
>
Expand Down Expand Up @@ -338,7 +343,9 @@ const DemoNav: React.FunctionComponent<Props> = () => {
target={'_blank'}
rel={'noopener'}
onClick={(): void => {
logEvent('open-admin-site');
logEvent('open-admin-site', {
action: AMPLITUDE_ACTIONS.CLICK,
});
}}
>
<FontAwesomeIcon icon={['fas', 'user-cog']} />
Expand Down
9 changes: 7 additions & 2 deletions src/layouts/demo/components/IntroductionSection.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ExternalLink from '@/components/dataDisplay/ExternalLink';
import { AMPLITUDE_ACTIONS } from '@/modules/core/amplitude/events';
import { LogEvent } from '@/modules/core/amplitude/types/Amplitude';
import I18nLink from '@/modules/core/i18n/components/I18nLink';
import { css } from '@emotion/react';
Expand Down Expand Up @@ -41,14 +42,18 @@ const IntroductionSection: React.FunctionComponent<Props> = (props): JSX.Element

<ExternalLink
href={'https://unlyed.github.io/next-right-now/concepts/presets'}
onClick={(): number => logEvent('open-what-is-preset-doc')}
onClick={(): number => logEvent('open-what-is-preset-doc', {
action: AMPLITUDE_ACTIONS.CLICK,
})}
>
What is a preset?
</ExternalLink>
&nbsp;-&nbsp;
<ExternalLink
href={'https://unlyed.github.io/next-right-now/getting-started/select-preset'}
onClick={(): number => logEvent('open-see-all-presets-doc')}
onClick={(): number => logEvent('open-see-all-presets-doc', {
action: AMPLITUDE_ACTIONS.CLICK,
})}
>
See all presets
</ExternalLink>
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/public/pagePublicTemplateSSG.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
getPublicLayoutStaticPaths,
getPublicLayoutStaticProps,
} from '@/layouts/public/publicLayoutSSG';
import { AMPLITUDE_PAGES } from '@/modules/core/amplitude/amplitude';
import { AMPLITUDE_PAGES } from '@/modules/core/amplitude/events';
import useCustomer from '@/modules/core/data/hooks/useCustomer';
import { Customer } from '@/modules/core/data/types/Customer';
import { createLogger } from '@/modules/core/logging/logger';
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/public/pagePublicTemplateSSR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
getPublicLayoutServerSideProps,
GetPublicLayoutServerSidePropsResults,
} from '@/layouts/public/publicLayoutSSR';
import { AMPLITUDE_PAGES } from '@/modules/core/amplitude/amplitude';
import { AMPLITUDE_PAGES } from '@/modules/core/amplitude/events';
import useCustomer from '@/modules/core/data/hooks/useCustomer';
import { Customer } from '@/modules/core/data/types/Customer';
import { createLogger } from '@/modules/core/logging/logger';
Expand Down
Loading

1 comment on commit 2442d2f

@github-actions
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.