@patientprism/snippet-sdk 1.0.0 → 1.0.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.
- package/README.md +32 -1
- package/package.json +1 -1
- package/types/index.d.ts +20 -3
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Patient Prism SDK
|
|
1
|
+
# Patient Prism Snippet SDK
|
|
2
2
|
This package includes the Patient Prism Snippet SDK typings, used to assist you with integrating the Patient Prism Snippet into your custom application flow.
|
|
3
3
|
|
|
4
4
|
# How to use
|
|
@@ -16,3 +16,34 @@ const data: Submission = {
|
|
|
16
16
|
|
|
17
17
|
(window.$prism as PrismSDK).submission.send(data, 'elementId');
|
|
18
18
|
```
|
|
19
|
+
|
|
20
|
+
# Form Tracking Control
|
|
21
|
+
You can control which forms and fields are tracked by the snippet using data attributes:
|
|
22
|
+
|
|
23
|
+
- `data-prism-exclude-form`: Add this attribute to any form element to exclude the entire form from tracking
|
|
24
|
+
- `data-prism-exclude-input`: Add this attribute to any input element to exclude just that specific field from tracking
|
|
25
|
+
- `data-prism-field-label`: Add this attribute to any input element to override the label used for tracking
|
|
26
|
+
|
|
27
|
+
Example:
|
|
28
|
+
```html
|
|
29
|
+
<!-- This form will be tracked, but the password field will be excluded -->
|
|
30
|
+
<form id="signup-form">
|
|
31
|
+
<input type="text" name="email" placeholder="Email">
|
|
32
|
+
<input type="password" name="password" data-prism-exclude-input placeholder="Password">
|
|
33
|
+
<button type="submit">Sign Up</button>
|
|
34
|
+
</form>
|
|
35
|
+
|
|
36
|
+
<!-- This entire form will be excluded from tracking -->
|
|
37
|
+
<form id="login-form" data-prism-exclude-form>
|
|
38
|
+
<input type="text" name="username" placeholder="Username">
|
|
39
|
+
<input type="password" name="password" placeholder="Password">
|
|
40
|
+
<button type="submit">Login</button>
|
|
41
|
+
</form>
|
|
42
|
+
|
|
43
|
+
<!-- Override field labels for tracking -->
|
|
44
|
+
<form id="contact-form">
|
|
45
|
+
<input type="text" name="name" data-prism-field-label="Patient Name" placeholder="Your Name">
|
|
46
|
+
<input type="email" name="email" data-prism-field-label="Patient Email" placeholder="Your Email">
|
|
47
|
+
<button type="submit">Submit</button>
|
|
48
|
+
</form>
|
|
49
|
+
```
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -12,20 +12,33 @@ export type SwapSDK = {
|
|
|
12
12
|
/**
|
|
13
13
|
* Initializes the Swap functionality.
|
|
14
14
|
*/
|
|
15
|
-
init: () => void
|
|
15
|
+
init: () => Promise<void>;
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
18
|
* Object containing methods related to Submission functionality.
|
|
19
19
|
*/
|
|
20
20
|
export type SubmissionSDK = {
|
|
21
|
+
/**
|
|
22
|
+
* Indicates whether hidden fields should be captured in submissions.
|
|
23
|
+
*/
|
|
24
|
+
captureHiddenFields: boolean;
|
|
21
25
|
/**
|
|
22
26
|
* Initialize the Submission functionality.
|
|
23
27
|
*/
|
|
24
|
-
init: () => void
|
|
28
|
+
init: () => Promise<void>;
|
|
25
29
|
/**
|
|
26
30
|
* Send the form submission.
|
|
27
31
|
*/
|
|
28
|
-
send: (data: Submission, elementID: string | HTMLElement, options?: SubmissionOptions) => void
|
|
32
|
+
send: (data: Submission, elementID: string | HTMLElement, options?: SubmissionOptions) => Promise<void>;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Object containing methods related to the Custom Field functionality.
|
|
36
|
+
*/
|
|
37
|
+
export type CustomFieldSDK = {
|
|
38
|
+
/**
|
|
39
|
+
* Recapture some or all of the custom fields.
|
|
40
|
+
*/
|
|
41
|
+
recapture: (keys?: string | string[] | Set<string>) => Promise<void>;
|
|
29
42
|
};
|
|
30
43
|
/**
|
|
31
44
|
* The global `$prism` object for managing Prism-related functionality.
|
|
@@ -51,6 +64,10 @@ export type PrismSDK = {
|
|
|
51
64
|
* Object containing methods related to Submission functionality.
|
|
52
65
|
*/
|
|
53
66
|
submission: SubmissionSDK;
|
|
67
|
+
/**
|
|
68
|
+
* Object containing methods related to the Custom Field functionality.
|
|
69
|
+
*/
|
|
70
|
+
custom_fields: CustomFieldSDK;
|
|
54
71
|
};
|
|
55
72
|
|
|
56
73
|
declare global {
|