@walkeros/web-destination-piwikpro 0.4.0 → 0.4.1

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/index.d.mts CHANGED
@@ -11,6 +11,7 @@ interface Settings {
11
11
  linkTracking?: boolean;
12
12
  url: string;
13
13
  }
14
+ type InitSettings = Partial<Settings>;
14
15
  interface Mapping {
15
16
  goalId?: string;
16
17
  goalValue?: string;
@@ -31,7 +32,7 @@ interface Env extends DestinationWeb.Env {
31
32
  };
32
33
  };
33
34
  }
34
- type Types = Destination$1.Types<Settings, Mapping, Env>;
35
+ type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
35
36
  type Destination = DestinationWeb.Destination<Types>;
36
37
  type Config = DestinationWeb.Config<Types>;
37
38
  type Rule = Mapping$1.Rule<Mapping>;
@@ -44,13 +45,14 @@ type index_Config = Config;
44
45
  type index_Destination = Destination;
45
46
  type index_Dimensions = Dimensions;
46
47
  type index_Env = Env;
48
+ type index_InitSettings = InitSettings;
47
49
  type index_Mapping = Mapping;
48
50
  type index_Rule = Rule;
49
51
  type index_Rules = Rules;
50
52
  type index_Settings = Settings;
51
53
  type index_Types = Types;
52
54
  declare namespace index {
53
- export type { index_Config as Config, index_Destination as Destination, index_Dimensions as Dimensions, index_Env as Env, index_Mapping as Mapping, index_Rule as Rule, index_Rules as Rules, index_Settings as Settings, index_Types as Types };
55
+ export type { index_Config as Config, index_Destination as Destination, index_Dimensions as Dimensions, index_Env as Env, index_InitSettings as InitSettings, index_Mapping as Mapping, index_Rule as Rule, index_Rules as Rules, index_Settings as Settings, index_Types as Types };
54
56
  }
55
57
 
56
58
  declare const destinationPiwikPro: Destination;
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ interface Settings {
11
11
  linkTracking?: boolean;
12
12
  url: string;
13
13
  }
14
+ type InitSettings = Partial<Settings>;
14
15
  interface Mapping {
15
16
  goalId?: string;
16
17
  goalValue?: string;
@@ -31,7 +32,7 @@ interface Env extends DestinationWeb.Env {
31
32
  };
32
33
  };
33
34
  }
34
- type Types = Destination$1.Types<Settings, Mapping, Env>;
35
+ type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
35
36
  type Destination = DestinationWeb.Destination<Types>;
36
37
  type Config = DestinationWeb.Config<Types>;
37
38
  type Rule = Mapping$1.Rule<Mapping>;
@@ -44,13 +45,14 @@ type index_Config = Config;
44
45
  type index_Destination = Destination;
45
46
  type index_Dimensions = Dimensions;
46
47
  type index_Env = Env;
48
+ type index_InitSettings = InitSettings;
47
49
  type index_Mapping = Mapping;
48
50
  type index_Rule = Rule;
49
51
  type index_Rules = Rules;
50
52
  type index_Settings = Settings;
51
53
  type index_Types = Types;
52
54
  declare namespace index {
53
- export type { index_Config as Config, index_Destination as Destination, index_Dimensions as Dimensions, index_Env as Env, index_Mapping as Mapping, index_Rule as Rule, index_Rules as Rules, index_Settings as Settings, index_Types as Types };
55
+ export type { index_Config as Config, index_Destination as Destination, index_Dimensions as Dimensions, index_Env as Env, index_InitSettings as InitSettings, index_Mapping as Mapping, index_Rule as Rule, index_Rules as Rules, index_Settings as Settings, index_Types as Types };
54
56
  }
55
57
 
