@djust-b2b/djust-front-sdk 1.22.0 → 1.22.2
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/instrument.d.ts +2 -0
- package/lib/instrument.js +33 -0
- package/lib/{index.d.ts → src/index.d.ts} +1 -0
- package/lib/{index.js → src/index.js} +1 -0
- package/lib/{settings → src/settings}/fetch-instance.js +23 -36
- package/package.json +1 -1
- /package/lib/{helpers → src/helpers}/parameters-validation.d.ts +0 -0
- /package/lib/{helpers → src/helpers}/parameters-validation.js +0 -0
- /package/lib/{helpers → src/helpers}/utils.d.ts +0 -0
- /package/lib/{helpers → src/helpers}/utils.js +0 -0
- /package/lib/{interfaces → src/interfaces}/index.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/index.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/address.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/address.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/attribute.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/attribute.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/auth.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/auth.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/buying-list.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/buying-list.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/cart.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/cart.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/common.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/common.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/custom-field.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/custom-field.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/customer-account.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/customer-account.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/customer-organisation.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/customer-organisation.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/customer-user.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/customer-user.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/incident.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/incident.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/navigation-category.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/navigation-category.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/offer.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/offer.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/order.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/order.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/payment.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/payment.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/price.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/price.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/product.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/product.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/quote.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/quote.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/searchProduct.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/searchProduct.js +0 -0
- /package/lib/{interfaces → src/interfaces}/models/supplier.d.ts +0 -0
- /package/lib/{interfaces → src/interfaces}/models/supplier.js +0 -0
- /package/lib/{services → src/services}/auth/definitions.d.ts +0 -0
- /package/lib/{services → src/services}/auth/definitions.js +0 -0
- /package/lib/{services → src/services}/auth/definitions.requests.d.ts +0 -0
- /package/lib/{services → src/services}/auth/definitions.requests.js +0 -0
- /package/lib/{services → src/services}/auth/index.d.ts +0 -0
- /package/lib/{services → src/services}/auth/index.js +0 -0
- /package/lib/{services → src/services}/buying-list/definitions.d.ts +0 -0
- /package/lib/{services → src/services}/buying-list/definitions.js +0 -0
- /package/lib/{services → src/services}/buying-list/index.d.ts +0 -0
- /package/lib/{services → src/services}/buying-list/index.js +0 -0
- /package/lib/{services → src/services}/cart/definitions.d.ts +0 -0
- /package/lib/{services → src/services}/cart/definitions.js +0 -0
- /package/lib/{services → src/services}/cart/index.d.ts +0 -0
- /package/lib/{services → src/services}/cart/index.js +0 -0
- /package/lib/{services → src/services}/commercial-order/definitions.d.ts +0 -0
- /package/lib/{services → src/services}/commercial-order/definitions.js +0 -0
- /package/lib/{services → src/services}/commercial-order/index.d.ts +0 -0
- /package/lib/{services → src/services}/commercial-order/index.js +0 -0
- /package/lib/{services → src/services}/custom-field/definitions.d.ts +0 -0
- /package/lib/{services → src/services}/custom-field/definitions.js +0 -0
- /package/lib/{services → src/services}/custom-field/index.d.ts +0 -0
- /package/lib/{services → src/services}/custom-field/index.js +0 -0
- /package/lib/{services → src/services}/customer-account/definitions.d.ts +0 -0
- /package/lib/{services → src/services}/customer-account/definitions.js +0 -0
- /package/lib/{services → src/services}/customer-account/index.d.ts +0 -0
- /package/lib/{services → src/services}/customer-account/index.js +0 -0
- /package/lib/{services → src/services}/customer-user/definitions.d.ts +0 -0
- /package/lib/{services → src/services}/customer-user/definitions.js +0 -0
- /package/lib/{services → src/services}/customer-user/index.d.ts +0 -0
- /package/lib/{services → src/services}/customer-user/index.js +0 -0
- /package/lib/{services → src/services}/incident/definitions.d.ts +0 -0
- /package/lib/{services → src/services}/incident/definitions.js +0 -0
- /package/lib/{services → src/services}/incident/index.d.ts +0 -0
- /package/lib/{services → src/services}/incident/index.js +0 -0
- /package/lib/{services → src/services}/logistic-order/definitions.d.ts +0 -0
- /package/lib/{services → src/services}/logistic-order/definitions.js +0 -0
- /package/lib/{services → src/services}/logistic-order/index.d.ts +0 -0
- /package/lib/{services → src/services}/logistic-order/index.js +0 -0
- /package/lib/{services → src/services}/navigation-category/definitions.d.ts +0 -0
- /package/lib/{services → src/services}/navigation-category/definitions.js +0 -0
- /package/lib/{services → src/services}/navigation-category/index.d.ts +0 -0
- /package/lib/{services → src/services}/navigation-category/index.js +0 -0
- /package/lib/{services → src/services}/product/definitions.d.ts +0 -0
- /package/lib/{services → src/services}/product/definitions.js +0 -0
- /package/lib/{services → src/services}/product/index.d.ts +0 -0
- /package/lib/{services → src/services}/product/index.js +0 -0
- /package/lib/{services → src/services}/product-variant/definitions.d.ts +0 -0
- /package/lib/{services → src/services}/product-variant/definitions.js +0 -0
- /package/lib/{services → src/services}/product-variant/index.d.ts +0 -0
- /package/lib/{services → src/services}/product-variant/index.js +0 -0
- /package/lib/{services → src/services}/quote/definitions.d.ts +0 -0
- /package/lib/{services → src/services}/quote/definitions.js +0 -0
- /package/lib/{services → src/services}/quote/index.d.ts +0 -0
- /package/lib/{services → src/services}/quote/index.js +0 -0
- /package/lib/{services → src/services}/supplier/definitions.d.ts +0 -0
- /package/lib/{services → src/services}/supplier/definitions.js +0 -0
- /package/lib/{services → src/services}/supplier/index.d.ts +0 -0
- /package/lib/{services → src/services}/supplier/index.js +0 -0
- /package/lib/{settings → src/settings}/fetch-instance.d.ts +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const Sentry = require("@sentry/node");
|
|
3
|
+
const { nodeProfilingIntegration } = require("@sentry/profiling-node");
|
|
4
|
+
let isSentryInitialized = false;
|
|
5
|
+
const SDK_VERSION = require("../package.json").version;
|
|
6
|
+
function initSentry(clientConfig) {
|
|
7
|
+
const { clientName, env, dsn } = clientConfig;
|
|
8
|
+
if (!clientName || !env || !dsn) {
|
|
9
|
+
console.warn("[Sentry] Missing clientName, env, or DSN. Sentry is not initialized.");
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (!isSentryInitialized) {
|
|
13
|
+
Sentry.init({
|
|
14
|
+
dsn,
|
|
15
|
+
environment: `${clientName}-${env}`,
|
|
16
|
+
release: `${clientName}-${env}-${SDK_VERSION}`, // Replace with your SDK version
|
|
17
|
+
integrations: [nodeProfilingIntegration(), Sentry.nativeNodeFetchIntegration()],
|
|
18
|
+
tracesSampleRate: 1.0, // Adjust for production
|
|
19
|
+
profilesSampleRate: 1.0,
|
|
20
|
+
});
|
|
21
|
+
isSentryInitialized = true;
|
|
22
|
+
console.log(`[Sentry] Initialized for ${clientName}-${env}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function captureError(error, context = {}) {
|
|
26
|
+
Sentry.withScope((scope) => {
|
|
27
|
+
Object.entries(context).forEach(([key, value]) => {
|
|
28
|
+
scope.setExtra(key, value);
|
|
29
|
+
});
|
|
30
|
+
Sentry.captureException(error);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
module.exports = { initSentry, captureError };
|
|
@@ -37,6 +37,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.DjustSDK = void 0;
|
|
40
|
+
require("../instrument");
|
|
40
41
|
const AuthServices = __importStar(require("./services/auth"));
|
|
41
42
|
const BuyingListServices = __importStar(require("./services/buying-list"));
|
|
42
43
|
const CartServices = __importStar(require("./services/cart"));
|
|
@@ -34,34 +34,24 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.enhancedFetch = exports.updateConfiguration = exports.initialize = void 0;
|
|
37
|
+
const instrument_1 = require("../../instrument");
|
|
37
38
|
const qs = __importStar(require("query-string"));
|
|
38
|
-
const Sentry = __importStar(require("@sentry/node"));
|
|
39
|
-
const profiling_node_1 = require("@sentry/profiling-node");
|
|
40
39
|
require("isomorphic-fetch");
|
|
41
|
-
const SDK_VERSION = require("../package.json").version;
|
|
42
40
|
let clientConfig = {
|
|
43
41
|
baseUrl: "",
|
|
44
42
|
clientId: "",
|
|
45
43
|
apiKey: "",
|
|
46
44
|
dsn: "https://39ef5198e24fa0ec7b743c460bd1ca63@o1191347.ingest.us.sentry.io/4508879498575872",
|
|
47
45
|
};
|
|
48
|
-
let
|
|
46
|
+
let isSDKInitialized = false;
|
|
49
47
|
const initialize = (initConfig) => {
|
|
50
48
|
clientConfig = {
|
|
51
49
|
...initConfig,
|
|
52
50
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
environment: `${clientConfig.clientName}-${clientConfig.env}`,
|
|
58
|
-
release: `${clientConfig.clientName}-${clientConfig.env}-${SDK_VERSION}`,
|
|
59
|
-
tracesSampleRate: 1.0,
|
|
60
|
-
profilesSampleRate: 1.0,
|
|
61
|
-
integrations: [(0, profiling_node_1.nodeProfilingIntegration)()],
|
|
62
|
-
});
|
|
63
|
-
isSentryInitialized = true;
|
|
64
|
-
console.log(`[Djust SDK] Sentry activé pour ${clientConfig.clientName}-${clientConfig.env}-${SDK_VERSION}`);
|
|
51
|
+
if (!isSDKInitialized) {
|
|
52
|
+
(0, instrument_1.initSentry)(clientConfig);
|
|
53
|
+
isSDKInitialized = true;
|
|
54
|
+
console.log("[Djust SDK] Initialized with client config:", clientConfig);
|
|
65
55
|
}
|
|
66
56
|
};
|
|
67
57
|
exports.initialize = initialize;
|
|
@@ -109,7 +99,7 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
|
|
|
109
99
|
var _a, _b, _c, _d, _e, _f;
|
|
110
100
|
if (!isClientInitialized(clientConfig)) {
|
|
111
101
|
const error = new Error('[Djust SDK] SDK not initialized. Provide both client ID and API key via the "initialize" method.');
|
|
112
|
-
|
|
102
|
+
(0, instrument_1.captureError)(error);
|
|
113
103
|
throw error;
|
|
114
104
|
}
|
|
115
105
|
const { clientId, apiKey, accessToken, locale, headers } = clientConfig;
|
|
@@ -152,16 +142,14 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
|
|
|
152
142
|
if (!response.ok) {
|
|
153
143
|
const errorMessage = await response.text();
|
|
154
144
|
const error = new Error(`[Djust SDK] Erreur HTTP ${status}: ${errorMessage}`);
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
scope.setExtra("env", clientConfig.env);
|
|
164
|
-
Sentry.captureException(error);
|
|
145
|
+
(0, instrument_1.captureError)(error, {
|
|
146
|
+
path,
|
|
147
|
+
method,
|
|
148
|
+
params,
|
|
149
|
+
body,
|
|
150
|
+
headers,
|
|
151
|
+
clientName: clientConfig.clientName,
|
|
152
|
+
env: clientConfig.env,
|
|
165
153
|
});
|
|
166
154
|
throw error;
|
|
167
155
|
}
|
|
@@ -194,15 +182,14 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
|
|
|
194
182
|
return { data, headers, status };
|
|
195
183
|
}
|
|
196
184
|
catch (error) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
Sentry.captureException(error);
|
|
185
|
+
(0, instrument_1.captureError)(error, {
|
|
186
|
+
path,
|
|
187
|
+
method,
|
|
188
|
+
params: JSON.stringify(params, null, 2),
|
|
189
|
+
body: JSON.stringify(body, null, 2),
|
|
190
|
+
headers: headers ? headers : undefined,
|
|
191
|
+
clientName: clientConfig.clientName,
|
|
192
|
+
env: clientConfig.env,
|
|
206
193
|
});
|
|
207
194
|
console.error("[Djust SDK] Erreur Fetch: ", error);
|
|
208
195
|
throw new Error(`[Djust SDK] ${error.message || "Une erreur inconnue est survenue."}`);
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|