@askdialog/dialog-sdk 2.13.0 → 2.14.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 CHANGED
@@ -122,7 +122,29 @@ If your site uses OneTrust auto-blocking, it may neutralize the assistant script
122
122
  - categorize the assistant CDN domain as strictly necessary in your OneTrust console, or
123
123
  - pass the optional `ignoreOneTrustAutoBlock: true` constructor flag so the SDK adds `data-ot-ignore` on the script it injects.
124
124
 
125
- Either is compliance-safe with regard to analytics: the assistant gates all analytics on consent internally and sends nothing without an explicit opt-in (inspect `window.dialog.audit.consent`).
125
+ Either is compliance-safe with regard to analytics: the assistant gates all analytics on consent internally and sends nothing without an explicit opt-in, unless you declared the consent yourself with `analyticsConsent` (inspect `window.dialog.audit.consent`).
126
+
127
+ ### Declaring the analytics consent
128
+
129
+ By default the assistant sends analytics events (add-to-cart, checkout, assistant usage) only once it detects a consent signal on the page: Google Consent Mode, TCF v2 or OneTrust. A site with no cookie banner emits no such signal, so nothing is sent for any of its visitors.
130
+
131
+ On those sites, pass the optional `analyticsConsent: 'granted'` constructor option:
132
+
133
+ ```ts
134
+ new Dialog({
135
+ apiKey: 'YOUR_API_KEY',
136
+ locale: 'en-US', currency: 'USD',
137
+ analyticsConsent: 'granted', // no cookie banner on this site
138
+ });
139
+ ```
140
+
141
+ It works like a Google Consent Mode `default` state:
142
+
143
+ - analytics is on from the first page view, for every visitor;
144
+ - a refusal coming from a consent platform present on the page still wins: a Google Consent Mode `update` set to `denied`, or OneTrust loaded without the performance group (`C0002`), turns analytics off for that visitor;
145
+ - `window.dialog.audit.consent` reports `detectedCmp: 'declared'` when the option is what enabled analytics.
146
+
147
+ Whether consent can be assumed for your visitors is your compliance decision. Omit the option to keep the default detection.
126
148
 
127
149
  ### Disabling add-to-cart
128
150
 
