@adhese/sdk 1.1.0 → 1.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @adhese/sdk
2
2
 
3
+ ## 1.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 180e82a: Fix issue where `mobile` would be passed as a param instead of the required `phone`, which would result in that the server would not return any ads
8
+
3
9
  ## 1.1.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -65,22 +65,22 @@ Example HTML:
65
65
  ## Options
66
66
  The `createAdhese` function accepts the following options:
67
67
 
68
- | Option | Type | Default | Description |
69
- |-----------------------|---------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
70
- | `account`<sup>*</sup> | `string` | - | Your Adhese account ID |
71
- | `host` | `string` | <code>'https://ads-<span v-pre>{{account}}</span>.adhese.com'</code> | The Adhese API host |
72
- | `poolHost` | `string` | <code>'https://pool-<span v-pre>{{account}}</span>.adhese.com'</code> | The Adhese pool host |
73
- | `location` | `string` | `window.location.pathname` | The page location. This is used to determine the current page location identifier. |
74
- | `requestType` | `'GET'` or `'POST'` | `'POST'` | The requestAds type to use for the Adhese API requests. This can be either `GET` or `POST`. `POST` is the default and offers the most options. `GET` is more limited as it needs pass its data as search parameters but can be used in environments where `POST` requests are not allowed. |
75
- | `debug` | `boolean` | `false` | Enable debug mode |
76
- | `findDomSlotsOnLoad` | `boolean` | `false` | Automatically find slots on the page and load them |
77
- | `parameters` | ``Record<string, string, Array<string>>`` | `{}` | Additional parameters to send with each request. Make sure that the keys of a parameter only contain `2` characters. |
78
- | `consent` | `boolean` | `false` | User consent for tracking |
79
- | `initialSlots` | `Array<Slot>` | `[]` | Slots to fetch before the DOM is ready |
80
- | `logReferrer` | `boolean` | `true` | Will log the `document.referrer` to the Adhese API in a `BASE64` string with the `re` parameter. |
81
- | `logUrl` | `boolean` | `true` | Will log the `location.href` to the Adhese API in a `BASE64` string with the `ur` parameter. |'
82
- | `eagerRendering` | `boolean` | `false` | Will render the ad as soon as it is fetched. In general it is recommended to keep this `false` for better performance. |
83
- | `queries` | `Record<string, string>` | `{mobile: '(max-width: 768px) and (pointer: coarse)',tablet: '(min-width: 769px) and (max-width: 1024px) and (pointer: coarse)',desktop: '(min-width: 1025px) and (pointer: fine)',}` | Will be used to determine the device type and screen size. The matching query key will be passed in the `dt` and `br` parameter. |
84
- | `plugins` | `ReadonlyArray<(context: AdheseContext) => void>` | `[]` | The plugins that are used for the Adhese instance. These plugins are called with the Adhese context and run during the initialization of the Adhese instance. |
68
+ | Option | Type | Default | Description |
69
+ |-----------------------|---------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
70
+ | `account`<sup>*</sup> | `string` | - | Your Adhese account ID |
71
+ | `host` | `string` | <code>'https://ads-<span v-pre>{{account}}</span>.adhese.com'</code> | The Adhese API host |
72
+ | `poolHost` | `string` | <code>'https://pool-<span v-pre>{{account}}</span>.adhese.com'</code> | The Adhese pool host |
73
+ | `location` | `string` | `window.location.pathname` | The page location. This is used to determine the current page location identifier. |
74
+ | `requestType` | `'GET'` or `'POST'` | `'POST'` | The requestAds type to use for the Adhese API requests. This can be either `GET` or `POST`. `POST` is the default and offers the most options. `GET` is more limited as it needs pass its data as search parameters but can be used in environments where `POST` requests are not allowed. |
75
+ | `debug` | `boolean` | `false` | Enable debug mode |
76
+ | `findDomSlotsOnLoad` | `boolean` | `false` | Automatically find slots on the page and load them |
77
+ | `parameters` | ``Record<string, string, Array<string>>`` | `{}` | Additional parameters to send with each request. Make sure that the keys of a parameter only contain `2` characters. |
78
+ | `consent` | `boolean` | `false` | User consent for tracking |
79
+ | `initialSlots` | `Array<Slot>` | `[]` | Slots to fetch before the DOM is ready |
80
+ | `logReferrer` | `boolean` | `true` | Will log the `document.referrer` to the Adhese API in a `BASE64` string with the `re` parameter. |
81
+ | `logUrl` | `boolean` | `true` | Will log the `location.href` to the Adhese API in a `BASE64` string with the `ur` parameter. |'
82
+ | `eagerRendering` | `boolean` | `false` | Will render the ad as soon as it is fetched. In general it is recommended to keep this `false` for better performance. |
83
+ | `queries` | `Record<string, string>` | `{phone: '(max-width: 768px) and (pointer: coarse)',tablet: '(min-width: 769px) and (max-width: 1024px) and (pointer: coarse)',desktop: '(min-width: 1025px) and (pointer: fine)',}` | Will be used to determine the device type and screen size. The matching query key will be passed in the `dt` and `br` parameter. |
84
+ | `plugins` | `ReadonlyArray<(context: AdheseContext) => void>` | `[]` | The plugins that are used for the Adhese instance. These plugins are called with the Adhese context and run during the initialization of the Adhese instance. |
85
85
 
