Skip to content

Commit

Permalink
release: fixes
Browse files Browse the repository at this point in the history
- chore: disable otter promos by default
- feat: add lang code for Formbricks survey
  • Loading branch information
abaicus authored Oct 24, 2024
2 parents 422f55c + dd8b781 commit a2bd6b2
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 11 deletions.
2 changes: 1 addition & 1 deletion assets/js/build/survey/survey_deps.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => 'd18c4036e32153ba476c');
<?php return array('dependencies' => array(), 'version' => 'c59f3ab226aad71e7c11');
2 changes: 1 addition & 1 deletion assets/js/build/survey/survey_deps.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion assets/js/src/survey_deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ import formbricks from "@formbricks/js/app";
* Emit a custom event to let other scripts know that formbricks is loaded.
*/
document.addEventListener("DOMContentLoaded", () => {
window.tsdk_formbricks = formbricks;
window.tsdk_formbricks = {
init: (args) => {
if ( typeof args.attributes === 'object' ) {
args.attributes = {
...window.tsdk_survey_attrs,
...args.attributes
}
}

formbricks?.init(args)
}
};

window.dispatchEvent(new Event("themeisle:survey:loaded"));
});
26 changes: 20 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"semantic-release": "^17.4.7"
},
"dependencies": {
"@formbricks/js": "^2.0.0",
"@formbricks/js": "^2.2.0",
"object-hash": "^3.0.0"
}
}
1 change: 0 additions & 1 deletion src/Modules/Promotions.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public function can_load( $product ) {

$this->debug = apply_filters( 'themeisle_sdk_promo_debug', $this->debug );
$promotions_to_load = apply_filters( $product->get_key() . '_load_promotions', array() );
$promotions_to_load[] = 'otter';
$promotions_to_load[] = 'optimole';
$promotions_to_load[] = 'rop';
$promotions_to_load[] = 'woo_plugins';
Expand Down
9 changes: 9 additions & 0 deletions src/Modules/Script_loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ public function load_survey( $handler ) {
$asset_file['version'],
true
);

$language = get_user_locale();
$available_languages = [
'de_DE' => 'de',
'de_DE_formal' => 'de',
];
$lang_code = isset( $available_languages[ $language ] ) ? $available_languages[ $language ] : 'en';

wp_localize_script( $handler, 'tsdk_survey_attrs', [ 'language' => $lang_code ] );
}

/**
Expand Down

0 comments on commit a2bd6b2

Please sign in to comment.