Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@timberio/core

Package Overview
Dependencies
Maintainers
5
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@timberio/core - npm Package Compare versions

Comparing version 0.32.0 to 0.33.0

3

dist/cjs/base.d.ts

@@ -8,2 +8,3 @@ import { ITimberLog, ITimberOptions, Context, LogLevel, Middleware, Sync } from "@timberio/types";

protected _apiKey: string;
protected _sourceKey: string;
protected _options: ITimberOptions;

@@ -21,3 +22,3 @@ protected _batch: any;

*/
constructor(apiKey: string, options?: Partial<ITimberOptions>);
constructor(apiKey: string, sourceKey: string, options?: Partial<ITimberOptions>);
private getContextFromError;

@@ -24,0 +25,0 @@ /**

@@ -7,4 +7,4 @@ "use strict";

const defaultOptions = {
// Default sync endpoint:
endpoint: "https://logs.timber.io/frames",
// Default sync endpoint (protocol + domain)
endpoint: "https://logs.timber.io",
// Maximum number of logs to sync in a single request to Timber.io

@@ -30,3 +30,3 @@ batchSize: 1000,

*/
constructor(apiKey, options) {
constructor(apiKey, sourceKey, options) {
// Middleware

@@ -44,2 +44,4 @@ this._middleware = [];

this._apiKey = apiKey;
// Store the source key, to connect the log to a particular source
this._sourceKey = sourceKey;
// Merge default and user options

@@ -46,0 +48,0 @@ this._options = Object.assign({}, defaultOptions, options);

@@ -11,7 +11,8 @@ "use strict";

const apiKey = "testing";
const base = new base_1.default(apiKey);
const sourceKey = "someSource";
const base = new base_1.default(apiKey, sourceKey);
expect(base._apiKey).toEqual(apiKey);
});
it("should throw if a `sync` method is missing", async () => {
const base = new base_1.default("testing");
const base = new base_1.default("testing", "someSource");
// Expect logging to throw an error, since we're missing a `sync` func

@@ -23,3 +24,3 @@ await expect(base.log("Test")).rejects.toThrowError(/sync/);

const message = "Test";
const base = new base_1.default("testing");
const base = new base_1.default("testing", "someSource");
// Add a mock sync method

@@ -35,11 +36,11 @@ base.setSync(async (logs) => logs);

it("should default log count to zero", () => {
const base = new base_1.default("testing");
const base = new base_1.default("testing", "someSource");
expect(base.logged).toEqual(0);
});
it("should default synced count to zero", () => {
const base = new base_1.default("testing");
const base = new base_1.default("testing", "someSource");
expect(base.synced).toEqual(0);
});
it("should increment log count on `.log()`", async () => {
const base = new base_1.default("testing");
const base = new base_1.default("testing", "someSource");
// Add a mock sync method

@@ -52,3 +53,3 @@ base.setSync(async (log) => log);

it("should sync after 500 ms", async () => {
const base = new base_1.default("testing");
const base = new base_1.default("testing", "someSource");
// Create a sync function that resolves after 500ms

@@ -76,3 +77,3 @@ base.setSync(async (log) => {

const firstMessage = "First message";
const base = new base_1.default("testing");
const base = new base_1.default("testing", "someSource");
// Add a mock sync method

@@ -92,3 +93,3 @@ base.setSync(async (log) => log);

it("should remove a pipeline function", async () => {
const base = new base_1.default("testing");
const base = new base_1.default("testing", "someSource");
// Create a pipeline function

@@ -108,3 +109,3 @@ const customPipeline = async (log) => log;

const message = "Test";
const base = new base_1.default("testing");
const base = new base_1.default("testing", "someSource");
// Add a mock sync method

@@ -120,3 +121,3 @@ base.setSync(async (log) => log);

const message = "Test";
const base = new base_1.default("testing");
const base = new base_1.default("testing", "someSource");
// Add a mock sync method

@@ -132,3 +133,3 @@ base.setSync(async (log) => log);

const message = "Test";
const base = new base_1.default("testing");
const base = new base_1.default("testing", "someSource");
// Add a mock sync method

@@ -144,3 +145,3 @@ base.setSync(async (log) => log);

const message = "Test";
const base = new base_1.default("testing");
const base = new base_1.default("testing", "someSource");
// Add a mock sync method

@@ -156,3 +157,3 @@ base.setSync(async (log) => log);

const message = "Test";
const base = new base_1.default("testing");
const base = new base_1.default("testing", "someSource");
// Add a mock sync method

@@ -169,3 +170,3 @@ base.setSync(async (log) => log);

const e = new Error(message);
const base = new base_1.default("testing");
const base = new base_1.default("testing", "someSource");
// Add a mock sync method

@@ -184,3 +185,3 @@ base.setSync(async (log) => log);

const e = new Error("Should NOT be ignored!");
const base = new base_1.default("testing");
const base = new base_1.default("testing", "someSource");
// Add a mock sync method which throws an error

@@ -195,3 +196,3 @@ base.setSync(async () => {

const message = "Testing exceptions";
const base = new base_1.default("testing", {
const base = new base_1.default("testing", "someSource", {
ignoreExceptions: true,

@@ -198,0 +199,0 @@ });

@@ -8,2 +8,3 @@ import { ITimberLog, ITimberOptions, Context, LogLevel, Middleware, Sync } from "@timberio/types";

protected _apiKey: string;
protected _sourceKey: string;
protected _options: ITimberOptions;

@@ -21,3 +22,3 @@ protected _batch: any;

*/
constructor(apiKey: string, options?: Partial<ITimberOptions>);
constructor(apiKey: string, sourceKey: string, options?: Partial<ITimberOptions>);
private getContextFromError;

@@ -24,0 +25,0 @@ /**

@@ -5,4 +5,4 @@ import { LogLevel, } from "@timberio/types";

const defaultOptions = {
// Default sync endpoint:
endpoint: "https://logs.timber.io/frames",
// Default sync endpoint (protocol + domain)
endpoint: "https://logs.timber.io",
// Maximum number of logs to sync in a single request to Timber.io

@@ -28,3 +28,3 @@ batchSize: 1000,

*/
constructor(apiKey, options) {
constructor(apiKey, sourceKey, options) {
// Middleware

@@ -42,2 +42,4 @@ this._middleware = [];

this._apiKey = apiKey;
// Store the source key, to connect the log to a particular source
this._sourceKey = sourceKey;
// Merge default and user options

@@ -44,0 +46,0 @@ this._options = Object.assign({}, defaultOptions, options);

@@ -6,7 +6,8 @@ import Base from "./base";

const apiKey = "testing";
const base = new Base(apiKey);
const sourceKey = "someSource";
const base = new Base(apiKey, sourceKey);
expect(base._apiKey).toEqual(apiKey);
});
it("should throw if a `sync` method is missing", async () => {
const base = new Base("testing");
const base = new Base("testing", "someSource");
// Expect logging to throw an error, since we're missing a `sync` func

@@ -18,3 +19,3 @@ await expect(base.log("Test")).rejects.toThrowError(/sync/);

const message = "Test";
const base = new Base("testing");
const base = new Base("testing", "someSource");
// Add a mock sync method

@@ -30,11 +31,11 @@ base.setSync(async (logs) => logs);

it("should default log count to zero", () => {
const base = new Base("testing");
const base = new Base("testing", "someSource");
expect(base.logged).toEqual(0);
});
it("should default synced count to zero", () => {
const base = new Base("testing");
const base = new Base("testing", "someSource");
expect(base.synced).toEqual(0);
});
it("should increment log count on `.log()`", async () => {
const base = new Base("testing");
const base = new Base("testing", "someSource");
// Add a mock sync method

@@ -47,3 +48,3 @@ base.setSync(async (log) => log);

it("should sync after 500 ms", async () => {
const base = new Base("testing");
const base = new Base("testing", "someSource");
// Create a sync function that resolves after 500ms

@@ -71,3 +72,3 @@ base.setSync(async (log) => {

const firstMessage = "First message";
const base = new Base("testing");
const base = new Base("testing", "someSource");
// Add a mock sync method

@@ -87,3 +88,3 @@ base.setSync(async (log) => log);

it("should remove a pipeline function", async () => {
const base = new Base("testing");
const base = new Base("testing", "someSource");
// Create a pipeline function

@@ -103,3 +104,3 @@ const customPipeline = async (log) => log;

const message = "Test";
const base = new Base("testing");
const base = new Base("testing", "someSource");
// Add a mock sync method

@@ -115,3 +116,3 @@ base.setSync(async (log) => log);

const message = "Test";
const base = new Base("testing");
const base = new Base("testing", "someSource");
// Add a mock sync method

@@ -127,3 +128,3 @@ base.setSync(async (log) => log);

const message = "Test";
const base = new Base("testing");
const base = new Base("testing", "someSource");
// Add a mock sync method

@@ -139,3 +140,3 @@ base.setSync(async (log) => log);

const message = "Test";
const base = new Base("testing");
const base = new Base("testing", "someSource");
// Add a mock sync method

@@ -151,3 +152,3 @@ base.setSync(async (log) => log);

const message = "Test";
const base = new Base("testing");
const base = new Base("testing", "someSource");
// Add a mock sync method

@@ -164,3 +165,3 @@ base.setSync(async (log) => log);

const e = new Error(message);
const base = new Base("testing");
const base = new Base("testing", "someSource");
// Add a mock sync method

@@ -179,3 +180,3 @@ base.setSync(async (log) => log);

const e = new Error("Should NOT be ignored!");
const base = new Base("testing");
const base = new Base("testing", "someSource");
// Add a mock sync method which throws an error

@@ -190,3 +191,3 @@ base.setSync(async () => {

const message = "Testing exceptions";
const base = new Base("testing", {
const base = new Base("testing", "someSource", {
ignoreExceptions: true,

@@ -193,0 +194,0 @@ });

{
"name": "@timberio/core",
"version": "0.32.0",
"version": "0.33.0",
"description": "Timber.io - logging core",

@@ -40,6 +40,6 @@ "keywords": [

"dependencies": {
"@timberio/tools": "^0.32.0",
"@timberio/types": "^0.32.0"
"@timberio/tools": "^0.33.0",
"@timberio/types": "^0.33.0"
},
"gitHead": "40b5f1cf02fb2552da392a3e04cb06a66453a21e"
"gitHead": "6ebcfc9c1d10df24abd9525aca1c2784e22646fc"
}

@@ -29,9 +29,13 @@ # 🌲 Timber - logging core

// Constructor must take a Timber.io API key, and (optional) options
public constructor(apiKey: string, options?: Partial<ITimberOptions>) {
// Make sure you pass the API key to the parent constructor!
super(apiKey, options);
public constructor(
orgApiKey: string,
sourceKey: string,
options?: Partial<ITimberOptions>,
) {
// Make sure you pass the organization API + source key to the parent constructor!
super(apiKey, sourceKey, options);
// Create a custom sync method
this.setSync(async (logs: ITimberLog[]) => {
// Sync the `log` somehow ... `this._apiKey` contains your Timber API key
// Sync the `log` somehow ... `this._apiKey` contains your Timber organization API key

@@ -38,0 +42,0 @@ // ....

@@ -7,3 +7,4 @@ import Base from "./base";

const apiKey = "testing";
const base = new Base(apiKey);
const sourceKey = "someSource";
const base = new Base(apiKey, sourceKey);

@@ -14,3 +15,3 @@ expect((base as any)._apiKey).toEqual(apiKey);

it("should throw if a `sync` method is missing", async () => {
const base = new Base("testing");
const base = new Base("testing", "someSource");

@@ -24,3 +25,3 @@ // Expect logging to throw an error, since we're missing a `sync` func

const message = "Test";
const base = new Base("testing");
const base = new Base("testing", "someSource");

@@ -41,3 +42,3 @@ // Add a mock sync method

it("should default log count to zero", () => {
const base = new Base("testing");
const base = new Base("testing", "someSource");

@@ -48,3 +49,3 @@ expect(base.logged).toEqual(0);

it("should default synced count to zero", () => {
const base = new Base("testing");
const base = new Base("testing", "someSource");

@@ -55,3 +56,3 @@ expect(base.synced).toEqual(0);

it("should increment log count on `.log()`", async () => {
const base = new Base("testing");
const base = new Base("testing", "someSource");

@@ -68,3 +69,3 @@ // Add a mock sync method

it("should sync after 500 ms", async () => {
const base = new Base("testing");
const base = new Base("testing", "someSource");

@@ -99,3 +100,3 @@ // Create a sync function that resolves after 500ms

const firstMessage = "First message";
const base = new Base("testing");
const base = new Base("testing", "someSource");

@@ -124,3 +125,3 @@ // Add a mock sync method

it("should remove a pipeline function", async () => {
const base = new Base("testing");
const base = new Base("testing", "someSource");

@@ -146,3 +147,3 @@ // Create a pipeline function

const message = "Test";
const base = new Base("testing");
const base = new Base("testing", "someSource");

@@ -162,3 +163,3 @@ // Add a mock sync method

const message = "Test";
const base = new Base("testing");
const base = new Base("testing", "someSource");

@@ -178,3 +179,3 @@ // Add a mock sync method

const message = "Test";
const base = new Base("testing");
const base = new Base("testing", "someSource");

@@ -194,3 +195,3 @@ // Add a mock sync method

const message = "Test";
const base = new Base("testing");
const base = new Base("testing", "someSource");

@@ -210,3 +211,3 @@ // Add a mock sync method

const message = "Test";
const base = new Base("testing");
const base = new Base("testing", "someSource");

@@ -227,3 +228,3 @@ // Add a mock sync method

const e = new Error(message);
const base = new Base("testing");
const base = new Base("testing", "someSource");

@@ -247,3 +248,3 @@ // Add a mock sync method

const e = new Error("Should NOT be ignored!");
const base = new Base("testing");
const base = new Base("testing", "someSource");

@@ -261,3 +262,3 @@ // Add a mock sync method which throws an error

const message = "Testing exceptions";
const base = new Base("testing", {
const base = new Base("testing", "someSource", {
ignoreExceptions: true,

@@ -264,0 +265,0 @@ });

@@ -16,4 +16,4 @@ import {

const defaultOptions: ITimberOptions = {
// Default sync endpoint:
endpoint: "https://logs.timber.io/frames",
// Default sync endpoint (protocol + domain)
endpoint: "https://logs.timber.io",

@@ -37,5 +37,8 @@ // Maximum number of logs to sync in a single request to Timber.io

class Timber {
// Timber API key
// Timber organization API key
protected _apiKey: string;
// Timber source key
protected _sourceKey: string;
// Timber library options

@@ -67,3 +70,7 @@ protected _options: ITimberOptions;

*/
public constructor(apiKey: string, options?: Partial<ITimberOptions>) {
public constructor(
apiKey: string,
sourceKey: string,
options?: Partial<ITimberOptions>,
) {
// First, check we have a valid API key

@@ -77,2 +84,5 @@ if (typeof apiKey !== "string" || apiKey === "") {

// Store the source key, to connect the log to a particular source
this._sourceKey = sourceKey;
// Merge default and user options

@@ -79,0 +89,0 @@ this._options = { ...defaultOptions, ...options };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc