@askdialog/dialog-sdk 1.0.26-beta.2 → 1.1.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/README.md +5 -2
- package/dist/Dialog.d.ts +13 -10
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Dialog.js +30 -21
- package/dist/EventsHandler.d.ts +4 -4
- package/dist/EventsHandler.js +2 -2
- package/dist/Tracking.d.ts +1 -1
- package/dist/Tracking.js +3 -3
- package/dist/config/config.development.js +3 -3
- package/dist/config/config.production.js +3 -3
- package/dist/config/index.js +3 -3
- package/dist/constants/theme.d.ts +1 -1
- package/dist/constants/theme.js +11 -11
- package/dist/constants/user.js +2 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/services/base.js +1 -1
- package/dist/services/suggestions.d.ts +1 -1
- package/dist/services/suggestions.js +2 -2
- package/dist/types/assistantEvent.js +1 -1
- package/dist/types/constructor.d.ts +4 -3
- package/dist/types/constructor.d.ts.map +1 -1
- package/dist/types/events.d.ts +1 -1
- package/dist/types/events.js +1 -1
- package/dist/types/global.d.ts +1 -1
- package/dist/types/index.d.ts +7 -7
- package/dist/types/index.js +7 -7
- package/dist/types/theme.d.ts +1 -1
- package/dist/utils/localization.js +1 -1
- package/package.json +2 -10
package/README.md
CHANGED
|
@@ -58,11 +58,13 @@ const client = new Dialog({
|
|
|
58
58
|
quantity,
|
|
59
59
|
currency,
|
|
60
60
|
variantId,
|
|
61
|
+
price,
|
|
61
62
|
}: {
|
|
62
63
|
productId: string;
|
|
63
64
|
quantity: number;
|
|
64
65
|
currency?: string;
|
|
65
66
|
variantId?: string;
|
|
67
|
+
price?: string;
|
|
66
68
|
}) => Promise<void>, // required
|
|
67
69
|
getProduct: async (
|
|
68
70
|
productId: string,
|
|
@@ -256,13 +258,14 @@ client.registerAddToCartEvent({
|
|
|
256
258
|
productId: 'ProductIdentifier', // {string} - Required
|
|
257
259
|
quantity: 1, // {number} - Required
|
|
258
260
|
currency: 'EUR', // {string} - Optional
|
|
259
|
-
variantId: 'VariantIdentifier' // {string} - Optional
|
|
260
|
-
|
|
261
|
+
variantId: 'VariantIdentifier', // {string} - Optional
|
|
262
|
+
price: '12.00' // {string} - Optional
|
|
261
263
|
});
|
|
262
264
|
|
|
263
265
|
client.registerSubmitCheckoutEvent({
|
|
264
266
|
productId: 'ProductIdentifier', // {string} - Required
|
|
265
267
|
quantity: 1, // {number} - Required
|
|
268
|
+
price: '12.00', // {string} - Required
|
|
266
269
|
currency: 'EUR', // {string} - Optional
|
|
267
270
|
variantId: 'VariantIdentifier' // {string} - Optional
|
|
268
271
|
});
|
package/dist/Dialog.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { DialogConstructor } from
|
|
2
|
-
import { Theme } from
|
|
3
|
-
import { DetailedLocaleInfo } from
|
|
4
|
-
import { Suggestion } from
|
|
5
|
-
import { GenericQuestionPayload, OpenAssistantPayload, ProductQuestionPayload } from
|
|
6
|
-
import { SimplifiedProduct } from
|
|
7
|
-
import { AssistantEvent } from
|
|
1
|
+
import { DialogConstructor } from "./types/constructor";
|
|
2
|
+
import { Theme } from "./types/theme";
|
|
3
|
+
import { DetailedLocaleInfo } from "./utils/localization";
|
|
4
|
+
import { Suggestion } from "./types/suggestion";
|
|
5
|
+
import { GenericQuestionPayload, OpenAssistantPayload, ProductQuestionPayload } from "./types/events";
|
|
6
|
+
import { SimplifiedProduct } from "./types/product";
|
|
7
|
+
import { AssistantEvent } from "./types/assistantEvent";
|
|
8
8
|
export declare class Dialog {
|
|
9
9
|
static readonly VERSION: string;
|
|
10
10
|
private _apiKey;
|
|
@@ -29,21 +29,24 @@ export declare class Dialog {
|
|
|
29
29
|
onAssistantEvent(listener: (event: AssistantEvent) => void): void;
|
|
30
30
|
dispatchAssistantEvent(event: AssistantEvent): void;
|
|
31
31
|
getProduct(productId: string, variantId?: string): Promise<SimplifiedProduct>;
|
|
32
|
-
addToCart({ productId, quantity, currency, variantId, }: {
|
|
32
|
+
addToCart({ productId, quantity, currency, variantId, price, }: {
|
|
33
33
|
productId: string;
|
|
34
34
|
quantity: number;
|
|
35
|
+
price?: string;
|
|
35
36
|
currency?: string;
|
|
36
37
|
variantId?: string;
|
|
37
38
|
}): Promise<void>;
|
|
38
|
-
registerAddToCartEvent({ productId, quantity, currency, variantId, }: {
|
|
39
|
+
registerAddToCartEvent({ productId, quantity, currency, variantId, price, }: {
|
|
39
40
|
productId: string;
|
|
40
41
|
quantity: number;
|
|
42
|
+
price?: string;
|
|
41
43
|
currency?: string;
|
|
42
44
|
variantId?: string;
|
|
43
45
|
}): void;
|
|
44
|
-
registerSubmitCheckoutEvent({ productId, quantity, currency, variantId, }: {
|
|
46
|
+
registerSubmitCheckoutEvent({ productId, quantity, currency, variantId, price, }: {
|
|
45
47
|
productId: string;
|
|
46
48
|
quantity: number;
|
|
49
|
+
price: string;
|
|
47
50
|
currency?: string;
|
|
48
51
|
variantId?: string;
|
|
49
52
|
}): void;
|
package/dist/Dialog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../src/Dialog.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EACL,kBAAkB,EAEnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAEL,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAMpD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,qBAAa,MAAM;IACjB,gBAAuB,OAAO,SAAuB;IAErD,OAAO,CAAC,OAAO,CAAS;IACx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AAU,CACf,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,iBAAiB,CAAC;IAIhB,SAAS,CAAC,EACrB,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,KAAK,GACN,EAAE;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBV,sBAAsB,CAAC,EAC5B,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,KAAK,GACN,EAAE;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,IAAI;IAYD,2BAA2B,CAAC,EACjC,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,KAAK,GACN,EAAE;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,IAAI;IAYR,OAAO,CAAC,cAAc;CA4BvB"}
|
package/dist/Dialog.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/* eslint-disable max-lines */
|
|
2
|
-
import { uuidv7 } from
|
|
3
|
-
import packageJson from
|
|
4
|
-
import { defaultTheme } from
|
|
5
|
-
import { getDetailedLocaleInfo, } from
|
|
6
|
-
import { ANONYMOUS_CUSTOMER_ID, CUSTOMER_ID } from
|
|
7
|
-
import { DialogEvents, } from
|
|
8
|
-
import { EventsHandler } from
|
|
9
|
-
import { Tracking } from
|
|
10
|
-
import { TrackingEvents } from
|
|
11
|
-
import { loadSuggestions } from
|
|
12
|
-
import { config } from
|
|
2
|
+
import { uuidv7 } from "uuidv7";
|
|
3
|
+
import packageJson from "../package.json";
|
|
4
|
+
import { defaultTheme } from "./constants/theme";
|
|
5
|
+
import { getDetailedLocaleInfo, } from "./utils/localization";
|
|
6
|
+
import { ANONYMOUS_CUSTOMER_ID, CUSTOMER_ID } from "./constants/user";
|
|
7
|
+
import { DialogEvents, } from "./types/events";
|
|
8
|
+
import { EventsHandler } from "./EventsHandler";
|
|
9
|
+
import { Tracking } from "./Tracking";
|
|
10
|
+
import { TrackingEvents } from "./types/trackings";
|
|
11
|
+
import { loadSuggestions } from "./services/suggestions";
|
|
12
|
+
import { config } from "./config";
|
|
13
13
|
export class Dialog {
|
|
14
14
|
static VERSION = packageJson.version;
|
|
15
15
|
_apiKey;
|
|
@@ -87,27 +87,35 @@ export class Dialog {
|
|
|
87
87
|
getProduct(productId, variantId) {
|
|
88
88
|
return this._callbacks.getProduct(productId, variantId);
|
|
89
89
|
}
|
|
90
|
-
async addToCart({ productId, quantity, currency, variantId, }) {
|
|
90
|
+
async addToCart({ productId, quantity, currency, variantId, price, }) {
|
|
91
91
|
await this._callbacks.addToCart({
|
|
92
92
|
productId,
|
|
93
93
|
variantId,
|
|
94
94
|
quantity,
|
|
95
95
|
currency,
|
|
96
|
+
price,
|
|
97
|
+
});
|
|
98
|
+
this.registerAddToCartEvent({
|
|
99
|
+
productId,
|
|
100
|
+
variantId,
|
|
101
|
+
quantity,
|
|
102
|
+
currency,
|
|
103
|
+
price,
|
|
96
104
|
});
|
|
97
|
-
this.registerAddToCartEvent({ productId, variantId, quantity, currency });
|
|
98
105
|
return;
|
|
99
106
|
}
|
|
100
|
-
registerAddToCartEvent({ productId, quantity, currency, variantId, }) {
|
|
107
|
+
registerAddToCartEvent({ productId, quantity, currency, variantId, price, }) {
|
|
101
108
|
this._tracking.track(TrackingEvents.USER_ADDED_TO_CART, {
|
|
102
109
|
user_id: this._userId,
|
|
103
110
|
product_id: productId,
|
|
104
111
|
variant_id: variantId,
|
|
105
112
|
quantity,
|
|
113
|
+
price,
|
|
106
114
|
locale: this._locale,
|
|
107
115
|
currency,
|
|
108
116
|
});
|
|
109
117
|
}
|
|
110
|
-
registerSubmitCheckoutEvent({ productId, quantity, currency, variantId, }) {
|
|
118
|
+
registerSubmitCheckoutEvent({ productId, quantity, currency, variantId, price, }) {
|
|
111
119
|
this._tracking.track(TrackingEvents.USER_SUBMITTED_CHECKOUT, {
|
|
112
120
|
user_id: this._userId,
|
|
113
121
|
product_id: productId,
|
|
@@ -115,16 +123,17 @@ export class Dialog {
|
|
|
115
123
|
quantity,
|
|
116
124
|
locale: this._locale,
|
|
117
125
|
currency,
|
|
126
|
+
price,
|
|
118
127
|
});
|
|
119
128
|
}
|
|
120
129
|
_loadAssistant() {
|
|
121
130
|
const localeInfo = getDetailedLocaleInfo(this._locale);
|
|
122
131
|
if (localeInfo === null) {
|
|
123
|
-
console.error(
|
|
132
|
+
console.error("Missing locale information");
|
|
124
133
|
return;
|
|
125
134
|
}
|
|
126
|
-
const div = document.createElement(
|
|
127
|
-
div.id =
|
|
135
|
+
const div = document.createElement("div");
|
|
136
|
+
div.id = "dialog-shopify-ai";
|
|
128
137
|
div.dataset.shopIsoCode = this._locale;
|
|
129
138
|
div.dataset.apiKey = this._apiKey;
|
|
130
139
|
div.dataset.userId = this._userId;
|
|
@@ -132,11 +141,11 @@ export class Dialog {
|
|
|
132
141
|
div.dataset.language = localeInfo.language;
|
|
133
142
|
document.body.appendChild(div);
|
|
134
143
|
setTimeout(() => {
|
|
135
|
-
const script = document.createElement(
|
|
136
|
-
script.type =
|
|
144
|
+
const script = document.createElement("script");
|
|
145
|
+
script.type = "text/javascript";
|
|
137
146
|
script.defer = true;
|
|
138
147
|
script.async = true;
|
|
139
|
-
script.type =
|
|
148
|
+
script.type = "module";
|
|
140
149
|
script.src = config.assistantUrl;
|
|
141
150
|
document.head.insertBefore(script, document.head.firstChild);
|
|
142
151
|
}, 50);
|
package/dist/EventsHandler.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { AssistantEvent, AssistantEventPayload, CommonPayload, GenericAssistantEventPayload } from
|
|
2
|
-
import { DialogEvent } from
|
|
1
|
+
import { AssistantEvent, AssistantEventPayload, CommonPayload, GenericAssistantEventPayload } from "./types/assistantEvent";
|
|
2
|
+
import { DialogEvent } from "./types/events";
|
|
3
3
|
export declare class EventsHandler {
|
|
4
4
|
private _locale;
|
|
5
5
|
private _userId?;
|
|
6
6
|
constructor(locale: string, userId?: string);
|
|
7
|
-
emitExternalEvent(type: DialogEvent[
|
|
8
|
-
emitAssistantEvent(type: AssistantEvent[
|
|
7
|
+
emitExternalEvent(type: DialogEvent["type"], payload?: DialogEvent["payload"]): void;
|
|
8
|
+
emitAssistantEvent(type: AssistantEvent["type"], payload?: GenericAssistantEventPayload): void;
|
|
9
9
|
onAssistantEvent(listener: (event: AssistantEvent<CommonPayload & AssistantEventPayload>) => void): () => void;
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=EventsHandler.d.ts.map
|
package/dist/EventsHandler.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DIALOG_ASSISTANT_EVENT, } from
|
|
2
|
-
import { DIALOG_CUSTOM_EVENT } from
|
|
1
|
+
import { DIALOG_ASSISTANT_EVENT, } from "./types/assistantEvent";
|
|
2
|
+
import { DIALOG_CUSTOM_EVENT } from "./types/events";
|
|
3
3
|
export class EventsHandler {
|
|
4
4
|
_locale;
|
|
5
5
|
_userId;
|
package/dist/Tracking.d.ts
CHANGED
package/dist/Tracking.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import posthog from
|
|
2
|
-
import { config } from
|
|
1
|
+
import posthog from "posthog-js";
|
|
2
|
+
import { config } from "./config";
|
|
3
3
|
export class Tracking {
|
|
4
4
|
_posthog;
|
|
5
5
|
_token = config.posthogApiKey;
|
|
6
|
-
_apiHost =
|
|
6
|
+
_apiHost = "https://eu.i.posthog.com";
|
|
7
7
|
_apiKey;
|
|
8
8
|
constructor(apiKey) {
|
|
9
9
|
this._apiKey = apiKey;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const config = {
|
|
2
|
-
baseApiUrl:
|
|
3
|
-
assistantUrl:
|
|
4
|
-
posthogApiKey:
|
|
2
|
+
baseApiUrl: "https://abkjr5ukvi.execute-api.eu-west-1.amazonaws.com",
|
|
3
|
+
assistantUrl: "https://d2bycosa71tnxv.cloudfront.net/assets/index.js",
|
|
4
|
+
posthogApiKey: "phc_WM5MRkqG7AiqOKeTmNKj0fNIl41ZOQex7wRhEswRlTA",
|
|
5
5
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const config = {
|
|
2
|
-
baseApiUrl:
|
|
3
|
-
assistantUrl:
|
|
4
|
-
posthogApiKey:
|
|
2
|
+
baseApiUrl: "https://rtbzcxkmwj.execute-api.eu-west-1.amazonaws.com",
|
|
3
|
+
assistantUrl: "https://d2zm7i5bmzo6ze.cloudfront.net/assets/index.js",
|
|
4
|
+
posthogApiKey: "phc_EKMR6Jt4OTMEYmoUlz0v58KPwqcFxI7aZCLckpSD8Tv",
|
|
5
5
|
};
|
package/dist/config/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const config = {
|
|
2
|
-
baseApiUrl:
|
|
3
|
-
assistantUrl:
|
|
4
|
-
posthogApiKey:
|
|
2
|
+
baseApiUrl: "https://rtbzcxkmwj.execute-api.eu-west-1.amazonaws.com",
|
|
3
|
+
assistantUrl: "https://d2zm7i5bmzo6ze.cloudfront.net/assets/index.js",
|
|
4
|
+
posthogApiKey: "phc_EKMR6Jt4OTMEYmoUlz0v58KPwqcFxI7aZCLckpSD8Tv",
|
|
5
5
|
};
|
package/dist/constants/theme.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
export const defaultTheme = {
|
|
2
|
-
backgroundColor:
|
|
3
|
-
primaryColor:
|
|
4
|
-
ctaTextColor:
|
|
5
|
-
ctaBorderType:
|
|
2
|
+
backgroundColor: "#FFFFFF",
|
|
3
|
+
primaryColor: "#000000",
|
|
4
|
+
ctaTextColor: "#FFFFFF",
|
|
5
|
+
ctaBorderType: "rounded",
|
|
6
6
|
capitalizeCtas: false,
|
|
7
|
-
fontFamily:
|
|
7
|
+
fontFamily: "Inter, sans-serif",
|
|
8
8
|
highlightProductName: true,
|
|
9
9
|
title: {
|
|
10
|
-
fontSize:
|
|
11
|
-
color:
|
|
10
|
+
fontSize: "16px",
|
|
11
|
+
color: "#000000",
|
|
12
12
|
},
|
|
13
13
|
description: {
|
|
14
|
-
fontSize:
|
|
15
|
-
color:
|
|
14
|
+
fontSize: "14px",
|
|
15
|
+
color: "#000000",
|
|
16
16
|
},
|
|
17
17
|
content: {
|
|
18
|
-
fontSize:
|
|
19
|
-
color:
|
|
18
|
+
fontSize: "14px",
|
|
19
|
+
color: "#000000",
|
|
20
20
|
},
|
|
21
21
|
};
|
package/dist/constants/user.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const ANONYMOUS_CUSTOMER_ID =
|
|
2
|
-
export const CUSTOMER_ID =
|
|
1
|
+
export const ANONYMOUS_CUSTOMER_ID = "ANONYMOUS_CUSTOMER_ID";
|
|
2
|
+
export const CUSTOMER_ID = "CUSTOMER_ID";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from "./Dialog";
|
|
2
|
+
export * from "./EventsHandler";
|
|
3
|
+
export * from "./Tracking";
|
|
4
|
+
export * from "./types";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from "./Dialog";
|
|
2
|
+
export * from "./EventsHandler";
|
|
3
|
+
export * from "./Tracking";
|
|
4
|
+
export * from "./types";
|
package/dist/services/base.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getBaseApiUrl } from
|
|
1
|
+
import { getBaseApiUrl } from "./base";
|
|
2
2
|
export const loadSuggestions = async (apiKey, locale, productId) => {
|
|
3
|
-
const pagePath = window.location.pathname.split(
|
|
3
|
+
const pagePath = window.location.pathname.split("?")[0];
|
|
4
4
|
const baseApiUrl = getBaseApiUrl();
|
|
5
5
|
const response = await fetch(`${baseApiUrl}/ai/product-questions?pagePath=${pagePath}&locale=${locale}&productId=${productId}`, {
|
|
6
6
|
headers: {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { SimplifiedProduct } from
|
|
2
|
-
import { Theme } from
|
|
1
|
+
import { SimplifiedProduct } from "./product";
|
|
2
|
+
import { Theme } from "./theme";
|
|
3
3
|
export interface DialogConstructor {
|
|
4
4
|
apiKey: string;
|
|
5
5
|
locale: string;
|
|
6
6
|
callbacks: {
|
|
7
|
-
addToCart: ({ productId, quantity, variantId, currency, }: {
|
|
7
|
+
addToCart: ({ productId, quantity, price, variantId, currency, }: {
|
|
8
8
|
productId: string;
|
|
9
9
|
quantity: number;
|
|
10
|
+
price?: string;
|
|
10
11
|
variantId?: string;
|
|
11
12
|
currency?: string;
|
|
12
13
|
}) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constructor.d.ts","sourceRoot":"","sources":["../../src/types/constructor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,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AO,CAAC,KAAK,CAAC,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
package/dist/types/events.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export interface OpenAssistantPayload {
|
|
|
23
23
|
fromQuestionSuggestion?: boolean;
|
|
24
24
|
selectedVariantId?: string;
|
|
25
25
|
}
|
|
26
|
-
export type DiagnosticButtonType =
|
|
26
|
+
export type DiagnosticButtonType = "productPageButton" | "simpleButton";
|
|
27
27
|
export interface DiagnosticPayload {
|
|
28
28
|
productTitle: string;
|
|
29
29
|
handle: string;
|
package/dist/types/events.js
CHANGED
package/dist/types/global.d.ts
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
1
|
+
export * from "./events";
|
|
2
|
+
export * from "./product";
|
|
3
|
+
export * from "./trackings";
|
|
4
|
+
export * from "./suggestion";
|
|
5
|
+
export * from "./theme";
|
|
6
|
+
export * from "./constructor";
|
|
7
|
+
export * from "./assistantEvent";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/types/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
1
|
+
export * from "./events";
|
|
2
|
+
export * from "./product";
|
|
3
|
+
export * from "./trackings";
|
|
4
|
+
export * from "./suggestion";
|
|
5
|
+
export * from "./theme";
|
|
6
|
+
export * from "./constructor";
|
|
7
|
+
export * from "./assistantEvent";
|
package/dist/types/theme.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export interface Theme {
|
|
|
2
2
|
backgroundColor?: string;
|
|
3
3
|
primaryColor?: string;
|
|
4
4
|
ctaTextColor?: string;
|
|
5
|
-
ctaBorderType?:
|
|
5
|
+
ctaBorderType?: "straight" | "rounded";
|
|
6
6
|
capitalizeCtas?: boolean;
|
|
7
7
|
fontFamily?: string;
|
|
8
8
|
highlightProductName?: boolean;
|
|
@@ -3,7 +3,7 @@ export const getDetailedLocaleInfo = (locale) => {
|
|
|
3
3
|
const localeObj = new Intl.Locale(locale);
|
|
4
4
|
const language = localeObj.language;
|
|
5
5
|
const countryCode = localeObj.region ?? localeObj.maximize().region;
|
|
6
|
-
const languageNames = new Intl.DisplayNames([
|
|
6
|
+
const languageNames = new Intl.DisplayNames(["en"], { type: "language" });
|
|
7
7
|
const languageName = languageNames.of(language);
|
|
8
8
|
if (languageName === undefined || countryCode === undefined) {
|
|
9
9
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askdialog/dialog-sdk",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Dialog SDK",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,17 +26,9 @@
|
|
|
26
26
|
"author": "Dialog",
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@eslint/js": "^9.39.1",
|
|
30
29
|
"esbuild": "^0.25.12",
|
|
31
|
-
"eslint": "^9.39.1",
|
|
32
|
-
"eslint-config-prettier": "^10.1.8",
|
|
33
30
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
34
|
-
"eslint-plugin-import": "^2.32.0"
|
|
35
|
-
"eslint-plugin-prettier": "^5.5.4",
|
|
36
|
-
"globals": "^16.5.0",
|
|
37
|
-
"prettier": "^3.6.2",
|
|
38
|
-
"typescript": "^5.9.3",
|
|
39
|
-
"typescript-eslint": "^8.46.4"
|
|
31
|
+
"eslint-plugin-import": "^2.32.0"
|
|
40
32
|
},
|
|
41
33
|
"publishConfig": {
|
|
42
34
|
"access": "public"
|