Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Formbricks survey from SDK #4217

Merged
merged 3 commits into from
Mar 28, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions assets/apps/dashboard/src/utils/survey.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* This file is used to initialize the FormBricks survey.
*/
import formbricks from '@formbricks/js';

/**
* Take the number of days since install and convert it to a category for NPS user profile.
*
@@ -26,21 +21,23 @@ const convertToCategory = (number, scale = 1) => {
};

if ('undefined' !== typeof window && 'undefined' !== typeof window.neveDash) {
formbricks.init({
environmentId: 'clr0ply35522h8up0bay2de4y',
apiHost: 'https://app.formbricks.com',
userId:
'neve_' +
(window.neveDash?.license?.key ??
window.neveDash?.rootUrl?.replace(/[^\w\d]*/g, '')),
attributes: {
plan: window.neveDash?.pro ? window.neveDash?.license?.tier : 0,
days_since_install: convertToCategory(
window.neveDash.daysSinceInstall
),
license_status: window.neveDash?.license?.valid ?? 'invalid',
free_version: window.neveDash?.version,
pro_version: window.neveDash?.proPluginVersion,
},
window.addEventListener('themeisle:survey:loaded', function () {
window?.tsdk_formbricks?.init?.({
environmentId: 'clr0ply35522h8up0bay2de4y',
apiHost: 'https://app.formbricks.com',
userId:
'neve_' +
(window.neveDash?.license?.key ??
window.neveDash?.rootUrl?.replace(/[^\w\d]*/g, '')),
attributes: {
plan: window.neveDash?.pro ? window.neveDash?.license?.tier : 0,
days_since_install: convertToCategory(
window.neveDash.daysSinceInstall
),
license_status: window.neveDash?.license?.valid ?? 'invalid',
free_version: window.neveDash?.version,
pro_version: window.neveDash?.proPluginVersion,
},
});
});
}
5 changes: 4 additions & 1 deletion inc/admin/dashboard/main.php
Original file line number Diff line number Diff line change
@@ -300,10 +300,13 @@ public function enqueue() {
$build_path = get_template_directory_uri() . '/assets/apps/dashboard/build/';
$dependencies = ( include get_template_directory() . '/assets/apps/dashboard/build/dashboard.asset.php' );

$survey_handler = apply_filters( 'themeisle_sdk_dependency_script_handler', 'survey' );
do_action( 'themeisle_sdk_dependency_enqueue_script', 'survey' );

wp_register_style( 'neve-dash-style', $build_path . 'style-dashboard.css', [ 'wp-components', 'neve-components' ], $dependencies['version'] );
wp_style_add_data( 'neve-dash-style', 'rtl', 'replace' );
wp_enqueue_style( 'neve-dash-style' );
wp_register_script( 'neve-dash-script', $build_path . 'dashboard.js', array_merge( $dependencies['dependencies'], [ 'updates' ] ), $dependencies['version'], true );
wp_register_script( 'neve-dash-script', $build_path . 'dashboard.js', array_merge( $dependencies['dependencies'], [ 'updates', $survey_handler ] ), $dependencies['version'], true );
wp_localize_script( 'neve-dash-script', 'neveDash', apply_filters( 'neve_dashboard_page_data', $this->get_localization() ) );
wp_enqueue_script( 'neve-dash-script' );

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -50,7 +50,6 @@
"pre-commit": "npx lint-staged"
},
"dependencies": {
"@formbricks/js": "^1.4.1",
"@neve-wp/components": "file:./assets/apps/components",
"array-move": "^3.0.1",
"classnames": "^2.2.6",
7 changes: 1 addition & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -2174,11 +2174,6 @@
minimatch "^3.0.4"
strip-json-comments "^3.1.1"

"@formbricks/js@^1.4.1":
version "1.4.1"
resolved "https://registry.yarnpkg.com/@formbricks/js/-/js-1.4.1.tgz#2dbba3463a0942a01e271a49021c1d90556a391b"
integrity sha512-lL+DsPAIdoiOPPQ4OX7bXOjvygGbD+hqU2nfurctz+iq/zZ2y/boQ3BpvqGxmqnsKLjY4scV31lPJi9kAnT7mw==

"@gar/promisify@^1.0.1", "@gar/promisify@^1.1.3":
version "1.1.3"
resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6"
@@ -2469,7 +2464,7 @@
glob-to-regexp "^0.3.0"

"@neve-wp/components@file:./assets/apps/components":
version "0.0.51"
version "0.0.54"

"@nodelib/[email protected]":
version "2.1.5"

Unchanged files with check annotations Beta

type EventResponse = {
error?: string;
success?: boolean;
response?: any;

Check warning on line 122 in assets/apps/customizer-controls/src/@types/utils.d.ts

GitHub Actions / npm (14.x)

Unexpected any. Specify a different type
};
type EventOptions = {
};
const Instructions: React.FC<Props> = ({ control }) => {
const { params, id } = control;

Check warning on line 11 in assets/apps/customizer-controls/src/builder-instructions/Instructions.tsx

GitHub Actions / npm (14.x)

'id' is assigned a value but never used
const { options } = params;
const { description, quickLinks, builderMigrated, hadOldBuilder } = options;

Check warning on line 13 in assets/apps/customizer-controls/src/builder-instructions/Instructions.tsx

GitHub Actions / npm (14.x)

'builderMigrated' is assigned a value but never used

Check warning on line 13 in assets/apps/customizer-controls/src/builder-instructions/Instructions.tsx

GitHub Actions / npm (14.x)

'hadOldBuilder' is assigned a value but never used
const linkKeys = Object.keys(quickLinks);