@saasquatch/squatch-js 2.3.1-2 → 2.3.1-3

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/CHANGELOG.md CHANGED
@@ -1,162 +1,162 @@
1
- # Changelog
2
- All notable changes to this project will be documented in this file.
3
-
4
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
-
7
- ## [Unreleased]
8
-
9
- ## [2.3.0] - 2021-05-19
10
- ### Added
11
- - Typescript definitions
12
- - CommonJS/ES modules build for smaller bundle sizes when using squatch-js from NPM
13
-
14
- ### Changed
15
- - `main` is now a CommonJS build instead of a UMD build
16
-
17
- ## [2.2.1] - 2020-06-17
18
- ### Changed
19
- - Remove the need to have JS Options, so that older clients can upgrade to squatch.js v2 easily.
20
-
21
- ## [2.2.0] - 2020-06-12
22
- ### Added
23
- - Reads `_saasquatch` from the URL and stores a 1st-party cookie on the specified landing page's domain.
24
- - Sets `cookies` on users during an upsert **automatically**
25
- ```js
26
- {
27
- user: {
28
- id: "abc",
29
- accountId: "abc",
30
- cookies: "SAASQUATCHCOOKIE",
31
- ...
32
- }
33
- ```
34
- - Reads the 1st-party cookie when using `autofill`
35
- ```js
36
- squatch.api().squatchReferralCookie().then(function(response) {
37
- element.value = response.codes["program-id"];
38
- });
39
- ```
40
-
41
- ## [2.1.8] - 2020-05-25
42
- No release notes.
43
-
44
- ## [2.1.7] - 2020-05-21
45
- No release notes.
46
-
47
- ## [2.1.6] - 2019-04-15
48
- No release notes.
49
-
50
- ## [2.1.5] - 2019-02-19
51
- No release notes.
52
-
53
- ## [2.1.4] - 2019-01-03
54
- No release notes.
55
-
56
- ## [2.1.3] - 2018-12-05
57
- No release notes.
58
-
59
- ## [2.1.2] - 2018-10-22
60
- No release notes.
61
-
62
- ## [2.1.1] - 2018-10-19
63
- ### Fixed
64
- - POPUP Widget in iOS Safari is not clickable when is hidden anymore
65
-
66
- ## [2.1.0] - 2018-09-26
67
- No release notes.
68
-
69
- ## [2.0.17] - 2017-12-21
70
- ### Fixed
71
- - Fixed content-type detection bug
72
-
73
- ## [2.0.16] - 2017-10-24
74
- ### Fixed
75
- - Fix scrolling issue to allow scrolling within popup modal
76
-
77
- ## [2.0.15] - 2017-10-12
78
- ### Added
79
- - Support for scrolling popup in mobile
80
-
81
- ## [2.0.14] - 2017-10-11
82
- ### Fixed
83
- - Fix registration form message in popup
84
-
85
- ## [2.0.13] - 2017-08-03
86
- No release notes.
87
-
88
- ## [2.0.12] - 2017-07-18
89
- No release notes.
90
-
91
- ## [2.0.11] - 2017-07-18
92
- No release notes.
93
-
94
- ## [2.0.10] - 2017-06-30
95
- No release notes.
96
-
97
- ## [2.0.9] - 2017-06-08
98
- No release notes.
99
-
100
- ## [2.0.8] - 2017-06-08
101
- No release notes.
102
-
103
- ## [2.0.7] - 2017-04-24
104
- No release notes.
105
-
106
- ## [2.0.6] - 2017-02-14
107
- ### Fixed
108
- - Fix share tracking
109
- - Ignore CONVERSION_WIDGET widget rules when there's no referrals
110
-
111
- ### Changed
112
- - Auto-fill content type check changed to non-case sensitive
113
-
114
- ## [2.0.5] - 2016-12-07
115
- No release notes.
116
-
117
- ## [2.0.4] - 2016-12-06
118
- No release notes.
119
-
120
- ## [2.0.3] - 2016-11-30
121
- No release notes.
122
-
123
- ## [2.0.2] - 2016-11-29
124
- No release notes.
125
-
126
- ## [2.0.1] - 2016-11-25
127
- No release notes.
128
-
129
- ## [2.0.0] - 2016-11-25
130
- No release notes.
131
-
132
- [Unreleased]: https://github.com/saasquatch/squatch-js/compare/v2.3.0...HEAD
133
- [2.3.0]: https://github.com/saasquatch/squatch-js/compare/v2.2.1...v2.3.0
134
- [2.2.1]: https://github.com/saasquatch/squatch-js/compare/v2.2.0...v2.2.1
135
- [2.2.0]: https://github.com/saasquatch/squatch-js/compare/v2.1.8...v2.2.0
136
- [2.1.8]: https://github.com/saasquatch/squatch-js/compare/v2.1.7...v2.1.8
137
- [2.1.7]: https://github.com/saasquatch/squatch-js/compare/v2.1.6...v2.1.7
138
- [2.1.6]: https://github.com/saasquatch/squatch-js/compare/v2.1.5...v2.1.6
139
- [2.1.5]: https://github.com/saasquatch/squatch-js/compare/v2.1.4...v2.1.5
140
- [2.1.4]: https://github.com/saasquatch/squatch-js/compare/v2.1.3...v2.1.4
141
- [2.1.3]: https://github.com/saasquatch/squatch-js/compare/v2.1.2...v2.1.3
142
- [2.1.2]: https://github.com/saasquatch/squatch-js/compare/v2.1.1...v2.1.2
143
- [2.1.1]: https://github.com/saasquatch/squatch-js/compare/v2.1.0...v2.1.1
144
- [2.1.0]: https://github.com/saasquatch/squatch-js/compare/v2.0.17...v2.1.0
145
- [2.0.17]: https://github.com/saasquatch/squatch-js/compare/v2.0.16...v2.0.17
146
- [2.0.16]: https://github.com/saasquatch/squatch-js/compare/v2.0.15...v2.0.16
147
- [2.0.15]: https://github.com/saasquatch/squatch-js/compare/v2.0.14...v2.0.15
148
- [2.0.14]: https://github.com/saasquatch/squatch-js/compare/v2.0.13...v2.0.14
149
- [2.0.13]: https://github.com/saasquatch/squatch-js/compare/v2.0.12...v2.0.13
150
- [2.0.12]: https://github.com/saasquatch/squatch-js/compare/v2.0.11...v2.0.12
151
- [2.0.11]: https://github.com/saasquatch/squatch-js/compare/v2.0.10...v2.0.11
152
- [2.0.10]: https://github.com/saasquatch/squatch-js/compare/v2.0.9...v2.0.10
153
- [2.0.9]: https://github.com/saasquatch/squatch-js/compare/v2.0.8...v2.0.9
154
- [2.0.8]: https://github.com/saasquatch/squatch-js/compare/v2.0.7...v2.0.8
155
- [2.0.7]: https://github.com/saasquatch/squatch-js/compare/v2.0.6...v2.0.7
156
- [2.0.6]: https://github.com/saasquatch/squatch-js/compare/v2.0.5...v2.0.6
157
- [2.0.5]: https://github.com/saasquatch/squatch-js/compare/v2.0.4...v2.0.5
158
- [2.0.4]: https://github.com/saasquatch/squatch-js/compare/v2.0.3...v2.0.4
159
- [2.0.3]: https://github.com/saasquatch/squatch-js/compare/v2.0.2...v2.0.3
160
- [2.0.2]: https://github.com/saasquatch/squatch-js/compare/v2.0.1...v2.0.2
161
- [2.0.1]: https://github.com/saasquatch/squatch-js/compare/v2.0.0...v2.0.1
162
- [2.0.0]: https://github.com/saasquatch/squatch-js/releases/tag/v2.0.0
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [2.3.0] - 2021-05-19
10
+ ### Added
11
+ - Typescript definitions
12
+ - CommonJS/ES modules build for smaller bundle sizes when using squatch-js from NPM
13
+
14
+ ### Changed
15
+ - `main` is now a CommonJS build instead of a UMD build
16
+
17
+ ## [2.2.1] - 2020-06-17
18
+ ### Changed
19
+ - Remove the need to have JS Options, so that older clients can upgrade to squatch.js v2 easily.
20
+
21
+ ## [2.2.0] - 2020-06-12
22
+ ### Added
23
+ - Reads `_saasquatch` from the URL and stores a 1st-party cookie on the specified landing page's domain.
24
+ - Sets `cookies` on users during an upsert **automatically**
25
+ ```js
26
+ {
27
+ user: {
28
+ id: "abc",
29
+ accountId: "abc",
30
+ cookies: "SAASQUATCHCOOKIE",
31
+ ...
32
+ }
33
+ ```
34
+ - Reads the 1st-party cookie when using `autofill`
35
+ ```js
36
+ squatch.api().squatchReferralCookie().then(function(response) {
37
+ element.value = response.codes["program-id"];
38
+ });
39
+ ```
40
+
41
+ ## [2.1.8] - 2020-05-25
42
+ No release notes.
43
+
44
+ ## [2.1.7] - 2020-05-21
45
+ No release notes.
46
+
47
+ ## [2.1.6] - 2019-04-15
48
+ No release notes.
49
+
50
+ ## [2.1.5] - 2019-02-19
51
+ No release notes.
52
+
53
+ ## [2.1.4] - 2019-01-03
54
+ No release notes.
55
+
56
+ ## [2.1.3] - 2018-12-05
57
+ No release notes.
58
+
59
+ ## [2.1.2] - 2018-10-22
60
+ No release notes.
61
+
62
+ ## [2.1.1] - 2018-10-19
63
+ ### Fixed
64
+ - POPUP Widget in iOS Safari is not clickable when is hidden anymore
65
+
66
+ ## [2.1.0] - 2018-09-26
67
+ No release notes.
68
+
69
+ ## [2.0.17] - 2017-12-21
70
+ ### Fixed
71
+ - Fixed content-type detection bug
72
+
73
+ ## [2.0.16] - 2017-10-24
74
+ ### Fixed
75
+ - Fix scrolling issue to allow scrolling within popup modal
76
+
77
+ ## [2.0.15] - 2017-10-12
78
+ ### Added
79
+ - Support for scrolling popup in mobile
80
+
81
+ ## [2.0.14] - 2017-10-11
82
+ ### Fixed
83
+ - Fix registration form message in popup
84
+
85
+ ## [2.0.13] - 2017-08-03
86
+ No release notes.
87
+
88
+ ## [2.0.12] - 2017-07-18
89
+ No release notes.
90
+
91
+ ## [2.0.11] - 2017-07-18
92
+ No release notes.
93
+
94
+ ## [2.0.10] - 2017-06-30
95
+ No release notes.
96
+
97
+ ## [2.0.9] - 2017-06-08
98
+ No release notes.
99
+
100
+ ## [2.0.8] - 2017-06-08
101
+ No release notes.
102
+
103
+ ## [2.0.7] - 2017-04-24
104
+ No release notes.
105
+
106
+ ## [2.0.6] - 2017-02-14
107
+ ### Fixed
108
+ - Fix share tracking
109
+ - Ignore CONVERSION_WIDGET widget rules when there's no referrals
110
+
111
+ ### Changed
112
+ - Auto-fill content type check changed to non-case sensitive
113
+
114
+ ## [2.0.5] - 2016-12-07
115
+ No release notes.
116
+
117
+ ## [2.0.4] - 2016-12-06
118
+ No release notes.
119
+
120
+ ## [2.0.3] - 2016-11-30
121
+ No release notes.
122
+
123
+ ## [2.0.2] - 2016-11-29
124
+ No release notes.
125
+
126
+ ## [2.0.1] - 2016-11-25
127
+ No release notes.
128
+
129
+ ## [2.0.0] - 2016-11-25
130
+ No release notes.
131
+
132
+ [Unreleased]: https://github.com/saasquatch/squatch-js/compare/v2.3.0...HEAD
133
+ [2.3.0]: https://github.com/saasquatch/squatch-js/compare/v2.2.1...v2.3.0
134
+ [2.2.1]: https://github.com/saasquatch/squatch-js/compare/v2.2.0...v2.2.1
135
+ [2.2.0]: https://github.com/saasquatch/squatch-js/compare/v2.1.8...v2.2.0
136
+ [2.1.8]: https://github.com/saasquatch/squatch-js/compare/v2.1.7...v2.1.8
137
+ [2.1.7]: https://github.com/saasquatch/squatch-js/compare/v2.1.6...v2.1.7
138
+ [2.1.6]: https://github.com/saasquatch/squatch-js/compare/v2.1.5...v2.1.6
139
+ [2.1.5]: https://github.com/saasquatch/squatch-js/compare/v2.1.4...v2.1.5
140
+ [2.1.4]: https://github.com/saasquatch/squatch-js/compare/v2.1.3...v2.1.4
141
+ [2.1.3]: https://github.com/saasquatch/squatch-js/compare/v2.1.2...v2.1.3
142
+ [2.1.2]: https://github.com/saasquatch/squatch-js/compare/v2.1.1...v2.1.2
143
+ [2.1.1]: https://github.com/saasquatch/squatch-js/compare/v2.1.0...v2.1.1
144
+ [2.1.0]: https://github.com/saasquatch/squatch-js/compare/v2.0.17...v2.1.0
145
+ [2.0.17]: https://github.com/saasquatch/squatch-js/compare/v2.0.16...v2.0.17
146
+ [2.0.16]: https://github.com/saasquatch/squatch-js/compare/v2.0.15...v2.0.16
147
+ [2.0.15]: https://github.com/saasquatch/squatch-js/compare/v2.0.14...v2.0.15
148
+ [2.0.14]: https://github.com/saasquatch/squatch-js/compare/v2.0.13...v2.0.14
149
+ [2.0.13]: https://github.com/saasquatch/squatch-js/compare/v2.0.12...v2.0.13
150
+ [2.0.12]: https://github.com/saasquatch/squatch-js/compare/v2.0.11...v2.0.12
151
+ [2.0.11]: https://github.com/saasquatch/squatch-js/compare/v2.0.10...v2.0.11
152
+ [2.0.10]: https://github.com/saasquatch/squatch-js/compare/v2.0.9...v2.0.10
153
+ [2.0.9]: https://github.com/saasquatch/squatch-js/compare/v2.0.8...v2.0.9
154
+ [2.0.8]: https://github.com/saasquatch/squatch-js/compare/v2.0.7...v2.0.8
155
+ [2.0.7]: https://github.com/saasquatch/squatch-js/compare/v2.0.6...v2.0.7
156
+ [2.0.6]: https://github.com/saasquatch/squatch-js/compare/v2.0.5...v2.0.6
157
+ [2.0.5]: https://github.com/saasquatch/squatch-js/compare/v2.0.4...v2.0.5
158
+ [2.0.4]: https://github.com/saasquatch/squatch-js/compare/v2.0.3...v2.0.4
159
+ [2.0.3]: https://github.com/saasquatch/squatch-js/compare/v2.0.2...v2.0.3
160
+ [2.0.2]: https://github.com/saasquatch/squatch-js/compare/v2.0.1...v2.0.2
161
+ [2.0.1]: https://github.com/saasquatch/squatch-js/compare/v2.0.0...v2.0.1
162
+ [2.0.0]: https://github.com/saasquatch/squatch-js/releases/tag/v2.0.0
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016 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) 2016 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,144 +1,144 @@
1
- # Referral SaaSquatch Javascript SDK
2
-
3
- ## Install the library
4
-
5
- To integrate any SaaSquatch program to your website or web app, copy/paste this snippet of JavaScript above the `</head>` tag of your page:
6
-
7
- ```html
8
- <script type="text/javascript">
9
- !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);
10
- </script>
11
- ```
12
-
13
- Or load the library synchronously from our CDN:
14
-
15
- ```html
16
- <script src="https://fast.ssqt.io/squatch-js@2" type="text/javascript"></script>
17
- ```
18
-
19
-
20
- ## Getting Started
21
- The `init` function lets you configure your global squatch instance.
22
-
23
- 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.
24
-
25
- ```html
26
- <script type="text/javascript">
27
- squatch.ready(function() {
28
-
29
- // Always call init
30
- squatch.init({
31
- tenantAlias: "YOUR_TENANT_ALIAS", // String (required)
32
- });
33
-
34
- squatch.widgets().upsertUser({
35
- user: { // Object (required)
36
- id: 'USER_ID', // String (required)
37
- accountId: 'USER_ACCOUNT_ID', // String (required)
38
- email: 'USER_EMAIL', // String (optional)
39
- firstName: 'USER_FIRST_NAME', // String (optional)
40
- lastName: 'USER_LAST_NAME', // String (optional)
41
-
42
- ...
43
- },
44
- engagementMedium: 'EMBED', // String (optional: POPUP, EMBED)
45
- widgetType: 'p/PROGRAM-ID/w/referrerWidget', // Update PROGRAM-ID
46
- jwt: 'TOKEN' // String (required by default, or disable Security in the portal)
47
-
48
- });
49
- </script>
50
- ```
51
-
52
- ## Data Only Operations
53
- You can create/upsert users without loading a widget.
54
-
55
- ```html
56
- <script type="text/javascript">
57
- squatch.ready(function() {
58
-
59
- // Always call init
60
- squatch.init({
61
- tenantAlias: "YOUR_TENANT_ALIAS" // String (required)
62
- });
63
-
64
- var user;
65
-
66
- squatch.api().upsertUser({
67
- user: { // Object (required)
68
- id: 'USER_ID', // String (required)
69
- accountId: 'USER_ACCOUNT_ID', // String (required)
70
- email: 'USER_EMAIL', // String (optional)
71
- firstName: 'USER_FIRST_NAME', // String (optional)
72
- lastName: 'USER_LAST_NAME', // String (optional)
73
- ...
74
- },
75
- engagementMedium: 'EMBED', // String (optional: POPUP, EMBED)
76
- widgetType: 'p/PROGRAM-ID/w/referrerWidget', // Update PROGRAM-ID
77
- jwt: 'TOKEN' // String (required)
78
- }).then(function(response) {
79
- user = response.user;
80
- }).catch(function(err){
81
- console.log(err);
82
- });
83
-
84
- // autofill
85
- var element = document.getElementById('my_coupon');
86
- element.value = user.referredBy.code;
87
-
88
- });
89
- </script>
90
- ```
91
-
92
- ## Get Referral Cookie Code
93
- You can also use the `api()` function to call the WidgetApi methods directly.
94
-
95
- ```html
96
- <script type="text/javascript">
97
- squatch.ready(function(){
98
-
99
- // Always call init
100
- squatch.init({tenantAlias: 'YOUR_TENANT_ALIAS'});
101
-
102
-
103
- var element = document.getElementById('my_coupon');
104
-
105
- squatch.api().squatchReferralCookie().then(function(response) {
106
- /* `response.codes` looks like `{"program_id":"NEWCO", "friend_program":"BOB"}` */
107
-
108
- element.value = response.codes["program-id"];
109
- });
110
-
111
- });
112
- </script>
113
- ```
114
-
115
- Want more control? Visit our [guide](https://github.com/saasquatch/squatch-js/blob/master/docs/docs.md).
116
-
117
-
118
- ## Install via NPM and Webpack (advanced)
119
-
120
- Squatch.js can also be installed via NPM and bundled into your application with Webpack.
121
-
122
- ```ssh
123
- # via npm
124
- $ npm install @saasquatch/squatch-js
125
- ```
126
-
127
- ```js
128
- import * as squatch from "@saasquatch/squatch-js";
129
-
130
- // Always call init
131
- squatch.init({
132
- tenantAlias: "YOUR_TENANT_ALIAS" // String (required)
133
- });
134
-
135
- // Don't need to wait for .ready when importing via NPM/Webpack
136
- squatch.api().upsertUser({...});
137
-
138
- ```
139
-
140
- ## Contributing
141
- This is an open source project! If you are interested in contributing please look at [contributing guidelines](CONTRIBUTING.md) first.
142
-
143
- ## Support
144
- Shoot us an email at [support@saasqt.ch](mailto:support@saasqt.ch) if you need help!
1
+ # Referral SaaSquatch Javascript SDK
2
+
3
+ ## Install the library
4
+
5
+ To integrate any SaaSquatch program to your website or web app, copy/paste this snippet of JavaScript above the `</head>` tag of your page:
6
+
7
+ ```html
8
+ <script type="text/javascript">
9
+ !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);
10
+ </script>
11
+ ```
12
+
13
+ Or load the library synchronously from our CDN:
14
+
15
+ ```html
16
+ <script src="https://fast.ssqt.io/squatch-js@2" type="text/javascript"></script>
17
+ ```
18
+
19
+
20
+ ## Getting Started
21
+ The `init` function lets you configure your global squatch instance.
22
+
23
+ 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.
24
+
25
+ ```html
26
+ <script type="text/javascript">
27
+ squatch.ready(function() {
28
+
29
+ // Always call init
30
+ squatch.init({
31
+ tenantAlias: "YOUR_TENANT_ALIAS", // String (required)
32
+ });
33
+
34
+ squatch.widgets().upsertUser({
35
+ user: { // Object (required)
36
+ id: 'USER_ID', // String (required)
37
+ accountId: 'USER_ACCOUNT_ID', // String (required)
38
+ email: 'USER_EMAIL', // String (optional)
39
+ firstName: 'USER_FIRST_NAME', // String (optional)
40
+ lastName: 'USER_LAST_NAME', // String (optional)
41
+
42
+ ...
43
+ },
44
+ engagementMedium: 'EMBED', // String (optional: POPUP, EMBED)
45
+ widgetType: 'p/PROGRAM-ID/w/referrerWidget', // Update PROGRAM-ID
46
+ jwt: 'TOKEN' // String (required by default, or disable Security in the portal)
47
+
48
+ });
49
+ </script>
50
+ ```
51
+
52
+ ## Data Only Operations
53
+ You can create/upsert users without loading a widget.
54
+
55
+ ```html
56
+ <script type="text/javascript">
57
+ squatch.ready(function() {
58
+
59
+ // Always call init
60
+ squatch.init({
61
+ tenantAlias: "YOUR_TENANT_ALIAS" // String (required)
62
+ });
63
+
64
+ var user;
65
+
66
+ squatch.api().upsertUser({
67
+ user: { // Object (required)
68
+ id: 'USER_ID', // String (required)
69
+ accountId: 'USER_ACCOUNT_ID', // String (required)
70
+ email: 'USER_EMAIL', // String (optional)
71
+ firstName: 'USER_FIRST_NAME', // String (optional)
72
+ lastName: 'USER_LAST_NAME', // String (optional)
73
+ ...
74
+ },
75
+ engagementMedium: 'EMBED', // String (optional: POPUP, EMBED)
76
+ widgetType: 'p/PROGRAM-ID/w/referrerWidget', // Update PROGRAM-ID
77
+ jwt: 'TOKEN' // String (required)
78
+ }).then(function(response) {
79
+ user = response.user;
80
+ }).catch(function(err){
81
+ console.log(err);
82
+ });
83
+
84
+ // autofill
85
+ var element = document.getElementById('my_coupon');
86
+ element.value = user.referredBy.code;
87
+
88
+ });
89
+ </script>
90
+ ```
91
+
92
+ ## Get Referral Cookie Code
93
+ You can also use the `api()` function to call the WidgetApi methods directly.
94
+
95
+ ```html
96
+ <script type="text/javascript">
97
+ squatch.ready(function(){
98
+
99
+ // Always call init
100
+ squatch.init({tenantAlias: 'YOUR_TENANT_ALIAS'});
101
+
102
+
103
+ var element = document.getElementById('my_coupon');
104
+
105
+ squatch.api().squatchReferralCookie().then(function(response) {
106
+ /* `response.codes` looks like `{"program_id":"NEWCO", "friend_program":"BOB"}` */
107
+
108
+ element.value = response.codes["program-id"];
109
+ });
110
+
111
+ });
112
+ </script>
113
+ ```
114
+
115
+ Want more control? Visit our [guide](https://github.com/saasquatch/squatch-js/blob/master/docs/docs.md).
116
+
117
+
118
+ ## Install via NPM and Webpack (advanced)
119
+
120
+ Squatch.js can also be installed via NPM and bundled into your application with Webpack.
121
+
122
+ ```ssh
123
+ # via npm
124
+ $ npm install @saasquatch/squatch-js
125
+ ```
126
+
127
+ ```js
128
+ import * as squatch from "@saasquatch/squatch-js";
129
+
130
+ // Always call init
131
+ squatch.init({
132
+ tenantAlias: "YOUR_TENANT_ALIAS" // String (required)
133
+ });
134
+
135
+ // Don't need to wait for .ready when importing via NPM/Webpack
136
+ squatch.api().upsertUser({...});
137
+
138
+ ```
139
+
140
+ ## Contributing
141
+ This is an open source project! If you are interested in contributing please look at [contributing guidelines](CONTRIBUTING.md) first.
142
+
143
+ ## Support
144
+ Shoot us an email at [support@saasqt.ch](mailto:support@saasqt.ch) if you need help!