usercase 1.0.1 → 1.0.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.
- package/README.md +36 -0
- package/dist/npm/index.cjs +1 -1
- package/dist/npm/index.d.ts +13 -5
- package/dist/npm/index.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -118,6 +118,42 @@ onMounted(() => {
|
|
|
118
118
|
| Option | Type | Required | Description |
|
|
119
119
|
|--------|------|----------|-------------|
|
|
120
120
|
| `project` | `string` | Yes | Your Usercase project ID |
|
|
121
|
+
| `requireConsent` | `boolean` | No | Wait for `Usercase.consent(true)` before starting. See [Consent](#consent). |
|
|
122
|
+
|
|
123
|
+
### `Usercase.consent(granted)`
|
|
124
|
+
|
|
125
|
+
Tell Usercase whether the visitor agreed to it. Call it from your consent banner (CMP) on every page load.
|
|
126
|
+
|
|
127
|
+
- `Usercase.consent(true)` starts Usercase if it is waiting for consent.
|
|
128
|
+
- `Usercase.consent(false)` stops Usercase on this page and removes its cookies (`eb_sid_*`, `eb_mic_label`) and browser storage (`Usercase*` keys). Your site's own cookies and storage are not touched.
|
|
129
|
+
|
|
130
|
+
Consent is not remembered by Usercase. Your consent banner remembers it and calls `consent()` again on each page.
|
|
131
|
+
|
|
132
|
+
## Consent
|
|
133
|
+
|
|
134
|
+
By default, Usercase starts as soon as the script loads. If your visitors must agree first (for example, visitors from the EU, UK, or Switzerland), turn on `requireConsent`. Until `Usercase.consent(true)` is called, Usercase does not load, set cookies, write to browser storage, or collect anything.
|
|
135
|
+
|
|
136
|
+
### Script Tag
|
|
137
|
+
|
|
138
|
+
Add these two lines to the install code, after `w.Usercase.project`:
|
|
139
|
+
|
|
140
|
+
```js
|
|
141
|
+
w.Usercase.requireConsent = true;
|
|
142
|
+
w.Usercase.consent = w.Usercase.consent || function (g) { w.Usercase.consented = g !== false; };
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Then call `window.Usercase.consent(true)` or `window.Usercase.consent(false)` from your consent banner. It is safe to call before the Usercase script has finished loading.
|
|
146
|
+
|
|
147
|
+
### npm
|
|
148
|
+
|
|
149
|
+
```js
|
|
150
|
+
import Usercase from 'usercase';
|
|
151
|
+
|
|
152
|
+
Usercase.init({ project: 'YOUR_PROJECT_ID', requireConsent: true });
|
|
153
|
+
|
|
154
|
+
// in your consent banner callback
|
|
155
|
+
Usercase.consent(true); // or Usercase.consent(false)
|
|
156
|
+
```
|
|
121
157
|
|
|
122
158
|
## License
|
|
123
159
|
|
package/dist/npm/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e={init(e){if("undefined"==typeof window)return void console.warn("Usercase: this package only works in the browser.");const s=window;if(s.Usercase=s.Usercase||{},s.Usercase.project=e.project,s.UsercaseInitialized)return;s.UsercaseInitialized=!0;const
|
|
1
|
+
"use strict";const e={init(e){if("undefined"==typeof window)return void console.warn("Usercase: this package only works in the browser.");const s=window;if(s.Usercase=s.Usercase||{},s.Usercase.project=e.project,e.requireConsent&&(s.Usercase.requireConsent=!0),s.UsercaseInitialized)return;s.UsercaseInitialized=!0;const n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src="https://app.usercase.io/plugin/1.0.1/eb-plugin-web.js";const t=document.getElementsByTagName("head")[0];t&&t.appendChild(n)},consent(e=!0){if("undefined"==typeof window)return;const s=window;s.Usercase=s.Usercase||{},"function"==typeof s.Usercase.consent?s.Usercase.consent(e):s.Usercase.consented=!1!==e}};module.exports=e;
|
package/dist/npm/index.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
interface
|
|
1
|
+
interface UsercaseOptions {
|
|
2
|
+
/** Your Usercase project ID */
|
|
2
3
|
project: string;
|
|
4
|
+
/** Wait for `Usercase.consent(true)` before starting. No cookies, storage, or collection until then. */
|
|
5
|
+
requireConsent?: boolean;
|
|
3
6
|
}
|
|
4
7
|
|
|
5
|
-
interface
|
|
6
|
-
init(options:
|
|
8
|
+
interface Usercase {
|
|
9
|
+
init(options: UsercaseOptions): void;
|
|
10
|
+
/**
|
|
11
|
+
* Tell Usercase whether the visitor agreed. Call it from your consent banner on every page load.
|
|
12
|
+
* `true` starts Usercase; `false` stops it and removes its cookies and browser storage.
|
|
13
|
+
*/
|
|
14
|
+
consent(granted?: boolean): void;
|
|
7
15
|
}
|
|
8
16
|
|
|
9
|
-
declare const
|
|
10
|
-
export default
|
|
17
|
+
declare const Usercase: Usercase;
|
|
18
|
+
export default Usercase;
|
package/dist/npm/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e={init(e){if("undefined"==typeof window)return void console.warn("Usercase: this package only works in the browser.");const s=window;if(s.Usercase=s.Usercase||{},s.Usercase.project=e.project,s.UsercaseInitialized)return;s.UsercaseInitialized=!0;const
|
|
1
|
+
const e={init(e){if("undefined"==typeof window)return void console.warn("Usercase: this package only works in the browser.");const s=window;if(s.Usercase=s.Usercase||{},s.Usercase.project=e.project,e.requireConsent&&(s.Usercase.requireConsent=!0),s.UsercaseInitialized)return;s.UsercaseInitialized=!0;const n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src="https://app.usercase.io/plugin/1.0.1/eb-plugin-web.js";const t=document.getElementsByTagName("head")[0];t&&t.appendChild(n)},consent(e=!0){if("undefined"==typeof window)return;const s=window;s.Usercase=s.Usercase||{},"function"==typeof s.Usercase.consent?s.Usercase.consent(e):s.Usercase.consented=!1!==e}};export{e as default};
|