Skip to content

Commit 3154748

Browse files
authored
Merge pull request #2411 from novuhq/segment-events-consolidation
feat: add segment events for onboarding
2 parents 4eb71bd + 2c5057e commit 3154748

File tree

18 files changed

+1516
-193
lines changed

18 files changed

+1516
-193
lines changed

.github/workflows/dev-deploy-web.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ jobs:
6969
echo REACT_APP_WS_URL="https://dev.ws.novu.co" >> .env
7070
echo REACT_APP_WIDGET_EMBED_PATH="https://dev.embed.novu.co/embed.umd.min.js" >> .env
7171
echo REACT_APP_NOVU_APP_ID=${{ secrets.NOVU_APP_ID }} >> .env
72+
echo REACT_APP_SEGMENT_KEY=${{ secrets.WEB_SEGMENT_KEY }} >> .env
7273
echo REACT_APP_SENTRY_DSN="https://[email protected]/6250907" >> .env
7374
echo REACT_APP_ENVIRONMENT=dev >> .env
7475
@@ -79,6 +80,7 @@ jobs:
7980
# Runs a single command using the runners shell
8081
- name: Build
8182
env:
83+
REACT_APP_SEGMENT_KEY: ${{ secrets.WEB_SEGMENT_KEY }}
8284
REACT_APP_INTERCOM_APP_ID: ${{ secrets.INTERCOM_APP_ID }}
8385
REACT_APP_API_URL: https://dev.api.novu.co
8486
REACT_APP_WS_URL: https://dev.ws.novu.co

.github/workflows/prod-deploy-web.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ jobs:
7070
echo REACT_APP_NOVU_APP_ID=${{ secrets.NOVU_APP_ID }} >> .env
7171
echo REACT_APP_SENTRY_DSN="https://[email protected]/6250907" >> .env
7272
echo REACT_APP_ENVIRONMENT=prod >> .env
73+
echo REACT_APP_SEGMENT_KEY=${{ secrets.WEB_SEGMENT_KEY }} >> .env
7374
7475
- name: Envsetup
7576
working-directory: apps/web
@@ -78,6 +79,7 @@ jobs:
7879
- name: Build
7980
env:
8081
REACT_APP_INTERCOM_APP_ID: ${{ secrets.INTERCOM_APP_ID }}
82+
REACT_APP_SEGMENT_KEY: ${{ secrets.WEB_SEGMENT_KEY }}
8183
REACT_APP_API_URL: https://api.novu.co
8284
REACT_APP_WS_URL: https://ws.novu.co
8385
REACT_APP_WIDGET_EMBED_PATH: https://embed.novu.co/embed.umd.min.js

apps/web/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ REACT_APP_ENVIRONMENT=dev
55
GLOBAL_CONTEXT_PATH=
66
WEB_CONTEXT_PATH=
77
REACT_APP_INTERCOM_APP_ID=intercom
8+
REACT_APP_SEGMENT_KEY=

apps/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"@mantine/spotlight": "^5.7.1",
4646
"@novu/notification-center": "^0.10.0",
4747
"@novu/shared": "^0.10.0",
48+
"@segment/analytics-next": "^1.48.0",
4849
"@sentry/react": "^6.3.1",
4950
"@sentry/tracing": "^6.3.1",
5051
"@storybook/addon-docs": "^6.4.19",

apps/web/src/App.tsx

Lines changed: 147 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { TemplateFormProvider } from './components/templates/TemplateFormProvide
3333
import { SpotLight } from './components/utils/Spotlight';
3434
import { SpotlightContext, SpotlightItem } from './store/spotlightContext';
3535
import { LinkVercelProjectPage } from './pages/partner-integrations/LinkVercelProjectPage';
36+
import { SegmentProvider } from './store/segment.context';
3637

