You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+23-5
Original file line number
Diff line number
Diff line change
@@ -35,12 +35,12 @@ This `micro-frontends-frame` app has 2 types of configs:
35
35
}
36
36
}
37
37
```
38
-
38
+
39
39
ii. Location of the AWS S3 files:
40
40
- Configure micro app names and relative URL to be used when deployed to production environment in file at location : `https://tc-platform-prod.s3.amazonaws.com/micro-frontends/micro-frontends-config-production.json`
41
41
- Configure micro app names and relative URL to be used when deployed to development environment in file at location : `https://tc-platform-dev.s3.amazonaws.com/micro-frontends/micro-frontends-config-development.json`
42
42
- Configure micro app names and relative URL to be used when deployed to local environment in file at location : `./micro-frontends-frame/config/micro-frontends-config-local.json`
43
-
43
+
44
44
45
45
2. Route mapping handled by the frame, containing `route path` and `micro app name` for each micro app. The configuration files are available on TC AWS S3 and have public access.
46
46
@@ -54,7 +54,7 @@ This `micro-frontends-frame` app has 2 types of configs:
54
54
- Configure route path and micro app name to be used when deployed to production environment in file at location : `https://tc-platform-prod.s3.amazonaws.com/micro-frontends/micro-frontends-routes-production.txt`
55
55
- Configure route path and micro app name to be used when deployed to development environment in file at location : `https://tc-platform-dev.s3.amazonaws.com/micro-frontends/micro-frontends-routes-development.txt`
56
56
- Configure route path and micro app name to be used when deployed to development environment in file at location : `./micro-frontends-frame/config/micro-frontends-routes-local.txt`
57
-
57
+
58
58
⚠️ **NOTE** : When a configuration files is updated on TC AWS S3, make sure to give public access to the file.
59
59
60
60
## NPM Commands
@@ -133,11 +133,29 @@ Make sure you have [Heroky CLI](https://devcenter.heroku.com/articles/heroku-cli
133
133
- `git push heroku master` - push changes to Heroku and trigger deploying
134
134
- ⚠️ **NOTE** : Authorization would not work because only predefined list of domain allowed by `accounts-app`.
135
135
136
+
## Segment Analytics
137
+
138
+
Because analytics can be normally initialized once per website, we are initializing Segment Analytics inside the Frame app instead of each child app separately. See [Segment Analytics Quick Guide](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/quickstart/).
139
+
140
+
- Analytics requires `SEGMENT_ANALYTICS_KEY` to work.
141
+
- It should be set as environment variable `SEGMENT_ANALYTICS_KEY` during running `npm run build` (for production build) or `npm run local-client` (for local development).
142
+
- If `SEGMENT_ANALYTICS_KEY` environment variable is not set during the build process, the Segment Analytics would not be initialized.
143
+
- Analytics would be exposed to the `window` object as `window.analytics`. See [Segment Analytics API Guide](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/).
144
+
- Note, that because we can build the Frame app without analytics initialized, all the child apps which use analytics should always check if it's initialized before usage, for example like this:
145
+
```js
146
+
if (window.analytics && typeof window.analytics.page === "function") {
147
+
window.analytics.page();
148
+
}
149
+
```
150
+
- Each child app should take care about calling `window.analytics.page()` each time the page is changed. We can pass [additional arguments](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/#page) to this method if needed.
151
+
- We can enable debug mode by calling `analytics.debug();` inside browser console, see [debug documentation](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/#debug).
152
+
- TODO: we might consider implementing one global logic for calling `window.analytics.page()` inside Frame of Navbar app so child apps wouldn't worry about this. Though we have to make sure that it works smoothly. In particular we have to make sure that if child app updates page `<title>` then `window.analytics.page()` is called after that and logs to the analytic correct page title. Also, child apps might want to provide additional arguments when calling `window.analytics.page()`. So we might come to this improvement in some time, after we try the current approach.
153
+
136
154
## Add/Remove child app
137
155
138
156
For adding a child app to the root app make the following steps:
139
157
140
-
1. Add child app path to importmap. File underpath
158
+
1. Add child app path to importmap. File underpath
141
159
-`https://tc-platform-prod.s3.amazonaws.com/micro-frontends/micro-frontends-config-production.json` for production deployment
142
160
-`https://tc-platform-dev.s3.amazonaws.com/micro-frontends/micro-frontends-config-development.json` for development deployment
143
161
-`./micro-frontends-frame/config/micro-frontends-config-local.json` for local deployment
@@ -154,7 +172,7 @@ For adding a child app to the root app make the following steps:
0 commit comments