Skip to content

Commit

Permalink
Cleaned up project a bit and renamed to ngx
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Newman authored and Tgure committed Jun 29, 2020
1 parent e66bcdf commit 51ff371
Show file tree
Hide file tree
Showing 9 changed files with 267 additions and 82 deletions.
25 changes: 24 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# Node
node_modules/*
npm-debug.log

# TypeScript
*.js
*.map
*.d.ts

# JetBrains
.idea
.project
.settings
.idea/*
*.iml
node_modules

# VS Code
.vscode/*

# Windows
Thumbs.db
Desktop.ini

# Mac
.DS_Store
**/.DS_Store
27 changes: 27 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Node
node_modules/*
npm-debug.log

# DO NOT IGNORE TYPESCRIPT FILES FOR NPM
# TypeScript
# *.js
# *.map
# *.d.ts

# JetBrains
.idea
.project
.settings
.idea/*
*.iml

# VS Code
.vscode/*

# Windows
Thumbs.db
Desktop.ini

# Mac
.DS_Store
**/.DS_Store
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: node_js
sudo: false
node_js:
- '4.2.1'
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# angular2-loggly-logger
# ngx-loggly-logger

## Description
Simple library to log to loggly in Angular2
Simple library to log to loggly in Angular

## Installation

To install follow this procedure:

