@saasquatch/squatch-js 2.4.3 → 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 +326 -291
- package/LICENSE +20 -20
- 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 +2 -15
- package/dist/api/graphql.d.ts +1 -0
- package/dist/squatch.d.ts +10 -2
- package/dist/squatch.esm.js +264 -153
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +266 -153
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +3 -3
- package/dist/squatch.min.js.map +1 -1
- package/dist/squatch.modern.js +1 -1
- package/dist/squatch.modern.js.map +1 -1
- package/dist/stats.html +1 -1
- package/dist/types.d.ts +10 -4
- package/dist/utils/cookieUtils.d.ts +1 -0
- package/dist/utils/io.d.ts +1 -0
- package/dist/utils/utmUtils.d.ts +14 -0
- package/dist/utils/validate.d.ts +2 -0
- package/dist/widgets/Widgets.d.ts +3 -17
- package/package.json +104 -104
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,
|
|
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.
|
|
@@ -25,19 +25,6 @@ export default class WidgetApi {
|
|
|
25
25
|
* let squatchApi = new WidgetApi({tenantAlias:'test_12b5bo1b25125'});
|
|
26
26
|
*/
|
|
27
27
|
constructor(config: ConfigOptions);
|
|
28
|
-
/**
|
|
29
|
-
* Creates/upserts an anonymous user.
|
|
30
|
-
*
|
|
31
|
-
* @param {Object} params Parameters for request
|
|
32
|
-
* @param {WidgetType} params.widgetType The content of the widget.
|
|
33
|
-
* @param {EngagementMedium} params.engagementMedium How to display the widget.
|
|
34
|
-
* @param {CookieUser} params.user An optional user object
|
|
35
|
-
* @param {string} params.jwt the JSON Web Token (JWT) that is used to
|
|
36
|
-
* validate the data (can be disabled)
|
|
37
|
-
*
|
|
38
|
-
* @return {Promise} json object if true, with the widget template, jsOptions and user details.
|
|
39
|
-
*/
|
|
40
|
-
cookieUser(params: CookieUser): Promise<any>;
|
|
41
28
|
/**
|
|
42
29
|
* Creates/upserts user.
|
|
43
30
|
*
|
|
@@ -52,7 +39,7 @@ export default class WidgetApi {
|
|
|
52
39
|
*
|
|
53
40
|
* @return {Promise} string if true, with the widget template, jsOptions and user details.
|
|
54
41
|
*/
|
|
55
|
-
upsertUser(params: WidgetConfig): Promise<any>;
|
|
42
|
+
upsertUser(params: WithRequired<WidgetConfig, "user">): Promise<any>;
|
|
56
43
|
/**
|
|
57
44
|
* Description here.
|
|
58
45
|
*
|
|
@@ -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;
|