@chordcommerce/analytics 1.21.2-beta.1 → 1.21.3

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
@@ -181,13 +181,19 @@ The release flow:
181
181
  4. If releasable commits exist, the package is published to npm and GitHub Packages, CHANGELOG.md is updated, and a Git tag is created.
182
182
  5. If no releasable commits exist, `semantic-release` exits cleanly and nothing is published.
183
183
 
184
+ ### PR titles must follow conventional commits
185
+
186
+ When using GitHub's **squash merge** (the default), the PR title becomes the first line of the squash commit message. Semantic-release only parses the **first line** to determine the version bump, so **the PR title must use a conventional commit prefix** (e.g., `fix: resolve consent race condition`). Individual commit messages in the PR body are ignored.
187
+
188
+ If the PR title does not start with a releasable prefix, no release will be published even if the individual commits within the PR use `fix:` or `feat:`.
189
+
184
190
  ### When a release happens (and when it doesn't)
185
191
 
186
192
  A release is published **only** when all three conditions are met:
187
193
 
188
194
  1. A push lands on `main` or `beta` (via merged PR or direct push)
189
195
  2. Tests pass
190
- 3. There are new commits since the last release tag with a releasable prefix
196
+ 3. There are new commits since the last release tag with a releasable prefix (checked against the **first line** of each commit message)
191
197
 
192
198
  **Releasable commit prefixes** (these trigger a version bump):
193
199
 
@@ -45,7 +45,7 @@ var utils_js_1 = require("./utils.js");
45
45
  * Returns initial consent configuration to be tracked after CDP is fully ready.
46
46
  */
47
47
  var addCdpSnippet = function (options) { return __awaiter(void 0, void 0, void 0, function () {
48
- var normalizedCDPDomain, cdpReadyPromise, s, initialConsent;
48
+ var normalizedCDPDomain, cdpReadyPromise, escapedNamespace, existingScript, s, initialConsent;
49
49
  return __generator(this, function (_a) {
50
50
  switch (_a.label) {
51
51
  case 0:
@@ -65,14 +65,20 @@ var addCdpSnippet = function (options) { return __awaiter(void 0, void 0, void 0
65
65
  };
66
66
  checkCdpReady();
67
67
  });
68
- s = document.createElement('script');
69
- s.async = true;
70
- s.src = "".concat(normalizedCDPDomain, "/p.js");
71
- s.setAttribute('data-debug', "".concat(!!options.debug));
72
- s.setAttribute('data-init-only', 'true');
73
- s.setAttribute('data-namespace', "_".concat(options.namespace));
74
- s.setAttribute('data-write-key', options.cdpWriteKey);
75
- document.head.appendChild(s);
68
+ escapedNamespace = typeof CSS !== 'undefined' && typeof CSS.escape === 'function'
69
+ ? CSS.escape("_".concat(options.namespace))
70
+ : "_".concat(options.namespace);
71
+ existingScript = document.querySelector("script[data-namespace=\"".concat(escapedNamespace, "\"]"));
72
+ if (!existingScript) {
73
+ s = document.createElement('script');
74
+ s.async = true;
75
+ s.src = "".concat(normalizedCDPDomain, "/p.js");
76
+ s.setAttribute('data-debug', "".concat(!!options.debug));
77
+ s.setAttribute('data-init-only', 'true');
78
+ s.setAttribute('data-namespace', "_".concat(options.namespace));
79
+ s.setAttribute('data-write-key', options.cdpWriteKey);
80
+ document.head.appendChild(s);
81
+ }
76
82
  // Wait for CDP to be ready before setting up consent
77
83
  return [4 /*yield*/, cdpReadyPromise];
78
84
  case 1:
@@ -180,14 +180,12 @@ var addCdpConsent = function (options) {
180
180
  case 2:
181
181
  _a.trys.push([2, 4, , 5]);
182
182
  return [4 /*yield*/, setupConsentManagement()];
183
- case 3:
184
- _a.sent();
185
- return [3 /*break*/, 5];
183
+ case 3: return [2 /*return*/, _a.sent()];
186
184
  case 4:
187
185
  error_1 = _a.sent();
188
186
  console.error('Error setting up consent management:', error_1);
189
- return [3 /*break*/, 5];
190
- case 5: return [2 /*return*/, null];
187
+ return [2 /*return*/, null];
188
+ case 5: return [2 /*return*/];
191
189
  }
192
190
  });
193
191
  }); };
@@ -32,14 +32,21 @@ export const addCdpSnippet = (options) => __awaiter(void 0, void 0, void 0, func
32
32
  };
33
33
  checkCdpReady();
34
34
  });
35
- const s = document.createElement('script');
36
- s.async = true;
37
- s.src = `${normalizedCDPDomain}/p.js`;
38
- s.setAttribute('data-debug', `${!!options.debug}`);
39
- s.setAttribute('data-init-only', 'true');
40
- s.setAttribute('data-namespace', `_${options.namespace}`);
41
- s.setAttribute('data-write-key', options.cdpWriteKey);
42
- document.head.appendChild(s);
35
+ // Guard against duplicate script injection (e.g. React StrictMode remounts)
36
+ const escapedNamespace = typeof CSS !== 'undefined' && typeof CSS.escape === 'function'
37
+ ? CSS.escape(`_${options.namespace}`)
38
+ : `_${options.namespace}`;
39
+ const existingScript = document.querySelector(`script[data-namespace="${escapedNamespace}"]`);
40
+ if (!existingScript) {
41
+ const s = document.createElement('script');
42
+ s.async = true;
43
+ s.src = `${normalizedCDPDomain}/p.js`;
44
+ s.setAttribute('data-debug', `${!!options.debug}`);
45
+ s.setAttribute('data-init-only', 'true');
46
+ s.setAttribute('data-namespace', `_${options.namespace}`);
47
+ s.setAttribute('data-write-key', options.cdpWriteKey);
48
+ document.head.appendChild(s);
49
+ }
43
50
  // Wait for CDP to be ready before setting up consent
44
51
  yield cdpReadyPromise;
45
52
  let initialConsent = null;
@@ -123,12 +123,12 @@ export const addCdpConsent = (options) => {
123
123
  }
124
124
  // Set up consent management and wait for it to complete
125
125
  try {
126
- yield setupConsentManagement();
126
+ return yield setupConsentManagement();
127
127
  }
128
128
  catch (error) {
129
129
  console.error('Error setting up consent management:', error);
130
+ return null;
130
131
  }
131
- return null;
132
132
  });
133
133
  const getConsentConfig = () => {
134
134
  if (!(adapter === null || adapter === void 0 ? void 0 : adapter.getCategories) || !(adapter === null || adapter === void 0 ? void 0 : adapter.isConsentReady)) {
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.21.2-beta.1",
4
+ "version": "1.21.3",
5
5
  "author": "Chord Commerce <help@chord.co> (https://www.chord.co)",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",