@pageactions/page-actions-js 0.1.0 → 0.1.1

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/README.md +41 -9
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,37 +1,69 @@
1
1
  # page-actions-js
2
2
 
3
- This is a [Node.js](https://nodejs.org/en) library published in NPM repository. It's intended for any JS browser application regardless of used framework.
3
+ This is a [Node.js](https://nodejs.org/en) library that allows publishing events to PageActions analytics dashboard. It's intended for any JS browser application regardless of used framework.
4
4
 
5
5
  ## Instalation
6
6
 
7
7
  To start with this library just install it as a project dependency.
8
8
 
9
9
  ```bash
10
- npm install @pageactions/pageactions-js
10
+ npm install @pageactions/page-actions-js
11
11
  ```
12
12
 
13
13
  ## How to use
14
14
 
15
- Basiclly by creating `PageActions` object and later calling methods when events occur. First interaction should always be a page view represented by `pageView()` method. You should create only one instance of `PageActions` for a given page/view. If you want to send events from different components, then the same `PageActions` object should be used by these components.
15
+ Basiclly by creating `PageActions` object and later calling functions when events occur. First interaction should always be a page view represented by a `pageView()` function. You should create only one instance of `PageActions` for a given page/view. If you want to send events from different components, then the same `PageActions` object should be used by these components.
16
16
 
17
17
  ### Create PageActions
18
18
 
19
19
  ```ts
20
- const pageActions = new PageActions('your-site-id.com').collector('https://eanlr.net/collector')
20
+ const pageActions = new PageActions('your-site-id.com')
21
+ .collector('https://page-actions.com/collector')
22
+ .accountId('your-account-id')
21
23
  ```
22
24
 
23
25
  The only parameter of constructor is a **siteId**. This is later used in Page Actions Dashboard to distinguish events from different sites.
24
26
 
25
- After creating new object it's mandatory to set a **collector URL** where all events will be sent. You can see your collector URL when you add new site in Page Actions Dashboard.
27
+ After creating new object it's mandatory to set a **collector URL** and **account ID**.
26
28
 
27
- ::: warning
28
- You can't report any interactions when collector URL is not configured
29
- :::
29
+ Collector URL is a place where all your interactions are sent. You can see your collector URL when you add new site in Page Actions Dashboard.
30
+
31
+ Account ID is your unique UUID identifier that you can get from your Account settings or get during new site onboarding.
32
+
33
+ You can't report any interaction when collector URL or account ID is not configured!
30
34
 
31
35
  ### Send page view
32
36
 
33
- This event should be sent every time page is viewed before any user interactions.
37
+ This event should be sent every time page is rendered before any user interactions. It starts a new history of consecutive actions.
38
+
39
+ This function must be called exactly once and should be the first interaction. After a navigation to a different page or a view a new instance of PageActions should created to represent a new page view.
40
+
41
+ It has no parameters and triggers sending an event to the collector service.
34
42
 
35
43
  ```ts
36
44
  pageActions.pageView()
37
45
  ```
46
+
47
+ ### Report action every time
48
+
49
+ The most basic way of reporting an action is by calling interaction() function with action type.
50
+
51
+ ```ts
52
+ pageActions.interaction('button_click')
53
+ ```
54
+
55
+ There is also a second form of this function with second parameter signaling that this is a terminal action. After such action no further events are recorded and sent to the collector. It's usefull to stop recording events then for example form was submitted.
56
+
57
+ ```ts
58
+ pageActions.interaction('form_submit', true)
59
+ ```
60
+
61
+ ### Report action only for the first time
62
+
63
+ Sometimes we only want to know that user started interacting with a form and don't want to now how many times such action occured. In that situation a firstInteraction() function is used.
64
+
65
+ ```ts
66
+ pageActions.firstInteraction('firstname_changed')
67
+ ```
68
+
69
+ This action will be reported at most one time. Every further call with the same action type will be ignored during page visit (same PageActions instance).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pageactions/page-actions-js",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "description": "Vanilla JavaScript PageActions client library",
6
6
  "author": "Page Actions <contact@page-actions.com>",