@saasquatch/squatch-js 2.6.0-8 → 2.6.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.
Files changed (61) hide show
  1. package/.github/workflows/size-limit.yml +14 -14
  2. package/.github/workflows/static.yml +89 -89
  3. package/CHANGELOG.md +388 -326
  4. package/LICENSE +20 -20
  5. package/README.md +259 -208
  6. package/babel.config.js +7 -7
  7. package/cucumber.js +45 -45
  8. package/demo/sandbox.ts +124 -124
  9. package/demo/toolbar.tsx +526 -526
  10. package/dist/api/WidgetApi.d.ts +1 -0
  11. package/dist/async.d.ts +2 -0
  12. package/dist/globals.d.ts +4 -0
  13. package/dist/squatch.esm.js +80 -49
  14. package/dist/squatch.esm.js.map +1 -1
  15. package/dist/squatch.js +80 -49
  16. package/dist/squatch.js.map +1 -1
  17. package/dist/squatch.min.js +1 -1
  18. package/dist/squatch.min.js.br +0 -0
  19. package/dist/squatch.min.js.map +1 -1
  20. package/dist/squatch.modern.js +1 -1
  21. package/dist/squatch.modern.js.map +1 -1
  22. package/dist/stats.html +1 -1
  23. package/dist/utils/decodeJwt.d.ts +1 -0
  24. package/dist/utils/validate.d.ts +0 -2
  25. package/dist/widgets/PopupWidget.d.ts +2 -2
  26. package/dist/widgets/declarative/DeclarativeWidget.d.ts +5 -0
  27. package/jest.config.ts +200 -200
  28. package/package.json +123 -123
  29. package/tsconfig.json +23 -23
  30. package/coverage/clover.xml +0 -865
  31. package/coverage/coverage-final.json +0 -20
  32. package/coverage/lcov-report/DeclarativeWidget.ts.html +0 -790
  33. package/coverage/lcov-report/WidgetApi.ts.html +0 -631
  34. package/coverage/lcov-report/Widgets.ts.html +0 -1105
  35. package/coverage/lcov-report/api/AnalyticsApi.ts.html +0 -304
  36. package/coverage/lcov-report/api/EventsApi.ts.html +0 -352
  37. package/coverage/lcov-report/api/WidgetApi.ts.html +0 -658
  38. package/coverage/lcov-report/api/graphql.ts.html +0 -130
  39. package/coverage/lcov-report/base.css +0 -224
  40. package/coverage/lcov-report/block-navigation.js +0 -87
  41. package/coverage/lcov-report/favicon.png +0 -0
  42. package/coverage/lcov-report/prettify.css +0 -1
  43. package/coverage/lcov-report/prettify.js +0 -2
  44. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  45. package/coverage/lcov-report/sorter.js +0 -196
  46. package/coverage/lcov-report/squatch.ts.html +0 -721
  47. package/coverage/lcov-report/utils/cookieUtils.ts.html +0 -415
  48. package/coverage/lcov-report/utils/decodeUserJwt.ts.html +0 -133
  49. package/coverage/lcov-report/utils/domready.ts.html +0 -160
  50. package/coverage/lcov-report/utils/io.ts.html +0 -400
  51. package/coverage/lcov-report/utils/utmUtils.ts.html +0 -277
  52. package/coverage/lcov-report/utils/validate.ts.html +0 -268
  53. package/coverage/lcov-report/validate.ts.html +0 -268
  54. package/coverage/lcov-report/widgets/EmbedWidget.ts.html +0 -481
  55. package/coverage/lcov-report/widgets/PopupWidget.ts.html +0 -685
  56. package/coverage/lcov-report/widgets/Widget.ts.html +0 -1159
  57. package/coverage/lcov-report/widgets/Widgets.ts.html +0 -1102
  58. package/coverage/lcov-report/widgets/declarative/DeclarativeWidget.ts.html +0 -790
  59. package/coverage/lcov-report/widgets/declarative/DeclarativeWidgets.ts.html +0 -388
  60. package/coverage/lcov.info +0 -1593
  61. package/stats.json +0 -1
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2023 ReferralSaaSquatch.com, Inc.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 ReferralSaaSquatch.com, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
  THE SOFTWARE.