3738
if (SENTRY_DSN) {
3839
Sentry.init({
@@ -68,162 +69,164 @@ applyToken(tokenStoredToken);
6869

6970
function App() {
7071
return (
71-
<HelmetProvider>
72-
<BrowserRouter basename={CONTEXT_PATH}>
73-
<QueryClientProvider client={queryClient}>
74-
<AuthHandlerComponent>
75-
<ThemeHandlerComponent>
76-
<SpotLightProvider>
77-
<Routes>
78-
<Route path="/auth/signup" element={<SignUpPage />} />
79-
<Route path="/auth/login" element={<LoginPage />} />
80-
<Route path="/auth/reset/request" element={<PasswordResetPage />} />
81-
<Route path="/auth/reset/:token" element={<PasswordResetPage />} />
82-
<Route path="/auth/invitation/:token" element={<InvitationPage />} />
83-
<Route path="/auth/application" element={<CreateOrganizationPage />} />
84-
<Route
85-
path="/partner-integrations/vercel/link-projects"
86-
element={
87-
<RequiredAuth>
88-
<LinkVercelProjectPage type="create" />
89-
</RequiredAuth>
90-
}
91-
/>
92-
<Route
93-
path="/partner-integrations/vercel/link-projects/edit"
94-
element={
95-
<RequiredAuth>
96-
<LinkVercelProjectPage type="edit" />
97-
</RequiredAuth>
98-
}
99-
/>
100-
<Route element={<AppLayout />}>
72+
<SegmentProvider>
73+
<HelmetProvider>
74+
<BrowserRouter basename={CONTEXT_PATH}>
75+
<QueryClientProvider client={queryClient}>
76+
<AuthHandlerComponent>
77+
<ThemeHandlerComponent>
78+
<SpotLightProvider>
79+
<Routes>
80+
<Route path="/auth/signup" element={<SignUpPage />} />
81+
<Route path="/auth/login" element={<LoginPage />} />
82+
<Route path="/auth/reset/request" element={<PasswordResetPage />} />
83+
<Route path="/auth/reset/:token" element={<PasswordResetPage />} />
84+
<Route path="/auth/invitation/:token" element={<InvitationPage />} />
85+
<Route path="/auth/application" element={<CreateOrganizationPage />} />
10186
<Route
102-
path="/*"
87+
path="/partner-integrations/vercel/link-projects"
10388
element={
10489
<RequiredAuth>
105-
<SpotLight>
106-
<HomePage />
107-
</SpotLight>
90+
<LinkVercelProjectPage type="create" />
10891
</RequiredAuth>
10992
}
11093
/>
11194
<Route
112-
path="/templates/create"
95+
path="/partner-integrations/vercel/link-projects/edit"
11396
element={
11497
<RequiredAuth>
115-
<TemplateFormProvider>
116-
<TemplateEditorProvider>
117-
<SpotLight>
118-
<TemplateEditorPage />
119-
</SpotLight>
120-
</TemplateEditorProvider>
121-
</TemplateFormProvider>
98+
<LinkVercelProjectPage type="edit" />
12299
</RequiredAuth>
123100
}
124101
/>
125-
<Route
126-
path="/templates/edit/:templateId"
127-
element={
128-
<RequiredAuth>
129-
<TemplateFormProvider>
130-
<TemplateEditorProvider>
131-
<SpotLight>
132-
<TemplateEditorPage />
133-
</SpotLight>
134-
</TemplateEditorProvider>
135-
</TemplateFormProvider>
136-
</RequiredAuth>
137-
}
138-
/>
139-
<Route
140-
path="/templates"
141-
element={
142-
<RequiredAuth>
143-
<SpotLight>
144-
<NotificationList />
145-
</SpotLight>
146-
</RequiredAuth>
147-
}
148-
/>
149-
<Route
150-
path="/quickstart"
151-
element={
152-
<RequiredAuth>
153-
<SpotLight>
154-
<QuickStartPage />
155-
</SpotLight>
156-
</RequiredAuth>
157-
}
158-
/>
159-
<Route
160-
path="/activities"
161-
element={
162-
<RequiredAuth>
163-
<SpotLight>
164-
<ActivitiesPage />
165-
</SpotLight>
166-
</RequiredAuth>
167-
}
168-
/>
169-
<Route
170-
path="/settings"
171-
element={
172-
<RequiredAuth>
173-
<SpotLight>
174-
<SettingsPage />
175-
</SpotLight>
176-
</RequiredAuth>
177-
}
178-
/>
179-
<Route
180-
path="/integrations"
181-
element={
182-
<RequiredAuth>
183-
<SpotLight>
184-
<IntegrationsStore />
185-
</SpotLight>
186-
</RequiredAuth>
187-
}
188-
/>
189-
<Route
190-
path="/team"
191-
element={
192-
<RequiredAuth>
193-
<SpotLight>
194-
<MembersInvitePage />
195-
</SpotLight>
196-
</RequiredAuth>
197-
}
198-
/>
199-
<Route
200-
path="/changes"
201-
element={
202-
<RequiredAuth>
203-
<SpotLight>
204-
<PromoteChangesPage />
205-
</SpotLight>
206-
</RequiredAuth>
207-
}
208-
/>
209-
<Route
210-
path="/subscribers"
211-
element={
212-
<RequiredAuth>
213-
<SpotLight>
214-
<SubscribersList />
215-
</SpotLight>
216-
</RequiredAuth>
217-
}
218-
/>
219-
</Route>
220-
</Routes>
221-
</SpotLightProvider>
222-
</ThemeHandlerComponent>
223-
</AuthHandlerComponent>
224-
</QueryClientProvider>
225-
</BrowserRouter>
226-
</HelmetProvider>
102+
<Route element={<AppLayout />}>
103+
<Route
104+
path="/*"
105+
element={
106+
<RequiredAuth>
107+
<SpotLight>
108+
<HomePage />
109+
</SpotLight>
110+
</RequiredAuth>
111+
}
112+
/>
113+
<Route
114+
path="/templates/create"
115+
element={
116+
<RequiredAuth>
117+
<TemplateFormProvider>
118+
<TemplateEditorProvider>
119+
<SpotLight>
120+
<TemplateEditorPage />
121+
</SpotLight>
122+
</TemplateEditorProvider>
123+
</TemplateFormProvider>
124+
</RequiredAuth>
125+
}
126+
/>
127+
<Route
128+
path="/templates/edit/:templateId"
129+
element={
130+
<RequiredAuth>
131+
<TemplateFormProvider>
132+
<TemplateEditorProvider>
133+
<SpotLight>
134+
<TemplateEditorPage />
135+
</SpotLight>
136+
</TemplateEditorProvider>
137+
</TemplateFormProvider>
138+
</RequiredAuth>
139+
}
140+
/>
141+
<Route
142+
path="/templates"
143+
element={
144+
<RequiredAuth>
145+
<SpotLight>
146+
<NotificationList />
147+
</SpotLight>
148+
</RequiredAuth>
149+
}
150+
/>
151+
<Route
152+
path="/quickstart"
153+
element={
154+
<RequiredAuth>
155+
<SpotLight>
156+
<QuickStartPage />
157+
</SpotLight>
158+
</RequiredAuth>
159+
}
160+
/>
161+
<Route
162+
path="/activities"
163+
element={
164+
<RequiredAuth>
165+
<SpotLight>
166+
<ActivitiesPage />
167+
</SpotLight>
168+
</RequiredAuth>
169+
}
170+
/>
171+
<Route
172+
path="/settings"
173+
element={
174+
<RequiredAuth>
175+
<SpotLight>
176+
<SettingsPage />
177+
</SpotLight>
178+
</RequiredAuth>
179+
}
180+
/>
181+
<Route
182+
path="/integrations"
183+
element={
184+
<RequiredAuth>
185+
<SpotLight>
186+
<IntegrationsStore />
187+
</SpotLight>
188+
</RequiredAuth>
189+
}
190+
/>
191+
<Route
192+
path="/team"
193+
element={
194+
<RequiredAuth>
195+
<SpotLight>
196+
<MembersInvitePage />
197+
</SpotLight>
198+
</RequiredAuth>
199+
}
200+
/>
201+
<Route
202+
path="/changes"
203+
element={
204+
<RequiredAuth>
205+
<SpotLight>
206+
<PromoteChangesPage />
207+
</SpotLight>
208+
</RequiredAuth>
209+
}
210+
/>
211+
<Route
212+
path="/subscribers"
213+
element={
214+
<RequiredAuth>
215+
<SpotLight>
216+
<SubscribersList />
217+
</SpotLight>
218+
</RequiredAuth>
219+
}
220+
/>
221+
</Route>
222+
</Routes>
223+
</SpotLightProvider>
224+
</ThemeHandlerComponent>
225+
</AuthHandlerComponent>
226+
</QueryClientProvider>
227+
</BrowserRouter>
228+
</HelmetProvider>
229+
</SegmentProvider>
227230
);
228231
}
229232

apps/web/src/hooks/use-segment.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
import { SegmentContext } from '../store/segment.context';
3+
4+
export const useSegment = () => {
5+
const result = React.useContext(SegmentContext);
6+
if (!result) {
7+
throw new Error('Context used outside of its Provider!');
8+
}
9+
10+
return result;
11+
};

0 commit comments

Comments
 (0)