@salesforcedevs/docs-components 1.27.6 → 1.27.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.27.6",
3
+ "version": "1.27.7",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -25,7 +25,7 @@
25
25
  "@types/lodash.orderby": "4.6.9",
26
26
  "@types/lodash.uniqby": "4.7.9"
27
27
  },
28
- "gitHead": "96007cd5dbbd2c0754377ecbaf6f5916082b2fb0",
28
+ "gitHead": "9a6692c538b9622479d013aeffb1a2c9760b7494",
29
29
  "volta": {
30
30
  "node": "20.19.0",
31
31
  "yarn": "1.22.19"
@@ -3,8 +3,8 @@ import { noCase } from "no-case";
3
3
  import { sentenceCase } from "sentence-case";
4
4
  import qs from "query-string";
5
5
  import { AmfModelParser } from "doc/amfModelParser";
6
- import { normalizeBoolean } from "dxUtils/normalizers";
7
- import type { OptionWithLink } from "typings/custom";
6
+ import { normalizeBoolean, toJson } from "dxUtils/normalizers";
7
+ import type { OptionWithLink, Breadcrumb } from "typings/custom";
8
8
  import type {
9
9
  AmfConfig,
10
10
  AmfMetadataTopic,
@@ -29,6 +29,7 @@ import {
29
29
  import { restoreScroll } from "dx/scrollManager";
30
30
  import { DocPhaseInfo } from "typings/custom";
31
31
  import { oldVersionDocInfo } from "docUtils/utils";
32
+ import { track as trackEvent } from "dxUtils/analytics";
32
33
 
33
34
  type NavigationItem = {
34
35
  label: string;
@@ -944,6 +945,16 @@ export default class AmfReference extends LightningElement {
944
945
  this.handleSelectedItem();
945
946
 
946
947
  this.updateDocPhase();
948
+
949
+ // Track page view when a new spec reference page is loaded
950
+ trackEvent(this.template.host, "doc_page_view", {
951
+ page_path: window.location.pathname + window.location.search,
952
+ reference_id: referenceId,
953
+ reference_type: "spec",
954
+ meta: meta,
955
+ topic_type: type,
956
+ article_name: this.getArticleName()
957
+ });
947
958
  }
948
959
 
949
960
  /**
@@ -1305,6 +1316,15 @@ export default class AmfReference extends LightningElement {
1305
1316
  this.isVersionFetched = true;
1306
1317
  this.updateDocPhase();
1307
1318
  this.selectedSidebarValue = window.location.pathname;
1319
+
1320
+ // Track page view when a new markdown reference page is loaded
1321
+ trackEvent(this.template.host, "doc_page_view", {
1322
+ page_path: window.location.pathname + window.location.search,
1323
+ reference_id: selectedItemRefId,
1324
+ reference_type: "markdown",
1325
+ topic_meta: referenceMeta,
1326
+ article_name: this.getArticleName()
1327
+ });
1308
1328
  }
1309
1329
  }
1310
1330
 
@@ -1444,6 +1464,23 @@ export default class AmfReference extends LightningElement {
1444
1464
  }
1445
1465
  }
1446
1466
 
1467
+ private getArticleName(): string | undefined {
1468
+ if (!this.breadcrumbs) {
1469
+ return undefined;
1470
+ }
1471
+ try {
1472
+ const breadcrumbArray = toJson(this.breadcrumbs) as Breadcrumb[];
1473
+ if (Array.isArray(breadcrumbArray) && breadcrumbArray.length > 0) {
1474
+ // Join all breadcrumb labels with "/" to create article name
1475
+ // e.g., "Tooling API Objects/FieldDefinition"
1476
+ return breadcrumbArray.map((crumb) => crumb.label).join("/");
1477
+ }
1478
+ } catch (e) {
1479
+ // If parsing fails, return undefined
1480
+ }
1481
+ return undefined;
1482
+ }
1483
+
1447
1484
  handleSelectedItem(): void {
1448
1485
  // update topic view
1449
1486
  const { referenceId, amfId, type } = this.selectedTopic!;
@@ -504,6 +504,18 @@ export default class DocXmlContent extends LightningElementWithState<{
504
504
  this.setState({
505
505
  isFetchingDocument: false
506
506
  });
507
+
508
+ // Track page view when a new document is loaded
509
+ trackGTM(this.template.host, "doc_page_view", {
510
+ page_path: this.pageReferenceToString(this.pageReference),
511
+ doc_id: this.pageReference.docId,
512
+ content_document_id: this.pageReference.contentDocumentId,
513
+ deliverable: this.pageReference.deliverable,
514
+ language: this.language?.id,
515
+ version: this.version?.id,
516
+ article_name: this.getArticleName()
517
+ });
518
+
507
519
  return data.content;
508
520
  }
509
521
 
@@ -528,6 +540,20 @@ export default class DocXmlContent extends LightningElementWithState<{
528
540
  if (!this.pageReference.hash) {
529
541
  document.body.scrollIntoView();
530
542
  }
543
+
544
+ // Track page view when new content is loaded (navigation within same document)
545
+ // Note: breadcrumbs will be built after this in updatePageReference,
546
+ // but we need to build them here to get article_name
547
+ this.buildBreadcrumbs();
548
+ trackGTM(this.template.host, "doc_page_view", {
549
+ page_path: this.pageReferenceToString(this.pageReference),
550
+ doc_id: this.pageReference.docId,
551
+ content_document_id: this.pageReference.contentDocumentId,
552
+ deliverable: this.pageReference.deliverable,
553
+ language: this.language?.id,
554
+ version: this.version?.id,
555
+ article_name: this.getArticleName()
556
+ });
531
557
  }
532
558
  this.setState({
533
559
  isFetchingContent: false
@@ -644,6 +670,15 @@ export default class DocXmlContent extends LightningElementWithState<{
644
670
  return this.breadcrumbs && this.breadcrumbs.length > 1;
645
671
  }
646
672
 
673
+ private getArticleName(): string | undefined {
674
+ if (!this.breadcrumbs || this.breadcrumbs.length === 0) {
675
+ return undefined;
676
+ }
677
+ // Join all breadcrumb labels with "/" to create article name
678
+ // e.g., "Tooling API Objects/FieldDefinition"
679
+ return this.breadcrumbs.map((crumb) => crumb.label).join("/");
680
+ }
681
+
647
682
  private buildBreadcrumbs(): void {
648
683
  const { contentDocumentId } = this.pageReference;
649
684
  if (!contentDocumentId) {