@segment/analytics-node
Advanced tools
Comparing version 1.0.0-beta.22 to 1.0.0-beta.23
@@ -5,3 +5,3 @@ "use strict"; | ||
// This file is generated. | ||
exports.version = '1.0.0-beta.22'; | ||
exports.version = '1.0.0-beta.23'; | ||
//# sourceMappingURL=version.js.map |
@@ -68,3 +68,3 @@ "use strict"; | ||
} | ||
const ac = new (global.AbortController || AbortController)(); | ||
const ac = new (globalThis.AbortController || AbortController)(); | ||
const timeoutId = setTimeout(() => { | ||
@@ -71,0 +71,0 @@ ac.abort(); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.b64encode = void 0; | ||
const buffer_1 = require("buffer"); | ||
/** | ||
@@ -8,13 +9,5 @@ * Base64 encoder that works in browser, worker, node runtimes. | ||
const b64encode = (str) => { | ||
if ( | ||
// in node env | ||
typeof Buffer !== 'undefined') { | ||
return Buffer.from(str).toString('base64'); | ||
} | ||
else { | ||
// in worker env | ||
return btoa(str); | ||
} | ||
return buffer_1.Buffer.from(str).toString('base64'); | ||
}; | ||
exports.b64encode = b64encode; | ||
//# sourceMappingURL=base-64-encode.js.map |
@@ -5,3 +5,7 @@ "use strict"; | ||
const detectRuntime = () => { | ||
if (typeof process === 'object' && process && process.env) { | ||
if (typeof process === 'object' && | ||
process && | ||
typeof process.env === 'object' && | ||
process.env && | ||
typeof process.version === 'string') { | ||
return 'node'; | ||
@@ -16,2 +20,6 @@ } | ||
} | ||
// @ts-ignore | ||
if (typeof EdgeRuntime === 'string') { | ||
return 'vercel-edge'; | ||
} | ||
if ( | ||
@@ -18,0 +26,0 @@ // @ts-ignore |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fetch = void 0; | ||
const tslib_1 = require("tslib"); | ||
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch")); | ||
exports.fetch = globalThis.fetch || node_fetch_1.default; | ||
const fetch = async (...args) => { | ||
if (globalThis.fetch) { | ||
return globalThis.fetch(...args); | ||
} // @ts-ignore | ||
// This guard causes is important, as it causes dead-code elimination to be enabled inside this block. | ||
else if (typeof EdgeRuntime !== 'string') { | ||
// @ts-ignore | ||
return (await Promise.resolve().then(() => __importStar(require('node-fetch')))).default(...args); | ||
} | ||
else { | ||
throw new Error('Invariant: an edge runtime that does not support fetch should not exist'); | ||
} | ||
}; | ||
exports.fetch = fetch; | ||
//# sourceMappingURL=fetch.js.map |
@@ -12,3 +12,3 @@ "use strict"; | ||
if (runtime === 'node') { | ||
ctx.updateEvent('_metadata.nodeVersion', process.versions.node); | ||
ctx.updateEvent('_metadata.nodeVersion', process.version); | ||
} | ||
@@ -15,0 +15,0 @@ ctx.updateEvent('_metadata.jsRuntime', runtime); |
// This file is generated. | ||
export const version = '1.0.0-beta.22'; | ||
export const version = '1.0.0-beta.23'; | ||
//# sourceMappingURL=version.js.map |
@@ -65,3 +65,3 @@ /** | ||
} | ||
const ac = new (global.AbortController || AbortController)(); | ||
const ac = new (globalThis.AbortController || AbortController)(); | ||
const timeoutId = setTimeout(() => { | ||
@@ -68,0 +68,0 @@ ac.abort(); |
@@ -0,1 +1,2 @@ | ||
import { Buffer } from 'buffer'; | ||
/** | ||
@@ -5,12 +6,4 @@ * Base64 encoder that works in browser, worker, node runtimes. | ||
export const b64encode = (str) => { | ||
if ( | ||
// in node env | ||
typeof Buffer !== 'undefined') { | ||
return Buffer.from(str).toString('base64'); | ||
} | ||
else { | ||
// in worker env | ||
return btoa(str); | ||
} | ||
return Buffer.from(str).toString('base64'); | ||
}; | ||
//# sourceMappingURL=base-64-encode.js.map |
export const detectRuntime = () => { | ||
if (typeof process === 'object' && process && process.env) { | ||
if (typeof process === 'object' && | ||
process && | ||
typeof process.env === 'object' && | ||
process.env && | ||
typeof process.version === 'string') { | ||
return 'node'; | ||
@@ -12,2 +16,6 @@ } | ||
} | ||
// @ts-ignore | ||
if (typeof EdgeRuntime === 'string') { | ||
return 'vercel-edge'; | ||
} | ||
if ( | ||
@@ -14,0 +22,0 @@ // @ts-ignore |
@@ -1,3 +0,14 @@ | ||
import { default as _fetch } from 'node-fetch'; | ||
export const fetch = globalThis.fetch || _fetch; | ||
export const fetch = async (...args) => { | ||
if (globalThis.fetch) { | ||
return globalThis.fetch(...args); | ||
} // @ts-ignore | ||
// This guard causes is important, as it causes dead-code elimination to be enabled inside this block. | ||
else if (typeof EdgeRuntime !== 'string') { | ||
// @ts-ignore | ||
return (await import('node-fetch')).default(...args); | ||
} | ||
else { | ||
throw new Error('Invariant: an edge runtime that does not support fetch should not exist'); | ||
} | ||
}; | ||
//# sourceMappingURL=fetch.js.map |
@@ -9,3 +9,3 @@ import { Publisher } from './publisher'; | ||
if (runtime === 'node') { | ||
ctx.updateEvent('_metadata.nodeVersion', process.versions.node); | ||
ctx.updateEvent('_metadata.nodeVersion', process.version); | ||
} | ||
@@ -12,0 +12,0 @@ ctx.updateEvent('_metadata.jsRuntime', runtime); |
@@ -1,2 +0,2 @@ | ||
export declare const version = "1.0.0-beta.22"; | ||
export declare const version = "1.0.0-beta.23"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -1,3 +0,3 @@ | ||
export type RuntimeEnv = 'node' | 'browser' | 'web-worker' | 'cloudflare-worker' | 'unknown'; | ||
export type RuntimeEnv = 'node' | 'browser' | 'web-worker' | 'cloudflare-worker' | 'vercel-edge' | 'unknown'; | ||
export declare const detectRuntime: () => RuntimeEnv; | ||
//# sourceMappingURL=env.d.ts.map |
{ | ||
"name": "@segment/analytics-node", | ||
"version": "1.0.0-beta.22", | ||
"version": "1.0.0-beta.23", | ||
"main": "./dist/cjs/index.js", | ||
@@ -33,2 +33,3 @@ "module": "./dist/esm/index.js", | ||
"@segment/analytics-core": "1.2.2", | ||
"buffer": "^6.0.3", | ||
"node-fetch": "^2.6.7", | ||
@@ -35,0 +36,0 @@ "tslib": "^2.4.1", |
@@ -291,3 +291,3 @@ # @segment/analytics-node | ||
track: (ctx) => { | ||
ctx.updateEvent('event', ctx.event.event.toLowerCase()) | ||
ctx.event.event = ctx.event.event.toLowerCase() | ||
return ctx | ||
@@ -294,0 +294,0 @@ } |
// This file is generated. | ||
export const version = '1.0.0-beta.22' | ||
export const version = '1.0.0-beta.23' |
@@ -67,3 +67,3 @@ /** | ||
} | ||
const ac = new (global.AbortController || AbortController)() | ||
const ac = new (globalThis.AbortController || AbortController)() | ||
@@ -70,0 +70,0 @@ const timeoutId = setTimeout(() => { |
@@ -0,1 +1,2 @@ | ||
import { Buffer } from 'buffer' | ||
/** | ||
@@ -5,11 +6,3 @@ * Base64 encoder that works in browser, worker, node runtimes. | ||
export const b64encode = (str: string): string => { | ||
if ( | ||
// in node env | ||
typeof Buffer !== 'undefined' | ||
) { | ||
return Buffer.from(str).toString('base64') | ||
} else { | ||
// in worker env | ||
return btoa(str) | ||
} | ||
return Buffer.from(str).toString('base64') | ||
} |
@@ -6,6 +6,13 @@ export type RuntimeEnv = | ||
| 'cloudflare-worker' | ||
| 'vercel-edge' | ||
| 'unknown' | ||
export const detectRuntime = (): RuntimeEnv => { | ||
if (typeof process === 'object' && process && process.env) { | ||
if ( | ||
typeof process === 'object' && | ||
process && | ||
typeof process.env === 'object' && | ||
process.env && | ||
typeof process.version === 'string' | ||
) { | ||
return 'node' | ||
@@ -23,2 +30,7 @@ } | ||
// @ts-ignore | ||
if (typeof EdgeRuntime === 'string') { | ||
return 'vercel-edge' | ||
} | ||
if ( | ||
@@ -25,0 +37,0 @@ // @ts-ignore |
@@ -1,3 +0,14 @@ | ||
import { default as _fetch } from 'node-fetch' | ||
export const fetch = globalThis.fetch || _fetch | ||
export const fetch: typeof globalThis.fetch = async (...args) => { | ||
if (globalThis.fetch) { | ||
return globalThis.fetch(...args) | ||
} // @ts-ignore | ||
// This guard causes is important, as it causes dead-code elimination to be enabled inside this block. | ||
else if (typeof EdgeRuntime !== 'string') { | ||
// @ts-ignore | ||
return (await import('node-fetch')).default(...args) as Response | ||
} else { | ||
throw new Error( | ||
'Invariant: an edge runtime that does not support fetch should not exist' | ||
) | ||
} | ||
} |
@@ -13,3 +13,3 @@ import { Publisher, PublisherProps } from './publisher' | ||
if (runtime === 'node') { | ||
ctx.updateEvent('_metadata.nodeVersion', process.versions.node) | ||
ctx.updateEvent('_metadata.nodeVersion', process.version) | ||
} | ||
@@ -16,0 +16,0 @@ ctx.updateEvent('_metadata.jsRuntime', runtime) |
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
176006
2854
5
2
+ Addedbuffer@^6.0.3
+ Addedbase64-js@1.5.1(transitive)
+ Addedbuffer@6.0.3(transitive)
+ Addedieee754@1.2.1(transitive)