Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added amplitude logging for inbox cmps #732

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion force-app/main/default/classes/stoHelperClass.cls
Original file line number Diff line number Diff line change
Expand Up @@ -242,5 +242,10 @@ public with sharing class stoHelperClass {
}

public class maxThreadLimitReachedException extends Exception {
}
}

@AuraEnabled(cacheable=true)
public static Thread__c getThread(String recordId) {
return [SELECT Id, CRM_Thread_Type__c, STO_Category_Formula__c, CRM_Is_Closed__c, CRM_Related_Object__c, STO_Medskriv__c FROM Thread__c WHERE Id = :recordId LIMIT 1];
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.homeicon {
margin: 1em;

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,36 @@
<div class="decorator-utils-container">
<div class="decorator-utils-content">
<nav class="brodsmulesti" aria-label="Brødsmulesti" itemprop="breadcrumb">
<a href="https://www.nav.no" target="_self" class="lenke brodsmulesti__home typo-normal"
<a
href="https://www.nav.no"
target="_self"
class="lenke brodsmulesti__home typo-normal"
onclick={handleClick}
><img src={homelogo} alt="" class="homeicon" /><span>nav.no</span></a
>
<span class="nav-frontend-chevron chevronboks chevron--hoyre"></span>
<template if:true={firstLevel}>
<a href={firstLevelLink} target="_self" class="lenke typo-normal"><span>{firstLevel}</span></a>
<a href={firstLevelLink} target="_self" class="lenke typo-normal" onclick={handleClick}
><span>{firstLevel}</span></a
>
<span class="nav-frontend-chevron chevronboks chevron--hoyre"></span>
</template>
<template if:true={secondLevel}>
<a href={secondLevelLink} target="_self" class="lenke brodsmulesti__transfor typo-normal"
<a
href={secondLevelLink}
target="_self"
class="lenke brodsmulesti__transfor typo-normal"
onclick={handleClick}
><span>{secondLevel}</span></a
>
<span class="nav-frontend-chevron chevronboks chevron--hoyre"></span>
</template>
<template if:true={thirdLevel}>
<a href={thirdLevelLink} target="_self" class="lenke brodsmulesti__transform typo-normal"
<a
href={thirdLevelLink}
target="_self"
class="lenke brodsmulesti__transform typo-normal"
onclick={handleClick}
><span>{thirdLevel}</span></a
>
<span class="nav-frontend-chevron chevronboks chevron--hoyre"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import navlogos from '@salesforce/resourceUrl/homelogo';
import navStyling from '@salesforce/resourceUrl/navStyling';
import index from '@salesforce/resourceUrl/index';
import { loadStyle } from 'lightning/platformResourceLoader';
import { logNavigationEvent, getComponentName } from 'c/inboxAmplitude';

export default class CommunityBreadCrumb extends LightningElement {
@api firstLevel;
Expand All @@ -12,10 +13,20 @@ export default class CommunityBreadCrumb extends LightningElement {
@api thirdLevel;
@api thirdLevelLink;
@api leafnode;

homelogo = navlogos;

renderedCallback() {
loadStyle(this, index);
loadStyle(this, navStyling);
}

handleClick(event) {
logNavigationEvent(
getComponentName(this.template),
'breadCrumb',
event.currentTarget.href,
event.currentTarget.textContent.trim()
);
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>51.0</apiVersion>
<isExposed>false</isExposed>
<apiVersion>62.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>Breadcrumb</masterLabel>
<targets>
<target>lightning__AppPage</target>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
<target>lightningCommunity__Page</target>
<target>lightningCommunity__Page</target>
<target>lightningCommunity__Default</target>
</targets>
<targetConfigs>
<targetConfig targets=" lightningCommunity__Default">
<property name="firstLevel" type="String" label='First Level' />
<property name="firstLevelLink" type="String" label='First Level URL Link location' />
<property name="secondLevel" type="String" label='Second Level' />
<property name="secondLevelLink" type="String" label='Second Level URL Link location' />
<property name="thirdLevel" type="String" label='Third Level' />
<property name="thirdLevelLink" type="String" label='Third Level URL Link location' />
<targetConfig targets="lightningCommunity__Default">
<property name="firstLevel" type="String" label='First Level' />
<property name="firstLevelLink" type="String" label='First Level URL Link location' />
<property name="secondLevel" type="String" label='Second Level' />
<property name="secondLevelLink" type="String" label='Second Level URL Link location' />
<property name="thirdLevel" type="String" label='Third Level' />
<property name="thirdLevelLink" type="String" label='Third Level URL Link location' />
<property name="leafnode" type="String" label='Leaf Node text' />
</targetConfig>
</targetConfigs>
<isExposed>true</isExposed>
</LightningComponentBundle>
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { LightningElement, api } from 'lwc';
import { logAccordionEvent, getComponentName } from 'c/inboxAmplitude';

export default class CommunityExpandablePanel extends LightningElement {
showpanel = false;
@api header;
@api body;

showpanel = false;

togglevisible() {
this.showpanel = !this.showpanel;
this.performAnimation();
logAccordionEvent(this.showpanel, this.header, getComponentName(this.template));
}

get accordianClass() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>52.0</apiVersion>
<apiVersion>62.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
6 changes: 5 additions & 1 deletion force-app/main/default/lwc/dsRadio/dsRadio.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export default class DsRadio extends LightningElement {
test?.focus();
}

getText() {
return this.getSelectedButton?.text;
}

checkForError() {
this.updateErrorText();
}
Expand All @@ -35,7 +39,7 @@ export default class DsRadio extends LightningElement {
this._options.forEach((option) => (option.checked = option.id === dataId));
this.updateErrorText();
const changeEvent = new CustomEvent('radiochange', {
detail: this.getValue()
detail: { text: this.getText(), value: this.getValue() }
});
this.dispatchEvent(changeEvent);
}
Expand Down
4 changes: 3 additions & 1 deletion force-app/main/default/lwc/navButton/navButton.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<template>
<a class="navds-button navds-button--primary navds-button--medium" target="_self" href={url}> {title} </a>
<a class="navds-button navds-button--primary navds-button--medium" target="_self" href={url} onclick={handleClick}>
{title}
</a>
</template>
8 changes: 5 additions & 3 deletions force-app/main/default/lwc/navButton/navButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { LightningElement, api } from 'lwc';
export default class NavButton extends LightningElement {
@api title;
@api url;
@api logAmplitudeEvent = false;

gotourl() {
console.log(this.url);
window.location.href = this.url + '&output=embed';
handleClick() {
if (this.logAmplitudeEvent) {
this.dispatchEvent(new CustomEvent('logevent'));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>52.0</apiVersion>
<apiVersion>62.0</apiVersion>
<masterLabel>NAV - Knapp</masterLabel>
<targets>
<target>lightningCommunity__Page</target>
Expand Down
2 changes: 2 additions & 0 deletions force-app/main/default/lwc/nksViewThread/nksViewThread.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
<c-crm-messaging-community-thread-viewer
record-id={_recordId}
max-length={maxLength}
log-amplitude-event
onlogevent={logAmplitudeEvent}
></c-crm-messaging-community-thread-viewer>
</template>
36 changes: 31 additions & 5 deletions force-app/main/default/lwc/nksViewThread/nksViewThread.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { LightningElement, wire, api } from 'lwc';
import { CurrentPageReference } from 'lightning/navigation';
import THREAD_TYPE from '@salesforce/schema/Thread__c.CRM_Thread_Type__c';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import getThread from '@salesforce/apex/stoHelperClass.getThread';
import basepath from '@salesforce/community/basePath';
import { AnalyticsEvents, logButtonEvent, setDecoratorParams, getComponentName } from 'c/inboxAmplitude';
import { getPageType } from 'c/stoUtils';

const urlMap = {
STO: (recordId) => basepath + '/skriv-til-oss/' + recordId,
Expand All @@ -19,7 +20,17 @@ export default class NksViewThread extends LightningElement {
@api threadType;
@api recordId;
@api maxLength;

_recordId;
pageTheme;
pageType;
pageTitle;

renderedCallback() {
if (this.threadType) {
this.pageType = getPageType(this.threadType);
}
}

@wire(CurrentPageReference)
getStateParameters(currentPageReference) {
Expand All @@ -30,14 +41,19 @@ export default class NksViewThread extends LightningElement {
}
}

getField;
@wire(getRecord, { recordId: '$_recordId', fields: [THREAD_TYPE] })
@wire(getThread, { recordId: '$_recordId' })
wiredThread({ error, data }) {
if (error) {
console.log('Error:', error);
} else if (data) {
const actualThreadType = getFieldValue(data, THREAD_TYPE);
this.pageTheme = data.STO_Category_Formula__c;
const actualThreadType = data.CRM_Thread_Type__c;
if (!allowedThreadTypes[this.threadType].includes(actualThreadType)) this.redirect(actualThreadType);

if (this.pageType && this.pageTheme) {
setDecoratorParams(this.pageType, this.pageTheme);
this.pageTitle = this.pageType + ' - ' + this.pageTheme;
}
}
}

Expand All @@ -47,4 +63,14 @@ export default class NksViewThread extends LightningElement {
// eslint-disable-next-line @locker/locker/distorted-xml-http-request-window-open
window.open(link, '_self');
}

logAmplitudeEvent() {
logButtonEvent(
AnalyticsEvents.FORM_COMPLETED,
'Send',
getComponentName(this.template),
this.pageTitle,
'ny melding'
);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>56.0</apiVersion>
<apiVersion>62.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>Beskjed til oss - View thread</masterLabel>
<targets>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { LightningElement, api, wire } from 'lwc';

import { publish, MessageContext } from 'lightning/messageService';
import globalModalOpen from '@salesforce/messageChannel/globalModalOpen__c';
import { AnalyticsEvents, logButtonEvent, logModalEvent, getComponentName } from 'c/inboxAmplitude';

export default class StoInboxCloseItem extends LightningElement {
@api thread;
@api index;

modalOpen = false;

@wire(MessageContext)
Expand All @@ -31,20 +32,28 @@ export default class StoInboxCloseItem extends LightningElement {
this.modalOpen = true;
this.modal.focusModal();
publish(this.messageContext, globalModalOpen, { status: 'true' });
logModalEvent(true, 'Avslutt samtale', getComponentName(this.template), 'Dine åpne samtaler');
}

closeModal() {
this.modalOpen = false;
const btn = this.template.querySelector('.endDialogBtn');
btn.focus();
publish(this.messageContext, globalModalOpen, { status: 'false' });
logModalEvent(false, 'Avslutt samtale', getComponentName(this.template), 'Dine åpne samtaler');
}

closeThread() {
const closeThreadEvent = new CustomEvent('closethread', {
detail: this.index
});
this.dispatchEvent(closeThreadEvent);
logButtonEvent(
AnalyticsEvents.FORM_COMPLETED,
'Ja avslutt samtale',
getComponentName(this.template),
'Dine åpne samtaler'
);
}

handleKeyboardEvent(event) {
Expand All @@ -58,6 +67,6 @@ export default class StoInboxCloseItem extends LightningElement {
}

get threadName() {
return this.thread.name + (this.isExternal === true ? ': Du sendte en melding' : ': Nav sendte en melding');
return this.thread.name + (this.isExternal ? ': Du sendte en melding' : ': Nav sendte en melding');
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>54.0</apiVersion>
<apiVersion>62.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>

This file was deleted.

Loading
Loading