@djust-b2b/djust-front-sdk 1.21.4 → 1.21.6
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
|
@@ -10,6 +10,9 @@ export declare const DjustSDK: {
|
|
|
10
10
|
storeId?: string;
|
|
11
11
|
storeViewId?: string;
|
|
12
12
|
customerAccountId?: string;
|
|
13
|
+
clientName?: string;
|
|
14
|
+
env?: string;
|
|
15
|
+
dsn?: string;
|
|
13
16
|
}) => void;
|
|
14
17
|
updateConfiguration: (newConfig: Partial<{
|
|
15
18
|
baseUrl: string;
|
|
@@ -22,6 +25,9 @@ export declare const DjustSDK: {
|
|
|
22
25
|
storeId?: string;
|
|
23
26
|
storeViewId?: string;
|
|
24
27
|
customerAccountId?: string;
|
|
28
|
+
clientName?: string;
|
|
29
|
+
env?: string;
|
|
30
|
+
dsn?: string;
|
|
25
31
|
}>) => void;
|
|
26
32
|
getIncidents({ customerAccountIds, linkedType, ids, status, idType, page, size, sort, }: import("./services/incident/definitions").getIncidentsParameters): Promise<import("./services/incident/definitions").getIncidentsResponse>;
|
|
27
33
|
getIncident({ incidentId, idType, }: import("./services/incident/definitions").getIncidentParameters): Promise<import("./services/incident/definitions").getIncidentResponse>;
|
package/lib/index.js
CHANGED
|
@@ -46,8 +46,8 @@ const NavigationCategoryServices = __importStar(require("./services/navigation-c
|
|
|
46
46
|
const ProductServices = __importStar(require("./services/product"));
|
|
47
47
|
const QuoteServices = __importStar(require("./services/quote"));
|
|
48
48
|
const SupplierServices = __importStar(require("./services/supplier"));
|
|
49
|
-
const LogisticOrderServices = __importStar(require("./services/logistic-order"));
|
|
50
49
|
const CommercialOrderServices = __importStar(require("./services/commercial-order"));
|
|
50
|
+
const LogisticOrderServices = __importStar(require("./services/logistic-order"));
|
|
51
51
|
const IncidentServices = __importStar(require("./services/incident"));
|
|
52
52
|
const fetch_instance_1 = require("./settings/fetch-instance");
|
|
53
53
|
exports.DjustSDK = {
|
|
@@ -10,6 +10,9 @@ type ClientConfig = {
|
|
|
10
10
|
storeId?: string;
|
|
11
11
|
storeViewId?: string;
|
|
12
12
|
customerAccountId?: string;
|
|
13
|
+
clientName?: string;
|
|
14
|
+
env?: string;
|
|
15
|
+
dsn?: string;
|
|
13
16
|
};
|
|
14
17
|
export declare const initialize: (initConfig: ClientConfig) => void;
|
|
15
18
|
export declare const updateConfiguration: (newConfig: Partial<ClientConfig>) => void;
|
|
@@ -35,12 +35,35 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.enhancedFetch = exports.updateConfiguration = exports.initialize = void 0;
|
|
37
37
|
const qs = __importStar(require("query-string"));
|
|
38
|
+
const Sentry = __importStar(require("@sentry/browser"));
|
|
38
39
|
require("isomorphic-fetch");
|
|
39
|
-
let clientConfig = {
|
|
40
|
+
let clientConfig = {
|
|
41
|
+
baseUrl: "",
|
|
42
|
+
clientId: "",
|
|
43
|
+
apiKey: "",
|
|
44
|
+
dsn: "https://39ef5198e24fa0ec7b743c460bd1ca63@o1191347.ingest.us.sentry.io/4508879498575872",
|
|
45
|
+
env: "development",
|
|
46
|
+
clientName: "Djust",
|
|
47
|
+
};
|
|
40
48
|
const initialize = (initConfig) => {
|
|
41
49
|
clientConfig = {
|
|
42
50
|
...initConfig,
|
|
43
51
|
};
|
|
52
|
+
if (clientConfig.dsn) {
|
|
53
|
+
Sentry.init({
|
|
54
|
+
dsn: clientConfig.dsn,
|
|
55
|
+
environment: clientConfig.env || "unknown",
|
|
56
|
+
release: `${clientConfig.clientName || "unknown"}`,
|
|
57
|
+
integrations: [
|
|
58
|
+
Sentry.browserTracingIntegration(),
|
|
59
|
+
Sentry.replayIntegration(),
|
|
60
|
+
],
|
|
61
|
+
tracesSampleRate: 1.0,
|
|
62
|
+
replaysSessionSampleRate: 0.1,
|
|
63
|
+
replaysOnErrorSampleRate: 1.0,
|
|
64
|
+
});
|
|
65
|
+
console.log(`[Djust SDK] Sentry initialized in ${clientConfig.clientName || "unknown"} environment: ${clientConfig.env || "unknown"}.`);
|
|
66
|
+
}
|
|
44
67
|
};
|
|
45
68
|
exports.initialize = initialize;
|
|
46
69
|
const updateConfiguration = (newConfig) => {
|
|
@@ -86,7 +109,11 @@ const isPublicRoute = (path, method) => {
|
|
|
86
109
|
const enhancedFetch = async ({ path, method, params = {}, body, }) => {
|
|
87
110
|
var _a, _b, _c, _d, _e, _f;
|
|
88
111
|
if (!isClientInitialized(clientConfig)) {
|
|
89
|
-
|
|
112
|
+
const error = new Error("[Djust SDK] SDK not initialized.");
|
|
113
|
+
Sentry.captureException(error, {
|
|
114
|
+
tags: { env: clientConfig.env },
|
|
115
|
+
});
|
|
116
|
+
throw error;
|
|
90
117
|
}
|
|
91
118
|
const { clientId, apiKey, accessToken, locale, headers } = clientConfig;
|
|
92
119
|
const requestHeaders = new Headers({
|
|
@@ -127,7 +154,17 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
|
|
|
127
154
|
const { status, headers } = response;
|
|
128
155
|
if (!response.ok) {
|
|
129
156
|
const errorMessage = await response.text();
|
|
130
|
-
|
|
157
|
+
const error = new Error(`[Djust SDK] HTTP error ${response.status}: ${errorMessage}`);
|
|
158
|
+
Sentry.captureException(error, {
|
|
159
|
+
extra: {
|
|
160
|
+
url: path,
|
|
161
|
+
method,
|
|
162
|
+
response: errorMessage,
|
|
163
|
+
status: response.status,
|
|
164
|
+
env: clientConfig.env,
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
throw error;
|
|
131
168
|
}
|
|
132
169
|
const isJsonResponse = (_d = headers
|
|
133
170
|
.get("content-type")) === null || _d === void 0 ? void 0 : _d.includes("application/json");
|
|
@@ -159,8 +196,8 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
|
|
|
159
196
|
return { data, headers, status };
|
|
160
197
|
}
|
|
161
198
|
catch (error) {
|
|
162
|
-
|
|
163
|
-
throw new Error(`[Djust SDK] ${error
|
|
199
|
+
Sentry.captureException(error, { tags: { env: clientConfig.env } });
|
|
200
|
+
throw new Error(`[Djust SDK] ${error || "Unknown error occurred"}`);
|
|
164
201
|
}
|
|
165
202
|
};
|
|
166
203
|
exports.enhancedFetch = enhancedFetch;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djust-b2b/djust-front-sdk",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.6",
|
|
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",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"lib/**/**.d.ts"
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
|
+
"@sentry/browser": "^9.2.0",
|
|
53
54
|
"isomorphic-fetch": "^3.0.0",
|
|
54
55
|
"query-string": "^7.1.1"
|
|
55
56
|
},
|