@sesamy/sesamy-js 1.19.8 → 1.19.10

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 CHANGED
@@ -714,11 +714,89 @@ In this example, the details of a specific checkout session are retrieved using
714
714
 
715
715
  By using the `getCheckout` function, you can easily fetch the details of a specific checkout session from the Sesamy API to view or process the transaction information.
716
716
 
717
- ## Transform
717
+ # Browser API
718
+
719
+ ## `detectAdblock()`
720
+
721
+ Detects the presence of an ad blocker in the browser by dynamically creating and checking the visibility of several ad-related HTML elements.
722
+
723
+ ### Parameters
724
+
725
+ None
726
+
727
+ ### Returns
728
+
729
+ Promise: A promise that resolves to a boolean value indicating whether an ad blocker is enabled (`true`) or not (`false`).
730
+
731
+ ### Example
732
+
733
+ The following example demonstrates how to use the `detectAdblock` function to detect if an ad blocker is enabled:
734
+
735
+ ```javascript
736
+ import { detectAdblock } from '@sesamy/sesamy-js';
737
+
738
+ // Detect if an ad blocker is enabled
739
+ detectAdblock()
740
+ .then(isAdblockEnabled => {
741
+ if (isAdblockEnabled) {
742
+ console.log('Adblocker is enabled');
743
+ } else {
744
+ console.log('Adblocker is not enabled');
745
+ }
746
+ })
747
+ .catch(error => {
748
+ console.error('Error detecting adblock:', error);
749
+ });
750
+ ```
751
+
752
+ ### Details
753
+
754
+ - The function creates a set of HTML `<div>` elements with IDs typically used by ad containers (e.g., 'AdHeader', 'AdContainer', etc.).
755
+ - These elements are appended to the body of the document and their visibility is checked after a short delay (100 milliseconds).
756
+
757
+ ## `isInAppBrowser()`
758
+
759
+ Detects if the current browsing context is an in-app browser and identifies the browser name if applicable.
760
+
761
+ ### Parameters
762
+
763
+ None
764
+
765
+ ### Returns
766
+
767
+ Object: An object containing two properties:
768
+
769
+ - `isInAppBrowser` (boolean): Indicates whether the current browsing context is an in-app browser (`true`) or not (`false`).
770
+ - `browserName` (string | null): The name of the in-app browser if detected, or `null` if not detected.
771
+
772
+ ### Example
773
+
774
+ The following example demonstrates how to use the `isInAppBrowser` function to check if the current context is an in-app browser and log the browser name if applicable:
775
+
776
+ ```javascript
777
+ import { isInAppBrowser } from '@sesamy/sesamy-js';
778
+
779
+ // Detect if the current context is an in-app browser
780
+ const result = isInAppBrowser();
781
+
782
+ if (result.isInAppBrowser) {
783
+ console.log(`Running inside an in-app browser: ${result.browserName}`);
784
+ } else {
785
+ console.log('Not running inside an in-app browser');
786
+ }
787
+ ```
788
+
789
+ ### Details
790
+
791
+ - A predefined list of common in-app browsers (e.g., Facebook, Instagram, LinkedIn, etc.) is checked against the user agent.
792
+ - If a match is found, the function returns `isInAppBrowser: true` and the corresponding `browserName`.
793
+ - If no known in-app browser signatures are detected, the function returns `isInAppBrowser: false` and `browserName: null`.
794
+
795
+ # Transforms
718
796
 
719
797
  The transform module allows for dynamic content manipulation based on specified rules. This can include inserting, replacing, or removing elements on a webpage.
720
798
 
721
- ### Configuration
799
+ ## Configuration
722
800
 
723
801
  The transform configuration is defined within the `Config` interface. The following properties are available:
724
802