Skip to content

Instantly share code, notes, and snippets.

@singh-shweta
Last active May 10, 2020 16:24
Show Gist options
  • Save singh-shweta/80488e8fa4c823a3b43e7dddf9508c46 to your computer and use it in GitHub Desktop.
Save singh-shweta/80488e8fa4c823a3b43e7dddf9508c46 to your computer and use it in GitHub Desktop.
This is just a component for example which can be used in any react project . This link in the component logs the navigation through the worker
import React from 'react';
import { sendLog } from "../initiateWorker";
/**
This is just a component for example which can be used in any react project .
This link in the component logs the navigation by passing the object to the worker using the sendLog exposed
*/
const AnchorLinkWithLogging = () => {
return (
<a
href="/"
onClick={(e) => {
e.preventDefault();
if (sendLog) {
sendLog({
type: "navigation",
href: "OtherUrl",
fromProduct: "Current Product Name",
user: "abcd@dummy.com",
});
}
}}
>
Test Worker
</a>
);
};
export default AnchorLinkWithLogging;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment