Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/openprocurement/angular-gtm-logger
https://github.com/openprocurement/angular-gtm-logger
Last synced: 17 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/openprocurement/angular-gtm-logger
- Owner: openprocurement
- License: apache-2.0
- Created: 2015-12-07T14:01:28.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-02-27T11:13:15.000Z (almost 6 years ago)
- Last Synced: 2024-11-09T11:35:58.691Z (2 months ago)
- Language: JavaScript
- Size: 21.5 KB
- Stars: 0
- Watchers: 11
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
Angular GTM Logger is a module which will decorate Angular's $log service, and provide a `GTMLogger` service which can be used to manually send messages of any kind to the GTM service.
### Getting Started
Once configured (by including "GTMLogger" as a module dependency), the `$log`
service will automatically be decorated, and all messages logged will be handled
as normal as well as formated and passed to GTMLogger.sendMessage.
The plain text messages are sent into the "json.message" field with the decorated log while custom JSON objects are sent via "json.messageObj" field.To use both the decorated $log and the GTMLogger service, you must first
configure it with an inputToken, which is done via the GTMLoggerProvider:```javascript
angular.module( 'myApp', ['GTMLogger'] ).run( function( GTMLogger, $log ) {
//This will be sent to both the console and GTM
$log.info( "I'm a little teapot." );//This will be sent to GTM only
GTMLogger.sendMessage( 'Short and Stout.' )
}```
### $log decoration
When sent through the `$log` decorator, messages will be formatted as follows:
```javascript
// Example: $log.warn( 'Danger! Danger!' );
{
level: "WARN",
timestamp: "2014-05-01T13:10Z",
msg: "Danger! Danger!"
}// Example: $log.debug( 'User submitted something:', { foo: 'A.J', bar: 'Space' } )
{
level: "DEBUG",
timestamp: "2014-05-01T13:18Z",
msg: ["User submitted something", { foo: 'A.J.', bar: 'Space' }]
}
```