@saasquatch/squatch-js 2.5.0-0 → 2.5.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/CHANGELOG.md +50 -2
- package/LICENSE +1 -1
- package/README.md +1 -0
- package/demo/sandbox.ts +7 -5
- package/demo/toolbar.tsx +1 -1
- package/dist/api/AnalyticsApi.d.ts +1 -1
- package/dist/api/WidgetApi.d.ts +4 -4
- package/dist/api/graphql.d.ts +1 -0
- package/dist/squatch.d.ts +10 -2
- package/dist/squatch.esm.js +292 -98
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +294 -98
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +3 -3
- package/dist/squatch.min.js.map +1 -0
- package/dist/squatch.modern.js +2 -0
- package/dist/squatch.modern.js.map +1 -0
- package/dist/stats.html +1 -1
- package/dist/types.d.ts +14 -4
- package/dist/utils/cookieUtils.d.ts +1 -0
- package/dist/utils/io.d.ts +2 -1
- package/dist/utils/utmUtils.d.ts +14 -0
- package/dist/utils/validate.d.ts +2 -0
- package/dist/widgets/Widgets.d.ts +3 -3
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
## [2.5.0] -
|
|
10
|
+
## [2.5.0] - 2023-05-16
|
|
11
11
|
|
|
12
12
|
### Removed
|
|
13
13
|
|
|
@@ -15,7 +15,53 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
15
15
|
|
|
16
16
|
### Changed
|
|
17
17
|
|
|
18
|
-
- Widgets.render now
|
|
18
|
+
- Widgets.render now queries renderWidget rather than cookieUser api method
|
|
19
|
+
- Added squatch.widget function to render a widget without user upsert
|
|
20
|
+
|
|
21
|
+
- Example:
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
var initObj = {
|
|
25
|
+
widgetType: "<MY_WIDGET>",
|
|
26
|
+
engagementMedium: "EMBED",
|
|
27
|
+
container: ".myContainer",
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
squatch
|
|
31
|
+
.widget(initObj)
|
|
32
|
+
.then(function (response) {
|
|
33
|
+
const widget = response.widget
|
|
34
|
+
})
|
|
35
|
+
.catch(function (error) {
|
|
36
|
+
console.log(error);
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- Added auto-popup widget support:
|
|
41
|
+
- Reads `_saasquatchExtra` from the URL on load
|
|
42
|
+
- Renders the encoded widget from `_saasquatchExtra` parameter as a Popup Widget on load
|
|
43
|
+
|
|
44
|
+
## [2.4.3] - 2023-04-20
|
|
45
|
+
|
|
46
|
+
### Changed
|
|
47
|
+
- Updated license copyright to be in line with SaaSquatch open-source policy.
|
|
48
|
+
|
|
49
|
+
## [2.4.2] - 2023-04-10
|
|
50
|
+
|
|
51
|
+
### Added
|
|
52
|
+
|
|
53
|
+
- Added value to return data `squatchReferralCookie` to retrieve the encoded cookie
|
|
54
|
+
|
|
55
|
+
- Example:
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
squatch
|
|
59
|
+
.api()
|
|
60
|
+
.squatchReferralCookie()
|
|
61
|
+
.then(function (response) {
|
|
62
|
+
const cookie = response.encodedCookie;
|
|
63
|
+
});
|
|
64
|
+
```
|
|
19
65
|
|
|
20
66
|
## [2.4.1] - 2022-09-23
|
|
21
67
|
|
|
@@ -243,6 +289,8 @@ No release notes.
|
|
|
243
289
|
|
|
244
290
|
[unreleased]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.5.0...HEAD
|
|
245
291
|
[2.5.0]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.4.1...@saasquatch%2Fsquatch-js@2.5.0
|
|
292
|
+
[2.4.3]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.4.2...@saasquatch%2Fsquatch-js@2.4.3
|
|
293
|
+
[2.4.2]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.4.1...@saasquatch%2Fsquatch-js@2.4.2
|
|
246
294
|
[2.4.1]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.4.0...@saasquatch%2Fsquatch-js@2.4.1
|
|
247
295
|
[2.4.0]: https://github.com/saasquatch/squatch-js/compare/v2.3.1...@saasquatch%2Fsquatch-js@2.4.0
|
|
248
296
|
[2.3.1]: https://github.com/saasquatch/squatch-js/compare/v2.3.0...v2.3.1
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2023 ReferralSaaSquatch.com, Inc.
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -45,6 +45,7 @@ Note: `engagementMedium` is required in the `squatch.widgets()` functions if you
|
|
|
45
45
|
widgetType: 'p/PROGRAM-ID/w/referrerWidget', // Update PROGRAM-ID
|
|
46
46
|
jwt: 'TOKEN' // String (required by default, or disable Security in the portal)
|
|
47
47
|
|
|
48
|
+
});
|
|
48
49
|
});
|
|
49
50
|
</script>
|
|
50
51
|
```
|
package/demo/sandbox.ts
CHANGED
|
@@ -36,8 +36,7 @@ export const popup: Sandbox = {
|
|
|
36
36
|
widgetType: "REFERRER_WIDGET",
|
|
37
37
|
engagementMedium: "POPUP",
|
|
38
38
|
user: user,
|
|
39
|
-
jwt:
|
|
40
|
-
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiNWI5ODBkMzRlNGIwY2FiZWUwN2YyY2IwIiwiYWNjb3VudElkIjoiQVpKWlNWRzBMUzFMQjE5UiIsImVtYWlsIjoiY2hlc3RlcnNjb3R0LnVleHdsdGdoQG1haWxvc2F1ci5pbyJ9fQ.MkrO7-980M7NRJcOUcdqCO1JftqmynLMK8bTEB3WObo",
|
|
39
|
+
jwt: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiNWI5ODBkMzRlNGIwY2FiZWUwN2YyY2IwIiwiYWNjb3VudElkIjoiQVpKWlNWRzBMUzFMQjE5UiIsImVtYWlsIjoiY2hlc3RlcnNjb3R0LnVleHdsdGdoQG1haWxvc2F1ci5pbyJ9fQ.MkrO7-980M7NRJcOUcdqCO1JftqmynLMK8bTEB3WObo",
|
|
41
40
|
},
|
|
42
41
|
};
|
|
43
42
|
|
|
@@ -53,8 +52,7 @@ export const embed: Sandbox = {
|
|
|
53
52
|
accountId: "AZJZSVG0LS1LB19R",
|
|
54
53
|
email: "chesterscott.uexwltgh@mailosaur.io",
|
|
55
54
|
},
|
|
56
|
-
jwt:
|
|
57
|
-
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiNWI5ODBkMzRlNGIwY2FiZWUwN2YyY2IwIiwiYWNjb3VudElkIjoiQVpKWlNWRzBMUzFMQjE5UiIsImVtYWlsIjoiY2hlc3RlcnNjb3R0LnVleHdsdGdoQG1haWxvc2F1ci5pbyJ9fQ.MkrO7-980M7NRJcOUcdqCO1JftqmynLMK8bTEB3WObo",
|
|
55
|
+
jwt: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiNWI5ODBkMzRlNGIwY2FiZWUwN2YyY2IwIiwiYWNjb3VudElkIjoiQVpKWlNWRzBMUzFMQjE5UiIsImVtYWlsIjoiY2hlc3RlcnNjb3R0LnVleHdsdGdoQG1haWxvc2F1ci5pbyJ9fQ.MkrO7-980M7NRJcOUcdqCO1JftqmynLMK8bTEB3WObo",
|
|
58
56
|
},
|
|
59
57
|
};
|
|
60
58
|
|
|
@@ -112,11 +110,15 @@ export function toURL(sandbox: Sandbox) {
|
|
|
112
110
|
}
|
|
113
111
|
|
|
114
112
|
export function href(sandbox: Sandbox) {
|
|
113
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
115
114
|
const param = window.btoa(JSON.stringify(sandbox));
|
|
116
115
|
var url = window.location.href;
|
|
117
116
|
if (url.indexOf("?") > 0) {
|
|
118
117
|
url = url.substring(0, url.indexOf("?"));
|
|
119
118
|
}
|
|
120
|
-
|
|
119
|
+
|
|
120
|
+
urlParams.delete("sandbox");
|
|
121
|
+
|
|
122
|
+
url += `?sandbox=${encodeURIComponent(param)}&${urlParams.toString()}`;
|
|
121
123
|
return url;
|
|
122
124
|
}
|
package/demo/toolbar.tsx
CHANGED
|
@@ -245,7 +245,7 @@ function ModeList(props) {
|
|
|
245
245
|
function UserList(props) {
|
|
246
246
|
return (
|
|
247
247
|
<details
|
|
248
|
-
title={"User: " + window["sandbox"].initObj.user
|
|
248
|
+
title={"User: " + window["sandbox"].initObj.user?.firstName}
|
|
249
249
|
key={0}
|
|
250
250
|
id={`dropdown-basic-1`}
|
|
251
251
|
>
|
|
@@ -18,7 +18,7 @@ export default class AnalyticsApi {
|
|
|
18
18
|
constructor(config: {
|
|
19
19
|
domain: string;
|
|
20
20
|
});
|
|
21
|
-
pushAnalyticsLoadEvent(params: SQHDetails): Promise<any
|
|
21
|
+
pushAnalyticsLoadEvent(params: SQHDetails): Promise<any> | undefined;
|
|
22
22
|
pushAnalyticsShareClickedEvent(params: SQHDetails & {
|
|
23
23
|
shareMedium: string;
|
|
24
24
|
}): Promise<any>;
|
package/dist/api/WidgetApi.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigOptions, WidgetConfig } from "../types";
|
|
1
|
+
import { ConfigOptions, ReferralCookie, WidgetConfig, WithRequired } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
*
|
|
4
4
|
* The WidgetApi class is a wrapper around the Widget Endpoints of the SaaSquatch REST API.
|
|
@@ -39,7 +39,7 @@ export default class WidgetApi {
|
|
|
39
39
|
*
|
|
40
40
|
* @return {Promise} string if true, with the widget template, jsOptions and user details.
|
|
41
41
|
*/
|
|
42
|
-
upsertUser(params: WidgetConfig): Promise<any>;
|
|
42
|
+
upsertUser(params: WithRequired<WidgetConfig, "user">): Promise<any>;
|
|
43
43
|
/**
|
|
44
44
|
* Description here.
|
|
45
45
|
*
|
|
@@ -74,7 +74,7 @@ export default class WidgetApi {
|
|
|
74
74
|
/**
|
|
75
75
|
* Looks up the referral code of the current user, if there is any.
|
|
76
76
|
*
|
|
77
|
-
* @return {Promise<
|
|
77
|
+
* @return {Promise<ReferralCookie>} code referral code if true.
|
|
78
78
|
*/
|
|
79
|
-
squatchReferralCookie(): Promise<
|
|
79
|
+
squatchReferralCookie(): Promise<ReferralCookie>;
|
|
80
80
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RENDER_WIDGET_QUERY = "\n query renderWidget ($user: UserIdInput, $engagementMedium: UserEngagementMedium, $widgetType: WidgetType, $locale: RSLocale) {\n renderWidget(user: $user, engagementMedium: $engagementMedium, widgetType: $widgetType, locale: $locale) {\n template\n user {\n id\n accountId\n }\n jsOptions\n widgetConfig {\n values\n }\n }\n }\n";
|
package/dist/squatch.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import PopupWidget from "./widgets/PopupWidget";
|
|
|
4
4
|
import CtaWidget from "./widgets/CtaWidget";
|
|
5
5
|
import WidgetApi from "./api/WidgetApi";
|
|
6
6
|
import EventsApi from "./api/EventsApi";
|
|
7
|
-
import { ConfigOptions } from "./types";
|
|
7
|
+
import { ConfigOptions, WidgetConfig, WidgetResult } from "./types";
|
|
8
8
|
export * from "./types";
|
|
9
9
|
export * from "./docs";
|
|
10
10
|
export { Widgets, EmbedWidget, PopupWidget, CtaWidget, WidgetApi };
|
|
@@ -32,6 +32,14 @@ export declare function widgets(): Widgets | null;
|
|
|
32
32
|
* @returns EventsApi static instance
|
|
33
33
|
*/
|
|
34
34
|
export declare function events(): EventsApi | null;
|
|
35
|
+
/**
|
|
36
|
+
* Entry-point for high level API to render a widget using the instance of {@link Widgets} created when you call {@link #init init}.
|
|
37
|
+
*/
|
|
38
|
+
export declare function widget(widgetConfig: WidgetConfig): Promise<WidgetResult | undefined> | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Extracts widget configuration from `_saasquatchExtra` UTM parameter. Initialises `squatch` and renders the widget as a {@link PopupWidget} via static instanct of {@link Widgets}.
|
|
41
|
+
*/
|
|
42
|
+
export declare function _auto(configIn: ConfigOptions): Promise<WidgetResult | undefined> | undefined;
|
|
35
43
|
/**
|
|
36
44
|
* Initializes the static `squatch` global. This sets up:
|
|
37
45
|
*
|
|
@@ -54,7 +62,7 @@ export declare function init(configIn: ConfigOptions): void;
|
|
|
54
62
|
* @example
|
|
55
63
|
* squatch.ready(function() {
|
|
56
64
|
* console.log("ready!");
|
|
57
|
-
* squatch.api().
|
|
65
|
+
* squatch.api().upsertUser();
|
|
58
66
|
* });
|
|
59
67
|
*/
|
|
60
68
|
export declare function ready(fn: () => any): void;
|