Skip to content

Commit 5207f05

Browse files
committed
Update external-profile-data.md
1 parent c35ae89 commit 5207f05

File tree

1 file changed

+24
-63
lines changed

1 file changed

+24
-63
lines changed

16/umbraco-engage/developers/profiling/external-profile-data.md

Lines changed: 24 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -25,75 +25,36 @@ When this component is registered a new tab will be rendered in the Profiles sec
2525
To render this External Profile Tab with a custom component, you have to create your component and register it with Umbraco Engage. The following code will show how to do both. Add the below code in a Typescript file:
2626

2727
```typescript
28-
// Create a component. We create a component named "myCustomExternalProfileDataComponent" here:
29-
30-
const element = "myCustomExternalProfileDataComponent";
31-
@customElement(element)
32-
export class CustomExternalDataElement
33-
extends UmbLitElement
34-
implements UmbWorkspaceViewElement
35-
{
36-
@state()
37-
private _components?: Array<ManifestUeExternalDataComponent["ELEMENT_TYPE"]>;
38-
39-
constructor() {
40-
super();
41-
42-
this.observe(
43-
umbExtensionsRegistry.byType(ENGAGE_EXTERNAL_DATA_EXTENSION_TYPE),
44-
async (data) => {
45-
if (!data) return;
46-
this._components = await Promise.all(
47-
data
48-
.sort((a, b) => (b.weight ?? 0) - (a.weight ?? 0))
49-
.map((d) => createExtensionElement(d))
50-
);
51-
}
52-
);
53-
}
54-
55-
render() {
56-
return html`
57-
${this._components?.map(
58-
(component) => html` <uui-box> ${component} </uui-box>`
59-
)}
60-
`;
61-
}
62-
}
63-
64-
export default CustomExternalDataElement;
65-
66-
declare global {
67-
interface HTMLElementTagNameMap {
68-
[element]: CustomExternalDataElement;
69-
}
28+
export class EngageProfileInsightElement extends UmbLitElement {
29+
#profileId = 0;
30+
31+
constructor() {
32+
super();
33+
this.consumeContext(UMB_ENTITY_WORKSPACE_CONTEXT, context => {
34+
this.observe(context?.unique, unique => {
35+
this.#profileId = +unique;
36+
});
37+
});
38+
}
39+
render() {
40+
return html`
41+
<h1>This is a custom external profile data element</h1>
42+
<p>Current profile id: ${this.#profileId}</p>`;
43+
}
7044
}
45+
export { EngageProfileInsightElement as element }
46+
customElements.define("profile-insight-demo", EngageProfileInsightElement);
7147
```
7248

73-
Then, load your component using a `manifest.ts` file:
49+
Then, load your component using a manifest.ts file. The extension type must be engageExternaldataComponent.
7450

7551
```json
7652
{
77-
type: "workspaceView",
78-
kind: ENGAGE_PROFILE_DETAIL_WORKSPACE_VIEW_KIND,
79-
alias: "Engage.Profile.Details.ExternalData.WorkspaceView",
80-
name: "Engage Profile Details External Data",
81-
element: () =>
82-
import("path-to-your-component"),
83-
meta: {
84-
label: "External Data",
85-
pathname: "path-name",
86-
icon: "your-custom-icon",
87-
},
88-
conditions: [
89-
{
90-
alias: UMB_WORKSPACE_CONDITION_ALIAS,
91-
match: ENGAGE_PROFILE_DETAILS_WORKSPACE_ALIAS,
92-
},
93-
{
94-
alias: ENGAGE_EXTERNAL_DATA_PACKAGE_CONDITION_ALIAS,
95-
},
96-
],
53+
"type": "engageExternalDataComponent",
54+
"alias": "EngageDemo.ExternalProfileData",
55+
"name": "External Profile Data Demo",
56+
"weight": 100,
57+
"js": "/path/to/my-javascript.js"
9758
}
9859
```
9960

0 commit comments

Comments
 (0)