You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* geenrate the session on the client via crypto.randomUUID
* update readme
* set the session before dispatching an event to ensure Hellotext.session returns the same value
* update form_controller
* add jest config files
* add dedicated session model and move initialization code there
* update code
* add jsdoc for Response class
* add jsdoc for Response class
* update dist
* 1.8.3
Copy file name to clipboardexpand all lines: README.md
+10-3
Original file line number
Diff line number
Diff line change
@@ -85,11 +85,18 @@ Short links redirections attaches a session identifier to the destination url as
85
85
86
86
### Get session
87
87
88
-
It is possible to obtain the current session by simply calling `Hellotext.session`.
88
+
It is possible to obtain the current session by simply calling `Hellotext.session`. When the session is present in the cookies,
89
+
the value stored in the cookies is returned. Otherwise, a new session is generated via [crypto.randomUUID()](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID).
90
+
The session is kept in the client and not sent to Hellotext's servers until an event is tracked.
91
+
92
+
An event is tracked in the following cases
93
+
94
+
- Explicitly calling `Hellotext.track` method.
95
+
- When a form is submitted and the form data is sent to Hellotext.
89
96
90
97
```javascript
91
-
awaitHellotext.session
92
-
// Returns bBJn9vR15yPaYkWmR2QK0jopMeNxrA6l
98
+
Hellotext.session
99
+
// Returns da834c54-97fa-44ef-bafd-2bd4fec60636
93
100
```
94
101
95
102
If the session has not been set yet, the result returned will be `undefined`.
function_toPrimitive(input,hint){if(typeofinput!=="object"||input===null)returninput;varprim=input[Symbol.toPrimitive];if(prim!==undefined){varres=prim.call(input,hint||"default");if(typeofres!=="object")returnres;thrownewTypeError("@@toPrimitive must return a primitive value.");}return(hint==="string" ? String : Number)(input);}
14
+
function_classPrivateFieldLooseBase(receiver,privateKey){if(!Object.prototype.hasOwnProperty.call(receiver,privateKey)){thrownewTypeError("attempted to use private field on non-instance");}returnreceiver;}
0 commit comments