@bigbinary/neeto-commons-frontend 2.0.17 → 2.0.19

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
@@ -1,13 +1,14 @@
1
1
  # neeto-commons-frontend
2
2
 
3
- The commons frontend library for Neeto Applications.
3
+ A library encapsulating common boilerplate frontend code required for all neeto
4
+ products.
4
5
 
5
6
  ## Installation Instructions
6
7
 
7
8
  Install from npm:
8
9
 
9
10
  ```bash
10
- yarn add "@bigbinary/neeto-commons-frontend@2.0.17"
11
+ yarn add "@bigbinary/neeto-commons-frontend@2.0.19"
11
12
  ```
12
13
 
13
14
  This package relies on the host project's tailwind configuration. So add
@@ -76,25 +77,24 @@ When you are migrating from version 1 to version 2, do the following:
76
77
  file. You can omit the `--watch` flag if you want to run the build only once.
77
78
  5. In a different terminal, run `yalc publish` to publish the
78
79
  neeto-commons-frontend to the local yalc store.
79
- 6. Run `yalc install` to install the neeto-commons-frontend to the host
80
- application.
81
- 7. After making all changes to `neeto-commons-frontend`, run `yalc push` to push
82
- the changes to the host application.
80
+ 6. Run `yalc add @bigbinary/neeto-commons-frontend` to install the
81
+ neeto-commons-frontend to the host application.
82
+ 7. After making necessary changes to `neeto-commons-frontend`, run `yalc push`
83
+ to push the changes to the host application (assuming that you are in watch
84
+ mode and the changes are bundled automatically).
83
85
  8. Video explanation on how to use yalc: https://vimeo.com/722958162/9e931b640c
84
86
 
85
87
  ## Building and releasing.
86
88
 
87
89
  This is how releases are managed in this repo.
88
90
 
89
- - We will create a branch with the next release version as its name (`1.0.x`)
91
+ - We will create a branch with the next release version as its name (`2.0.x`)
90
92
  from main branch.
91
93
  - Version in