1. __npm install angular2-loggly-logger --save__
1. __npm install ngx-loggly-logger --save__
2. Add __LogglyService__ import to your __@NgModule__ like example below
```js
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { MyTestApp } from './my-test-app';
import { LogglyService } from 'angular2-loggly-logger';
import { NgxLogglyModule } from 'ngx-loggly-logger';

@NgModule({
providers: [ LogglyService ],
Expand All @@ -25,7 +25,7 @@ To install follow this procedure:
```
3. Use the following in your components, etc.
```js
import {LogglyService} from 'angular2-loggly-logger';
import {LogglyService} from 'ngx-loggly-logger';
constructor(private _logglyService:LogglyService) {
}
Expand Down
23 changes: 21 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
export * from "./src/loggly-service";
export class LogglyModule {}
import {NgModule, ModuleWithProviders} from '@angular/core';
import {CommonModule} from '@angular/common';
import {LogglyService} from './src/loggly.service';

export * from './src/loggly.service';

@NgModule({
imports: [
CommonModule
],
declarations: [],
exports: []
})
export class NgxLogglyModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: NgxLogglyModule,
providers: [LogglyService]
};
}
}
88 changes: 43 additions & 45 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,51 @@
{
"name": "angular2-loggly-logger",
"version": "0.0.10",
"description": "Angular2 Service for logging to Loggly",
"scripts": {},
"contributors": [],
"license": "MIT",
"devDependencies": {
"@types/node": "^6.0.38",
"angular2-template-loader": "^0.6.0",
"awesome-typescript-loader": "~3.0.0-beta.17",
"css-loader": "^0.26.0",
"raw-loader": "^0.5.1",
"to-string-loader": "^1.1.4",
"typescript": "^2.0.10",
"webpack": "2.2.0-rc.3",
"webpack-dev-server": "2.2.0-rc.0",
"webpack-merge": "~2.3.1"
"name": "ngx-loggly-logger",
"version": "0.0.19",
"scripts": {
"build": "ngc -p tsconfig.json",
"lint": "tslint src/**/*.ts",
"test": "tsc && karma start",
"prepublish": "tsc",
"tsc": "tsc"
},
"dependencies": {
"@angular/common": "~2.4.1",
"@angular/compiler": "~2.4.1",
"@angular/core": "~2.4.1",
"@angular/forms": "~2.4.1",
"@angular/http": "~2.4.1",
"@angular/platform-browser": "~2.4.1",
"@angular/platform-browser-dynamic": "~2.4.1",
"@angular/platform-server": "~2.4.1",
"@angular/router": "~3.4.1",
"@angular/upgrade": "~2.4.1",
"core-js": "^2.4.1",
"ie-shim": "^0.1.0",
"ng2-cookies": "^1.0.4",
"reflect-metadata": "^0.1.9",
"rxjs": "~5.0.2",
"zone.js": "~0.7.4"
},
"keywords": [
"Angular2",
"angular2-loggly",
"ng2-loggly",
"angular2-loggly-logger",
"ng2-loggly-logger"
],
"repository": {
"type": "git",
"url": "git+https://github.com/Tgure/angular2-loggly-logger.git"
"url": "https://github.com/Tgure/ngx-loggly-logger"
},
"author": {
"name": "Aaron Newman",
"email": "[email protected]"
},
"keywords": [
"angular"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/Tgure/angular2-loggly-logger/issues"
"url": "https://github.com/Tgure/ngx-loggly-logger/issues"
},
"main": "./dist/index.js",
"dependencies": {
"ng2-cookies": "~1.0.4"
},
"devDependencies": {
"@angular/common": "~2.4.8",
"@angular/http": "~2.4.1",
"@angular/platform-browser": "~2.4.1",
"@angular/compiler": "~2.4.5",
"@angular/compiler-cli": "~2.4.5",
"@angular/core": "~2.4.8",
"@angular/platform-server": "~2.4.5",
"codelyzer": "~2.0.0",
"rxjs": "~5.1.1",
"tslint": "~4.4.2",
"typescript": "~2.1.6",
"zone.js": "~0.7.7",
"@types/es6-shim": "~0.31.32",
"@types/protractor": "~4.0.0",
"@types/jasmine": "~2.5.40",
"@types/selenium-webdriver": "~2.53.39"
},
"homepage": "https://github.com/Tgure/angular2-loggly-logger#readme"
"engines": {
"node": ">=0.8.0"
}
}
32 changes: 14 additions & 18 deletions src/loggly-service.ts → src/loggly.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {Injectable} from '@angular/core';
import {Http, Headers, RequestOptions} from '@angular/http';
import {Cookie} from 'ng2-cookies/ng2-cookies';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import {Http, Headers, RequestOptions, Response} from '@angular/http';
import {Cookie} from 'ng2-cookies';

@Injectable()
export class LogglyService {
Expand All @@ -10,10 +11,6 @@ export class LogglyService {
private LOGGLY_SESSION_KEY: any;
private LOGGLY_SESSION_KEY_LENGTH: any;
private LOGGLY_PROXY_DOMAIN: any;
private key: boolean;
private sendConsoleErrors: boolean;
private tag: string;
private useDomainProxy: boolean;
private session_id: any;
private inputUrl: any;

Expand All @@ -28,7 +25,7 @@ export class LogglyService {
uuid() {
// lifted from here -> http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#2117523
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
let r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
Expand All @@ -45,16 +42,16 @@ export class LogglyService {

setDomainProxy(tracker: any, useDomainProxy: any) {
tracker.useDomainProxy = useDomainProxy;
//refresh inputUrl value
// refresh inputUrl value
this.setInputUrl(tracker);
}

setSendConsoleError(tracker: any, sendConsoleErrors: any) {
tracker.sendConsoleErrors = sendConsoleErrors;

if (tracker.sendConsoleErrors === true) {
var _onerror = window.onerror;
//send console error messages to Loggly
let _onerror = window.onerror;
// send console error messages to Loggly
window.onerror = function (msg, url, line, col) {
tracker.push({
category: 'BrowserJsException',
Expand All @@ -74,7 +71,7 @@ export class LogglyService {
}

setInputUrl(tracker: any) {
if (tracker.useDomainProxy == true) {
if (tracker.useDomainProxy === true) {
tracker.inputUrl = this.LOGGLY_INPUT_PREFIX
+ window.location.host
+ '/'
Expand All @@ -83,8 +80,7 @@ export class LogglyService {
+ tracker.key
+ '/tag/'
+ tracker.tag;
}
else {
} else {
tracker.inputUrl = this.LOGGLY_INPUT_PREFIX
+ (tracker.logglyCollectorDomain || this.LOGGLY_COLLECTOR_DOMAIN)
+ '/inputs/'
Expand All @@ -108,13 +104,13 @@ export class LogglyService {
}

push(data: any) {
var type = typeof data;
let type = typeof data;

if (!data || !(type === 'object' || type === 'string')) {
return;
}

var self: any = this;
let self: any = this;


if (type === 'string') {
Expand Down Expand Up @@ -173,13 +169,13 @@ export class LogglyService {
}

readCookie(): any {
var cookie = Cookie.get(this.LOGGLY_SESSION_KEY);
let cookie = Cookie.get(this.LOGGLY_SESSION_KEY);
if (cookie) {
var i = cookie.indexOf(this.LOGGLY_SESSION_KEY);
let i = cookie.indexOf(this.LOGGLY_SESSION_KEY);
if (i < 0) {
return false;
} else {
var end = cookie.indexOf(';', i + 1);
let end = cookie.indexOf(';', i + 1);
end = end < 0 ? cookie.length : end;
return cookie.slice(i + this.LOGGLY_SESSION_KEY_LENGTH, end);
}
Expand Down
29 changes: 18 additions & 11 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
{
"compilerOptions": {
"noImplicitAny": true,
"module": "commonjs",
"target": "es5",
"outDir": "dist",
"rootDir": ".",
"sourceMap": true,
"target": "ES5",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"types": [
"core-js",
"node"
]
"sourceMap": true,
"declaration": true,
"outDir": "./dist",
"typeRoots": [
"node_modules/@types"
]
},
"files": [
"index.ts"
],
"exclude": [
"node_modules"
]
"node_modules",
"dist",
"**/*.spec.ts"
],
"angularCompilerOptions": {
"strictMetadataEmit": true
}
}
Loading

0 comments on commit 51ff371

Please sign in to comment.