@tugitark/react-widget 1.5.3 → 1.5.5

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.
Files changed (2) hide show
  1. package/index.md +23 -12
  2. package/package.json +2 -2
package/index.md CHANGED
@@ -8,31 +8,42 @@ Also see [the original integration guide](https://www.tugitark.com/chat-setup) f
8
8
  Minimal Example
9
9
  -----------------
10
10
 
11
- This is the smallest number of properties that you can pass to `<TugiWidget>` and have it still operate correctly. These properties are given to you on signing up with Tugi Tark and must be entered accurately.
11
+ To use the Tugi Tark widget on your page, simply call the exported default component. With no parameters given the code will try its upmost to determine the current player and brand, falling back to unauthenticated users when it can't (which will require them to verify their e-mail address and will not provide their profile to the AI Agent).
12
12
 
13
13
  ```react
14
14
  import TugiWidget from '@tugitark/react-widget';
15
15
 
16
- function Component(props) {
16
+ function Component() {
17
17
  return (
18
- <TugiWidget
19
- user={props.userId}
20
- brandId="a040050697fc4b2db16acfbbad1d0da4"
21
- brandName="Super Casino"
22
- tenantId="gb-casinos-ltd"
23
- />
18
+ <TugiWidget />
24
19
  );
25
20
  }
26
21
  ```
27
22
 
28
- If your server has the standard `/.tugi` endpoints (as provided by our back-end libraries and documented in our [developer documentation](https://gitlab.com/tugitark/integration/docs)) this is enough to get started with the Tugi Widget. The `brandId`, `brandName`, and `tenantId` will be provided by us based on details provided by you when signing up with our system. They are not secret, so can safely appear in client-side code, but are case-sensitive so must remain exactly as specified by us.
23
+ If your server has the standard `/.tugi` endpoints (as provided by our back-end libraries and documented in our [developer documentation](https://gitlab.com/tugitark/integration/docs)) this is enough to get started with the Tugi Widget. The `/.tugi/jwt/issue` endpoint will be called with no ID given, and if that can return the data for the current player (e.g. from the HTTP session) this is enough. Alternatively you can pass an ID explicitly:
24
+
25
+ ```react
26
+ import TugiWidget from '@tugitark/react-widget';
27
+
28
+ interface Props {
29
+ userId: string;
30
+ }
31
+
32
+ function Component(props: Props) {
33
+ return (
34
+ <TugiWidget user={props.userId} />
35
+ );
36
+ }
37
+ ```
29
38
 
30
39
  `user` is the ID within your system of the current player. How you determine the current player's unique ID depends entirely on your system and is left as a provided parameter here. This is the ID that the widget will internally pass to the `/.tugi/jwt/issue` endpoint to retrieve the player's profile, and so must in some way identify an end-user on your server.
31
40
 
41
+ Calls to `<TugiWidget />` are idempotent, if the parameter objects are equivalent. The library will perform deep value comparisons between the parameters of two calls and only act on those that have changed.
42
+
32
43
  Custom Example
33
44
  ----------------
34
45
 
35
- This is a more extensive widget example, with colour-scheme customisation and an explicit JWT lookup function. The HTTP and websocket addresses are also specified, though match the defaults.
46
+ This is a more extensive widget example, with colour-scheme customisation and an explicit JWT lookup function. The HTTP and websocket addresses are also specified, though match the defaults. The `brandId`, `brandName`, and `tenantId` will be provided by us based on details provided by you when signing up with our system. They are not secret, so can safely appear in client-side code, but are case-sensitive so must remain exactly as specified by us. When not specified (as in the previous example) they are retrieved from the `/.tugi/config` endpoint - either a custom version or one served by the `Tugi Players` library.
36
47
 
37
48
  ```react
38
49
  import TugiWidget from '@tugitark/react-widget';
@@ -78,7 +89,7 @@ function Component(props: Props) {
78
89
 
79
90
  The full list of properties that can be passed to the `<TugiWidget>` component are:
80
91
 
81
- * `user` Optional. When given will be used to look up a player's data from the server. You can disable this automatic lookup by passing a custom `jwtFn` or by not passing the `user` parameter. However, if you specify neither `user` nor `jwtFn` then the player will not be able to send any messages to Tugi Tark and you will get the free version of the widget instead (see below).
92
+ * `user` Optional. When given will be used to look up a player's data from the server. You can disable this automatic lookup by passing a custom `jwtFn` or by not passing the `user` parameter. If you specify neither `user` nor `jwtFn` then the player will get the unauthenticated version of the widget, or the free version (FAQ only) with a few extra parameters (see below).
82
93
  * `jwtFn` Optional. A function to override the default method for retrieving a player's data (via JWT). While this and `user` are both optional, one of them must be specified.
83
94
  * `brandId` Required. The ID of your brand, as provided by Tugi Tark.
84
95
  * `brandName` Required. The name of your brand, as provided by you initially.
@@ -106,7 +117,7 @@ A "proactive" message can be used to detect that a player has a problem and offe
106
117
  Free Version
107
118
  --------------
108
119
 
109
- If both `tugiFn` and `user` are missing from the `<TugiWidget>` properties then the widget goes in to the special free mode (more accurately, both must be `null` or `undefined` - if you want a user who isn't logged in pass a `user` of `''`). In this mode the user cannot send or receive any messages, they can only view a few pre-defined FAQ-style help topics:
120
+ If both `tugiFn` and `user` are missing from the `<TugiWidget>` properties AND one of the free-mode-only properties are given then the widget goes in to the special free mode. In this mode the user cannot send or receive any messages, they can only view a few pre-defined FAQ-style help topics:
110
121
 
111
122
  ```react
112
123
  import TugiWidget from '@tugitark/react-widget';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tugitark/react-widget",
3
- "version": "1.5.3",
3
+ "version": "1.5.5",
4
4
  "description": "Wraps the tugitark widget in a React component.",
5
5
  "scripts": {
6
6
  "build": "npx esbuild index.ts --target=es6 --outfile=index.js && sed -i 's/\\bconst\\b/var/g' index.js && sed -i 's/\\blet\\b/var/g' index.js && npx esbuild index.js --allow-overwrite --minify --target=es5 --outfile=index.js && npx tsc --noErrorTruncation --declaration --emitDeclarationOnly --target es6 --module nodenext --moduleResolution nodenext --outDir . index.ts"
@@ -12,7 +12,7 @@
12
12
  "index.md"
13
13
  ],
14
14
  "dependencies": {
15
- "@tugitark/declarative-widget": "^1.3.3"
15
+ "@tugitark/declarative-widget": "^1.3.5"
16
16
  },
17
17
  "peerDependencies": {
18
18
  "react": ">=0.0.0"