92
94
  [README.md](https://github.com/bigbinary/neeto-commons-frontend/blob/main/README.md#L10)
93
95
  and
94
96
  [package.json](https://github.com/bigbinary/neeto-commons-frontend/blob/main/package.json#L3)
95
97
  will be updated to the current branch name.
96
- - From now on, we can install the package to neeto-applications using the
97
- version `2.X.Y`.
98
98
  - We will create a draft PR of this branch targeting main. This keeps the branch
99
99
  in sync with main branch (bot-bigbinary will auto-merge the changes).
100
100
  - When all features have been built, we will deploy it to all neeto-applications
@@ -103,20 +103,17 @@ This is how releases are managed in this repo.
103
103
  usage of yalc is explained in this video:
104
104
  https://vimeo.com/722958162/9e931b640c
105
105
  - In case if we notice any problem during verification, like any missed edge
106
- cases, we will fix the problem in this repo and re-run `yalc push` to install
107
- the latest changes.
108
- - Once everything is fine and the verification is complete, we will create a
106
+ cases, we will fix the problem in neeto-commons-frontend locally and re-run
107
+ `yalc push` to update the local host projects.
108
+ - Once everything is working fine and the verification is complete, create a PR
109
+ with those bug fixes and get it merged.
110
+ - We will now merge the PR `2.X.Y` to main.
111
+ - We can now create a
109
112
  [new github release](https://github.com/bigbinary/neeto-commons-frontend/releases/new)
110
- from `2.X.Y` branch with the exact same name for the tag (`2.X.Y`). The target
111
- branch will be kept as `2.X.Y`. This will create a tag from the latest `2.X.Y`
112
- branch and this ensures that the latest commit on that branch will remain
113
- intact even if that branch gets deleted.
113
+ from main branch with the current version as the tag name (`2.X.Y`).
114
114
  - Whenever a new release is created with a new version number, the github
115
115
  actions will automatically publish the built package to npm.
116
- - Now we will squash and merge the PR `2.X.Y` to main and delete its source
117
- branch. This will delete all commits except the top one (since we have created
118
- a tag with it).
119
- - Immediately, we will open another branch with the next version (`2.X.Y`) and
116
+ - Immediately, we will open another branch with the next version (`2.X.Z`) and
120
117
  the cycle will continue.
121
118
  - Now we can run `yalc remove neeto-commons-frontend` to remove yalc based
122
119
  package and run `yarn add neeto-commons-frontend@2.X.Y` to fetch the latest
@@ -217,7 +217,9 @@ nullSafe(filterNonNull);
217
217
  var HEADERS_KEYS = {
218
218
  xAuthEmail: "X-Auth-Email",
219
219
  xAuthToken: "X-Auth-Token",
220
- xCsrfToken: "X-CSRF-TOKEN"
220
+ xCsrfToken: "X-CSRF-TOKEN",
221
+ contentType: "Content-Type",
222
+ accept: "Accept"
221
223
  };
222
224
 
223
225
  var resetAuthTokens = function resetAuthTokens() {
@@ -231,12 +233,9 @@ var shouldNot = function shouldNot(skip) {
231
233
  };
232
234
 
233
235
  var setAuthHeaders = function setAuthHeaders() {
234
- var _globalProps$user, _globalProps$user2;
236
+ var _document$querySelect, _axios$defaults$heade, _globalProps$user, _globalProps$user2;
235
237
 
236
- axios__default["default"].defaults.headers = _defineProperty({
237
- Accept: "application/json",
238
- "Content-Type": "application/json"
239
- }, HEADERS_KEYS.xCsrfToken, document.querySelector('[name="csrf-token"]').getAttribute("content"));
238
+ axios__default["default"].defaults.headers = (_axios$defaults$heade = {}, _defineProperty(_axios$defaults$heade, HEADERS_KEYS.accept, "application/json"), _defineProperty(_axios$defaults$heade, HEADERS_KEYS.contentType, "application/json"), _defineProperty(_axios$defaults$heade, HEADERS_KEYS.xCsrfToken, (_document$querySelect = document.querySelector('[name="csrf-token"]')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.getAttribute("content")), _axios$defaults$heade);
240
239
  var token = (_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.authenticationToken;
241
240
  var email = (_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.email;
242
241
 
@@ -573,25 +572,15 @@ function initializeLogger() {
573
572
  }
574
573
 
575
574
  function initializeMixPanel() {
576
- var isProduction = process.env.NODE_ENV === "production";
577
- var isTokenPresent = !!process.env.MIXPANEL_TOKEN;
578
575
  var isUserLoggedIn = !ramda.either(ramda.isEmpty, ramda.isNil)(globalProps.user);
579
-
580
- if (isProduction && isTokenPresent && isUserLoggedIn) {
581
- mixpanel__default["default"].init(process.env.MIXPANEL_TOKEN || "");
582
- mixpanel__default["default"].people.set({
583
- $email: globalProps.user.email,
584
- $fist_name: globalProps.user.firstName,
585
- $last_name: globalProps.user.lastName
586
- });
587
- mixpanel__default["default"].identify(globalProps.user.email);
588
- } else {
589
- /*
590
- We need to initialize mixpanel with a bogus token in development and test environment to
591
- prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.
592
- */
593
- mixpanel__default["default"].init("TEST_TOKEN");
594
- }
576
+ mixpanel__default["default"].init(process.env.MIXPANEL_TOKEN || "TEST_TOKEN");
577
+ if (!isUserLoggedIn) return;
578
+ mixpanel__default["default"].people.set({
579
+ $email: globalProps.user.email,
580
+ $fist_name: globalProps.user.firstName,
581
+ $last_name: globalProps.user.lastName
582
+ });
583
+ mixpanel__default["default"].identify(globalProps.user.email);
595
584
  }
596
585
 
597
586
  exports.globalProps = {};
package/initializers.js CHANGED
@@ -206,7 +206,9 @@ nullSafe(filterNonNull);
206
206
  var HEADERS_KEYS = {
207
207
  xAuthEmail: "X-Auth-Email",
208
208
  xAuthToken: "X-Auth-Token",
209
- xCsrfToken: "X-CSRF-TOKEN"
209
+ xCsrfToken: "X-CSRF-TOKEN",
210
+ contentType: "Content-Type",
211
+ accept: "Accept"
210
212
  };
211
213
 
212
214
  var resetAuthTokens = function resetAuthTokens() {
@@ -220,12 +222,9 @@ var shouldNot = function shouldNot(skip) {
220
222
  };
221
223
 
222
224
  var setAuthHeaders = function setAuthHeaders() {
223
- var _globalProps$user, _globalProps$user2;
225
+ var _document$querySelect, _axios$defaults$heade, _globalProps$user, _globalProps$user2;
224
226
 
225
- axios.defaults.headers = _defineProperty({
226
- Accept: "application/json",
227
- "Content-Type": "application/json"
228
- }, HEADERS_KEYS.xCsrfToken, document.querySelector('[name="csrf-token"]').getAttribute("content"));
227
+ axios.defaults.headers = (_axios$defaults$heade = {}, _defineProperty(_axios$defaults$heade, HEADERS_KEYS.accept, "application/json"), _defineProperty(_axios$defaults$heade, HEADERS_KEYS.contentType, "application/json"), _defineProperty(_axios$defaults$heade, HEADERS_KEYS.xCsrfToken, (_document$querySelect = document.querySelector('[name="csrf-token"]')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.getAttribute("content")), _axios$defaults$heade);
229
228
  var token = (_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.authenticationToken;
230
229
  var email = (_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.email;
231
230
 
@@ -562,25 +561,15 @@ function initializeLogger() {
562
561
  }
563
562
 
564
563
  function initializeMixPanel() {
565
- var isProduction = process.env.NODE_ENV === "production";
566
- var isTokenPresent = !!process.env.MIXPANEL_TOKEN;
567
564
  var isUserLoggedIn = !either(isEmpty, isNil)(globalProps.user);
568
-
569
- if (isProduction && isTokenPresent && isUserLoggedIn) {
570
- mixpanel.init(process.env.MIXPANEL_TOKEN || "");
571
- mixpanel.people.set({
572
- $email: globalProps.user.email,
573
- $fist_name: globalProps.user.firstName,
574
- $last_name: globalProps.user.lastName
575
- });
576
- mixpanel.identify(globalProps.user.email);
577
- } else {
578
- /*
579
- We need to initialize mixpanel with a bogus token in development and test environment to
580
- prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.
581
- */
582
- mixpanel.init("TEST_TOKEN");
583
- }
565
+ mixpanel.init(process.env.MIXPANEL_TOKEN || "TEST_TOKEN");
566
+ if (!isUserLoggedIn) return;
567
+ mixpanel.people.set({
568
+ $email: globalProps.user.email,
569
+ $fist_name: globalProps.user.firstName,
570
+ $last_name: globalProps.user.lastName
571
+ });
572
+ mixpanel.identify(globalProps.user.email);
584
573
  }
585
574
 
586
575
  var globalProps$1 = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-commons-frontend",
3
- "version": "2.0.17",
3
+ "version": "2.0.19",
4
4
  "description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
5
5
  "repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
6
6
  "author": "Amaljith K <amaljith.k@bigbinary.com>",
@@ -87,6 +87,7 @@
87
87
  "ramda": "^0.28.0",
88
88
  "react": "^17.0.2",
89
89
  "react-dom": "17.0.2",
90
+ "react-helmet": "^6.1.0",
90
91
  "react-i18next": "11.16.8",
91
92
  "react-query": "^3.39.2",
92
93
  "react-router-dom": "^5.2.0",