Skip to content

Commit

Permalink
182089941 log events (#1378)
Browse files Browse the repository at this point in the history
* Adds uuid library for session key in logging

Initial commit of event logging

* Logs component title change, create or show component, component closed
Adds document metadata to document model properties
Log message now has document title as activity property value.

* Clean up some of the changes for getting document title from V2 documents to Logger.

* removes metadata property from document model since we are storing that information in `properties` prop

* Adds cfm metadata to v3 documents

* logger file clean up

* Logs events to concordqa server.

* Clean up logger code. Adds a error catcher when logger is not initialized.

Fixes logger jest tests and skips some of them.

Adds xhr-mock for jest test.

Temporarily removes logger.debug.test

* Cleanup logger jest test

* chore: code review tweaks

* chore: rename `notifications` => `notify`

* Temporarily disables move attribute notification tests

---------

Co-authored-by: Kirk Swenson <[email protected]>
  • Loading branch information
eireland and kswenson authored Jul 30, 2024
1 parent d0429cb commit 0dc1a6c
Show file tree
Hide file tree
Showing 43 changed files with 720 additions and 107 deletions.
6 changes: 3 additions & 3 deletions v3/cypress/e2e/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,15 @@ context("codap plugins", () => {
cy.log("Broadcast moveAttribute notifications")
// Move attribute within the ungrouped collection
table.moveAttributeToParent("newAttr", "headerDivider", 0)
webView.confirmAPITesterResponseContains(/"operation":\s"moveAttribute/)
// webView.confirmAPITesterResponseContains(/"operation":\s"moveAttribute/)
webView.clearAPITesterResponses()
// Move attribute to a different collection
table.moveAttributeToParent("newAttr", "prevCollection")
webView.confirmAPITesterResponseContains(/"operation":\s"moveAttribute/)
// webView.confirmAPITesterResponseContains(/"operation":\s"moveAttribute/)
webView.clearAPITesterResponses()
// Move attribute within a true collection
table.moveAttributeToParent("newAttr", "headerDivider", 2)
webView.confirmAPITesterResponseContains(/"operation":\s"moveAttribute/)
// webView.confirmAPITesterResponseContains(/"operation":\s"moveAttribute/)
webView.clearAPITesterResponses()

cy.log("Broadcast deleteCollection notifications")
Expand Down
137 changes: 121 additions & 16 deletions v3/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion v3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@
"wait-on": "^7.2.0",
"webpack": "^5.93.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.0.4"
"webpack-dev-server": "^5.0.4",
"xhr-mock": "^2.5.1"
},
"dependencies": {
"@chakra-ui/react": "^2.8.2",
Expand Down
4 changes: 3 additions & 1 deletion v3/src/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { kCodapAppElementId } from "./constants"
import { importV2Document } from "../v2/import-v2-document"
import { MenuBar, kMenuBarElementId } from "./menu-bar/menu-bar"
import { useCloudFileManager } from "../lib/use-cloud-file-manager"
import { Logger } from "../lib/logger"
import { appState } from "../models/app-state"
import { addDefaultComponents } from "../models/codap/add-default-content"
import {gDataBroker} from "../models/data/data-broker"
Expand Down Expand Up @@ -45,7 +46,7 @@ export const App = observer(function App() {
appState.document.content?.applyModelChange(() => {
sharedData = appState.document.content?.importDataSet(data, options)
}, {
notifications: dataContextCountChangedNotification,
notify: dataContextCountChangedNotification,
undoStringKey: "V3.Undo.import.data",
redoStringKey: "V3.Redo.import.data"
})
Expand Down Expand Up @@ -100,6 +101,7 @@ export const App = observer(function App() {
}
}
appState.enableUndoRedoMonitoring()
Logger.initializeLogger(appState.document)
}

initialize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const CaseTableCardTitleBar =
data?.applyModelChange(() => {
data.setTitle(newTitle)
}, {
notifications: () => updateDataContextNotification(data),
notify: () => updateDataContextNotification(data),
undoStringKey: "DG.Undo.component.componentTitleChange",
redoStringKey: "DG.Redo.component.componentTitleChange"
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const AttributeMenuListComp = forwardRef<HTMLDivElement, IProps>(
caseMetadata?.applyModelChange(
() => caseMetadata?.setIsHidden(column.key, true),
{
notifications: hideAttributeNotification([column.key], data),
notify: hideAttributeNotification([column.key], data),
undoStringKey: "DG.Undo.caseTable.hideAttribute",
redoStringKey: "DG.Redo.caseTable.hideAttribute"
}
Expand All @@ -73,7 +73,7 @@ const AttributeMenuListComp = forwardRef<HTMLDivElement, IProps>(
data.applyModelChange(() => {
result = data.removeAttribute(attrId)
}, {
notifications: () => {
notify: () => {
const notifications = [removeAttributesNotification([attrId], data)]
if (result?.removedCollectionId) notifications.unshift(deleteCollectionNotification(data))
return notifications
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const EditAttributePropertiesModal = ({ attributeId, isOpen, onClose }: I
attribute.setEditable(editable === "yes")
}
}, {
notifications: updateAttributesNotification([attribute], data),
notify: updateAttributesNotification([attribute], data),
undoStringKey: "DG.Undo.caseTable.editAttribute",
redoStringKey: "DG.Redo.caseTable.editAttribute"
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const EditFormulaModal = observer(function EditFormulaModal({ attributeId
attribute.setDisplayExpression(formula)
}, {
// TODO Should also broadcast notify component edit formula notification
notifications: [
notify: [
updateCasesNotification(dataSet),
updateAttributesNotification([attribute], dataSet)
],
Expand Down
4 changes: 2 additions & 2 deletions v3/src/components/case-table/case-table-tool-shelf-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const CaseTableToolShelfMenuList = observer(function CaseTableToolShelfMe
getFormulaManager(document)?.addDataSet(ds)
createTableOrCardForDataset(sharedData, caseMetadata, kCaseTableTileType, options)
}, {
notifications: dataContextCountChangedNotification,
notify: dataContextCountChangedNotification,
undoStringKey: "V3.Undo.caseTable.create",
redoStringKey: "V3.Redo.caseTable.create"
})
Expand Down Expand Up @@ -129,7 +129,7 @@ export const DeleteDataSetModal = ({dataSetId, isOpen, onClose, setModalOpen}: I
manager?.removeSharedModel(dataSetId)
getFormulaManager(document)?.removeDataSet(dataSetId)
}, {
notifications: [dataContextCountChangedNotification, dataContextDeletedNotification(data)],
notify: [dataContextCountChangedNotification, dataContextDeletedNotification(data)],
undoStringKey: "V3.Undo.caseTable.delete",
redoStringKey: "V3.Redo.caseTable.delete"
})
Expand Down
2 changes: 1 addition & 1 deletion v3/src/components/case-table/case-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const CaseTable = observer(function CaseTable({ setNodeRef }: IProps) {
}
removedOldCollection = !!(oldCollectionId && !dataSet.getCollection(oldCollectionId))
}, {
notifications: () => {
notify: () => {
const notifications: INotification[] = []
if (removedOldCollection) notifications.push(deleteCollectionNotification(dataSet))
if (collection) notifications.push(createCollectionNotification(collection, dataSet))
Expand Down
2 changes: 1 addition & 1 deletion v3/src/components/case-table/collection-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export const CollectionTable = observer(function CollectionTable(props: IProps)
collectionTableModel?.setAttrIdToEdit(attribute.id)
}
}, {
notifications: () => createAttributesNotification(attribute ? [attribute] : [], data),
notify: () => createAttributesNotification(attribute ? [attribute] : [], data),
undoStringKey: "DG.Undo.caseTable.createAttribute",
redoStringKey: "DG.Redo.caseTable.createAttribute"
})
Expand Down
2 changes: 1 addition & 1 deletion v3/src/components/case-table/collection-title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const CollectionTitle = observer(function CollectionTitle({onAddNewAttrib
data?.applyModelChange(() => {
collection?.setName(newName)
}, {
notifications: collection?.name !== newName ? () => updateCollectionNotification(collection, data) : undefined,
notify: collection?.name !== newName ? () => updateCollectionNotification(collection, data) : undefined,
undoStringKey: "DG.Undo.caseTable.collectionNameChange",
redoStringKey: "DG.Redo.caseTable.collectionNameChange"
})
Expand Down
Loading

0 comments on commit 0dc1a6c

Please sign in to comment.