@deriv-com/analytics 1.38.7 → 1.38.8
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.
- package/dist/browser/analytics.bundle.global.js +6 -6
- package/dist/browser/analytics.bundle.global.js.map +1 -1
- package/dist/browser/analytics.esm.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/metafile-iife.json +1 -1
- package/dist/{posthog-ZJSIYY5Q.mjs → posthog-72HGN74H.mjs} +4 -4
- package/dist/{posthog-ZJSIYY5Q.mjs.map → posthog-72HGN74H.mjs.map} +1 -1
- package/dist/{posthog-DV6iayrn.d.ts → posthog-BXTVRi7y.d.ts} +1 -0
- package/dist/{posthog-lAeI7PhD.d.mts → posthog-Df2P2mKj.d.mts} +1 -0
- package/dist/providers/posthog/index.d.mts +1 -1
- package/dist/providers/posthog/index.d.ts +1 -1
- package/dist/providers/posthog/index.js +2 -2
- package/dist/providers/posthog/index.js.map +1 -1
- package/dist/providers/posthog/index.mjs +2 -2
- package/dist/providers/posthog/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';var chunkNOEKD4DT_js=require('../../chunk-NOEKD4DT.js'),
|
|
2
|
-
var
|
|
1
|
+
'use strict';var chunkNOEKD4DT_js=require('../../chunk-NOEKD4DT.js'),e=require('posthog-js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var e__default=/*#__PURE__*/_interopDefault(e);/* @deriv-com/analytics - NPM Package - Built with tsup */
|
|
2
|
+
var o=class o{constructor(t){this.has_initialized=false;this.has_identified=false;this.init=()=>{try{let{apiKey:t,api_host:s,config:i={}}=this.options;if(!t){console.warn("Posthog: No API key provided");return}let f={api_host:s||chunkNOEKD4DT_js.d,ui_host:chunkNOEKD4DT_js.e,autocapture:!0,capture_pageview:"history_change",session_recording:{recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,...i.session_recording},before_send:r=>{if(typeof window>"u")return null;let n=window.location.hostname;return n==="localhost"||n==="127.0.0.1"||chunkNOEKD4DT_js.f.some(a=>n.endsWith(`.${a}`)||n===a)?r:null},...i};e__default.default.init(t,f),this.has_initialized=!0;}catch(t){console.error("Posthog: Failed to initialize",t);}};this.identifyEvent=(t,s)=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{let i=typeof e__default.default._isIdentified=="function"?e__default.default._isIdentified():this.has_identified;t&&!i&&(e__default.default.identify(t,{...s,client_id:t}),this.has_identified=!0);}catch(i){console.error("Posthog: Failed to identify user",i);}};this.reset=()=>{if(this.has_initialized)try{e__default.default.reset(),this.has_identified=!1;}catch(t){console.error("Posthog: Failed to reset",t);}};this.capture=(t,s)=>{if(this.has_initialized)try{e__default.default.capture(t,s);}catch(i){console.error("Posthog: Failed to capture event",i);}};this.options=t,this.init();}};o.getPosthogInstance=t=>(o._instance||(o._instance=new o(t)),o._instance);var l=o;exports.Posthog=l;//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/providers/posthog.ts"],"names":["_Posthog","options","apiKey","api_host","config","posthogConfig","posthogApiHost","posthogUiHost","event","currentHost","allowedDomains","domain","posthog","error","user_id","traits","isIdentified","
|
|
1
|
+
{"version":3,"sources":["../../../src/providers/posthog.ts"],"names":["_Posthog","options","apiKey","api_host","config","posthogConfig","posthogApiHost","posthogUiHost","event","currentHost","allowedDomains","domain","posthog","error","user_id","traits","isIdentified","event_name","properties","Posthog"],"mappings":";AAmBO,IAAMA,CAAAA,CAAN,MAAMA,CAAQ,CAMjB,WAAA,CAAYC,CAAAA,CAA0B,CALtC,IAAA,CAAA,eAAA,CAAkB,KAAA,CAClB,IAAA,CAAA,cAAA,CAAiB,KAAA,CAyBjB,IAAA,CAAA,IAAA,CAAO,IAAY,CACf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,SAAA,CAAA,CApBhB,IAAMmB,CAAAA,CAANnB","file":"index.js","sourcesContent":["import posthog from 'posthog-js'\nimport type { TPosthogConfig, TPosthogIdentifyTraits, TPosthogOptions } from './posthogTypes'\nimport type { TCoreAttributes } from '../types'\nimport { allowedDomains, posthogApiHost, posthogUiHost } from '../utils/urls'\n\n/**\n * PostHog analytics wrapper with singleton pattern.\n * Provides optional PostHog integration for event tracking and session recording.\n *\n * Features:\n * - Dynamically loads PostHog SDK on demand\n * - Domain allowlisting for security\n * - Automatic user identification and aliasing\n * - Custom event tracking with property sanitization\n * - Built-in caching and retry mechanisms (handled by posthog-js library)\n *\n * Note: PostHog handles its own event queuing, caching, and retry logic internally.\n * No additional caching is needed at the wrapper level.\n */\nexport class Posthog {\n has_initialized = false\n has_identified = false\n private static _instance: Posthog\n private options: TPosthogOptions\n\n constructor(options: TPosthogOptions) {\n this.options = options\n this.init()\n }\n\n /**\n * Get or create the singleton instance of Posthog\n * @param options - PostHog configuration options including API key\n * @returns The Posthog singleton instance\n */\n public static getPosthogInstance = (options: TPosthogOptions): Posthog => {\n if (!Posthog._instance) {\n Posthog._instance = new Posthog(options)\n }\n return Posthog._instance\n }\n\n /**\n * Initialize PostHog with configuration\n * Configures PostHog instance with provided options\n */\n init = (): void => {\n try {\n const { apiKey, api_host, config = {} } = this.options\n\n if (!apiKey) {\n console.warn('Posthog: No API key provided')\n return\n }\n\n const posthogConfig: TPosthogConfig = {\n api_host: api_host || posthogApiHost,\n ui_host: posthogUiHost,\n autocapture: true,\n capture_pageview: 'history_change',\n session_recording: {\n recordCrossOriginIframes: true,\n minimumDurationMilliseconds: 30000,\n ...config.session_recording,\n },\n before_send: event => {\n if (typeof window === 'undefined') return null\n\n const currentHost = window.location.hostname\n if (currentHost === 'localhost' || currentHost === '127.0.0.1') return event\n\n const isAllowed = allowedDomains.some(\n domain => currentHost.endsWith(`.${domain}`) || currentHost === domain\n )\n return isAllowed ? event : null\n },\n ...config,\n }\n\n // Initialize PostHog\n posthog.init(apiKey, posthogConfig)\n this.has_initialized = true\n } catch (error) {\n console.error('Posthog: Failed to initialize', error)\n }\n }\n\n /**\n * Identify a user with PostHog\n * Creates an alias between anonymous ID and user ID, then identifies with traits\n *\n * @param user_id - The user ID to identify\n * @param traits - User properties (language, country_of_residence, etc.)\n */\n identifyEvent = (user_id: string, traits?: TPosthogIdentifyTraits): void => {\n if (!this.has_initialized) {\n console.warn('Posthog: Cannot identify - not initialized')\n return\n }\n\n try {\n const isIdentified =\n typeof posthog._isIdentified === 'function' ? posthog._isIdentified() : this.has_identified\n\n if (user_id && !isIdentified) {\n posthog.identify(user_id, { ...traits, client_id: user_id })\n this.has_identified = true\n }\n } catch (error) {\n console.error('Posthog: Failed to identify user', error)\n }\n }\n\n /**\n * Reset PostHog state\n * Clears user identification and resets the instance\n */\n reset = (): void => {\n if (!this.has_initialized) return\n\n try {\n posthog.reset()\n this.has_identified = false\n } catch (error) {\n console.error('Posthog: Failed to reset', error)\n }\n }\n\n /**\n * Capture a custom event with properties\n * Properties are pre-flattened and cleaned by analytics.ts before being passed here\n *\n * @param event_name - The name of the event to track\n * @param properties - Event properties including core attributes (already flattened and cleaned)\n */\n capture = (event_name: string, properties?: Record<string, any> & Partial<TCoreAttributes>): void => {\n if (!this.has_initialized) return\n\n try {\n posthog.capture(event_name, properties)\n } catch (error) {\n console.error('Posthog: Failed to capture event', error)\n }\n }\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {f,e
|
|
2
|
-
var
|
|
1
|
+
import {f,e,d}from'../../chunk-DNCZM4KN.mjs';import e$1 from'posthog-js';/* @deriv-com/analytics - NPM Package - Built with tsup */
|
|
2
|
+
var o=class o{constructor(t){this.has_initialized=false;this.has_identified=false;this.init=()=>{try{let{apiKey:t,api_host:s,config:i={}}=this.options;if(!t){console.warn("Posthog: No API key provided");return}let f$1={api_host:s||d,ui_host:e,autocapture:!0,capture_pageview:"history_change",session_recording:{recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,...i.session_recording},before_send:r=>{if(typeof window>"u")return null;let n=window.location.hostname;return n==="localhost"||n==="127.0.0.1"||f.some(a=>n.endsWith(`.${a}`)||n===a)?r:null},...i};e$1.init(t,f$1),this.has_initialized=!0;}catch(t){console.error("Posthog: Failed to initialize",t);}};this.identifyEvent=(t,s)=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{let i=typeof e$1._isIdentified=="function"?e$1._isIdentified():this.has_identified;t&&!i&&(e$1.identify(t,{...s,client_id:t}),this.has_identified=!0);}catch(i){console.error("Posthog: Failed to identify user",i);}};this.reset=()=>{if(this.has_initialized)try{e$1.reset(),this.has_identified=!1;}catch(t){console.error("Posthog: Failed to reset",t);}};this.capture=(t,s)=>{if(this.has_initialized)try{e$1.capture(t,s);}catch(i){console.error("Posthog: Failed to capture event",i);}};this.options=t,this.init();}};o.getPosthogInstance=t=>(o._instance||(o._instance=new o(t)),o._instance);var l=o;export{l as Posthog};//# sourceMappingURL=index.mjs.map
|
|
3
3
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/providers/posthog.ts"],"names":["_Posthog","options","apiKey","api_host","config","posthogConfig","posthogApiHost","posthogUiHost","event","currentHost","allowedDomains","domain","posthog","error","user_id","traits","isIdentified","
|
|
1
|
+
{"version":3,"sources":["../../../src/providers/posthog.ts"],"names":["_Posthog","options","apiKey","api_host","config","posthogConfig","posthogApiHost","posthogUiHost","event","currentHost","allowedDomains","domain","posthog","error","user_id","traits","isIdentified","event_name","properties","Posthog"],"mappings":";AAmBO,IAAMA,CAAAA,CAAN,MAAMA,CAAQ,CAMjB,WAAA,CAAYC,CAAAA,CAA0B,CALtC,IAAA,CAAA,eAAA,CAAkB,KAAA,CAClB,IAAA,CAAA,cAAA,CAAiB,KAAA,CAyBjB,IAAA,CAAA,IAAA,CAAO,IAAY,CACf,GAAI,CACA,GAAM,CAAE,MAAA,CAAAC,CAAA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","sourcesContent":["import posthog from 'posthog-js'\nimport type { TPosthogConfig, TPosthogIdentifyTraits, TPosthogOptions } from './posthogTypes'\nimport type { TCoreAttributes } from '../types'\nimport { allowedDomains, posthogApiHost, posthogUiHost } from '../utils/urls'\n\n/**\n * PostHog analytics wrapper with singleton pattern.\n * Provides optional PostHog integration for event tracking and session recording.\n *\n * Features:\n * - Dynamically loads PostHog SDK on demand\n * - Domain allowlisting for security\n * - Automatic user identification and aliasing\n * - Custom event tracking with property sanitization\n * - Built-in caching and retry mechanisms (handled by posthog-js library)\n *\n * Note: PostHog handles its own event queuing, caching, and retry logic internally.\n * No additional caching is needed at the wrapper level.\n */\nexport class Posthog {\n has_initialized = false\n has_identified = false\n private static _instance: Posthog\n private options: TPosthogOptions\n\n constructor(options: TPosthogOptions) {\n this.options = options\n this.init()\n }\n\n /**\n * Get or create the singleton instance of Posthog\n * @param options - PostHog configuration options including API key\n * @returns The Posthog singleton instance\n */\n public static getPosthogInstance = (options: TPosthogOptions): Posthog => {\n if (!Posthog._instance) {\n Posthog._instance = new Posthog(options)\n }\n return Posthog._instance\n }\n\n /**\n * Initialize PostHog with configuration\n * Configures PostHog instance with provided options\n */\n init = (): void => {\n try {\n const { apiKey, api_host, config = {} } = this.options\n\n if (!apiKey) {\n console.warn('Posthog: No API key provided')\n return\n }\n\n const posthogConfig: TPosthogConfig = {\n api_host: api_host || posthogApiHost,\n ui_host: posthogUiHost,\n autocapture: true,\n capture_pageview: 'history_change',\n session_recording: {\n recordCrossOriginIframes: true,\n minimumDurationMilliseconds: 30000,\n ...config.session_recording,\n },\n before_send: event => {\n if (typeof window === 'undefined') return null\n\n const currentHost = window.location.hostname\n if (currentHost === 'localhost' || currentHost === '127.0.0.1') return event\n\n const isAllowed = allowedDomains.some(\n domain => currentHost.endsWith(`.${domain}`) || currentHost === domain\n )\n return isAllowed ? event : null\n },\n ...config,\n }\n\n // Initialize PostHog\n posthog.init(apiKey, posthogConfig)\n this.has_initialized = true\n } catch (error) {\n console.error('Posthog: Failed to initialize', error)\n }\n }\n\n /**\n * Identify a user with PostHog\n * Creates an alias between anonymous ID and user ID, then identifies with traits\n *\n * @param user_id - The user ID to identify\n * @param traits - User properties (language, country_of_residence, etc.)\n */\n identifyEvent = (user_id: string, traits?: TPosthogIdentifyTraits): void => {\n if (!this.has_initialized) {\n console.warn('Posthog: Cannot identify - not initialized')\n return\n }\n\n try {\n const isIdentified =\n typeof posthog._isIdentified === 'function' ? posthog._isIdentified() : this.has_identified\n\n if (user_id && !isIdentified) {\n posthog.identify(user_id, { ...traits, client_id: user_id })\n this.has_identified = true\n }\n } catch (error) {\n console.error('Posthog: Failed to identify user', error)\n }\n }\n\n /**\n * Reset PostHog state\n * Clears user identification and resets the instance\n */\n reset = (): void => {\n if (!this.has_initialized) return\n\n try {\n posthog.reset()\n this.has_identified = false\n } catch (error) {\n console.error('Posthog: Failed to reset', error)\n }\n }\n\n /**\n * Capture a custom event with properties\n * Properties are pre-flattened and cleaned by analytics.ts before being passed here\n *\n * @param event_name - The name of the event to track\n * @param properties - Event properties including core attributes (already flattened and cleaned)\n */\n capture = (event_name: string, properties?: Record<string, any> & Partial<TCoreAttributes>): void => {\n if (!this.has_initialized) return\n\n try {\n posthog.capture(event_name, properties)\n } catch (error) {\n console.error('Posthog: Failed to capture event', error)\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deriv-com/analytics",
|
|
3
|
-
"version": "1.38.
|
|
3
|
+
"version": "1.38.8",
|
|
4
4
|
"description": "Comprehensive analytics package for Deriv applications. Provides unified event tracking, A/B testing, and user analytics through RudderStack, PostHog and GrowthBook integrations with built-in caching and offline support.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rudderstack",
|