@djust-b2b/djust-front-sdk 1.21.8 → 1.21.10

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/lib/index.d.ts CHANGED
@@ -1,34 +1,6 @@
1
1
  export declare const DjustSDK: {
2
- initialize: (initConfig: {
3
- baseUrl: string;
4
- clientId: string;
5
- apiKey: string;
6
- timeout?: number;
7
- locale?: string;
8
- headers?: Headers;
9
- accessToken?: string;
10
- storeId?: string;
11
- storeViewId?: string;
12
- customerAccountId?: string;
13
- clientName?: string;
14
- env?: string;
15
- dsn?: string;
16
- }) => void;
17
- updateConfiguration: (newConfig: Partial<{
18
- baseUrl: string;
19
- clientId: string;
20
- apiKey: string;
21
- timeout?: number;
22
- locale?: string;
23
- headers?: Headers;
24
- accessToken?: string;
25
- storeId?: string;
26
- storeViewId?: string;
27
- customerAccountId?: string;
28
- clientName?: string;
29
- env?: string;
30
- dsn?: string;
31
- }>) => void;
2
+ initialize: (initConfig: import("./settings/fetch-instance").ClientConfig) => void;
3
+ updateConfiguration: (newConfig: Partial<import("./settings/fetch-instance").ClientConfig>) => void;
32
4
  getIncidents({ customerAccountIds, linkedType, ids, status, idType, page, size, sort, }: import("./services/incident/definitions").getIncidentsParameters): Promise<import("./services/incident/definitions").getIncidentsResponse>;
33
5
  getIncident({ incidentId, idType, }: import("./services/incident/definitions").getIncidentParameters): Promise<import("./services/incident/definitions").getIncidentResponse>;
34
6
  createOrderLogisticIncident({ logisticOrderId, idType, customField, reasonCode, }: import("./services/incident/definitions").createOrderLogisticIncidentParameters): Promise<import("./services/incident/definitions").createOrderLogisticIncidentResponse>;
@@ -1,5 +1,5 @@
1
1
  import { DjustConfig } from "../interfaces/models/common";
2
- type ClientConfig = {
2
+ export type ClientConfig = {
3
3
  baseUrl: string;
4
4
  clientId: string;
5
5
  apiKey: string;
@@ -25,4 +25,3 @@ export declare const enhancedFetch: <T = any>({ path, method, params, body, }: R
25
25
  headers: Headers;
26
26
  status: number;
27
27
  }>;
28
- export {};
@@ -59,11 +59,20 @@ const initialize = (initConfig) => {
59
59
  integrations: [
60
60
  Sentry.browserTracingIntegration(),
61
61
  Sentry.replayIntegration(),
62
+ Sentry.httpClientIntegration(),
63
+ Sentry.browserApiErrorsIntegration({
64
+ setTimeout: true,
65
+ setInterval: true,
66
+ requestAnimationFrame: true,
67
+ XMLHttpRequest: true,
68
+ eventTarget: true,
69
+ }),
62
70
  ],
63
71
  tracesSampleRate: 1.0,
64
72
  replaysSessionSampleRate: 0.1,
65
73
  replaysOnErrorSampleRate: 1.0,
66
74
  profilesSampleRate: 1.0,
75
+ sendDefaultPii: true,
67
76
  });
68
77
  console.log(`[Djust SDK] Sentry initialized in ${clientConfig.clientName || "unknown"} environment: ${clientConfig.env || "unknown"}.`);
69
78
  }
@@ -124,8 +133,16 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
124
133
  "dj-api-key": apiKey,
125
134
  "Content-Type": "application/json",
126
135
  });
127
- if (!isPublicRoute(path, method) && accessToken)
128
- requestHeaders.append("Authorization", `Bearer ${accessToken}`);
136
+ if (!isPublicRoute(path, method)) {
137
+ if (accessToken) {
138
+ requestHeaders.append("Authorization", `Bearer ${accessToken}`);
139
+ }
140
+ else {
141
+ Sentry.captureException(new Error("[Djust SDK] Access token is missing for a private route."), {
142
+ tags: { env: clientConfig.env, clientName: clientConfig.clientName },
143
+ });
144
+ }
145
+ }
129
146
  if (locale)
130
147
  requestHeaders.append("locale", locale);
131
148
  // Use provided params or fallback to clientConfig defaults
@@ -162,7 +179,8 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
162
179
  extra: {
163
180
  url: fullPath,
164
181
  method,
165
- response: errorMessage,
182
+ response: response,
183
+ errorMessage: errorMessage,
166
184
  status: response.status,
167
185
  env: clientConfig.env,
168
186
  headers: (() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djust-b2b/djust-front-sdk",
3
- "version": "1.21.8",
3
+ "version": "1.21.10",
4
4
  "description": "DJUST Front SDK is a versatile JavaScript Software Development Kit (SDK) ",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",