@stacksee/analytics 0.13.0 → 0.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ var o = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
2
+ function l(e) {
3
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
4
+ }
5
+ export {
6
+ o as c,
7
+ l as g
8
+ };
@@ -130,7 +130,7 @@ export declare class ServerAnalytics<TEventMap extends Record<string, Record<str
130
130
  * }
131
131
  * ```
132
132
  */
133
- identify(userId: string, traits?: Record<string, unknown>): void;
133
+ identify(userId: string, traits?: Record<string, unknown>): Promise<void>;
134
134
  /**
135
135
  * Tracks a custom event with properties and optional context.
136
136
  *
@@ -320,7 +320,7 @@ export declare class ServerAnalytics<TEventMap extends Record<string, Record<str
320
320
  */
321
321
  pageView(properties?: Record<string, unknown>, options?: {
322
322
  context?: EventContext<TUserTraits>;
323
- }): void;
323
+ }): Promise<void>;
324
324
  /**
325
325
  * Tracks when a user leaves a page from the server side.
326
326
  *
@@ -1,4 +1,4 @@
1
- import { c as W, g as ae } from "./_commonjsHelpers-B4e78b8K.js";
1
+ import { c as W, g as ae } from "./_commonjsHelpers-DaMA6jEr.js";
2
2
  var Z = { exports: {} }, re;
3
3
  function se() {
4
4
  return re || (re = 1, (function(l, c) {
@@ -50,9 +50,9 @@ export declare class BentoServerProvider extends BaseAnalyticsProvider {
50
50
  private currentUserEmail?;
51
51
  constructor(config: BentoServerConfig);
52
52
  initialize(): Promise<void>;
53
- identify(userId: string, traits?: Record<string, unknown>): void;
53
+ identify(userId: string, traits?: Record<string, unknown>): Promise<void>;
54
54
  track(event: BaseEvent, context?: EventContext): Promise<void>;
55
- pageView(properties?: Record<string, unknown>, context?: EventContext): void;
55
+ pageView(properties?: Record<string, unknown>, context?: EventContext): Promise<void>;
56
56
  reset(): Promise<void>;
57
57
  shutdown(): Promise<void>;
58
58
  }
@@ -1,6 +1,6 @@
1
1
  var f = Object.defineProperty;
2
- var p = (d, h, e) => h in d ? f(d, h, { enumerable: !0, configurable: !0, writable: !0, value: e }) : d[h] = e;
3
- var r = (d, h, e) => p(d, typeof h != "symbol" ? h + "" : h, e);
2
+ var p = (o, h, e) => h in o ? f(o, h, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[h] = e;
3
+ var r = (o, h, e) => p(o, typeof h != "symbol" ? h + "" : h, e);
4
4
  import { B as u } from "../base.provider-AfFL5W_P.js";
5
5
  import { i as a } from "../client-DTHZYkxx.js";
6
6
  import { P as z } from "../client-DTHZYkxx.js";
@@ -296,10 +296,11 @@ class m extends u {
296
296
  if (!this.config.identificationCode || typeof this.config.identificationCode != "string")
297
297
  throw new Error("Pirsch requires an identificationCode");
298
298
  try {
299
- const { Pirsch: e } = await import("../web-imCcOhDC.js").then((i) => i.w);
299
+ const { Pirsch: e } = await import("../web-D-ZwlgeQ.js").then((i) => i.w);
300
300
  this.client = new e({
301
301
  identificationCode: this.config.identificationCode,
302
- ...this.config.hostname && { hostname: this.config.hostname }
302
+ ...this.config.hostname && { hostname: this.config.hostname },
303
+ ...this.config.timeout && { timeout: this.config.timeout }
303
304
  }), this.initialized = !0, this.log("Initialized successfully", this.config);
304
305
  } catch (e) {
305
306
  throw console.error(
@@ -347,15 +348,15 @@ class m extends u {
347
348
  return;
348
349
  const s = e && Object.keys(e).length > 0 ? Object.fromEntries(
349
350
  Object.entries(e).filter(
350
- ([, o]) => typeof o == "string" || typeof o == "number" || typeof o == "boolean"
351
+ ([, d]) => typeof d == "string" || typeof d == "number" || typeof d == "boolean"
351
352
  )
352
353
  ) : void 0, t = {
353
354
  ...((l = i == null ? void 0 : i.page) == null ? void 0 : l.url) && { url: i.page.url },
354
355
  ...((g = i == null ? void 0 : i.page) == null ? void 0 : g.title) && { title: i.page.title },
355
356
  ...s && { tags: s }
356
357
  }, n = Object.keys(t).length > 0 ? t : void 0;
357
- this.client.hit(n).catch((o) => {
358
- console.error("[Pirsch-Client] Failed to track page view:", o);
358
+ this.client.hit(n).catch((d) => {
359
+ console.error("[Pirsch-Client] Failed to track page view:", d);
359
360
  }), this.log("Tracked page view", { properties: e, context: i });
360
361
  }
361
362
  pageLeave(e, i) {
@@ -8,6 +8,11 @@ export interface EmitKitServerConfig {
8
8
  * Your EmitKit API key (starts with emitkit_)
9
9
  */
10
10
  apiKey: string;
11
+ /**
12
+ * Request timeout in milliseconds
13
+ * @default 5000
14
+ */
15
+ timeout?: number;
11
16
  /**
12
17
  * Default channel name for events
13
18
  * @default 'general'
@@ -61,9 +66,9 @@ export declare class EmitKitServerProvider extends BaseAnalyticsProvider {
61
66
  private currentUserEmail?;
62
67
  constructor(config: EmitKitServerConfig);
63
68
  initialize(): Promise<void>;
64
- identify(userId: string, traits?: Record<string, unknown>): void;
69
+ identify(userId: string, traits?: Record<string, unknown>): Promise<void>;
65
70
  track(event: BaseEvent, context?: EventContext): Promise<void>;
66
- pageView(properties?: Record<string, unknown>, context?: EventContext): void;
71
+ pageView(properties?: Record<string, unknown>, context?: EventContext): Promise<void>;
67
72
  reset(): Promise<void>;
68
73
  shutdown(): Promise<void>;
69
74
  /**
@@ -10,6 +10,11 @@ export interface PirschClientConfig {
10
10
  * The hostname/domain being tracked (e.g., "example.com")
11
11
  */
12
12
  hostname?: string;
13
+ /**
14
+ * Request timeout in milliseconds
15
+ * @default 5000
16
+ */
17
+ timeout?: number;
13
18
  /**
14
19
  * Enable debug logging
15
20
  */
@@ -1,6 +1,6 @@
1
1
  import { BaseEvent, EventContext } from '../../core/events/types.js';
2
2
  import { BaseAnalyticsProvider } from '../base.provider.js';
3
- import { PirschProxyHeader, Protocol } from 'pirsch-sdk';
3
+ type Protocol = "http" | "https";
4
4
  export interface PirschServerConfig {
5
5
  /**
6
6
  * The hostname/domain being tracked (required)
@@ -22,9 +22,10 @@ export interface PirschServerConfig {
22
22
  */
23
23
  clientSecret: string;
24
24
  /**
25
- * Trusted proxy headers for IP extraction
25
+ * Request timeout in milliseconds
26
+ * @default 10000
26
27
  */
27
- trustedProxyHeaders?: PirschProxyHeader[];
28
+ timeout?: number;
28
29
  /**
29
30
  * Enable debug logging
30
31
  */
@@ -33,17 +34,50 @@ export interface PirschServerConfig {
33
34
  * Enable/disable the provider
34
35
  */
35
36
  enabled?: boolean;
37
+ /**
38
+ * Disable Pirsch's bot filter
39
+ * Useful for controlled environments where you want to track all requests
40
+ */
41
+ disableBotFilter?: boolean;
36
42
  }
37
43
  export declare class PirschServerProvider extends BaseAnalyticsProvider {
38
44
  name: string;
39
- private client?;
40
45
  private initialized;
41
46
  private config;
47
+ private accessToken;
48
+ private tokenExpiresAt;
49
+ private isAccessKey;
42
50
  constructor(config: PirschServerConfig);
43
51
  initialize(): Promise<void>;
44
- identify(userId: string, traits?: Record<string, unknown>): void;
52
+ /**
53
+ * Fetch with timeout using AbortController
54
+ */
55
+ private fetchWithTimeout;
56
+ /**
57
+ * Ensure we have a valid access token (for OAuth mode)
58
+ */
59
+ private ensureToken;
60
+ /**
61
+ * Make an authenticated request to Pirsch API
62
+ */
63
+ private request;
64
+ /**
65
+ * Filter object to only include scalar values (string, number, boolean)
66
+ */
67
+ private filterScalars;
68
+ /**
69
+ * Convert object values to strings for Pirsch event_meta
70
+ * Pirsch API requires event_meta to be a single dimension object of string values
71
+ */
72
+ private toStringRecord;
73
+ /**
74
+ * Build a Pirsch hit from context
75
+ */
76
+ private buildHit;
77
+ identify(userId: string, traits?: Record<string, unknown>): Promise<void>;
45
78
  track(event: BaseEvent, context?: EventContext): Promise<void>;
46
- pageView(properties?: Record<string, unknown>, context?: EventContext): void;
79
+ pageView(properties?: Record<string, unknown>, context?: EventContext): Promise<void>;
47
80
  reset(): Promise<void>;
48
81
  shutdown(): Promise<void>;
49
82
  }
83
+ export {};