@akinon/next 1.21.0-rc.5 → 1.21.0-rc.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.21.0-rc.7
4
+
5
+ ### Minor Changes
6
+
7
+ - 5ace3508: ZERO-2439: Add anonymous tracking page
8
+ - be04d041: ZERO-2452: UA events converted to be compatible with GA4 and types are declared
9
+ - c75e1e45: ZERO-2452: GA4 support for gtm events
10
+
11
+ ## 1.21.0-rc.6
12
+
13
+ ### Minor Changes
14
+
15
+ - b4452e9d: ZERO-2463: Refactor Sentry initialization and add Sentry DSN option to settings
16
+
3
17
  ## 1.21.0-rc.5
4
18
 
5
19
  ### Patch Changes
@@ -1,39 +1,71 @@
1
- #!/usr/bin/env node
2
-
3
1
  const fs = require('fs');
4
2
  const path = require('path');
5
- const rootDir = path.resolve(process.cwd());
6
- const spawn = require('cross-spawn');
7
- const availablePlugins = require('../plugins');
3
+ const { execSync } = require('child_process');
4
+
5
+ function findBaseDir() {
6
+ const insideNodeModules = __dirname.includes('node_modules');
7
+ return insideNodeModules
8
+ ? process.cwd()
9
+ : path.resolve(__dirname, '../../../apps/projectzeronext');
10
+ }
8
11
 
9
- let plugins;
12
+ const BASE_DIR = findBaseDir();
13
+ const getFullPath = (relativePath) => path.join(BASE_DIR, relativePath);
14
+
15
+ const packageJsonPath = getFullPath('package.json');
16
+ let packageJson;
10
17
 
11
18
  try {
12
- plugins = require(path.resolve(rootDir, './src/plugins.js'));
19
+ packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
13
20
  } catch (error) {
14
- console.error('No plugins.js file found, skipping plugin installation.');
15
- process.exit(0);
21
+ console.error('Error reading package.json:', error);
22
+ process.exit(1);
16
23
  }
17
24
 
18
- let installCmd = [];
25
+ const pluginsJsPath = getFullPath('src/plugins.js');
26
+ let installedPlugins;
27
+
28
+ try {
29
+ installedPlugins = require(pluginsJsPath);
30
+ } catch (error) {
31
+ console.error('Error loading installed plugins:', error);
32
+ process.exit(1);
33
+ }
19
34
 
20
- availablePlugins
21
- .filter((p) => plugins?.includes(p))
22
- .forEach((name) => {
23
- installCmd.push(`@akinon/${name}`);
24
- });
35
+ const protectedPackages = ['@akinon/next', 'next'];
25
36
 
26
- spawn.sync('yarn', ['cache clean']);
37
+ const pluginsToRemove = Object.keys(packageJson.dependencies || {}).filter(
38
+ (dep) =>
39
+ dep.startsWith('@akinon/') &&
40
+ !installedPlugins.includes(dep.replace('@akinon/', '')) &&
41
+ !protectedPackages.includes(dep)
42
+ );
27
43
 
28
- for (const plugin of availablePlugins) {
29
- spawn.sync('yarn', ['remove', `@akinon/${plugin}`]);
30
- }
44
+ pluginsToRemove.forEach((plugin) => {
45
+ try {
46
+ execSync(`yarn remove ${plugin}`, { stdio: 'inherit', cwd: BASE_DIR });
47
+ } catch (error) {
48
+ console.warn(
49
+ `Warning: Could not remove ${plugin}. It may not have been installed.`
50
+ );
51
+ }
52
+ });
31
53
 
32
- if (
33
- installCmd.length > 0 &&
34
- !fs.existsSync(path.resolve(rootDir, '../../turbo.json'))
35
- ) {
36
- spawn.sync('yarn', ['add', ...installCmd, '--ignore-scripts'], {
37
- stdio: 'inherit'
38
- });
39
- }
54
+ installedPlugins.forEach((plugin) => {
55
+ const packageName = `@akinon/${plugin}`;
56
+ if (
57
+ !Object.keys(packageJson.dependencies || {}).includes(packageName) &&
58
+ !protectedPackages.includes(packageName)
59
+ ) {
60
+ try {
61
+ const version = packageJson.dependencies['@akinon/next'].replace('^', '');
62
+ const command = `yarn add ${packageName}@${version} --exact --ignore-scripts`;
63
+ execSync(command, { stdio: 'inherit', cwd: BASE_DIR });
64
+ } catch (error) {
65
+ console.warn(
66
+ '\n\x1b[33m%s\x1b[0m',
67
+ `Error adding ${packageName}: ${error}`
68
+ );
69
+ }
70
+ }
71
+ });
@@ -1,6 +1,6 @@
1
1
  import { api } from './api';
2
2
  import { user } from '../urls';
3
- import { ForgotPasswordFormType } from '../../types';
3
+ import { ForgotPasswordFormType, Order } from '../../types';
4
4
  import { buildClientRequestUrl } from '../../utils';
5
5
 
6
6
  interface GetCaptchaResponse {
@@ -84,6 +84,21 @@ const userApi = api.injectEndpoints({
84
84
  contentType: 'application/json'
85
85
  })
86
86
  })
87
+ }),
88
+ getAnonymousTracking: build.mutation<
89
+ Order,
90
+ { email: string; number: string }
91
+ >({
92
+ query: ({ email, number }) => ({
93
+ url: buildClientRequestUrl(user.anonymousOrderTracking, {
94
+ useFormData: true
95
+ }),
96
+ method: 'POST',
97
+ body: {
98
+ email,
99
+ number
100
+ }
101
+ })
87
102
  })
88
103
  }),
