@commercetools-frontend/fullstory 2.1.3 → 2.2.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.
package/README.md CHANGED
@@ -127,6 +127,32 @@ import { Masking as FullStoryMasking } from '@commercetools-frontend/fullstory';
127
127
 
128
128
  Each of the components above accepts an `as` `prop` which can be either `span` or `div` depending on your layout needs.
129
129
 
130
+ ### Marking
131
+
132
+ FullStory allows definitions of CSS and other Elements that represent key pieces of data you use regularly. When defining these key pieces you will have to write stable CSS selectors to those elements. These selectors should be resilient to changes in the layout of any Merchant Center application.
133
+
134
+ One way to achieve this is to mark elements directly or contextualize them in a `section` element. The `Marking` API of this package helps with this.
135
+
136
+ To wrap an entire section of an application you can use `FullStory.Marking.Section`:
137
+
138
+ ```jsx
139
+ import { Marking as FullStoryMarking } from '@commercetools-frontend/fullstory';
140
+
141
+ <FullStoryMarking.Section name="Discount Rules">
142
+ <PartOfApplication />
143
+ </FullStoryMarking.Section>;
144
+ ```
145
+
146
+ Please do not wrap individual elements. If you need to mark individual elements such as a unlabelled input you can use `applyMarker`:
147
+
148
+ ```jsx
149
+ import { Marking as FullStoryMarking } from '@commercetools-frontend/fullstory';
150
+
151
+ <input {...FullStoryMarking.applyMarker('Discount Rule')} />;
152
+ ```
153
+
154
+ Both cases will add a `data-tracking="Discount Rule"` to either the `input` or `section` element. You can then use these elements to target the element as in `input[data-tracking="Discount Rule"]` or `section[data-tracking="Discount Rules"] button[label="some label"]`.
155
+
130
156
  ## FAQ
131
157
 
132
158
  Question: _I want to disable FullStory on a specific environment_
@@ -72,8 +72,8 @@ function initialize() {
72
72
  }
73
73
  }
74
74
 
