@commercetools-frontend/fullstory 2.5.4 → 3.0.0

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.
@@ -13,7 +13,6 @@ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/ob
13
13
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
14
14
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
15
15
  var react = require('react');
16
- var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
17
16
  var jsxRuntime = require('@emotion/react/jsx-runtime');
18
17
  var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
19
18
 
@@ -57,28 +56,19 @@ function initialize() {
57
56
  function ownKeys$1(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
58
57
  function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$1(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
59
58
  const defaultTrackingArgs = {
59
+ properties: {},
60
60
  disable: false,
61
61
  additionalUserVars: undefined
62
62
  };
63
63
  function useTrackingEffect() {
64
64
  let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultTrackingArgs,
65
+ properties = _ref.properties,
65
66
  disable = _ref.disable,
66
67
  additionalUserVars = _ref.additionalUserVars;
67
- const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
68
- user: context.user,
69
- project: context.project,
70
- cloudEnvironment: context.environment.cloudEnvironment,
71
- organizationId: context.project?.ownerId,
72
- isProductionProject: context.project?.isProductionProject
73
- })),
74
- project = _useApplicationContex.project,
75
- user = _useApplicationContex.user,
76
- cloudEnvironment = _useApplicationContex.cloudEnvironment,
77
- organizationId = _useApplicationContex.organizationId,
78
- isProductionProject = _useApplicationContex.isProductionProject;
79
68
  react.useEffect(() => {
69
+ // These values are related to segmenting users in the FS dashboard
80
70
  function getUserRole() {
81
- switch (project?.isUserAdminOfCurrentProject) {
71
+ switch (properties.isUserAdminOfCurrentProject) {
82
72
  case true:
83
73
  return 'admin';
84
74
  case false:
@@ -92,25 +82,19 @@ function useTrackingEffect() {
92
82
  if (!browser.isInitialized() || disable) {
93
83
  return;
94
84
  }
95
- if (!user?.id) {
85
+ if (!properties.userId) {
96
86
  browser.FullStory('setIdentity', {
97
87
  anonymous: true
98
88
  });
99
89
  } else {
100
90
  browser.FullStory('setIdentity', {
101
- uid: user.id,
102
- properties: _objectSpread$1({
103
- environment: cloudEnvironment,
104
- projectKey: project?.key,
105
- isProductionProject,
106
- organizationId,
107
- userBusinessRole: user.businessRole,
108
- userLocale: user.locale,
91
+ uid: properties.userId,
92
+ properties: _objectSpread$1(_objectSpread$1({}, properties), {}, {
109
93
  userRole: getUserRole()
110
94
  }, additionalUserVars)
111
95
  });
112
96
  }
113
- }, [disable, additionalUserVars, cloudEnvironment, project?.key, user?.businessRole, user?.id, user?.locale, isProductionProject, organizationId, project?.isUserAdminOfCurrentProject]);
97
+ }, [disable, additionalUserVars, properties]);
114
98
  return null;
115
99
  }
116
100
 
@@ -13,7 +13,6 @@ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/ob
13
13
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
14
14
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
15
15
  var react = require('react');
16
- var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
17
16
  var jsxRuntime = require('@emotion/react/jsx-runtime');
18
17
  var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
19
18
 
@@ -57,28 +56,19 @@ function initialize() {
57
56
  function ownKeys$1(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
58
57
  function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$1(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
59
58
  const defaultTrackingArgs = {
59
+ properties: {},
60
60
  disable: false,
61
61
  additionalUserVars: undefined
62
62
  };
63
63
  function useTrackingEffect() {
64
64
  let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultTrackingArgs,
65
+ properties = _ref.properties,
65
66
  disable = _ref.disable,
66
67
  additionalUserVars = _ref.additionalUserVars;
67
- const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
68
- user: context.user,
69
- project: context.project,
70
- cloudEnvironment: context.environment.cloudEnvironment,
71
- organizationId: context.project?.ownerId,
72
- isProductionProject: context.project?.isProductionProject
73
- })),
74
- project = _useApplicationContex.project,
75
- user = _useApplicationContex.user,
76
- cloudEnvironment = _useApplicationContex.cloudEnvironment,
77
- organizationId = _useApplicationContex.organizationId,
78
- isProductionProject = _useApplicationContex.isProductionProject;
79
68
  react.useEffect(() => {
69
+ // These values are related to segmenting users in the FS dashboard
80
70
  function getUserRole() {
81
- switch (project?.isUserAdminOfCurrentProject) {
71
+ switch (properties.isUserAdminOfCurrentProject) {
82
72
  case true:
83
73
  return 'admin';
84
74
  case false:
@@ -92,25 +82,19 @@ function useTrackingEffect() {
92
82
  if (!browser.isInitialized() || disable) {
93
83
  return;
94
84
  }
95
- if (!user?.id) {
85
+ if (!properties.userId) {
96
86
  browser.FullStory('setIdentity', {
97
87
  anonymous: true
98
88
  });
99
89
  } else {
100
90
  browser.FullStory('setIdentity', {
101
- uid: user.id,
102
- properties: _objectSpread$1({
103
- environment: cloudEnvironment,
104
- projectKey: project?.key,
105
- isProductionProject,
106
- organizationId,
107
- userBusinessRole: user.businessRole,
108
- userLocale: user.locale,
91
+ uid: properties.userId,
92
+ properties: _objectSpread$1(_objectSpread$1({}, properties), {}, {
109
93
  userRole: getUserRole()
110
94
  }, additionalUserVars)
111
95
  });
112
96
  }
113
- }, [disable, additionalUserVars, cloudEnvironment, project?.key, user?.businessRole, user?.id, user?.locale, isProductionProject, organizationId, project?.isUserAdminOfCurrentProject]);
97
+ }, [disable, additionalUserVars, properties]);
114
98
  return null;
115
99
  }
116
100
 
@@ -9,7 +9,6 @@ import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/obje
9
9
  import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
10
10
  import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
11
11
  import { useEffect } from 'react';
12
- import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors';
13
12
  import { jsx } from '@emotion/react/jsx-runtime';
14
13
  import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/esm/objectWithoutProperties';
15
14
 
@@ -42,28 +41,19 @@ function initialize() {
42
41
  function ownKeys$1(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
43
42
  function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$1(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$1(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
44
43
  const defaultTrackingArgs = {
44
+ properties: {},
45
45
  disable: false,
46
46
  additionalUserVars: undefined
47
47
  };
48
48
  function useTrackingEffect() {
49
49
  let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultTrackingArgs,
50
+ properties = _ref.properties,
50
51
  disable = _ref.disable,
51
52
  additionalUserVars = _ref.additionalUserVars;
52
- const _useApplicationContex = useApplicationContext(context => ({
53
- user: context.user,
54
- project: context.project,
55
- cloudEnvironment: context.environment.cloudEnvironment,
56
- organizationId: context.project?.ownerId,
57
- isProductionProject: context.project?.isProductionProject
58
- })),
59
- project = _useApplicationContex.project,
60
- user = _useApplicationContex.user,
61
- cloudEnvironment = _useApplicationContex.cloudEnvironment,
62
- organizationId = _useApplicationContex.organizationId,
63
- isProductionProject = _useApplicationContex.isProductionProject;
64
53
  useEffect(() => {
54
+ // These values are related to segmenting users in the FS dashboard
65
55
  function getUserRole() {
66
- switch (project?.isUserAdminOfCurrentProject) {
56
+ switch (properties.isUserAdminOfCurrentProject) {
67
57
  case true:
68
58
  return 'admin';
69
59
  case false:
@@ -77,25 +67,19 @@ function useTrackingEffect() {
77
67
  if (!isInitialized() || disable) {
78
68
  return;
79
69
  }
80
- if (!user?.id) {
70
+ if (!properties.userId) {
81
71
  FullStory('setIdentity', {
82
72
  anonymous: true
83
73
  });
84
74
  } else {
85
75
  FullStory('setIdentity', {
86
- uid: user.id,
87
- properties: _objectSpread$1({
88
- environment: cloudEnvironment,
89
- projectKey: project?.key,
90
- isProductionProject,
91
- organizationId,
92
- userBusinessRole: user.businessRole,
93
- userLocale: user.locale,
76
+ uid: properties.userId,
77
+ properties: _objectSpread$1(_objectSpread$1({}, properties), {}, {
94
78
  userRole: getUserRole()
95
79
  }, additionalUserVars)
96
80
  });
97
81
  }
98
- }, [disable, additionalUserVars, cloudEnvironment, project?.key, user?.businessRole, user?.id, user?.locale, isProductionProject, organizationId, project?.isUserAdminOfCurrentProject]);
82
+ }, [disable, additionalUserVars, properties]);
99
83
  return null;
100
84
  }
101
85
 
@@ -1,5 +1,5 @@
1
1
  export { initialize } from "./initialize.js";
2
- export { useTrackingEffect } from "./tracking-effect.js";
2
+ export { useTrackingEffect, type TFullStoryProperties, } from "./tracking-effect.js";
3
3
  export { sendEvent } from "./send-event.js";
4
4
  export { setUserVars } from "./set-user-vars.js";
5
5
  export { Masking } from "./masking.js";
@@ -1,8 +1,20 @@
1
1
  /// <reference types="node" />
2
2
  import { KeyObject } from 'crypto';
3
3
  type TTrackingArgs = {
4
+ properties: TFullStoryProperties;
4
5
  disable?: boolean;
5
6
  additionalUserVars?: KeyObject;
6
7
  };
7
- declare function useTrackingEffect({ disable, additionalUserVars, }?: TTrackingArgs): null;
8
+ type Nullable<T> = T | null | undefined;
9
+ export type TFullStoryProperties = {
10
+ userId?: Nullable<string>;
11
+ environment?: Nullable<string>;
12
+ projectKey?: Nullable<string>;
13
+ isProductionProject?: Nullable<boolean>;
14
+ organizationId?: Nullable<string>;
15
+ userBusinessRole?: Nullable<string>;
16
+ userLocale?: Nullable<string>;
17
+ isUserAdminOfCurrentProject?: Nullable<boolean>;
18
+ };
19
+ declare function useTrackingEffect({ properties, disable, additionalUserVars, }?: TTrackingArgs): null;
8
20
  export { useTrackingEffect };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/fullstory",
3
- "version": "2.5.4",
3
+ "version": "3.0.0",
4
4
  "description": "A package integrating with the FullStory SDK",
5
5
  "license": "MIT",
6
6
  "main": "dist/commercetools-frontend-fullstory.cjs.js",
@@ -15,18 +15,15 @@
15
15
  "dependencies": {
16
16
  "@babel/core": "^7.22.11",
17
17
  "@babel/runtime-corejs3": "^7.21.0",
18
- "@fullstory/browser": "2.0.5"
18
+ "@fullstory/browser": "2.0.6"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@apollo/client": "3.7.10",
22
- "@commercetools-frontend/application-shell": "23.0.0",
23
- "@commercetools-frontend/application-shell-connectors": "23.0.0",
24
- "@commercetools-frontend/constants": "23.0.0",
25
22
  "@emotion/react": "11.14.0",
26
23
  "@testing-library/react": "12.1.5",
27
24
  "@testing-library/react-hooks": "8.0.1",
28
25
  "@types/jest": "^29.5.2",
29
- "@types/node": "22.13.4",
26
+ "@types/node": "22.13.9",
30
27
  "@types/react": "17.0.83",
31
28
  "@types/testing-library__jest-dom": "^5.14.6",
32
29
  "graphql": "16.10.0",
@@ -39,10 +36,8 @@
39
36
  "typescript": "5.2.2"
40
37
  },
41
38
  "peerDependencies": {
42
- "@commercetools-frontend/application-shell-connectors": "^23.0.0",
43
- "@commercetools-frontend/constants": "^23.0.0",
44
39
  "@emotion/react": "11.x",
45
- "react": "17.x",
40
+ "react": "17.x || 18.x",
46
41
  "react-intl": "6.x"
47
42
  },
48
43
  "publishConfig": {