package/dist/Dialog.d.ts CHANGED
@@ -20,8 +20,9 @@ export declare class Dialog {
20
20
  private _eventsHandler;
21
21
  private _ignoreOneTrustAutoBlock;
22
22
  private _disableAddToCart;
23
+ private _analyticsConsent?;
23
24
  private _currentProduct?;
24
- constructor({ apiKey, locale, currency, countryCode, callbacks, theme, userId, ignoreOneTrustAutoBlock, disableAddToCart, product, }: DialogConstructor);
25
+ constructor({ apiKey, locale, currency, countryCode, callbacks, theme, userId, ignoreOneTrustAutoBlock, disableAddToCart, analyticsConsent, product, }: DialogConstructor);
25
26
  get apiKey(): string;
26
27
  get theme(): Theme;
27
28
  get userId(): string;
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../src/Dialog.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,iBAAiB,EAClB,MAAM,qBAAqB,CAAC;AAC7B,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,EACL,cAAc,EACd,uBAAuB,EAEvB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE9E,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,qBAAa,MAAM;IACjB,gBAAuB,OAAO,SAAuB;IAErD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,YAAY,CAAC,CAAS;IAE9B,OAAO,CAAC,UAAU,CAAC,C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
22
  _eventsHandler;
23
23
  _ignoreOneTrustAutoBlock;
24
24
  _disableAddToCart;
25
+ _analyticsConsent;
25
26
  _currentProduct;
26
- constructor({ apiKey, locale, currency, countryCode, callbacks, theme, userId, ignoreOneTrustAutoBlock, disableAddToCart, product, }) {
27
+ constructor({ apiKey, locale, currency, countryCode, callbacks, theme, userId, ignoreOneTrustAutoBlock, disableAddToCart, analyticsConsent, product, }) {
27
28
  this._apiKey = apiKey;
28
29
  this._locale = locale;
29
30
  this._currency = currency;
@@ -31,6 +32,7 @@ export class Dialog {
31
32
  this._callbacks = callbacks;
32
33
  this._ignoreOneTrustAutoBlock = ignoreOneTrustAutoBlock ?? false;
33
34
  this._disableAddToCart = disableAddToCart ?? false;
35
+ this._analyticsConsent = analyticsConsent;
34
36
  this._currentProduct =
35
37
  product !== undefined && Dialog._isValidProductId(product.id)
36
38
  ? product
@@ -248,6 +250,9 @@ export class Dialog {
248
250
  // Hide the add-to-cart button in the assistant.
249
251
  div.dataset.disableAddToCart = "true";
250
252
  }
253
+ if (this._analyticsConsent === "granted") {
254
+ div.dataset.analyticsConsent = this._analyticsConsent;
255
+ }
251
256
  document.body.appendChild(div);
252
257
  if (this._currentProduct !== undefined) {
253
258
  this._applyCurrentProductDataset();
@@ -77,3 +77,23 @@ describe("Dialog._loadAssistant add-to-cart toggle", () => {
77
77
  expect(div.dataset.disableAddToCart).toBeUndefined();
78
78
  });
79
79
  });
80
+ describe("Dialog._loadAssistant analytics consent", () => {
81
+ it("declares the granted consent on the injected div", () => {
82
+ vi.useFakeTimers();
83
+ const { div } = stubDocument();
84
+ loadAssistant(buildDialog({ _analyticsConsent: "granted" }));
85
+ expect(div.dataset.analyticsConsent).toBe("granted");
86
+ });
87
+ it("declares nothing by default", () => {
88
+ vi.useFakeTimers();
89
+ const { div } = stubDocument();
90
+ loadAssistant(buildDialog());
91
+ expect(div.dataset.analyticsConsent).toBeUndefined();
92
+ });
93
+ it("ignores a value other than granted", () => {
94
+ vi.useFakeTimers();
95
+ const { div } = stubDocument();
96
+ loadAssistant(buildDialog({ _analyticsConsent: "true" }));
97
+ expect(div.dataset.analyticsConsent).toBeUndefined();
98
+ });
99
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=suggestions.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suggestions.spec.d.ts","sourceRoot":"","sources":["../../src/__tests__/suggestions.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,38 @@
1
+ // @vitest-environment jsdom
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
+ import { config } from "../config";
4
+ import { loadSuggestions } from "../services/suggestions";
5
+ const fetchMock = vi.fn();
6
+ const apiKey = "a5c3c7e0-5f2b-4d3a-9b1e-2f6c8d7a1b23";
7
+ const productId = "9053100277937";
8
+ describe("loadSuggestions", () => {
9
+ beforeEach(() => {
10
+ vi.stubGlobal("fetch", fetchMock);
11
+ window.history.pushState({}, "", "/products/serum-eclat");
12
+ fetchMock.mockResolvedValue({
13
+ json: () => Promise.resolve({ questions: [] }),
14
+ });
15
+ });
16
+ afterEach(() => {
17
+ vi.unstubAllGlobals();
18
+ fetchMock.mockReset();
19
+ });
20
+ it("calls the monolith route with the api key header", async () => {
21
+ await loadSuggestions(apiKey, "fr", productId);
22
+ const [url, init] = fetchMock.mock.calls[0];
23
+ const parsed = new URL(url);
24
+ expect(parsed.origin).toBe(new URL(config.monolithApiUrl).origin);
25
+ expect(parsed.pathname).toBe("/public/product-page-questions");
26
+ expect(Object.fromEntries(parsed.searchParams)).toEqual({
27
+ pagePath: "/products/serum-eclat",
28
+ locale: "fr",
29
+ productId,
30
+ });
31
+ expect(init.headers).toEqual({ "x-dialog-api-key": apiKey });
32
+ });
33
+ it("returns the parsed body", async () => {
34
+ const body = { questions: [{ question: "Is it vegan?" }] };
35
+ fetchMock.mockResolvedValue({ json: () => Promise.resolve(body) });
36
+ await expect(loadSuggestions(apiKey, "en", productId)).resolves.toEqual(body);
37
+ });
38
+ });
@@ -1,5 +1,4 @@
1
1
  export declare const config: {
2
- baseApiUrl: string;
3
2
  monolithApiUrl: string;
4
3
  assistantUrl: string;
5
4
  };
@@ -1 +1 @@
1
- {"version":3,"file":"config.development.d.ts","sourceRoot":"","sources":["../../src/config/config.development.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;CAKlB,CAAC;AACF,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC"}
1
+ {"version":3,"file":"config.development.d.ts","sourceRoot":"","sources":["../../src/config/config.development.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;CAKlB,CAAC;AACF,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC"}
@@ -1,6 +1,6 @@
1
1
  export const config = {
2
- baseApiUrl: "https://hr5buzenb1.execute-api.eu-west-1.amazonaws.com",
3
- // Nest monolith (staging) — serves POST /public/search/lexical.
4
- monolithApiUrl: "https://fvcphlqyle.execute-api.eu-west-1.amazonaws.com",
2
+ // Nest monolith (staging) — serves POST /public/search/lexical and
3
+ // GET /public/product-page-questions.
4
+ monolithApiUrl: "https://api-staging.askdialog.ai",
5
5
  assistantUrl: "https://d2bycosa71tnxv.cloudfront.net/assets/index.js",
6
6
  };
@@ -1,5 +1,4 @@
1
1
  export declare const config: {
2
- baseApiUrl: string;
3
2
  monolithApiUrl: string;
4
3
  assistantUrl: string;
5
4
  };
@@ -1 +1 @@
1
- {"version":3,"file":"config.production.d.ts","sourceRoot":"","sources":["../../src/config/config.production.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;CAOlB,CAAC;AACF,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC"}
1
+ {"version":3,"file":"config.production.d.ts","sourceRoot":"","sources":["../../src/config/config.production.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;CAOlB,CAAC;AACF,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC"}
@@ -1,8 +1,8 @@
1
1
  export const config = {
2
- baseApiUrl: "https://rtbzcxkmwj.execute-api.eu-west-1.amazonaws.com",
3
- // Nest monolith (production) — serves POST /public/search/lexical. Custom domain,
4
- // same as the dashboard's VITE_MONOLITH_API_URL: the raw execute-api
5
- // gateway URL answers 500 on every route and must not be used.
2
+ // Nest monolith (production) — serves POST /public/search/lexical and
3
+ // GET /public/product-page-questions. Custom domain, same as the dashboard's
4
+ // VITE_MONOLITH_API_URL: the raw execute-api gateway URL answers 500 on
5
+ // every route and must not be used.
6
6
  monolithApiUrl: "https://api.askdialog.ai",
7
7
  assistantUrl: "https://d2zm7i5bmzo6ze.cloudfront.net/assets/index.js",
8
8
  };
@@ -1,5 +1,4 @@
1
1
  export declare const config: {
2
- baseApiUrl: string;
3
2
  monolithApiUrl: string;
4
3
  assistantUrl: string;
5
4
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;CAOlB,CAAC;AACF,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;CAOlB,CAAC;AACF,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC"}
@@ -1,8 +1,8 @@
1
1
  export const config = {
2
- baseApiUrl: "https://rtbzcxkmwj.execute-api.eu-west-1.amazonaws.com",
3
- // Nest monolith (production) — serves POST /public/search/lexical. Custom domain,
4
- // same as the dashboard's VITE_MONOLITH_API_URL: the raw execute-api
5
- // gateway URL answers 500 on every route and must not be used.
2
+ // Nest monolith (production) — serves POST /public/search/lexical and
3
+ // GET /public/product-page-questions. Custom domain, same as the dashboard's
4
+ // VITE_MONOLITH_API_URL: the raw execute-api gateway URL answers 500 on
5
+ // every route and must not be used.
6
6
  monolithApiUrl: "https://api.askdialog.ai",
7
7
  assistantUrl: "https://d2zm7i5bmzo6ze.cloudfront.net/assets/index.js",
8
8
  };
@@ -1 +1 @@
1
- {"version":3,"file":"suggestions.d.ts","sourceRoot":"","sources":["../../src/services/suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD,eAAO,MAAM,eAAe,GAC1B,QAAQ,MAAM,EACd,QAAQ,MAAM,EACd,WAAW,MAAM,KAChB,OAAO,CAAC,UAAU,CAiBpB,CAAC"}
1
+ {"version":3,"file":"suggestions.d.ts","sourceRoot":"","sources":["../../src/services/suggestions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKjD,eAAO,MAAM,eAAe,GAC1B,QAAQ,MAAM,EACd,QAAQ,MAAM,EACd,WAAW,MAAM,KAChB,OAAO,CAAC,UAAU,CAepB,CAAC"}
@@ -1,10 +1,12 @@
1
- import { getBaseApiUrl } from "./base";
1
+ import { config } from "../config";
2
+ const PRODUCT_QUESTIONS_PATH = "/public/product-page-questions";
3
+ const API_KEY_HEADER = "x-dialog-api-key";
2
4
  export const loadSuggestions = async (apiKey, locale, productId) => {
3
5
  const pagePath = window.location.pathname.split("?")[0];
4
- const baseApiUrl = getBaseApiUrl();
5
- const response = await fetch(`${baseApiUrl}/ai/product-questions?pagePath=${pagePath}&locale=${locale}&productId=${productId}`, {
6
+ const query = new URLSearchParams({ pagePath, locale, productId });
7
+ const response = await fetch(`${config.monolithApiUrl}${PRODUCT_QUESTIONS_PATH}?${query.toString()}`, {
6
8
  headers: {
7
- Authorization: apiKey,
9
+ [API_KEY_HEADER]: apiKey,
8
10
  },
9
11
  });
10
12
  const data = await response.json();
@@ -11,6 +11,7 @@ export interface CurrentProduct {
11
11
  id: string;
12
12
  variantId?: string;
13
13
  }
14
+ export type AnalyticsConsent = "granted";
14
15
  export interface DialogConstructor {
15
16
  apiKey: string;
16
17
  /** BCP-47 locale, e.g. `fr-FR`. */
@@ -51,6 +52,7 @@ export interface DialogConstructor {
51
52
  * Product links and recommendation browsing are unaffected.
52
53
  */
53
54
  disableAddToCart?: boolean;
55
+ analyticsConsent?: AnalyticsConsent;
54
56
  /**
55
57
  * The product of the page the SDK is instantiated on, when it is a product
56
58
  * page. The assistant uses it as the conversation's product context for
@@ -1 +1 @@
1
- {"version":3,"file":"constructor.d.ts","sourceRoot":"","sources":["../../src/types/constructor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,UAAU,EAAE,CACV,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,KACf,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAChC,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxE;AAED,MAAM,WAAW,cAAc;IAC7B,6EAA6E;IAC7E,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,uBAAuB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AAO,CAAC;IAClC;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askdialog/dialog-sdk",
3
- "version": "2.13.0",
3
+ "version": "2.14.0",
4
4
  "private": false,
5
5
  "description": "Dialog SDK",
6
6
  "main": "dist/index.js",
@@ -1,2 +0,0 @@
1
- export declare const getBaseApiUrl: () => string;
2
- //# sourceMappingURL=base.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/services/base.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,QAAO,MAEhC,CAAC"}
@@ -1,4 +0,0 @@
1
- import { config } from "../config";
2
- export const getBaseApiUrl = () => {
3
- return config.baseApiUrl;
4
- };