highseat 0.0.1 → 0.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 +12 -2
- package/index.d.ts +9 -0
- package/index.js +15 -1
- package/package.json +11 -4
package/README.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Highseat
|
|
2
2
|
|
|
3
|
-
Privacy-first web analytics.
|
|
3
|
+
Privacy-first, cookieless web analytics.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { snippet } from "highseat"
|
|
9
|
+
|
|
10
|
+
const tag = snippet({ site: "site_123", src: "https://example.com/script.js" })
|
|
11
|
+
// <script defer src="https://example.com/script.js" data-site="site_123"></script>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`snippet` returns the script tag that installs the tracker. Paste it into the `<head>` of every page.
|
|
15
|
+
More of the SDK lands in later versions.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface SnippetOptions {
|
|
2
|
+
/** The public site id, as shown in the dashboard. */
|
|
3
|
+
site: string
|
|
4
|
+
/** The URL the tracker script is served from. */
|
|
5
|
+
src: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** Returns the script tag that installs the Highseat tracker on a page. */
|
|
9
|
+
export function snippet(options: SnippetOptions): string
|
package/index.js
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
const ATTRIBUTE_ESCAPES = { "&": "&", '"': """, "<": "<", ">": ">" }
|
|
2
|
+
|
|
3
|
+
function escapeAttribute(value) {
|
|
4
|
+
return String(value).replace(/[&"<>]/g, character => ATTRIBUTE_ESCAPES[character])
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Returns the script tag that installs the Highseat tracker on a page.
|
|
9
|
+
*/
|
|
10
|
+
export function snippet({ site, src }) {
|
|
11
|
+
if (!site) throw new TypeError("snippet: `site` is required")
|
|
12
|
+
if (!src) throw new TypeError("snippet: `src` is required")
|
|
13
|
+
|
|
14
|
+
return `<script defer src="${escapeAttribute(src)}" data-site="${escapeAttribute(site)}"></script>`
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "highseat",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Highseat: privacy-first web analytics.
|
|
5
|
-
"keywords": ["analytics", "privacy", "web-analytics"],
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Highseat: privacy-first web analytics. Helpers for installing the tracker.",
|
|
5
|
+
"keywords": ["analytics", "privacy", "web-analytics", "cookieless"],
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Piotr Kulpinski",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "index.js",
|
|
10
|
-
"
|
|
10
|
+
"types": "index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./index.d.ts",
|
|
14
|
+
"default": "./index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": ["index.js", "index.d.ts", "README.md"],
|
|
11
18
|
"repository": {
|
|
12
19
|
"type": "git",
|
|
13
20
|
"url": "https://github.com/highseat"
|