@segment/analytics-node
Advanced tools
Comparing version 1.0.0-beta.24 to 1.0.0-beta.25
@@ -30,2 +30,3 @@ "use strict"; | ||
httpRequestTimeout: settings.httpRequestTimeout, | ||
disable: settings.disable, | ||
flushInterval, | ||
@@ -32,0 +33,0 @@ }, this); |
@@ -5,3 +5,3 @@ "use strict"; | ||
// This file is generated. | ||
exports.version = '1.0.0-beta.24'; | ||
exports.version = '1.0.0-beta.25'; | ||
//# sourceMappingURL=version.js.map |
@@ -19,3 +19,3 @@ "use strict"; | ||
class Publisher { | ||
constructor({ host, path, maxRetries, maxEventsInBatch, flushInterval, writeKey, httpRequestTimeout, }, emitter) { | ||
constructor({ host, path, maxRetries, maxEventsInBatch, flushInterval, writeKey, httpRequestTimeout, disable, }, emitter) { | ||
this._emitter = emitter; | ||
@@ -28,2 +28,3 @@ this._maxRetries = maxRetries; | ||
this._httpRequestTimeout = httpRequestTimeout ?? 10000; | ||
this._disable = Boolean(disable); | ||
} | ||
@@ -151,2 +152,6 @@ createBatch() { | ||
}); | ||
if (this._disable) { | ||
clearTimeout(timeoutId); | ||
return batch.resolveEvents(); | ||
} | ||
const response = await (0, fetch_1.fetch)(this._url, requestInit); | ||
@@ -153,0 +158,0 @@ clearTimeout(timeoutId); |
@@ -27,2 +27,3 @@ import { bindAll, pTimeout } from '@segment/analytics-core'; | ||
httpRequestTimeout: settings.httpRequestTimeout, | ||
disable: settings.disable, | ||
flushInterval, | ||
@@ -29,0 +30,0 @@ }, this); |
// This file is generated. | ||
export const version = '1.0.0-beta.24'; | ||
export const version = '1.0.0-beta.25'; | ||
//# sourceMappingURL=version.js.map |
@@ -16,3 +16,3 @@ import { backoff } from '@segment/analytics-core'; | ||
export class Publisher { | ||
constructor({ host, path, maxRetries, maxEventsInBatch, flushInterval, writeKey, httpRequestTimeout, }, emitter) { | ||
constructor({ host, path, maxRetries, maxEventsInBatch, flushInterval, writeKey, httpRequestTimeout, disable, }, emitter) { | ||
this._emitter = emitter; | ||
@@ -25,2 +25,3 @@ this._maxRetries = maxRetries; | ||
this._httpRequestTimeout = httpRequestTimeout ?? 10000; | ||
this._disable = Boolean(disable); | ||
} | ||
@@ -148,2 +149,6 @@ createBatch() { | ||
}); | ||
if (this._disable) { | ||
clearTimeout(timeoutId); | ||
return batch.resolveEvents(); | ||
} | ||
const response = await fetch(this._url, requestInit); | ||
@@ -150,0 +155,0 @@ clearTimeout(timeoutId); |
@@ -31,4 +31,8 @@ export interface AnalyticsSettings { | ||
httpRequestTimeout?: number; | ||
/** | ||
* Disable the analytics library. All calls will be a noop. Default: false. | ||
*/ | ||
disable?: boolean; | ||
} | ||
export declare const validateSettings: (settings: AnalyticsSettings) => void; | ||
//# sourceMappingURL=settings.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export declare const version = "1.0.0-beta.24"; | ||
export declare const version = "1.0.0-beta.25"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -11,2 +11,3 @@ import type { Context } from '../../app/context'; | ||
httpRequestTimeout?: number; | ||
disable?: boolean; | ||
} | ||
@@ -27,3 +28,4 @@ /** | ||
private _emitter; | ||
constructor({ host, path, maxRetries, maxEventsInBatch, flushInterval, writeKey, httpRequestTimeout, }: PublisherProps, emitter: NodeEmitter); | ||
private _disable; | ||
constructor({ host, path, maxRetries, maxEventsInBatch, flushInterval, writeKey, httpRequestTimeout, disable, }: PublisherProps, emitter: NodeEmitter); | ||
private createBatch; | ||
@@ -30,0 +32,0 @@ private clearBatch; |
{ | ||
"name": "@segment/analytics-node", | ||
"version": "1.0.0-beta.24", | ||
"version": "1.0.0-beta.25", | ||
"main": "./dist/cjs/index.js", | ||
@@ -5,0 +5,0 @@ "module": "./dist/esm/index.js", |
@@ -208,12 +208,9 @@ # @segment/analytics-node | ||
## Development: Disabling Analytics for Tests | ||
- If you want to intercept / disable analytics for integration tests, you can use something like [nock](https://github.com/nock/nock) | ||
- Set `disable: true`. | ||
```ts | ||
// Note: nock will _not_ work if polyfill fetch with something like undici, as nock uses the http module. Undici has its own interception method. | ||
import nock from 'nock' | ||
nock('https://api.segment.io') | ||
.post('/v1/batch') | ||
.reply(201) | ||
.persist() | ||
const analytics = new Analytics({ | ||
... | ||
disable: process.env.NODE_ENV === 'test' | ||
}) | ||
``` | ||
@@ -255,3 +252,3 @@ | ||
- The `enable` configuration option has been removed-- see "Disabling Analytics" section | ||
- The configuration option for disabling analytics has changed. `enable: false` -> `disable: true` | ||
- the `errorHandler` configuration option has been remove -- see "Error Handling" section | ||
@@ -258,0 +255,0 @@ - `flushAt` configuration option -> `maxEventsInBatch`. |
@@ -52,2 +52,3 @@ import { CoreAnalytics, bindAll, pTimeout } from '@segment/analytics-core' | ||
httpRequestTimeout: settings.httpRequestTimeout, | ||
disable: settings.disable, | ||
flushInterval, | ||
@@ -54,0 +55,0 @@ }, |
@@ -33,2 +33,6 @@ import { ValidationError } from '@segment/analytics-core' | ||
httpRequestTimeout?: number | ||
/** | ||
* Disable the analytics library. All calls will be a noop. Default: false. | ||
*/ | ||
disable?: boolean | ||
} | ||
@@ -35,0 +39,0 @@ |
// This file is generated. | ||
export const version = '1.0.0-beta.24' | ||
export const version = '1.0.0-beta.25' |
@@ -30,2 +30,3 @@ import { backoff } from '@segment/analytics-core' | ||
httpRequestTimeout?: number | ||
disable?: boolean | ||
} | ||
@@ -48,2 +49,3 @@ | ||
private _emitter: NodeEmitter | ||
private _disable: boolean | ||
constructor( | ||
@@ -58,2 +60,3 @@ { | ||
httpRequestTimeout, | ||
disable, | ||
}: PublisherProps, | ||
@@ -72,2 +75,3 @@ emitter: NodeEmitter | ||
this._httpRequestTimeout = httpRequestTimeout ?? 10000 | ||
this._disable = Boolean(disable) | ||
} | ||
@@ -216,2 +220,7 @@ | ||
if (this._disable) { | ||
clearTimeout(timeoutId) | ||
return batch.resolveEvents() | ||
} | ||
const response = await fetch(this._url, requestInit) | ||
@@ -218,0 +227,0 @@ |
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
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
Sorry, the diff of this file is not supported yet
174232
2885
355