@salesforcedevs/docs-components 1.3.175 → 1.3.178-canary.0

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.3.175",
3
+ "version": "1.3.178-canary.0",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -24,5 +24,5 @@
24
24
  "@types/lodash.orderby": "^4.6.7",
25
25
  "@types/lodash.uniqby": "^4.7.7"
26
26
  },
27
- "gitHead": "5417c0fa28a39ac5c1cade341f447a38a9d7da54"
27
+ "gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad"
28
28
  }
@@ -4,6 +4,7 @@
4
4
  class="content-type content-type-reference"
5
5
  coveo-organization-id={coveoOrganizationId}
6
6
  coveo-public-access-token={coveoPublicAccessToken}
7
+ coveo-analytics-token={coveoAnalyticsToken}
7
8
  coveo-search-hub={coveoSearchHub}
8
9
  coveo-advanced-query-config={coveoAdvancedQueryConfig}
9
10
  breadcrumbs={breadcrumbs}
@@ -4,7 +4,6 @@ import { sentenceCase } from "sentence-case";
4
4
  import qs from "query-string";
5
5
  import { AmfModelParser } from "doc/amfModelParser";
6
6
  import { normalizeBoolean } from "dxUtils/normalizers";
7
- import { CoveoAnalyticsClient } from "coveo.analytics";
8
7
  import type {
9
8
  AmfConfig,
10
9
  AmfMetadataTopic,
@@ -225,19 +224,6 @@ export default class AmfReference extends LightningElement {
225
224
  }
226
225
  }
227
226
 
