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 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
 
@@ -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 t=document.createElement("script");t.type="text/javascript",t.async=!0,t.src="https://app.usercase.io/plugin/1.0.1/eb-plugin-web.js";const n=document.getElementsByTagName("head")[0];n&&n.appendChild(t)}};module.exports=e;
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;
@@ -1,10 +1,18 @@
1
- interface EarningbirdsOptions {
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 Earningbirds {
6
- init(options: EarningbirdsOptions): void;
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 Earningbirds: Earningbirds;
10
- export default Earningbirds;
17
+ declare const Usercase: Usercase;
18
+ export default Usercase;
@@ -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 t=document.createElement("script");t.type="text/javascript",t.async=!0,t.src="https://app.usercase.io/plugin/1.0.1/eb-plugin-web.js";const n=document.getElementsByTagName("head")[0];n&&n.appendChild(t)}};export{e as default};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "usercase",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Usercase web plugin for user research",
5
5
  "main": "dist/npm/index.cjs",
6
6
  "module": "dist/npm/index.mjs",