Skip to content

Commit bec9087

Browse files
authored
Merge pull request #1423 from AppQuality/develop
Improve plans, add supports for upcomings purchasable plans and add a direct link to UserPilot (skipping Segment)
2 parents 2a6545a + b722036 commit bec9087

44 files changed

Lines changed: 1326 additions & 333 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/e2e.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
# run 6 copies of the job in parallel
20-
shard: [1, 2, 3, 4, 5, 6]
19+
# run 8 copies of the job in parallel
20+
shard: [1, 2, 3, 4, 5, 6, 7, 8]
2121

22-
name: "Playwright Tests - pwc"
22+
name: 'Playwright Tests - pwc'
2323
timeout-minutes: 20
2424
runs-on: ubuntu-22.04
2525
container: mcr.microsoft.com/playwright:v1.39.0-jammy
@@ -43,7 +43,16 @@ jobs:
4343

4444
- uses: actions/setup-node@v3
4545
with:
46-
node-version: "18.x"
46+
node-version: '18.x'
47+
48+
- name: Cache node_modules
49+
uses: actions/cache@v3
50+
with:
51+
path: |
52+
node_modules
53+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
54+
restore-keys: |
55+
${{ runner.os }}-yarn-
4756
4857
- name: Install dependencies
4958
run: |

