@propertechnologies/espia
Advanced tools
Comparing version 0.1.0 to 0.2.0
export interface EspiaSetup { | ||
source: string; | ||
session?: string; | ||
enabled?: boolean; | ||
} | ||
export type Overwrites = Partial<EspiaSetup>; | ||
export declare function espia(value: EspiaSetup): void; | ||
export declare function setSource(value: string): void; | ||
export declare function setSession(value: string): void; | ||
export declare function track(category: string, metadata?: object, overwrites?: Overwrites): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.track = exports.setSource = exports.espia = void 0; | ||
exports.track = exports.setSession = exports.espia = void 0; | ||
const BASE = "https://analytics.proper.ai"; | ||
@@ -22,12 +22,18 @@ const EVENT_URL = `${BASE}/events`; | ||
let _session; | ||
let _enabled = true; | ||
function espia(value) { | ||
var _a; | ||
_source = value.source; | ||
_session = value.session; | ||
_enabled = (_a = value.enabled) !== null && _a !== void 0 ? _a : true; | ||
} | ||
exports.espia = espia; | ||
function setSource(value) { | ||
_source = value; | ||
function setSession(value) { | ||
_session = value; | ||
} | ||
exports.setSource = setSource; | ||
exports.setSession = setSession; | ||
function track(category, metadata, overwrites) { | ||
if (!_enabled) { | ||
return; | ||
} | ||
if (_source === undefined && (overwrites === null || overwrites === void 0 ? void 0 : overwrites.source) === undefined) { | ||
@@ -34,0 +40,0 @@ throw new Error("Make sure you init espia with a source before tracking events"); |
{ | ||
"name": "@propertechnologies/espia", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Typed wrapper around analytics.proper.ai", | ||
@@ -11,3 +11,4 @@ "main": "dist/index.js", | ||
"test": "jest", | ||
"prettier": "prettier --write ." | ||
"prettier": "prettier --write .", | ||
"deploy": "rm -rf dist && npm run build && npm publish --access public" | ||
}, | ||
@@ -14,0 +15,0 @@ "author": "Proper Technologies", |
2943
4
52