228
- private logCoveoPageView() {
229
- if (this.coveoOrganizationId && this.coveoAnalyticsToken) {
230
- const ua = new CoveoAnalyticsClient({
231
- token: this.coveoAnalyticsToken,
232
- endpoint: `https://${this.coveoOrganizationId}.analytics.org.coveo.com`
233
- });
234
- ua.sendViewEvent({
235
- contentIdKey: "@clickableuri",
236
- contentIdValue: window.location.href
237
- });
238
- }
239
- }
240
-
241
227
  /**
242
228
  * Check if the URL hash to see whether this is one we want to redirect
243
229
  * See GUS W-10718771 for references where we want hash-based redirects
@@ -941,8 +927,6 @@ export default class AmfReference extends LightningElement {
941
927
  this.handleSelectedItem();
942
928
 
943
929
  this.updateDocPhase();
944
-
945
- this.logCoveoPageView();
946
930
  }
947
931
 
948
932
  /**
@@ -1204,8 +1188,6 @@ export default class AmfReference extends LightningElement {
1204
1188
  if (referenceItem) {
1205
1189
  window.location.href = referenceItem.href;
1206
1190
  }
1207
-
1208
- this.logCoveoPageView();
1209
1191
  }
1210
1192
 
1211
1193
  /**
@@ -1298,8 +1280,6 @@ export default class AmfReference extends LightningElement {
1298
1280
  }
1299
1281
  this.updateDocPhase();
1300
1282
  this.selectedSidebarValue = window.location.pathname;
1301
-
1302
- this.logCoveoPageView();
1303
1283
  }
1304
1284
  }
1305
1285
 
@@ -4,6 +4,7 @@ import { closest } from "kagekiri";
4
4
  import { toJson } from "dxUtils/normalizers";
5
5
  import { highlightTerms } from "dxUtils/highlight";
6
6
  import { SearchSyncer } from "docUtils/searchSyncer";
7
+ import { CoveoAnalyticsClient } from "coveo.analytics";
7
8
 
8
9
  type AnchorMap = { [key: string]: { intersect: boolean; id: string } };
9
10
 
@@ -32,9 +33,11 @@ export default class ContentLayout extends LightningElement {
32
33
  @api enableSlotChange = false;
33
34
  @api coveoOrganizationId!: string;
34
35
  @api coveoPublicAccessToken!: string;
36
+ @api coveoAnalyticsToken!: string;
35
37
  @api coveoSearchHub!: string;
36
38
  @api coveoAdvancedQueryConfig!: string;
37
39
  @api useOldSidebar?: boolean = false;
40
+ @api logCoveoPageViewOnlyOnConnect: boolean = false;
38
41
 
39
42
  @api
40
43
  get breadcrumbs() {
@@ -127,6 +130,19 @@ export default class ContentLayout extends LightningElement {
127
130
  );
128
131
  }
129
132
 
133
+ private logCoveoPageView() {
134
+ if (this.coveoOrganizationId && this.coveoAnalyticsToken) {
135
+ const ua = new CoveoAnalyticsClient({
136
+ token: this.coveoAnalyticsToken,
137
+ endpoint: `https://${this.coveoOrganizationId}.analytics.org.coveo.com`
138
+ });
139
+ ua.sendViewEvent({
140
+ contentIdKey: "@clickableuri",
141
+ contentIdValue: window.location.href
142
+ });
143
+ }
144
+ }
145
+
130
146
  connectedCallback(): void {
131
147
  const hasParentHighlightListener = closest(
132
148
  "doc-xml-content",
@@ -139,6 +155,9 @@ export default class ContentLayout extends LightningElement {
139
155
  );
140
156
  this.searchSyncer.init();
141
157
  }
158
+ if (this.logCoveoPageViewOnlyOnConnect) {
159
+ this.logCoveoPageView();
160
+ }
142
161
  }
143
162
 
144
163
  renderedCallback(): void {
@@ -159,6 +178,8 @@ export default class ContentLayout extends LightningElement {
159
178
  if (!this.hasRendered) {
160
179
  this.hasRendered = true;
161
180
  this.restoreScroll();
181
+ } else if (!this.logCoveoPageViewOnlyOnConnect) {
182
+ this.logCoveoPageView();
162
183
  }
163
184
  }
164
185
 
@@ -3,6 +3,7 @@
3
3
  if:true={loaded}
4
4
  coveo-organization-id={coveoOrganizationId}
5
5
  coveo-public-access-token={coveoPublicAccessToken}
6
+ coveo-analytics-token={coveoAnalyticsToken}
6
7
  coveo-search-hub={coveoSearchHub}
7
8
  coveo-advanced-query-config={coveoAdvancedQueryConfig}
8
9
  sidebar-header="Pages"
@@ -12,12 +12,11 @@ import {
12
12
  PageReference,
13
13
  TocMap
14
14
  } from "./types";
15
- import { LightningElementWithState } from "docBaseElements/lightningElementWithState";
15
+ import { SearchSyncer } from "docUtils/searchSyncer";
16
+ import { LightningElementWithState } from "dxBaseElements/lightningElementWithState";
16
17
  import { oldVersionDocInfo } from "docUtils/utils";
17
18
  import { Breadcrumb, DocPhaseInfo, Language } from "typings/custom";
18
19
  import { track as trackGTM } from "dxUtils/analytics";
19
- import { CoveoAnalyticsClient } from "coveo.analytics";
20
- import { SearchSyncer } from "docUtils/searchSyncer";
21
20
 
22
21
  // TODO: Imitating from actual implementation as doc-content use it like this. We should refactor it later.
23
22
  const handleContentError = (error: any): void => console.log(error);
@@ -438,19 +437,6 @@ export default class DocXmlContent extends LightningElementWithState<{
438
437
  );
439
438
  }
440
439
 
441
- async logCoveoPageView() {
442
- if (this.coveoOrganizationId && this.coveoAnalyticsToken) {
443
- const ua = new CoveoAnalyticsClient({
444
- token: this.coveoAnalyticsToken,
445
- endpoint: `https://${this.coveoOrganizationId}.analytics.org.coveo.com`
446
- }); // MILES TODO: replace 'fullsalesforce' with coveo organizationid
447
- ua.sendViewEvent({
448
- contentIdKey: "@clickableuri",
449
- contentIdValue: window.location.href
450
- });
451
- }
452
- }
453
-
454
440
  async fetchDocument(): Promise<void> {
455
441
  this.setState({
456
442
  isFetchingDocument: true
@@ -515,7 +501,6 @@ export default class DocXmlContent extends LightningElementWithState<{
515
501
  }
516
502
 
517
503
  async fetchContent(): Promise<void> {
518
- this.logCoveoPageView();
519
504
  this.setState({
520
505
  isFetchingContent: true
521
506
  });
package/LICENSE DELETED
@@ -1,12 +0,0 @@
1
- Copyright (c) 2020, Salesforce.com, Inc.
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
-
6
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
-
8
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
-
10
- * Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
-
12
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,93 +0,0 @@
1
- import { LightningElement, track } from "lwc";
2
-
3
- /**
4
- * This is a helper class for when you want your LWC component to have state
5
- * that is automatically tracked _along with_ its previous state, in a React-
6
- * like fashion, so that you can compare current state with previous state
7
- * after a render (like React's `commponentDidUpdate`). One benefit of doing
8
- * things this way is that you can put all of your reactions to state changes
9
- * in one place, in `renderedCallback`, rather than having them in various
10
- * places throughout the component.
11
- *
12
- * The API consists in `this.prevState`, `this.state`, and `this.setState`.
13
- *
14
- * Usage:
15
- *
16
- * ```
17
- * type MyState = {
18
- * isFetchingContent: boolean;
19
- * };
20
- *
21
- * class MyFetchingComponent extends LightningElementWithState<MyState> {
22
- * constructor() {
23
- * // `this.state` can only be initialized once
24
- * this.state = {
25
- * isFetchingContent: false
26
- * };
27
- * }
28
- *
29
- * // Queued for execution whenever a `setState` call completes
30
- * renderedCallback() {
31
- * if (this.prevState.isFetchingContent && !this.state.isFetchingContent) {
32
- * // Do something knowing that we just finished fetching.
33
- * notifyFetchSuccessful();
34
- * }
35
- * }
36
- *
37
- * fetchSomething() {
38
- * this.setState({
39
- * isFetchingContent: true
40
- * });
41
- *
42
- * fetch(whatever).then(() => {
43
- * this.setState({
44
- * isFetching: false
45
- * }
46
- * });
47
- * }
48
- * }
49
- * ```
50
- */
51
- export abstract class LightningElementWithState<
52
- T extends { [key: string]: unknown }
53
- > extends LightningElement {
54
- private _prevState = {} as T;
55
- @track private _state = {} as T;
56
-
57
- private _didInitializeState = false;
58
-
59
- protected get prevState(): T {
60
- return Object.freeze({
61
- ...this._prevState
62
- });
63
- }
64
-
65
- protected get state(): T {
66
- return Object.freeze({
67
- ...this._state
68
- });
69
- }
70
-
71
- protected set state(initialState: T) {
72
- if (!this._didInitializeState) {
73
- this._state = {
74
- ...initialState
75
- };
76
- this._didInitializeState = true;
77
- } else {
78
- throw new Error(
79
- "To mutate state after initialization, use `this.setState`."
80
- );
81
- }
82
- }
83
-
84
- protected setState = (state: Partial<T>): void => {
85
- this._prevState = {
86
- ...this._state
87
- };
88
- this._state = {
89
- ...this._state,
90
- ...state
91
- };
92
- };
93
- }