86
86
  \* Required
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const name = "@adhese/sdk";
4
- const version = "1.1.0";
4
+ const version = "1.1.1";
5
5
  exports.name = name;
6
6
  exports.version = version;
7
7
  //# sourceMappingURL=package.json.cjs.map
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const sdkShared = require("@adhese/sdk-shared");
4
4
  function useQueryDetector(context, queries = {
5
- mobile: "(max-width: 768px)",
5
+ phone: "(max-width: 768px)",
6
6
  tablet: "(min-width: 769px) and (max-width: 1024px)",
7
7
  desktop: "(min-width: 1025px)"
8
8
  }) {
@@ -1 +1 @@
1
- {"version":3,"file":"queryDetector.cjs","sources":["../../../src/queryDetector/queryDetector.ts"],"sourcesContent":["import { type ComputedRef, computed, debounce, ref } from '@adhese/sdk-shared';\nimport type { AdheseContext } from '@adhese/sdk';\n\n/**\n * Create a query detector that will match a list of media queries and keeps track of the current matching query\n */\nexport function useQueryDetector(context: AdheseContext, queries: Record<string, string> = {\n mobile: '(max-width: 768px)',\n tablet: '(min-width: 769px) and (max-width: 1024px)',\n desktop: '(min-width: 1025px)',\n}): [ComputedRef<string>, () => void] {\n const entries = Object.entries(queries);\n\n const active = ref(getQuery(entries));\n const queryList = entries.map(([, query]) => window.matchMedia(query));\n\n const handleOnChange = debounce((): void => {\n active.value = getQuery(entries);\n }, {\n waitMs: 50,\n });\n\n context.hooks.onInit(() => {\n for (const query of queryList)\n query.addEventListener('change', handleOnChange.call);\n\n handleOnChange.call();\n });\n\n function dispose(): void {\n for (const query of queryList)\n query.removeEventListener('change', handleOnChange.call);\n }\n\n context.hooks.onDispose(dispose);\n\n return [computed(() => active.value), dispose];\n}\n\nfunction getQuery(entries: ReadonlyArray<[string, string]>): string {\n for (const [device, query] of entries) {\n if (window.matchMedia(query).matches)\n return device;\n }\n\n return 'unknown';\n}\n"],"names":["ref","debounce","computed"],"mappings":";;;AAMgB,SAAA,iBAAiB,SAAwB,UAAkC;AAAA,EACzF,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AACX,GAAsC;AAC9B,QAAA,UAAU,OAAO,QAAQ,OAAO;AAEtC,QAAM,SAASA,UAAA,IAAI,SAAS,OAAO,CAAC;AAC9B,QAAA,YAAY,QAAQ,IAAI,CAAC,CAAA,EAAG,KAAK,MAAM,OAAO,WAAW,KAAK,CAAC;AAE/D,QAAA,iBAAiBC,UAAAA,SAAS,MAAY;AACnC,WAAA,QAAQ,SAAS,OAAO;AAAA,EAAA,GAC9B;AAAA,IACD,QAAQ;AAAA,EAAA,CACT;AAEO,UAAA,MAAM,OAAO,MAAM;AACzB,eAAW,SAAS;AACZ,YAAA,iBAAiB,UAAU,eAAe,IAAI;AAEtD,mBAAe,KAAK;AAAA,EAAA,CACrB;AAED,WAAS,UAAgB;AACvB,eAAW,SAAS;AACZ,YAAA,oBAAoB,UAAU,eAAe,IAAI;AAAA,EAC3D;AAEQ,UAAA,MAAM,UAAU,OAAO;AAE/B,SAAO,CAACC,UAAS,SAAA,MAAM,OAAO,KAAK,GAAG,OAAO;AAC/C;AAEA,SAAS,SAAS,SAAkD;AAClE,aAAW,CAAC,QAAQ,KAAK,KAAK,SAAS;AACjC,QAAA,OAAO,WAAW,KAAK,EAAE;AACpB,aAAA;AAAA,EACX;AAEO,SAAA;AACT;;"}
1
+ {"version":3,"file":"queryDetector.cjs","sources":["../../../src/queryDetector/queryDetector.ts"],"sourcesContent":["import { type ComputedRef, computed, debounce, ref } from '@adhese/sdk-shared';\nimport type { AdheseContext } from '@adhese/sdk';\n\n/**\n * Create a query detector that will match a list of media queries and keeps track of the current matching query\n */\nexport function useQueryDetector(context: AdheseContext, queries: Record<string, string> = {\n phone: '(max-width: 768px)',\n tablet: '(min-width: 769px) and (max-width: 1024px)',\n desktop: '(min-width: 1025px)',\n}): [ComputedRef<string>, () => void] {\n const entries = Object.entries(queries);\n\n const active = ref(getQuery(entries));\n const queryList = entries.map(([, query]) => window.matchMedia(query));\n\n const handleOnChange = debounce((): void => {\n active.value = getQuery(entries);\n }, {\n waitMs: 50,\n });\n\n context.hooks.onInit(() => {\n for (const query of queryList)\n query.addEventListener('change', handleOnChange.call);\n\n handleOnChange.call();\n });\n\n function dispose(): void {\n for (const query of queryList)\n query.removeEventListener('change', handleOnChange.call);\n }\n\n context.hooks.onDispose(dispose);\n\n return [computed(() => active.value), dispose];\n}\n\nfunction getQuery(entries: ReadonlyArray<[string, string]>): string {\n for (const [device, query] of entries) {\n if (window.matchMedia(query).matches)\n return device;\n }\n\n return 'unknown';\n}\n"],"names":["ref","debounce","computed"],"mappings":";;;AAMgB,SAAA,iBAAiB,SAAwB,UAAkC;AAAA,EACzF,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AACX,GAAsC;AAC9B,QAAA,UAAU,OAAO,QAAQ,OAAO;AAEtC,QAAM,SAASA,UAAA,IAAI,SAAS,OAAO,CAAC;AAC9B,QAAA,YAAY,QAAQ,IAAI,CAAC,CAAA,EAAG,KAAK,MAAM,OAAO,WAAW,KAAK,CAAC;AAE/D,QAAA,iBAAiBC,UAAAA,SAAS,MAAY;AACnC,WAAA,QAAQ,SAAS,OAAO;AAAA,EAAA,GAC9B;AAAA,IACD,QAAQ;AAAA,EAAA,CACT;AAEO,UAAA,MAAM,OAAO,MAAM;AACzB,eAAW,SAAS;AACZ,YAAA,iBAAiB,UAAU,eAAe,IAAI;AAEtD,mBAAe,KAAK;AAAA,EAAA,CACrB;AAED,WAAS,UAAgB;AACvB,eAAW,SAAS;AACZ,YAAA,oBAAoB,UAAU,eAAe,IAAI;AAAA,EAC3D;AAEQ,UAAA,MAAM,UAAU,OAAO;AAE/B,SAAO,CAACC,UAAS,SAAA,MAAM,OAAO,KAAK,GAAG,OAAO;AAC/C;AAEA,SAAS,SAAS,SAAkD;AAClE,aAAW,CAAC,QAAQ,KAAK,KAAK,SAAS;AACjC,QAAA,OAAO,WAAW,KAAK,EAAE;AACpB,aAAA;AAAA,EACX;AAEO,SAAA;AACT;;"}
@@ -1,5 +1,5 @@
1
1
  const name = "@adhese/sdk";
2
- const version = "1.1.0";
2
+ const version = "1.1.1";
3
3
  export {
4
4
  name,
5
5
  version
@@ -1,6 +1,6 @@
1
1
  import { ref, debounce, computed } from "@adhese/sdk-shared";
2
2
  function useQueryDetector(context, queries = {
3
- mobile: "(max-width: 768px)",
3
+ phone: "(max-width: 768px)",
4
4
  tablet: "(min-width: 769px) and (max-width: 1024px)",
5
5
  desktop: "(min-width: 1025px)"
6
6
  }) {
@@ -1 +1 @@
1
- {"version":3,"file":"queryDetector.js","sources":["../../src/queryDetector/queryDetector.ts"],"sourcesContent":["import { type ComputedRef, computed, debounce, ref } from '@adhese/sdk-shared';\nimport type { AdheseContext } from '@adhese/sdk';\n\n/**\n * Create a query detector that will match a list of media queries and keeps track of the current matching query\n */\nexport function useQueryDetector(context: AdheseContext, queries: Record<string, string> = {\n mobile: '(max-width: 768px)',\n tablet: '(min-width: 769px) and (max-width: 1024px)',\n desktop: '(min-width: 1025px)',\n}): [ComputedRef<string>, () => void] {\n const entries = Object.entries(queries);\n\n const active = ref(getQuery(entries));\n const queryList = entries.map(([, query]) => window.matchMedia(query));\n\n const handleOnChange = debounce((): void => {\n active.value = getQuery(entries);\n }, {\n waitMs: 50,\n });\n\n context.hooks.onInit(() => {\n for (const query of queryList)\n query.addEventListener('change', handleOnChange.call);\n\n handleOnChange.call();\n });\n\n function dispose(): void {\n for (const query of queryList)\n query.removeEventListener('change', handleOnChange.call);\n }\n\n context.hooks.onDispose(dispose);\n\n return [computed(() => active.value), dispose];\n}\n\nfunction getQuery(entries: ReadonlyArray<[string, string]>): string {\n for (const [device, query] of entries) {\n if (window.matchMedia(query).matches)\n return device;\n }\n\n return 'unknown';\n}\n"],"names":[],"mappings":";AAMgB,SAAA,iBAAiB,SAAwB,UAAkC;AAAA,EACzF,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AACX,GAAsC;AAC9B,QAAA,UAAU,OAAO,QAAQ,OAAO;AAEtC,QAAM,SAAS,IAAI,SAAS,OAAO,CAAC;AAC9B,QAAA,YAAY,QAAQ,IAAI,CAAC,CAAA,EAAG,KAAK,MAAM,OAAO,WAAW,KAAK,CAAC;AAE/D,QAAA,iBAAiB,SAAS,MAAY;AACnC,WAAA,QAAQ,SAAS,OAAO;AAAA,EAAA,GAC9B;AAAA,IACD,QAAQ;AAAA,EAAA,CACT;AAEO,UAAA,MAAM,OAAO,MAAM;AACzB,eAAW,SAAS;AACZ,YAAA,iBAAiB,UAAU,eAAe,IAAI;AAEtD,mBAAe,KAAK;AAAA,EAAA,CACrB;AAED,WAAS,UAAgB;AACvB,eAAW,SAAS;AACZ,YAAA,oBAAoB,UAAU,eAAe,IAAI;AAAA,EAC3D;AAEQ,UAAA,MAAM,UAAU,OAAO;AAE/B,SAAO,CAAC,SAAS,MAAM,OAAO,KAAK,GAAG,OAAO;AAC/C;AAEA,SAAS,SAAS,SAAkD;AAClE,aAAW,CAAC,QAAQ,KAAK,KAAK,SAAS;AACjC,QAAA,OAAO,WAAW,KAAK,EAAE;AACpB,aAAA;AAAA,EACX;AAEO,SAAA;AACT;"}
1
+ {"version":3,"file":"queryDetector.js","sources":["../../src/queryDetector/queryDetector.ts"],"sourcesContent":["import { type ComputedRef, computed, debounce, ref } from '@adhese/sdk-shared';\nimport type { AdheseContext } from '@adhese/sdk';\n\n/**\n * Create a query detector that will match a list of media queries and keeps track of the current matching query\n */\nexport function useQueryDetector(context: AdheseContext, queries: Record<string, string> = {\n phone: '(max-width: 768px)',\n tablet: '(min-width: 769px) and (max-width: 1024px)',\n desktop: '(min-width: 1025px)',\n}): [ComputedRef<string>, () => void] {\n const entries = Object.entries(queries);\n\n const active = ref(getQuery(entries));\n const queryList = entries.map(([, query]) => window.matchMedia(query));\n\n const handleOnChange = debounce((): void => {\n active.value = getQuery(entries);\n }, {\n waitMs: 50,\n });\n\n context.hooks.onInit(() => {\n for (const query of queryList)\n query.addEventListener('change', handleOnChange.call);\n\n handleOnChange.call();\n });\n\n function dispose(): void {\n for (const query of queryList)\n query.removeEventListener('change', handleOnChange.call);\n }\n\n context.hooks.onDispose(dispose);\n\n return [computed(() => active.value), dispose];\n}\n\nfunction getQuery(entries: ReadonlyArray<[string, string]>): string {\n for (const [device, query] of entries) {\n if (window.matchMedia(query).matches)\n return device;\n }\n\n return 'unknown';\n}\n"],"names":[],"mappings":";AAMgB,SAAA,iBAAiB,SAAwB,UAAkC;AAAA,EACzF,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AACX,GAAsC;AAC9B,QAAA,UAAU,OAAO,QAAQ,OAAO;AAEtC,QAAM,SAAS,IAAI,SAAS,OAAO,CAAC;AAC9B,QAAA,YAAY,QAAQ,IAAI,CAAC,CAAA,EAAG,KAAK,MAAM,OAAO,WAAW,KAAK,CAAC;AAE/D,QAAA,iBAAiB,SAAS,MAAY;AACnC,WAAA,QAAQ,SAAS,OAAO;AAAA,EAAA,GAC9B;AAAA,IACD,QAAQ;AAAA,EAAA,CACT;AAEO,UAAA,MAAM,OAAO,MAAM;AACzB,eAAW,SAAS;AACZ,YAAA,iBAAiB,UAAU,eAAe,IAAI;AAEtD,mBAAe,KAAK;AAAA,EAAA,CACrB;AAED,WAAS,UAAgB;AACvB,eAAW,SAAS;AACZ,YAAA,oBAAoB,UAAU,eAAe,IAAI;AAAA,EAC3D;AAEQ,UAAA,MAAM,UAAU,OAAO;AAE/B,SAAO,CAAC,SAAS,MAAM,OAAO,KAAK,GAAG,OAAO;AAC/C;AAEA,SAAS,SAAS,SAAkD;AAClE,aAAW,CAAC,QAAQ,KAAK,KAAK,SAAS;AACjC,QAAA,OAAO,WAAW,KAAK,EAAE;AACpB,aAAA;AAAA,EACX;AAEO,SAAA;AACT;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adhese/sdk",
3
3
  "type": "module",
4
- "version": "1.1.0",
4
+ "version": "1.1.1",
5
5
  "description": "Adhese SDK",
6
6
  "license": "GPL-3.0",
7
7
  "repository": {