@sesamy/sesamy-js 1.3.3 → 1.3.4
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 +69 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# sesamy-js
|
|
2
|
+
|
|
3
|
+
The Sesamy browser javascript API
|
|
4
|
+
|
|
5
|
+
The project handles analytics, authentication and communication with the Seasmy API
|
|
6
|
+
|
|
7
|
+
## Analytics
|
|
8
|
+
|
|
9
|
+
The analytics module is used to track events and page views. It is using the [GetAnalytics](https://getanalytics.io/) library to send events to the Sesamy interaction endpoint.
|
|
10
|
+
|
|
11
|
+
The following events are tracked:
|
|
12
|
+
|
|
13
|
+
- Page views, with events triggered on router updates
|
|
14
|
+
|
|
15
|
+
## API
|
|
16
|
+
|
|
17
|
+
The following methods are available on the `sesamy` object:
|
|
18
|
+
|
|
19
|
+
- init - Initializes the sesamy-js library
|
|
20
|
+
- auth
|
|
21
|
+
- getUser: fetches the user's profile
|
|
22
|
+
- isAuthenticated: checks if the user is authenticated
|
|
23
|
+
- loginWithRedirect: redirects the user to the login page
|
|
24
|
+
- logout: logs the user out
|
|
25
|
+
- entitlements
|
|
26
|
+
- get: fetches a single entitlement by id
|
|
27
|
+
- list - fetches the user's entitlements
|
|
28
|
+
- profile
|
|
29
|
+
- get: fetches the user's profile
|
|
30
|
+
- update: updates the user's profile
|
|
31
|
+
- tags
|
|
32
|
+
- get: fetches the user's tags
|
|
33
|
+
- set: sets a tag for the user
|
|
34
|
+
- push: pushes a tag to a tag list
|
|
35
|
+
- getVersion: returns the version of the sesamy-js library
|
|
36
|
+
|
|
37
|
+
## Events
|
|
38
|
+
|
|
39
|
+
The following events are emitted by the sesamy-js library:
|
|
40
|
+
|
|
41
|
+
- `sesamyReady` - Emitted when the `sesamy-js` library is ready to be used
|
|
42
|
+
- `sesamyAuthenticated` - Emitted when the user is authenticated
|
|
43
|
+
|
|
44
|
+
## Usage
|
|
45
|
+
|
|
46
|
+
The script can either be initiated with a JSON object in a script tag or by calling the init method.
|
|
47
|
+
|
|
48
|
+
The script will look for a script tag with the id `sesamy-js`, and if it isn't found it will wait for a call to the init function before initializing. The only required part is the `clientId` attribute.
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<script type="application/json" id="sesamy-js">
|
|
52
|
+
{
|
|
53
|
+
"clientId": "demo"
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
These are the available configuration options, with their default values:
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
{
|
|
62
|
+
clientId: null,
|
|
63
|
+
namespace: 'sesamy',
|
|
64
|
+
analytics: {
|
|
65
|
+
enabled: true,
|
|
66
|
+
endpoint: 'https://logs.sesamy.com/events'
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"registry": "https://registry.npmjs.org/",
|
|
7
7
|
"tag": "latest"
|
|
8
8
|
},
|
|
9
|
-
"version": "1.3.
|
|
9
|
+
"version": "1.3.4",
|
|
10
10
|
"main": "./dist/sesamy-js.cjs",
|
|
11
11
|
"module": "./dist/sesamy-js.mjs",
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"scripts": {
|
|
24
24
|
"dev": "vite",
|
|
25
25
|
"build": "rimraf build/**/* && tsc && vite build --config vite.dev.config.ts",
|
|
26
|
-
"build:prod": "rimraf build/**/* && tsc && vite build && dts-bundle-generator --config ./dts-bundle-generator.config.ts && copyfiles ./package.json build",
|
|
26
|
+
"build:prod": "rimraf build/**/* && tsc && vite build && dts-bundle-generator --config ./dts-bundle-generator.config.ts && copyfiles ./package.json build && copyfiles ./README.md build",
|
|
27
27
|
"preview": "vite preview",
|
|
28
28
|
"type-check": "tsc",
|
|
29
29
|
"semantic-release": "semantic-release",
|