@chordcommerce/analytics 1.18.2 → 1.18.3-beta.1

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.
@@ -75,10 +75,18 @@ var addCdpSnippet = function (options) { return __awaiter(void 0, void 0, void 0
75
75
  case 1:
76
76
  // Wait for CDP to be ready before setting up consent
77
77
  _a.sent();
78
- if (options.consent) {
79
- (0, index_js_1.addCdpConsent)(options).init();
78
+ if (!options.consent) return [3 /*break*/, 3];
79
+ if (options.debug && options.enableLogging) {
80
+ console.log('Chord CDP: Setting up consent management');
80
81
  }
81
- return [2 /*return*/];
82
+ return [4 /*yield*/, (0, index_js_1.addCdpConsent)(options).init()];
83
+ case 2:
84
+ _a.sent();
85
+ if (options.debug && options.enableLogging) {
86
+ console.log('Chord CDP: Consent management setup complete');
87
+ }
88
+ _a.label = 3;
89
+ case 3: return [2 /*return*/];
82
90
  }
83
91
  });
84
92
  }); };
@@ -209,7 +209,7 @@ var addCdpConsent = function (options) {
209
209
  * Returns a promise that resolves to true if CDP should be loaded, false otherwise.
210
210
  */
211
211
  var init = function () { return __awaiter(void 0, void 0, void 0, function () {
212
- var canBeTracked;
212
+ var canBeTracked, error_1;
213
213
  return __generator(this, function (_a) {
214
214
  switch (_a.label) {
215
215
  case 0:
@@ -226,11 +226,18 @@ var addCdpConsent = function (options) {
226
226
  return [2 /*return*/, false];
227
227
  _a.label = 2;
228
228
  case 2:
229
- // Set up consent management in the background
230
- setupConsentManagement().catch(function (error) {
231
- console.error('Error setting up consent management:', error);
232
- });
233
- return [2 /*return*/, true];
229
+ _a.trys.push([2, 4, , 5]);
230
+ return [4 /*yield*/, setupConsentManagement()];
231
+ case 3:
232
+ _a.sent();
233
+ return [3 /*break*/, 5];
234
+ case 4:
235
+ error_1 = _a.sent();
236
+ if (options.debug && options.enableLogging) {
237
+ console.error('Error setting up consent management:', error_1);
238
+ }
239
+ return [3 /*break*/, 5];
240
+ case 5: return [2 /*return*/, true];
234
241
  }
235
242
  });
236
243
  }); };
@@ -40,7 +40,13 @@ export const addCdpSnippet = (options) => __awaiter(void 0, void 0, void 0, func
40
40
  // Wait for CDP to be ready before setting up consent
41
41
  yield cdpReadyPromise;
42
42
  if (options.consent) {
43
- addCdpConsent(options).init();
43
+ if (options.debug && options.enableLogging) {
44
+ console.log('Chord CDP: Setting up consent management');
45
+ }
46
+ yield addCdpConsent(options).init();
47
+ if (options.debug && options.enableLogging) {
48
+ console.log('Chord CDP: Consent management setup complete');
49
+ }
44
50
  }
45
51
  });
46
52
  /*
@@ -148,10 +148,14 @@ export const addCdpConsent = (options) => {
148
148
  if (!canBeTracked)
149
149
  return false;
150
150
  }
151
- // Set up consent management in the background
152
- setupConsentManagement().catch((error) => {
153
- console.error('Error setting up consent management:', error);
154
- });
151
+ try {
152
+ yield setupConsentManagement();
153
+ }
154
+ catch (error) {
155
+ if (options.debug && options.enableLogging) {
156
+ console.error('Error setting up consent management:', error);
157
+ }
158
+ }
155
159
  return true;
156
160
  });
157
161
  return {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chordcommerce/analytics",
3
3
  "description": "Chord Commerce event tracking",
4
- "version": "1.18.2",
4
+ "version": "1.18.3-beta.1",
5
5
  "author": "Chord Commerce <help@chord.co> (https://www.chord.co)",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",