.github/workflows/push.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ jobs:
1313
- uses: actions/checkout@v2
1414
with:
1515
fetch-depth: 0
16+
17+
- name: Cache node_modules
18+
uses: actions/cache@v3
19+
with:
20+
path: |
21+
node_modules
22+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
23+
restore-keys: |
24+
${{ runner.os }}-yarn-
25+
1626
- name: Use Node.js 18.x
1727
uses: actions/setup-node@v2
1828
with:

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
"private": true,
55
"dependencies": {
66
"@analytics/google-tag-manager": "^0.6.0",
7-
"@analytics/segment": "^2.1.0",
87
"@appquality/languages": "1.4.3",
9-
"@appquality/unguess-design-system": "4.0.48",
8+
"@appquality/unguess-design-system": "4.0.49",
109
"@atlaskit/pragmatic-drag-and-drop": "^1.7.4",
1110
"@atlaskit/pragmatic-drag-and-drop-flourish": "^2.0.3",
1211
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
@@ -35,6 +34,7 @@
3534
"ts-node": "^10.9.2",
3635
"typescript": "^4.6.2",
3736
"use-analytics": "^1.1.0",
37+
"userpilot": "^1.4.1",
3838
"uuid": "^10.0.0",
3939
"web-vitals": "^2.1.4",
4040
"yup": "^0.32.11"

src/@types/analytics__segment/index.d.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/analytics.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import Analytics from 'analytics';
21
import googleTagManager from '@analytics/google-tag-manager';
3-
import segmentPlugin from '@analytics/segment';
2+
import Analytics from 'analytics';
3+
import userpilot from './common/analytics-plugins/userpilot';
44
import { isDev } from './common/isDevEnvironment';
55

66
const analytics = Analytics({
77
app: 'unguess-react',
8-
plugins: [
9-
googleTagManager({
10-
containerId: process.env.REACT_APP_GTM_ID || 'GTM-WVXPS94',
11-
...(isDev() && {
12-
auth: 'HjeAxSQB9e685mi-_8YiDw',
13-
preview: 'env-4',
8+
...(process.env.NODE_ENV !== 'test' && {
9+
plugins: [
10+
googleTagManager({
11+
containerId: process.env.REACT_APP_GTM_ID || 'GTM-WVXPS94',
12+
...(isDev() && {
13+
auth: 'HjeAxSQB9e685mi-_8YiDw',
14+
preview: 'env-4',
15+
}),
16+
}),
17+
userpilot({
18+
token: isDev() ? 'STG-NX-54e88e10' : 'NX-54e88e10',
1419
}),
15-
}),
16-
segmentPlugin({
17-
writeKey: isDev()
18-
? 'AxHbacd31w50NwjDM8tadsP82hSwTz4Z'
19-
: 'oxd3W7coKxDdzq99F88doV5VvQrESbJh',
20-
}),
21-
],
20+
],
21+
}),
2222
});
2323

2424
export default analytics;

src/assets/join-loghi.png

-123 KB
Loading

src/assets/join-loghi.webp

-45.4 KB
Loading

src/common/Track.tsx

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,38 @@ import { useGetUsersMeQuery } from 'src/features/api';
55
import { useActiveWorkspace } from 'src/hooks/useActiveWorkspace';
66
import { useAnalytics } from 'use-analytics';
77

8-
// const tagManagerArgs: TagManagerArgs = {
9-
// gtmId: process.env.REACT_APP_GTM_ID || 'GTM-WVXPS94',
10-
// ...(isDev() && {
11-
// auth: 'HjeAxSQB9e685mi-_8YiDw',
12-
// preview: 'env-4',
13-
// }),
14-
// events: {
15-
// unguess_loaded: 'unguess_loaded',
16-
// workspace_change: 'workspace_change',
17-
// generic_error: 'generic_error',
18-
// },
19-
// };
20-
// TagManager.initialize(tagManagerArgs);
21-
228
export const Track = ({
239
title,
10+
description,
11+
metaTags,
2412
children,
2513
}: {
2614
title: string;
15+
description?: string;
16+
metaTags?: { name: string; content: string }[];
2717
children: React.ReactNode;
2818
}) => {
2919
const { data: userData, isLoading, isSuccess } = useGetUsersMeQuery();
3020
const { activeWorkspace } = useActiveWorkspace();
3121
const { track, identify, page } = useAnalytics();
3222
const location = useLocation();
3323

24+
const defaultMeta = [
25+
{ name: 'og:description', content: description ?? title },
26+
{ name: 'robots', content: 'noindex, nofollow' },
27+
];
28+
29+
// Merge metaTags over defaultMeta, overriding by name
30+
const meta: { name: string; content: string }[] = [
31+
...defaultMeta.map((def) => {
32+
const override = metaTags?.find((m) => m.name === def.name);
33+
return override ?? def;
34+
}),
35+
...(metaTags?.filter(
36+
(m) => !defaultMeta.some((def) => def.name === m.name)
37+
) ?? []),
38+
];
39+
3440
useEffect(() => {
3541
page();
3642
}, [location]);
@@ -39,7 +45,10 @@ export const Track = ({
3945
<Helmet>
4046
<title>{title} - UNGUESS</title>
4147
<meta property="og:title" content={title} />
42-
<meta name="description" content={title} />
48+
<meta name="description" content={description ?? title} />
49+
{meta.map((m) => (
50+
<meta key={m.name} name={m.name} content={m.content} />
51+
))}
4352
</Helmet>
4453
);
4554

@@ -53,6 +62,7 @@ export const Track = ({
5362
name: userData.name,
5463
email: userData.email,
5564
company: activeWorkspace.company,
65+
workspace: activeWorkspace,
5666
});
5767

5868
track(
@@ -68,8 +78,8 @@ export const Track = ({
6878
},
6979
{
7080
plugins: {
71-
// disable track event for segment
72-
segment: false,
81+
// disable userpilot for this event
82+
userpilot: false,
7383
},
7484
}
7585
);
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { User } from 'src/features/api';
2+
import { Userpilot } from 'userpilot';
3+
4+
declare global {
5+
interface Window {
6+
userpilot?: {
7+
initialized: number;
8+
};
9+
}
10+
}
11+
12+
interface UserpilotConfig {
13+
token: string;
14+
name?: string;
15+
}
16+
17+
interface IPayload {
18+
type: string;
19+
userId: string;
20+
}
21+
22+
interface IIdentifyPayload extends IPayload {
23+
traits: User & { workspace: { id: number; company: string } };
24+
}
25+
26+
export default function userpilotPlugin(pluginSettings: UserpilotConfig) {
27+
return {
28+
name: 'userpilot',
29+
config: { ...pluginSettings },
30+
initialize: ({ config }: { config: UserpilotConfig }) => {
31+
Userpilot.initialize(config.token);
32+
},
33+
identify: ({ payload }: { payload: IIdentifyPayload }) => {
34+
const { userId, traits } = payload;
35+
const { workspace, ...basicTraits } = traits;
36+
37+
Userpilot.identify(userId, {
38+
...basicTraits,
39+
company: {
40+
id: workspace.id,
41+
name: workspace.company,
42+
},
43+
});
44+
},
45+
46+
page: () => {
47+
Userpilot.reload();
48+
},
49+
50+
track: ({
51+
payload,
52+
}: {
53+
payload: IPayload & { event: string; properties: Record<string, any> };
54+
}) => {
55+
const { event, properties, userId } = payload;
56+
Userpilot.track(event, { ...properties, userId });
57+
},
58+
59+
loaded: () => !!window.userpilot,
60+
};
61+
}

0 commit comments

Comments
 (0)