56
58
  declare const destinationPiwikPro: Destination;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/types/index.ts"],"sourcesContent":["import type { Settings, Mapping, Destination } from './types';\nimport type { DestinationWeb } from '@walkeros/web-core';\nimport { getMappingValue, isArray } from '@walkeros/core';\nimport { getEnv } from '@walkeros/web-core';\n\n// Types\nexport * as DestinationPiwikPro from './types';\n\nexport const destinationPiwikPro: Destination = {\n type: 'piwikpro',\n\n config: {},\n\n init({ config, env }) {\n const { window } = getEnv(env);\n const w = window as Window;\n const { settings, loadScript } = config;\n const { appId, url } = settings || {};\n\n // Required parameters\n if (!appId || !url) return false;\n\n // Set up the Piwik Pro interface _paq\n w._paq = w._paq || [];\n\n const paq = w._paq.push;\n if (loadScript) {\n // Load the JavaScript Tracking Client\n addScript(url, env);\n\n // Register the tracker url only with script loading\n paq(['setTrackerUrl', url + 'ppms.php']);\n\n // Register app id\n paq(['setSiteId', appId]);\n }\n\n // Enable download and outlink tracking if not disabled\n if (settings?.linkTracking !== false) paq(['enableLinkTracking']);\n },\n\n async push(event, { config, mapping = {}, data, env }) {\n const { window } = getEnv(env);\n const paq = (window as Window)._paq!.push;\n\n // Send pageviews if not disabled\n if (event.name === 'page view' && !mapping.settings) {\n paq(['trackPageView', await getMappingValue(event, 'data.title')]);\n return;\n }\n\n const eventMapping: Mapping = mapping.settings || {};\n\n const parameters = isArray(data) ? data : [data];\n\n paq([event.name, ...parameters]);\n\n if (eventMapping.goalId) {\n const goalValue = eventMapping.goalValue\n ? getMappingValue(event, eventMapping.goalValue)\n : undefined;\n\n paq([\n 'trackGoal',\n eventMapping.goalId,\n goalValue,\n // @TODO dimensions\n ]);\n }\n },\n};\n\nfunction addScript(url: string, env?: DestinationWeb.Env) {\n const { document } = getEnv(env);\n const doc = document as Document;\n const script = doc.createElement('script');\n script.type = 'text/javascript';\n script.src = url + 'ppms.js';\n script.async = true;\n script.defer = true;\n doc.head.appendChild(script);\n}\n\nexport default destinationPiwikPro;\n","import type {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationWeb } from '@walkeros/web-core';\n\ndeclare global {\n interface Window {\n _paq?: Array<unknown>;\n }\n}\n\nexport interface Settings {\n appId: string;\n linkTracking?: boolean;\n url: string;\n}\n\nexport interface Mapping {\n goalId?: string;\n goalValue?: string;\n}\n\nexport interface Env extends DestinationWeb.Env {\n window: {\n _paq: Array<unknown>;\n };\n document: {\n createElement: (tagName: string) => {\n type: string;\n src: string;\n async?: boolean;\n defer?: boolean;\n };\n head: {\n appendChild: (node: unknown) => void;\n };\n };\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env>;\n\nexport type Destination = DestinationWeb.Destination<Types>;\nexport type Config = DestinationWeb.Config<Types>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C;AAE/B,QAAI,aAAa,QAAQ;AACvB,YAAM,YAAY,aAAa,gBAC3B,6BAAgB,OAAO,aAAa,SAAS,IAC7C;AAEJ,UAAI;AAAA,QACF;AAAA,QACA,aAAa;AAAA,QACb;AAAA;AAAA,MAEF,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEA,SAAS,UAAU,KAAa,KAA0B;AACxD,QAAM,EAAE,SAAS,QAAI,wBAAO,GAAG;AAC/B,QAAM,MAAM;AACZ,QAAM,SAAS,IAAI,cAAc,QAAQ;AACzC,SAAO,OAAO;AACd,SAAO,MAAM,MAAM;AACnB,SAAO,QAAQ;AACf,SAAO,QAAQ;AACf,MAAI,KAAK,YAAY,MAAM;AAC7B;AAEA,IAAO,gBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/types/index.ts"],"sourcesContent":["import type { Settings, Mapping, Destination } from './types';\nimport type { DestinationWeb } from '@walkeros/web-core';\nimport { getMappingValue, isArray } from '@walkeros/core';\nimport { getEnv } from '@walkeros/web-core';\n\n// Types\nexport * as DestinationPiwikPro from './types';\n\nexport const destinationPiwikPro: Destination = {\n type: 'piwikpro',\n\n config: {},\n\n init({ config, env }) {\n const { window } = getEnv(env);\n const w = window as Window;\n const { settings, loadScript } = config;\n const { appId, url } = settings || {};\n\n // Required parameters\n if (!appId || !url) return false;\n\n // Set up the Piwik Pro interface _paq\n w._paq = w._paq || [];\n\n const paq = w._paq.push;\n if (loadScript) {\n // Load the JavaScript Tracking Client\n addScript(url, env);\n\n // Register the tracker url only with script loading\n paq(['setTrackerUrl', url + 'ppms.php']);\n\n // Register app id\n paq(['setSiteId', appId]);\n }\n\n // Enable download and outlink tracking if not disabled\n if (settings?.linkTracking !== false) paq(['enableLinkTracking']);\n },\n\n async push(event, { config, mapping = {}, data, env }) {\n const { window } = getEnv(env);\n const paq = (window as Window)._paq!.push;\n\n // Send pageviews if not disabled\n if (event.name === 'page view' && !mapping.settings) {\n paq(['trackPageView', await getMappingValue(event, 'data.title')]);\n return;\n }\n\n const eventMapping: Mapping = mapping.settings || {};\n\n const parameters = isArray(data) ? data : [data];\n\n paq([event.name, ...parameters]);\n\n if (eventMapping.goalId) {\n const goalValue = eventMapping.goalValue\n ? getMappingValue(event, eventMapping.goalValue)\n : undefined;\n\n paq([\n 'trackGoal',\n eventMapping.goalId,\n goalValue,\n // @TODO dimensions\n ]);\n }\n },\n};\n\nfunction addScript(url: string, env?: DestinationWeb.Env) {\n const { document } = getEnv(env);\n const doc = document as Document;\n const script = doc.createElement('script');\n script.type = 'text/javascript';\n script.src = url + 'ppms.js';\n script.async = true;\n script.defer = true;\n doc.head.appendChild(script);\n}\n\nexport default destinationPiwikPro;\n","import type {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationWeb } from '@walkeros/web-core';\n\ndeclare global {\n interface Window {\n _paq?: Array<unknown>;\n }\n}\n\nexport interface Settings {\n appId: string;\n linkTracking?: boolean;\n url: string;\n}\n\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {\n goalId?: string;\n goalValue?: string;\n}\n\nexport interface Env extends DestinationWeb.Env {\n window: {\n _paq: Array<unknown>;\n };\n document: {\n createElement: (tagName: string) => {\n type: string;\n src: string;\n async?: boolean;\n defer?: boolean;\n };\n head: {\n appendChild: (node: unknown) => void;\n };\n };\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport type Destination = DestinationWeb.Destination<Types>;\nexport type Config = DestinationWeb.Config<Types>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport interface Dimensions {\n [i: number]: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAAyC;AACzC,sBAAuB;;;ACHvB;;;ADQO,IAAM,sBAAmC;AAAA,EAC9C,MAAM;AAAA,EAEN,QAAQ,CAAC;AA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;AACZ,QAAM,SAAS,IAAI,cAAc,QAAQ;AACzC,SAAO,OAAO;AACd,SAAO,MAAM,MAAM;AACnB,SAAO,QAAQ;AACf,SAAO,QAAQ;AACf,MAAI,KAAK,YAAY,MAAM;AAC7B;AAEA,IAAO,gBAAQ;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/types/index.ts"],"sourcesContent":["import type { Settings, Mapping, Destination } from './types';\nimport type { DestinationWeb } from '@walkeros/web-core';\nimport { getMappingValue, isArray } from '@walkeros/core';\nimport { getEnv } from '@walkeros/web-core';\n\n// Types\nexport * as DestinationPiwikPro from './types';\n\nexport const destinationPiwikPro: Destination = {\n type: 'piwikpro',\n\n config: {},\n\n init({ config, env }) {\n const { window } = getEnv(env);\n const w = window as Window;\n const { settings, loadScript } = config;\n const { appId, url } = settings || {};\n\n // Required parameters\n if (!appId || !url) return false;\n\n // Set up the Piwik Pro interface _paq\n w._paq = w._paq || [];\n\n const paq = w._paq.push;\n if (loadScript) {\n // Load the JavaScript Tracking Client\n addScript(url, env);\n\n // Register the tracker url only with script loading\n paq(['setTrackerUrl', url + 'ppms.php']);\n\n // Register app id\n paq(['setSiteId', appId]);\n }\n\n // Enable download and outlink tracking if not disabled\n if (settings?.linkTracking !== false) paq(['enableLinkTracking']);\n },\n\n async push(event, { config, mapping = {}, data, env }) {\n const { window } = getEnv(env);\n const paq = (window as Window)._paq!.push;\n\n // Send pageviews if not disabled\n if (event.name === 'page view' && !mapping.settings) {\n paq(['trackPageView', await getMappingValue(event, 'data.title')]);\n return;\n }\n\n const eventMapping: Mapping = mapping.settings || {};\n\n const parameters = isArray(data) ? data : [data];\n\n paq([event.name, ...parameters]);\n\n if (eventMapping.goalId) {\n const goalValue = eventMapping.goalValue\n ? getMappingValue(event, eventMapping.goalValue)\n : undefined;\n\n paq([\n 'trackGoal',\n eventMapping.goalId,\n goalValue,\n // @TODO dimensions\n ]);\n }\n },\n};\n\nfunction addScript(url: string, env?: DestinationWeb.Env) {\n const { document } = getEnv(env);\n const doc = document as Document;\n const script = doc.createElement('script');\n script.type = 'text/javascript';\n script.src = url + 'ppms.js';\n script.async = true;\n script.defer = true;\n doc.head.appendChild(script);\n}\n\nexport default destinationPiwikPro;\n","import type {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationWeb } from '@walkeros/web-core';\n\ndeclare global {\n interface Window {\n _paq?: Array<unknown>;\n }\n}\n\nexport interface Settings {\n appId: string;\n linkTracking?: boolean;\n url: string;\n}\n\nexport interface Mapping {\n goalId?: string;\n goalValue?: string;\n}\n\nexport interface Env extends DestinationWeb.Env {\n window: {\n _paq: Array<unknown>;\n };\n document: {\n createElement: (tagName: string) => {\n type: string;\n src: string;\n async?: boolean;\n defer?: boolean;\n };\n head: {\n appendChild: (node: unknown) => void;\n };\n };\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env>;\n\nexport type Destination = DestinationWeb.Destination<Types>;\nexport type Config = DestinationWeb.Config<Types>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport interface Dimensions {\n [i: number]: string;\n}\n"],"mappings":";AAEA,SAAS,iBAAiB,eAAe;AACzC,SAAS,cAAc;;;ACHvB;;;ADQO,IAAM,sBAAmC;AAAA,EAC9C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,KAAK,EAAE,QAAQ,IAAI,GAAG;AACpB,UAAM,EAAE,OAAO,IAAI,OAAO,GAAG;AAC7B,UAAM,IAAI;AACV,UAAM,EAAE,UAAU,WAAW,IAAI;AACjC,UAAM,EAAE,OAAO,IAAI,IAAI,YAAY,CAAC;AAGpC,QAAI,CAAC,SAAS,CAAC,IAAK,QAAO;AAG3B,MAAE,OAAO,EAAE,QAAQ,CAAC;AAEpB,UAAM,MAAM,EAAE,KAAK;AACnB,QAAI,YAAY;AAEd,gBAAU,KAAK,GAAG;AAGlB,UAAI,CAAC,iBAAiB,MAAM,UAAU,CAAC;AAGvC,UAAI,CAAC,aAAa,KAAK,CAAC;AAAA,IAC1B;AAGA,SAAI,qCAAU,kBAAiB,MAAO,KAAI,CAAC,oBAAoB,CAAC;AAAA,EAClE;AAAA,EAEA,MAAM,KAAK,OAAO,EAAE,QAAQ,UAAU,CAAC,GAAG,MAAM,IAAI,GAAG;AACrD,UAAM,EAAE,OAAO,IAAI,OAAO,GAAG;AAC7B,UAAM,MAAO,OAAkB,KAAM;AAGrC,QAAI,MAAM,SAAS,eAAe,CAAC,QAAQ,UAAU;AACnD,UAAI,CAAC,iBAAiB,MAAM,gBAAgB,OAAO,YAAY,CAAC,CAAC;AACjE;AAAA,IACF;AAEA,UAAM,eAAwB,QAAQ,YAAY,CAAC;AAEnD,UAAM,aAAa,QAAQ,IAAI,IAAI,OAAO,CAAC,IAAI;AAE/C,QAAI,CAAC,MAAM,MAAM,GAAG,UAAU,CAAC;AAE/B,QAAI,aAAa,QAAQ;AACvB,YAAM,YAAY,aAAa,YAC3B,gBAAgB,OAAO,aAAa,SAAS,IAC7C;AAEJ,UAAI;AAAA,QACF;AAAA,QACA,aAAa;AAAA,QACb;AAAA;AAAA,MAEF,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEA,SAAS,UAAU,KAAa,KAA0B;AACxD,QAAM,EAAE,SAAS,IAAI,OAAO,GAAG;AAC/B,QAAM,MAAM;AACZ,QAAM,SAAS,IAAI,cAAc,QAAQ;AACzC,SAAO,OAAO;AACd,SAAO,MAAM,MAAM;AACnB,SAAO,QAAQ;AACf,SAAO,QAAQ;AACf,MAAI,KAAK,YAAY,MAAM;AAC7B;AAEA,IAAO,gBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/types/index.ts"],"sourcesContent":["import type { Settings, Mapping, Destination } from './types';\nimport type { DestinationWeb } from '@walkeros/web-core';\nimport { getMappingValue, isArray } from '@walkeros/core';\nimport { getEnv } from '@walkeros/web-core';\n\n// Types\nexport * as DestinationPiwikPro from './types';\n\nexport const destinationPiwikPro: Destination = {\n type: 'piwikpro',\n\n config: {},\n\n init({ config, env }) {\n const { window } = getEnv(env);\n const w = window as Window;\n const { settings, loadScript } = config;\n const { appId, url } = settings || {};\n\n // Required parameters\n if (!appId || !url) return false;\n\n // Set up the Piwik Pro interface _paq\n w._paq = w._paq || [];\n\n const paq = w._paq.push;\n if (loadScript) {\n // Load the JavaScript Tracking Client\n addScript(url, env);\n\n // Register the tracker url only with script loading\n paq(['setTrackerUrl', url + 'ppms.php']);\n\n // Register app id\n paq(['setSiteId', appId]);\n }\n\n // Enable download and outlink tracking if not disabled\n if (settings?.linkTracking !== false) paq(['enableLinkTracking']);\n },\n\n async push(event, { config, mapping = {}, data, env }) {\n const { window } = getEnv(env);\n const paq = (window as Window)._paq!.push;\n\n // Send pageviews if not disabled\n if (event.name === 'page view' && !mapping.settings) {\n paq(['trackPageView', await getMappingValue(event, 'data.title')]);\n return;\n }\n\n const eventMapping: Mapping = mapping.settings || {};\n\n const parameters = isArray(data) ? data : [data];\n\n paq([event.name, ...parameters]);\n\n if (eventMapping.goalId) {\n const goalValue = eventMapping.goalValue\n ? getMappingValue(event, eventMapping.goalValue)\n : undefined;\n\n paq([\n 'trackGoal',\n eventMapping.goalId,\n goalValue,\n // @TODO dimensions\n ]);\n }\n },\n};\n\nfunction addScript(url: string, env?: DestinationWeb.Env) {\n const { document } = getEnv(env);\n const doc = document as Document;\n const script = doc.createElement('script');\n script.type = 'text/javascript';\n script.src = url + 'ppms.js';\n script.async = true;\n script.defer = true;\n doc.head.appendChild(script);\n}\n\nexport default destinationPiwikPro;\n","import type {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationWeb } from '@walkeros/web-core';\n\ndeclare global {\n interface Window {\n _paq?: Array<unknown>;\n }\n}\n\nexport interface Settings {\n appId: string;\n linkTracking?: boolean;\n url: string;\n}\n\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {\n goalId?: string;\n goalValue?: string;\n}\n\nexport interface Env extends DestinationWeb.Env {\n window: {\n _paq: Array<unknown>;\n };\n document: {\n createElement: (tagName: string) => {\n type: string;\n src: string;\n async?: boolean;\n defer?: boolean;\n };\n head: {\n appendChild: (node: unknown) => void;\n };\n };\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport type Destination = DestinationWeb.Destination<Types>;\nexport type Config = DestinationWeb.Config<Types>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport interface Dimensions {\n [i: number]: string;\n}\n"],"mappings":";AAEA,SAAS,iBAAiB,eAAe;AACzC,SAAS,cAAc;;;ACHvB;;;ADQO,IAAM,sBAAmC;AAAA,EAC9C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,KAAK,EAAE,QAAQ,IAAI,GAAG;AACpB,UAAM,EAAE,OAAO,IAAI,OAAO,GAAG;AAC7B,UAAM,IAAI;AACV,UAAM,EAAE,UAAU,WAAW,IAAI;AACjC,UAAM,EAAE,OAAO,IAAI,IAAI,YAAY,CAAC;AAGpC,QAAI,CAAC,SAAS,CAAC,IAAK,QAAO;AAG3B,MAAE,OAAO,EAAE,QAAQ,CAAC;AAEpB,UAAM,MAAM,EAAE,KAAK;AACnB,QAAI,YAAY;AAEd,gBAAU,KAAK,GAAG;AAGlB,UAAI,CAAC,iBAAiB,MAAM,UAAU,CAAC;AAGvC,UAAI,CAAC,aAAa,KAAK,CAAC;AAAA,IAC1B;AAGA,SAAI,qCAAU,kBAAiB,MAAO,KAAI,CAAC,oBAAoB,CAAC;AAAA,EAClE;AAAA,EAEA,MAAM,KAAK,OAAO,EAAE,QAAQ,UAAU,CAAC,GAAG,MAAM,IAAI,GAAG;AACrD,UAAM,EAAE,OAAO,IAAI,OAAO,GAAG;AAC7B,UAAM,MAAO,OAAkB,KAAM;AAGrC,QAAI,MAAM,SAAS,eAAe,CAAC,QAAQ,UAAU;AACnD,UAAI,CAAC,iBAAiB,MAAM,gBAAgB,OAAO,YAAY,CAAC,CAAC;AACjE;AAAA,IACF;AAEA,UAAM,eAAwB,QAAQ,YAAY,CAAC;AAEnD,UAAM,aAAa,QAAQ,IAAI,IAAI,OAAO,CAAC,IAAI;AAE/C,QAAI,CAAC,MAAM,MAAM,GAAG,UAAU,CAAC;AAE/B,QAAI,aAAa,QAAQ;AACvB,YAAM,YAAY,aAAa,YAC3B,gBAAgB,OAAO,aAAa,SAAS,IAC7C;AAEJ,UAAI;AAAA,QACF;AAAA,QACA,aAAa;AAAA,QACb;AAAA;AAAA,MAEF,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEA,SAAS,UAAU,KAAa,KAA0B;AACxD,QAAM,EAAE,SAAS,IAAI,OAAO,GAAG;AAC/B,QAAM,MAAM;AACZ,QAAM,SAAS,IAAI,cAAc,QAAQ;AACzC,SAAO,OAAO;AACd,SAAO,MAAM,MAAM;AACnB,SAAO,QAAQ;AACf,SAAO,QAAQ;AACf,MAAI,KAAK,YAAY,MAAM;AAC7B;AAEA,IAAO,gBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@walkeros/web-destination-piwikpro",
3
3
  "description": "Piwik PRO destination for walkerOS",
4
- "version": "0.4.0",
4
+ "version": "0.4.1",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -35,8 +35,8 @@
35
35
  "update": "npx npm-check-updates -u && npm update"
36
36
  },
37
37
  "dependencies": {
38
- "@walkeros/core": "0.4.0",
39
- "@walkeros/web-core": "0.4.0"
38
+ "@walkeros/core": "0.4.1",
39
+ "@walkeros/web-core": "0.4.1"
40
40
  },
41
41
  "devDependencies": {},
42
42
  "repository": {