@commercetools-frontend/fullstory 2.4.4 → 2.4.5

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.
@@ -66,27 +66,32 @@ function useTrackingEffect() {
66
66
  const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
67
67
  user: context.user,
68
68
  project: context.project,
69
- cloudEnvironment: context.environment.cloudEnvironment
69
+ cloudEnvironment: context.environment.cloudEnvironment,
70
+ organizationId: context.project?.ownerId,
71
+ isProductionProject: context.project?.isProductionProject
70
72
  })),
71
73
  project = _useApplicationContex.project,
72
74
  user = _useApplicationContex.user,
73
- cloudEnvironment = _useApplicationContex.cloudEnvironment;
74
- const getUserRole = () => {
75
- switch (project === null || project === void 0 ? void 0 : project.isUserAdminOfCurrentProject) {
76
- case true:
77
- return 'admin';
78
- case false:
79
- return 'regular';
80
- default:
81
- return 'unknown';
82
- }
83
- };
75
+ cloudEnvironment = _useApplicationContex.cloudEnvironment,
76
+ organizationId = _useApplicationContex.organizationId,
77
+ isProductionProject = _useApplicationContex.isProductionProject;
84
78
  react.useEffect(() => {
79
+ function getUserRole() {
80
+ switch (project?.isUserAdminOfCurrentProject) {
81
+ case true:
82
+ return 'admin';
83
+ case false:
84
+ return 'regular';
85
+ default:
86
+ return 'unknown';
87
+ }
88
+ }
89
+
85
90
  // It's not safe to invoke any FullStory SDK methods.
86
91
  if (!browser.isInitialized() || disable) {
87
92
  return;
88
93
  }
89
- if (!(user !== null && user !== void 0 && user.id)) {
94
+ if (!user?.id) {
90
95
  browser.FullStory('setIdentity', {
91
96
  anonymous: true
92
97
  });
@@ -95,14 +100,16 @@ function useTrackingEffect() {
95
100
  uid: user.id,
96
101
  properties: _objectSpread$1({
97
102
  environment: cloudEnvironment,
98
- projectKey: project === null || project === void 0 ? void 0 : project.key,
103
+ projectKey: project?.key,
104
+ isProductionProject,
105
+ organizationId,
99
106
  userBusinessRole: user.businessRole,
100
107
  userLocale: user.locale,
101
108
  userRole: getUserRole()
102
109
  }, additionalUserVars)
103
110
  });
104
111
  }
105
- }, [disable, additionalUserVars, cloudEnvironment, project === null || project === void 0 ? void 0 : project.key, user === null || user === void 0 ? void 0 : user.businessRole, user === null || user === void 0 ? void 0 : user.id, user === null || user === void 0 ? void 0 : user.locale]);
112
+ }, [disable, additionalUserVars, cloudEnvironment, project?.key, user?.businessRole, user?.id, user?.locale, isProductionProject, organizationId, project?.isUserAdminOfCurrentProject]);
106
113
  return null;
107
114
  }
108
115
 
@@ -66,27 +66,32 @@ function useTrackingEffect() {
66
66
  const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
67
67
  user: context.user,
68
68
  project: context.project,
69
- cloudEnvironment: context.environment.cloudEnvironment
69
+ cloudEnvironment: context.environment.cloudEnvironment,
70
+ organizationId: context.project?.ownerId,
71
+ isProductionProject: context.project?.isProductionProject
70
72
  })),
71
73
  project = _useApplicationContex.project,
72
74
  user = _useApplicationContex.user,
73
- cloudEnvironment = _useApplicationContex.cloudEnvironment;
74
- const getUserRole = () => {
75
- switch (project === null || project === void 0 ? void 0 : project.isUserAdminOfCurrentProject) {
76
- case true:
77
- return 'admin';
78
- case false:
79
- return 'regular';
80
- default:
81
- return 'unknown';
82
- }
83
- };
75
+ cloudEnvironment = _useApplicationContex.cloudEnvironment,
76
+ organizationId = _useApplicationContex.organizationId,
77
+ isProductionProject = _useApplicationContex.isProductionProject;
84
78
  react.useEffect(() => {
79
+ function getUserRole() {
80
+ switch (project?.isUserAdminOfCurrentProject) {
81
+ case true:
82
+ return 'admin';
83
+ case false:
84
+ return 'regular';
85
+ default:
86
+ return 'unknown';
87
+ }
88
+ }
89
+
85
90
  // It's not safe to invoke any FullStory SDK methods.
86
91
  if (!browser.isInitialized() || disable) {
87
92
  return;
88
93
  }
89
- if (!(user !== null && user !== void 0 && user.id)) {
94
+ if (!user?.id) {
90
95
  browser.FullStory('setIdentity', {
91
96
  anonymous: true
92
97
  });
@@ -95,14 +100,16 @@ function useTrackingEffect() {
95
100
  uid: user.id,
96
101
  properties: _objectSpread$1({
97
102
  environment: cloudEnvironment,
98
- projectKey: project === null || project === void 0 ? void 0 : project.key,
103
+ projectKey: project?.key,
104
+ isProductionProject,
105
+ organizationId,
99
106
  userBusinessRole: user.businessRole,
100
107
  userLocale: user.locale,
101
108
  userRole: getUserRole()
102
109
  }, additionalUserVars)
103
110
  });
104
111
  }
105
- }, [disable, additionalUserVars, cloudEnvironment, project === null || project === void 0 ? void 0 : project.key, user === null || user === void 0 ? void 0 : user.businessRole, user === null || user === void 0 ? void 0 : user.id, user === null || user === void 0 ? void 0 : user.locale]);
112
+ }, [disable, additionalUserVars, cloudEnvironment, project?.key, user?.businessRole, user?.id, user?.locale, isProductionProject, organizationId, project?.isUserAdminOfCurrentProject]);
106
113
  return null;