89
104
  overrideExisting: false
@@ -95,5 +110,6 @@ export const {
95
110
  useConfirmEmailVerificationQuery,
96
111
  useValidateCaptchaMutation,
97
112
  useLogoutMutation,
98
- useForgotPasswordMutation
113
+ useForgotPasswordMutation,
114
+ useGetAnonymousTrackingMutation
99
115
  } = userApi;
package/data/urls.ts CHANGED
@@ -172,7 +172,8 @@ export const user = {
172
172
  `/users/email-set-primary/${token}/`,
173
173
  confirmEmailVerification: (token: string) =>
174
174
  `/users/registration/account-confirm-email/${token}/`,
175
- csrfToken: '/csrf_token/'
175
+ csrfToken: '/csrf_token/',
176
+ anonymousOrderTracking: '/users/orders/anonymous'
176
177
  };
177
178
 
178
179
  export const b2b = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@akinon/next",
3
3
  "description": "Core package for Project Zero Next",
4
- "version": "1.21.0-rc.5",
4
+ "version": "1.21.0-rc.7",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -32,7 +32,7 @@
32
32
  "@typescript-eslint/eslint-plugin": "6.7.4",
33
33
  "@typescript-eslint/parser": "6.7.4",
34
34
  "eslint": "^8.14.0",
35
- "@akinon/eslint-plugin-projectzero": "1.21.0-rc.5",
35
+ "@akinon/eslint-plugin-projectzero": "1.21.0-rc.7",
36
36
  "eslint-config-prettier": "8.5.0"
37
37
  }
38
38
  }
package/sentry/index.ts CHANGED
@@ -1,27 +1,33 @@
1
1
  import * as Sentry from '@sentry/nextjs';
2
+ import settings from 'settings';
2
3
 
3
4
  const SENTRY_DSN: string =
4
- process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
5
+ settings.sentryDsn ||
6
+ process.env.SENTRY_DSN ||
7
+ process.env.NEXT_PUBLIC_SENTRY_DSN;
5
8
 
6
9
  export const initSentry = (
7
10
  type: 'Server' | 'Client' | 'Edge',
8
- options: Sentry.BrowserOptions | Sentry.NodeOptions | Sentry.EdgeOptions = {}
11
+ options: Sentry.BrowserOptions | Sentry.NodeOptions | Sentry.EdgeOptions = {
12
+ dsn: SENTRY_DSN,
13
+ integrations: [],
14
+ tracesSampleRate: 1.0
15
+ }
9
16
  ) => {
10
- // TODO: Handle options with ESLint rules
11
-
12
- // TODO: Remove Zero Project DSN
13
-
14
- Sentry.init({
15
- dsn:
16
- SENTRY_DSN ||
17
- 'https://d8558ef8997543deacf376c7d8d7cf4b@o64293.ingest.sentry.io/4504338423742464',
17
+ const initOptions = {
18
+ ...options,
18
19
  initialScope: {
19
20
  tags: {
21
+ ...((
22
+ options.initialScope as {
23
+ tags?: Record<string, string>;
24
+ }
25
+ )?.tags ?? {}),
20
26
  APP_TYPE: 'ProjectZeroNext',
21
27
  TYPE: type
22
28
  }
23
- },
24
- tracesSampleRate: 1.0,
25
- integrations: []
26
- });
29
+ }
30
+ };
31
+
32
+ Sentry.init(initOptions);
27
33
  };
package/types/gtm.ts CHANGED
@@ -14,3 +14,51 @@ export interface GTMUserType {
14
14
  gender: string;
15
15
  emailAllowed: boolean;
16
16
  }
17
+
18
+ export interface GA4EventItem {
19
+ item_id: string | number;
20
+ item_name: string | number;
21
+ coupon?: string | number;
22
+ discount?: string | null;
23
+ index?: number;
24
+ item_brand?: string;
25
+ item_category?: string;
26
+ item_category2?: string;
27
+ item_category3?: string;
28
+ item_category4?: string;
29
+ item_category5?: string;
30
+ item_list_id?: string;
31
+ item_list_name?: string;
32
+ item_variant?: string;
33
+ price?: string | number;
34
+ quantity?: number;
35
+ sale_status?: string;
36
+ stock_status?: string;
37
+ discount_percent?: number;
38
+ discount_price?: string;
39
+ product_gender?: string;
40
+ product_size?: string;
41
+ [key: string]: any;
42
+ }
43
+
44
+ export interface GA4EventParams {
45
+ item_list_id?: string;
46
+ item_list_name?: string;
47
+ value?: number;
48
+ currency?: string;
49
+ shipping_tier?: string;
50
+ coupon?: string;
51
+ selected_shipping_option?: string;
52
+ creative_name?: string;
53
+ creative_slot?: string;
54
+ promotion_id?: string;
55
+ promotion_name?: string;
56
+ items?: GA4EventItem[];
57
+ transaction_id?: string;
58
+ tax?: number;
59
+ shipping?: number;
60
+ shipping_country?: string;
61
+ shipping_city?: string;
62
+ payment_method?: string;
63
+ [key: string]: any;
64
+ }
package/types/index.ts CHANGED
@@ -71,6 +71,12 @@ export interface Currency {
71
71
 
72
72
  export interface Settings {
73
73
  commerceUrl: string;
74
+ /**
75
+ * This option allows you to track Sentry events on the client side, in addition to server and edge environments.
76
+ *
77
+ * It overrides process.env.NEXT_PUBLIC_SENTRY_DSN and process.env.SENTRY_DSN.
78
+ */
79
+ sentryDsn?: string;
74
80
  redis: {
75
81
  defaultExpirationTime: number;
76
82
  };