75
- function ownKeys(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; }
76
- function _objectSpread(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(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(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
75
+ 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; }
76
+ 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; }
77
77
  const defaultTrackingArgs = {
78
78
  disable: false,
79
79
  additionalUserVars: undefined
@@ -98,7 +98,7 @@ function useTrackingEffect() {
98
98
  if (!(user !== null && user !== void 0 && user.id)) {
99
99
  FullStory__namespace.anonymize();
100
100
  } else {
101
- FullStory__namespace.identify(user.id, _objectSpread({
101
+ FullStory__namespace.identify(user.id, _objectSpread$1({
102
102
  environment: tenant,
103
103
  projectKey: project === null || project === void 0 ? void 0 : project.key,
104
104
  userBusinessRole: user.businessRole,
@@ -150,6 +150,24 @@ const Masking = {
150
150
  Exclude
151
151
  };
152
152
 
153
+ function ownKeys(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; }
154
+ function _objectSpread(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(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(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
155
+ function applyMarker(name) {
156
+ return {
157
+ 'data-tracking': name
158
+ };
159
+ }
160
+ function Section(props) {
161
+ return jsxRuntime.jsx("section", _objectSpread(_objectSpread({}, applyMarker(props.name)), {}, {
162
+ children: props.children
163
+ }));
164
+ }
165
+ const Marking = {
166
+ Section,
167
+ applyMarker
168
+ };
169
+
170
+ exports.Marking = Marking;
153
171
  exports.Masking = Masking;
154
172
  exports.initialize = initialize;
155
173
  exports.sendEvent = sendEvent;
@@ -72,8 +72,8 @@ function initialize() {
72
72
  }
73
73
  }
74
74
 
75
- function ownKeys(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; }
76
- function _objectSpread(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(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(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
75
+ 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; }
76
+ 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; }
77
77
  const defaultTrackingArgs = {
78
78
  disable: false,
79
79
  additionalUserVars: undefined
@@ -98,7 +98,7 @@ function useTrackingEffect() {
98
98
  if (!(user !== null && user !== void 0 && user.id)) {
99
99
  FullStory__namespace.anonymize();
100
100
  } else {
101
- FullStory__namespace.identify(user.id, _objectSpread({
101
+ FullStory__namespace.identify(user.id, _objectSpread$1({
102
102
  environment: tenant,
103
103
  projectKey: project === null || project === void 0 ? void 0 : project.key,
104
104
  userBusinessRole: user.businessRole,
@@ -150,6 +150,24 @@ const Masking = {
150
150
  Exclude
151
151
  };
152
152
 
153
+ function ownKeys(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; }
154
+ function _objectSpread(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(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(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
155
+ function applyMarker(name) {
156
+ return {
157
+ 'data-tracking': name
158
+ };
159
+ }
160
+ function Section(props) {
161
+ return jsxRuntime.jsx("section", _objectSpread(_objectSpread({}, applyMarker(props.name)), {}, {
162
+ children: props.children
163
+ }));
164
+ }
165
+ const Marking = {
166
+ Section,
167
+ applyMarker
168
+ };
169
+
170
+ exports.Marking = Marking;
153
171
  exports.Masking = Masking;
154
172
  exports.initialize = initialize;
155
173
  exports.sendEvent = sendEvent;
@@ -38,8 +38,8 @@ function initialize() {
38
38
  }
39
39
  }
40
40
 
41
- function ownKeys(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; }
42
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
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; }
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; }
43
43
  const defaultTrackingArgs = {
44
44
  disable: false,
45
45
  additionalUserVars: undefined
@@ -64,7 +64,7 @@ function useTrackingEffect() {
64
64
  if (!(user !== null && user !== void 0 && user.id)) {
65
65
  FullStory.anonymize();
66
66
  } else {
67
- FullStory.identify(user.id, _objectSpread({
67
+ FullStory.identify(user.id, _objectSpread$1({
68
68
  environment: tenant,
69
69
  projectKey: project === null || project === void 0 ? void 0 : project.key,
70
70
  userBusinessRole: user.businessRole,
@@ -116,4 +116,21 @@ const Masking = {
116
116
  Exclude
117
117
  };
118
118
 
119
- export { Masking, initialize, sendEvent, setUserVars, useTrackingEffect };
119
+ function ownKeys(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; }
120
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
121
+ function applyMarker(name) {
122
+ return {
123
+ 'data-tracking': name
124
+ };
125
+ }
126
+ function Section(props) {
127
+ return jsx("section", _objectSpread(_objectSpread({}, applyMarker(props.name)), {}, {
128
+ children: props.children
129
+ }));
130
+ }
131
+ const Marking = {
132
+ Section,
133
+ applyMarker
134
+ };
135
+
136
+ export { Marking, Masking, initialize, sendEvent, setUserVars, useTrackingEffect };
@@ -3,3 +3,4 @@ export { useTrackingEffect } 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";
6
+ export { Marking } from "./marking.js";
@@ -0,0 +1,14 @@
1
+ import type { ReactNode } from 'react';
2
+ export type TMarkingProps = {
3
+ name: string;
4
+ children: ReactNode;
5
+ };
6
+ declare function applyMarker(name: TMarkingProps['name']): {
7
+ 'data-tracking': string;
8
+ };
9
+ declare function Section(props: TMarkingProps): import("@emotion/react/types/jsx-namespace").EmotionJSX.Element;
10
+ declare const Marking: {
11
+ Section: typeof Section;
12
+ applyMarker: typeof applyMarker;
13
+ };
14
+ export { Marking };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/fullstory",
3
- "version": "2.1.3",
3
+ "version": "2.2.0",
4
4
  "description": "A package integrating with the FullStory SDK",
5
5
  "license": "MIT",
6
6
  "main": "dist/commercetools-frontend-fullstory.cjs.js",
@@ -20,9 +20,9 @@
20
20
  },
21
21
  "devDependencies": {
22
22
  "@apollo/client": "3.7.10",
23
- "@commercetools-frontend/application-shell": "22.8.2",
24
- "@commercetools-frontend/application-shell-connectors": "22.8.2",
25
- "@commercetools-frontend/constants": "22.8.2",
23
+ "@commercetools-frontend/application-shell": "22.9.1",
24
+ "@commercetools-frontend/application-shell-connectors": "22.9.1",
25
+ "@commercetools-frontend/constants": "22.9.1",
26
26
  "@emotion/react": "^11.11.1",
27
27
  "@testing-library/react": "12.1.5",
28
28
  "@testing-library/react-hooks": "8.0.1",