107
114
  }
108
115
 
@@ -51,27 +51,32 @@ function useTrackingEffect() {
51
51
  const _useApplicationContex = useApplicationContext(context => ({
52
52
  user: context.user,
53
53
  project: context.project,
54
- cloudEnvironment: context.environment.cloudEnvironment
54
+ cloudEnvironment: context.environment.cloudEnvironment,
55
+ organizationId: context.project?.ownerId,
56
+ isProductionProject: context.project?.isProductionProject
55
57
  })),
56
58
  project = _useApplicationContex.project,
57
59
  user = _useApplicationContex.user,
58
- cloudEnvironment = _useApplicationContex.cloudEnvironment;
59
- const getUserRole = () => {
60
- switch (project === null || project === void 0 ? void 0 : project.isUserAdminOfCurrentProject) {
61
- case true:
62
- return 'admin';
63
- case false:
64
- return 'regular';
65
- default:
66
- return 'unknown';
67
- }
68
- };
60
+ cloudEnvironment = _useApplicationContex.cloudEnvironment,
61
+ organizationId = _useApplicationContex.organizationId,
62
+ isProductionProject = _useApplicationContex.isProductionProject;
69
63
  useEffect(() => {
64
+ function getUserRole() {
65
+ switch (project?.isUserAdminOfCurrentProject) {
66
+ case true:
67
+ return 'admin';
68
+ case false:
69
+ return 'regular';
70
+ default:
71
+ return 'unknown';
72
+ }
73
+ }
74
+
70
75
  // It's not safe to invoke any FullStory SDK methods.
71
76
  if (!isInitialized() || disable) {
72
77
  return;
73
78
  }
74
- if (!(user !== null && user !== void 0 && user.id)) {
79
+ if (!user?.id) {
75
80
  FullStory('setIdentity', {
76
81
  anonymous: true
77
82
  });
@@ -80,14 +85,16 @@ function useTrackingEffect() {
80
85
  uid: user.id,
81
86
  properties: _objectSpread$1({
82
87
  environment: cloudEnvironment,
83
- projectKey: project === null || project === void 0 ? void 0 : project.key,
88
+ projectKey: project?.key,
89
+ isProductionProject,
90
+ organizationId,
84
91
  userBusinessRole: user.businessRole,
85
92
  userLocale: user.locale,
86
93
  userRole: getUserRole()
87
94
  }, additionalUserVars)
88
95
  });
89
96
  }
90
- }, [disable, additionalUserVars, cloudEnvironment, project === null || project === void 0 ? void 0 : project.key, user === null || user === void 0 ? void 0 : user.businessRole, user === null || user === void 0 ? void 0 : user.id, user === null || user === void 0 ? void 0 : user.locale]);
97
+ }, [disable, additionalUserVars, cloudEnvironment, project?.key, user?.businessRole, user?.id, user?.locale, isProductionProject, organizationId, project?.isUserAdminOfCurrentProject]);
91
98
  return null;
92
99
  }
93
100
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/fullstory",
3
- "version": "2.4.4",
3
+ "version": "2.4.5",
4
4
  "description": "A package integrating with the FullStory SDK",
5
5
  "license": "MIT",
6
6
  "main": "dist/commercetools-frontend-fullstory.cjs.js",
@@ -20,14 +20,14 @@
20
20
  },
21
21
  "devDependencies": {
22
22
  "@apollo/client": "3.7.10",
23
- "@commercetools-frontend/application-shell": "22.29.0",
24
- "@commercetools-frontend/application-shell-connectors": "22.29.0",
25
- "@commercetools-frontend/constants": "22.29.0",
23
+ "@commercetools-frontend/application-shell": "22.30.3",
24
+ "@commercetools-frontend/application-shell-connectors": "22.30.3",
25
+ "@commercetools-frontend/constants": "22.30.3",
26
26
  "@emotion/react": "^11.11.1",
27
27
  "@testing-library/react": "12.1.5",
28
28
  "@testing-library/react-hooks": "8.0.1",
29
29
  "@types/jest": "^29.5.2",
30
- "@types/node": "20.14.9",
30
+ "@types/node": "20.14.14",
31
31
  "@types/react": "17.0.80",
32
32
  "@types/testing-library__jest-dom": "^5.14.6",
33
33
  "graphql": "16.9.0",
@@ -40,8 +40,8 @@
40
40
  "typescript": "5.2.2"
41
41
  },
42
42
  "peerDependencies": {
43
- "@commercetools-frontend/application-shell-connectors": "22.29.0",
44
- "@commercetools-frontend/constants": "22.29.0",
43
+ "@commercetools-frontend/application-shell-connectors": "^22.30.3",
44
+ "@commercetools-frontend/constants": "^22.30.3",
45
45
  "@emotion/react": "11.x",
46
46
  "react": "17.x",
47
47
  "react-intl": "6.x"