package/README.md CHANGED
@@ -1,208 +1,259 @@
1
- # Referral SaaSquatch Javascript SDK
2
-
3
- - [Referral SaaSquatch Javascript SDK](#referral-saasquatch-javascript-sdk)
4
- - [Install the library](#install-the-library)
5
- - [Getting Started](#getting-started)
6
- - [Data Only Operations](#data-only-operations)
7
- - [Create/upsert users without loading a widget.](#createupsert-users-without-loading-a-widget)
8
- - [Get Referral Cookie Code](#get-referral-cookie-code)
9
- - [Install via NPM and Webpack (advanced)](#install-via-npm-and-webpack-advanced)
10
- - [Component API:](#component-api)
11
- - [`squatch-embed`](#squatch-embed)
12
- - [`squatch-popup`](#squatch-popup)
13
- - [Legacy](#legacy)
14
- - [Rendering a widget via Widgets API](#rendering-a-widget-via-widgets-api)
15
- - [Contributing](#contributing)
16
- - [Support](#support)
17
-
18
-
19
- ## Install the library
20
-
21
- To integrate any SaaSquatch program to your website or web app, copy/paste this snippet of JavaScript above the `</head>` tag of your page:
22
-
23
- ```html
24
- <script type="text/javascript">
25
- !function(a,b){a("squatch","https://fast.ssqt.io/squatch-js@2",b)}(function(a,b,c){var d,e,f;c["_"+a]={},c[a]={},c[a].ready=function(b){c["_" + a].ready = c["_" + a].ready || [];c["_" + a].ready.push(b);},e=document.createElement("script"),e.async=1,e.src=b,f=document.getElementsByTagName("script")[0],f.parentNode.insertBefore(e,f)},this);
26
- </script>
27
- ```
28
-
29
- Or load the library synchronously from our CDN:
30
-
31
- ```html
32
- <script src="https://fast.ssqt.io/squatch-js@2" type="text/javascript"></script>
33
- ```
34
-
35
-
36
- ## Getting Started
37
-
38
- Include either of the squatchjs generated web-components in your page's HTML to render your desired widget:
39
- ```html
40
- <!-- EMBED WIDGET -->
41
- <squatch-embed widget="WIDGET_TYPE"><!-- Widget is rendered here --></squatch-embed>
42
-
43
- <!-- POPUP WIDGET -->
44
- <squatch-popup widget="WIDGET_TYPE"><!-- Widget is rendered here --></squatch-popup>
45
- ```
46
- For rendering widgets and API calls, squatchjs respects configurations set on the following:
47
- - `window.squatchToken`: Signed JWT for calls to the SaaSquatch API -- [How to generate valid JWT Tokens](https://docs.saasquatch.com/topics/json-web-tokens#example-building-the-jwt)
48
- - `window.squatchTenant`: SaaSquatch tenant alias
49
- - `window.squatchConfig`: Additional configuration overrides (Optional)
50
- - `debug`: Turn on console debugging (Default: `false`)
51
-
52
- **Note**: If `window.squatchToken` is undefined, widgets will be rendered as [Instant Access widgets](https://docs.saasquatch.com/topics/widget-types#instant-access-widgets).
53
-
54
-
55
-
56
-
57
-
58
- ## Data Only Operations
59
-
60
-
61
- #### Create/upsert users without loading a widget.
62
-
63
- ```html
64
- <script type="text/javascript">
65
- // Assuming window.squatchTenant, and window.squatchToken are set
66
-
67
- squatch.ready(function() {
68
- var user;
69
-
70
- squatch.api().upsertUser({
71
- user: { // Object (required)
72
- id: 'USER_ID', // String (required)
73
- accountId: 'USER_ACCOUNT_ID', // String (required)
74
- email: 'USER_EMAIL', // String (optional)
75
- firstName: 'USER_FIRST_NAME', // String (optional)
76
- lastName: 'USER_LAST_NAME', // String (optional)
77
- ...
78
- },
79
- engagementMedium: 'EMBED', // String (optional: POPUP, EMBED)
80
- widgetType: 'p/PROGRAM-ID/w/referrerWidget', // Update PROGRAM-ID
81
- }).then(function(response) {
82
- user = response.user;
83
- }).catch(function(err){
84
- console.log(err);
85
- });
86
-
87
- // autofill
88
- var element = document.getElementById('my_coupon');
89
- element.value = user.referredBy.code;
90
-
91
- });
92
- </script>
93
- ```
94
-
95
- ## Get Referral Cookie Code
96
- You can also use the `api()` function to call the WidgetApi methods directly.
97
-
98
- ```html
99
- <script type="text/javascript">
100
- squatch.ready(function(){
101
-
102
- var element = document.getElementById('my_coupon');
103
-
104
- squatch.api().squatchReferralCookie().then(function(response) {
105
- /* `response.codes` looks like `{"program_id":"NEWCO", "friend_program":"BOB"}` */
106
-
107
- element.value = response.codes["program-id"];
108
- });
109
-
110
- });
111
- </script>
112
- ```
113
-
114
- Want more control? Visit our [guide](https://github.com/saasquatch/squatch-js/blob/master/docs/docs.md).
115
-
116
-
117
- ## Install via NPM and Webpack (advanced)
118
-
119
- Squatch.js can also be installed via NPM and bundled into your application with Webpack.
120
-
121
- ```ssh
122
- # via npm
123
- $ npm install @saasquatch/squatch-js
124
- ```
125
-
126
- ```js
127
- import * as squatch from "@saasquatch/squatch-js";
128
-
129
- // Always call init
130
- squatch.init({
131
- tenantAlias: "YOUR_TENANT_ALIAS" // String (required)
132
- });
133
-
134
- // Don't need to wait for .ready when importing via NPM/Webpack
135
- squatch.api().upsertUser({...});
136
-
137
- ```
138
-
139
- ## Component API:
140
-
141
- ### `squatch-embed`
142
- ```html
143
- <squatch-embed widget="WIDGET_TYPE" [ container="#selector" | locale="en_US" ]>
144
- <!-- Children of squatch-embed act as a loading state -->
145
- Loading...
146
- </squatch-embed>
147
- ```
148
-
149
- - `widget`: Specifies the SaaSquatch `widgetType` identifier of the desired widget
150
- - Required
151
- - Changing this attribute's value causes the widget to reload.
152
- - `container`: A CSS selector for a container element to use as the parent of the widget's iframe.
153
- - Default: `null`
154
- - Note, if no container is specified, the widget iframe will attach to the shadow DOM of `squatch-embed`.
155
- - `locale`: Locale that determines the widget translation displayed. Should be of the form "xx_XX".
156
- - Default: Browser's current locale
157
- - Changing this attribute's value causes the widget to reload.
158
-
159
- ### `squatch-popup`
160
- ```html
161
- <squatch-embed widget="WIDGET_TYPE" [ open | container="#selector" | locale="en_US" ]>
162
- <!-- Clicking a child of squatch-popup opens the popup -->
163
- <button>Click me to open</button>
164
- </squatch-embed>
165
- ```
166
-
167
- - `widget: string`: Specifies the SaaSquatch `widgetType` identifier of the desired widget
168
- - Required
169
- - `open: boolean`: Whether to the popup is open when loaded into the page
170
- - Default: `false`
171
- - `container`: A CSS selector for a container element to use as the parent of the widget's iframe.
172
- - Default: `null`
173
- - Note, if no container is specified, the widget iframe will attach to the shadow DOM of `squatch-embed`.
174
- - `locale`: Locale that determines the widget translation displayed. Should be of the form "xx_XX".
175
- - Default: Browser's current locale
176
- - Changing this attribute's value causes the widget to reload.
177
-
178
- ## Legacy
179
-
180
- ### Rendering a widget via Widgets API
181
- Note: `engagementMedium` is required in the `squatch.widgets()` functions if you want to load the widget. Otherwise, squatch.js will look for your portal settings and render the widget that's mapped to the URL where this snippet is included.
182
-
183
- ```html
184
- <script type="text/javascript">
185
- squatch.ready(function() {
186
-
187
- squatch.widgets().upsertUser({
188
- user: { // Object (required)
189
- id: 'USER_ID', // String (required)
190
- accountId: 'USER_ACCOUNT_ID', // String (required)
191
- email: 'USER_EMAIL', // String (optional)
192
- firstName: 'USER_FIRST_NAME', // String (optional)
193
- lastName: 'USER_LAST_NAME', // String (optional)
194
-
195
- ...
196
- },
197
- engagementMedium: 'EMBED', // String (optional: POPUP, EMBED)
198
- widgetType: 'p/PROGRAM-ID/w/referrerWidget', // Update PROGRAM-ID
199
- });
200
- });
201
- </script>
202
- ```
203
-
204
- ## Contributing
205
- This is an open source project! If you are interested in contributing please look at [contributing guidelines](CONTRIBUTING.md) first.
206
-
207
- ## Support
208
- Shoot us an email at [support@saasqt.ch](mailto:support@saasqt.ch) if you need help!
1
+ # Referral SaaSquatch Javascript SDK
2
+
3
+ - [Referral SaaSquatch Javascript SDK](#referral-saasquatch-javascript-sdk)
4
+ - [Install the library](#install-the-library)
5
+ - [Getting Started](#getting-started)
6
+ - [Data Only Operations](#data-only-operations)
7
+ - [Create/upsert users without loading a widget.](#createupsert-users-without-loading-a-widget)
8
+ - [Get Referral Cookie Code](#get-referral-cookie-code)
9
+ - [Install via NPM and Webpack (advanced)](#install-via-npm-and-webpack-advanced)
10
+ - [Component API:](#component-api)
11
+ - [`squatch-embed`](#squatch-embed)
12
+ - [`squatch-popup`](#squatch-popup)
13
+ - [Legacy](#legacy)
14
+ - [Rendering a widget via Widgets API](#rendering-a-widget-via-widgets-api)
15
+ - [Contributing](#contributing)
16
+ - [Support](#support)
17
+
18
+ ## Install the library
19
+
20
+ To integrate any SaaSquatch program to your website or web app, copy/paste this snippet of JavaScript above the `</head>` tag of your page:
21
+
22
+ ```html
23
+ <script type="text/javascript">
24
+ !(function (a, b) {
25
+ a("squatch", "https://fast.ssqt.io/squatch-js@2", b);
26
+ })(function (a, b, c) {
27
+ var d, e, f;
28
+ (c["_" + a] = {}),
29
+ (c[a] = {}),
30
+ (c[a].ready = function (b) {
31
+ c["_" + a].ready = c["_" + a].ready || [];
32
+ c["_" + a].ready.push(b);
33
+ }),
34
+ (e = document.createElement("script")),
35
+ (e.async = 1),
36
+ (e.src = b),
37
+ (f = document.getElementsByTagName("script")[0]),
38
+ f.parentNode.insertBefore(e, f);
39
+ }, this);
40
+ </script>
41
+ ```
42
+
43
+ Or load the library synchronously from our CDN:
44
+
45
+ ```html
46
+ <script src="https://fast.ssqt.io/squatch-js@2" type="text/javascript"></script>
47
+ ```
48
+
49
+ ## Getting Started
50
+
51
+ Include either of the squatchjs generated web-components in your page's HTML to render your desired widget:
52
+
53
+ ```html
54
+ <!-- EMBED WIDGET -->
55
+ <squatch-embed widget="WIDGET_TYPE"
56
+ ><!-- Widget is rendered here --></squatch-embed
57
+ >
58
+
59
+ <!-- POPUP WIDGET -->
60
+ <squatch-popup widget="WIDGET_TYPE"
61
+ ><!-- Widget is rendered here --></squatch-popup
62
+ >
63
+ ```
64
+
65
+ For rendering widgets and API calls, squatchjs respects configurations set on the following:
66
+
67
+ - `window.squatchToken`: Signed JWT for calls to the SaaSquatch API -- [How to generate valid JWT Tokens](https://docs.saasquatch.com/topics/json-web-tokens#example-building-the-jwt)
68
+ - `window.squatchTenant`: SaaSquatch tenant alias
69
+ - `window.squatchConfig`: Additional configuration overrides (Optional)
70
+ - `debug`: Turn on console debugging (Default: `false`)
71
+ - `window.squatchOnReady`: Declarative on ready function to be run when the squatch-js module has finished loading
72
+
73
+ ```html
74
+ <script type="text/javascript">
75
+ window.squatchOnReady = () => {
76
+ squatch.widgets().upsertUser({
77
+ user: { // Object (required)
78
+ id: 'USER_ID', // String (required)
79
+ accountId: 'USER_ACCOUNT_ID', // String (required)
80
+ email: 'USER_EMAIL', // String (optional)
81
+ firstName: 'USER_FIRST_NAME', // String (optional)
82
+ lastName: 'USER_LAST_NAME', // String (optional)
83
+
84
+ ...
85
+ },
86
+ engagementMedium: 'EMBED', // String (optional: POPUP, EMBED)
87
+ widgetType: 'p/PROGRAM-ID/w/referrerWidget', // Update PROGRAM-ID
88
+ });
89
+ }
90
+ </script>
91
+ ```
92
+
93
+ **Note**: If `window.squatchToken` is undefined, widgets will be rendered as [Instant Access widgets](https://docs.saasquatch.com/topics/widget-types#instant-access-widgets).
94
+
95
+ ## Data Only Operations
96
+
97
+ #### Create/upsert users without loading a widget.
98
+
99
+ ```html
100
+ <script type="text/javascript">
101
+ // Assuming window.squatchTenant, and window.squatchToken are set
102
+
103
+ squatch.ready(function() {
104
+ var user;
105
+
106
+ squatch.api().upsertUser({
107
+ user: { // Object (required)
108
+ id: 'USER_ID', // String (required)
109
+ accountId: 'USER_ACCOUNT_ID', // String (required)
110
+ email: 'USER_EMAIL', // String (optional)
111
+ firstName: 'USER_FIRST_NAME', // String (optional)
112
+ lastName: 'USER_LAST_NAME', // String (optional)
113
+ ...
114
+ },
115
+ engagementMedium: 'EMBED', // String (optional: POPUP, EMBED)
116
+ widgetType: 'p/PROGRAM-ID/w/referrerWidget', // Update PROGRAM-ID
117
+ }).then(function(response) {
118
+ user = response.user;
119
+ }).catch(function(err){
120
+ console.log(err);
121
+ });
122
+
123
+ // autofill
124
+ var element = document.getElementById('my_coupon');
125
+ element.value = user.referredBy.code;
126
+
127
+ });
128
+ </script>
129
+ ```
130
+
131
+ ## Get Referral Cookie Code
132
+
133
+ You can also use the `api()` function to call the WidgetApi methods directly.
134
+
135
+ ```html
136
+ <script type="text/javascript">
137
+ squatch.ready(function () {
138
+ var element = document.getElementById("my_coupon");
139
+
140
+ squatch
141
+ .api()
142
+ .squatchReferralCookie()
143
+ .then(function (response) {
144
+ /* `response.codes` looks like `{"program_id":"NEWCO", "friend_program":"BOB"}` */
145
+
146
+ element.value = response.codes["program-id"];
147
+ });
148
+ });
149
+ </script>
150
+ ```
151
+
152
+ Want more control? Visit our [guide](https://github.com/saasquatch/squatch-js/blob/master/docs/docs.md).
153
+
154
+ ## Install via NPM and Webpack (advanced)
155
+
156
+ Squatch.js can also be installed via NPM and bundled into your application with Webpack.
157
+
158
+ ```ssh
159
+ # via npm
160
+ $ npm install @saasquatch/squatch-js
161
+ ```
162
+
163
+ ```js
164
+ import * as squatch from "@saasquatch/squatch-js";
165
+
166
+ // Always call init
167
+ squatch.init({
168
+ tenantAlias: "YOUR_TENANT_ALIAS" // String (required)
169
+ });
170
+
171
+ // Don't need to wait for .ready when importing via NPM/Webpack
172
+ squatch.api().upsertUser({...});
173
+
174
+ ```
175
+
176
+ ## Component API:
177
+
178
+ ### `squatch-embed`
179
+
180
+ ```html
181
+ <squatch-embed widget="WIDGET_TYPE" [ container="#selector" | locale="en_US" ]>
182
+ <!-- Children of squatch-embed act as a loading state -->
183
+ Loading...
184
+ </squatch-embed>
185
+ ```
186
+
187
+ - `widget`: Specifies the SaaSquatch `widgetType` identifier of the desired widget
188
+ - Required
189
+ - Changing this attribute's value causes the widget to reload.
190
+ - `container`: A CSS selector for a container element to use as the parent of the widget's iframe.
191
+ - Default: `null`
192
+ - Note, if no container is specified, the widget iframe will attach to the shadow DOM of `squatch-embed`.
193
+ - `locale`: Locale that determines the widget translation displayed. Should be of the form "xx_XX".
194
+ - Default: Browser's current locale
195
+ - Changing this attribute's value causes the widget to reload.
196
+
197
+ ### `squatch-popup`
198
+
199
+ ```html
200
+ <squatch-embed
201
+ widget="WIDGET_TYPE"
202
+ [
203
+ open
204
+ |
205
+ container="#selector"
206
+ |
207
+ locale="en_US"
208
+ ]
209
+ >
210
+ <!-- Clicking a child of squatch-popup opens the popup -->
211
+ <button>Click me to open</button>
212
+ </squatch-embed>
213
+ ```
214
+
215
+ - `widget: string`: Specifies the SaaSquatch `widgetType` identifier of the desired widget
216
+ - Required
217
+ - `open: boolean`: Whether to the popup is open when loaded into the page
218
+ - Default: `false`
219
+ - `container`: A CSS selector for a container element to use as the parent of the widget's iframe.
220
+ - Default: `null`
221
+ - Note, if no container is specified, the widget iframe will attach to the shadow DOM of `squatch-embed`.
222
+ - `locale`: Locale that determines the widget translation displayed. Should be of the form "xx_XX".
223
+ - Default: Browser's current locale
224
+ - Changing this attribute's value causes the widget to reload.
225
+
226
+ ## Legacy
227
+
228
+ ### Rendering a widget via Widgets API
229
+
230
+ Note: `engagementMedium` is required in the `squatch.widgets()` functions if you want to load the widget. Otherwise, squatch.js will look for your portal settings and render the widget that's mapped to the URL where this snippet is included.
231
+
232
+ ```html
233
+ <script type="text/javascript">
234
+ squatch.ready(function() {
235
+
236
+ squatch.widgets().upsertUser({
237
+ user: { // Object (required)
238
+ id: 'USER_ID', // String (required)
239
+ accountId: 'USER_ACCOUNT_ID', // String (required)
240
+ email: 'USER_EMAIL', // String (optional)
241
+ firstName: 'USER_FIRST_NAME', // String (optional)
242
+ lastName: 'USER_LAST_NAME', // String (optional)
243
+
244
+ ...
245
+ },
246
+ engagementMedium: 'EMBED', // String (optional: POPUP, EMBED)
247
+ widgetType: 'p/PROGRAM-ID/w/referrerWidget', // Update PROGRAM-ID
248
+ });
249
+ });
250
+ </script>
251
+ ```
252
+
253
+ ## Contributing
254
+
255
+ This is an open source project! If you are interested in contributing please look at [contributing guidelines](CONTRIBUTING.md) first.
256
+
257
+ ## Support
258
+
259
+ Shoot us an email at [support@saasqt.ch](mailto:support@saasqt.ch) if you need help!
package/babel.config.js CHANGED
@@ -1,8 +1,8 @@
1
- module.exports = {
2
- presets: [
3
- [
4
- "@babel/preset-env",
5
- { targets: { esmodules: true }}
6
- ]
7
- ]
1
+ module.exports = {
2
+ presets: [
3
+ [
4
+ "@babel/preset-env",
5
+ { targets: { esmodules: true }}
6
+ ]
7
+ ]
8
8
  }
package/cucumber.js CHANGED
@@ -1,45 +1,45 @@
1
- // cucumber.js
2
- // const dotenv = require('dotenv');
3
- const os = require("os");
4
- // dotenv.config();
5
-
6
- /**
7
- *
8
- * Configures Cucumber
9
- *
10
- * Sets up the required stuff to make React code operate nicely in a Node environment
11
- *
12
- * Source: https://medium.com/@Charles_Stover/behavior-driven-react-development-with-cucumber-faf596d9d71b
13
- *
14
- */
15
- const CPU_COUNT = os.cpus().length;
16
- const IS_DEV = process.env.NODE_ENV === "development";
17
- const FAIL_FAST = IS_DEV ? ["--fail-fast"] : [];
18
- const FORMAT =
19
- process.env.CI || !process.stdout.isTTY ? "progress" : "progress-bar";
20
-
21
- exports.default = [
22
- ...FAIL_FAST,
23
- `--format ${FORMAT}`,
24
- `--parallel ${CPU_COUNT}`,
25
-
26
- // "test/**/*.feature",
27
- "test/specs/**/*.feature",
28
-
29
- `--tags "@testsuite:squatch-js and not @skip"`,
30
-
31
- // Babel and jsDom make our code work as if it's in the browser
32
- // "--require-module jsdom-global/register",
33
- // "--require-module ts-node/register",
34
- "--require-module " + __dirname + "/babelregister.js",
35
- // '--require-module source-map-support/register',
36
-
37
- // Order matters -- these setups need to happen first
38
- // "--require tests/cucumber-setup/loaders.ts",
39
-
40
- // Step definitions go last
41
- "--require test/step_definitions/**/steps.ts",
42
- // "--require test/step_definitions/**/*.tsx",
43
-
44
- // '--format usage',
45
- ].join(" ");
1
+ // cucumber.js
2
+ // const dotenv = require('dotenv');
3
+ const os = require("os");
4
+ // dotenv.config();
5
+
6
+ /**
7
+ *
8
+ * Configures Cucumber
9
+ *
10
+ * Sets up the required stuff to make React code operate nicely in a Node environment
11
+ *
12
+ * Source: https://medium.com/@Charles_Stover/behavior-driven-react-development-with-cucumber-faf596d9d71b
13
+ *
14
+ */
15
+ const CPU_COUNT = os.cpus().length;
16
+ const IS_DEV = process.env.NODE_ENV === "development";
17
+ const FAIL_FAST = IS_DEV ? ["--fail-fast"] : [];
18
+ const FORMAT =
19
+ process.env.CI || !process.stdout.isTTY ? "progress" : "progress-bar";
20
+
21
+ exports.default = [
22
+ ...FAIL_FAST,
23
+ `--format ${FORMAT}`,
24
+ `--parallel ${CPU_COUNT}`,
25
+
26
+ // "test/**/*.feature",
27
+ "test/specs/**/*.feature",
28
+
29
+ `--tags "@testsuite:squatch-js and not @skip"`,
30
+
31
+ // Babel and jsDom make our code work as if it's in the browser
32
+ // "--require-module jsdom-global/register",
33
+ // "--require-module ts-node/register",
34
+ "--require-module " + __dirname + "/babelregister.js",
35
+ // '--require-module source-map-support/register',
36
+
37
+ // Order matters -- these setups need to happen first
38
+ // "--require tests/cucumber-setup/loaders.ts",
39
+
40
+ // Step definitions go last
41
+ "--require test/step_definitions/**/steps.ts",
42
+ // "--require test/step_definitions/**/*.tsx",
43
+
44
+ // '--format usage',
45
+ ].join(" ");