Skip to content

Commit d25cbfd

Browse files
authored
send plugin version (#130)
* send plugin version * update gitignore
1 parent fd30476 commit d25cbfd

File tree

5 files changed

+30
-11
lines changed

5 files changed

+30
-11
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
*.swo
22
*.swp
33
intercom-wordpress.zip
4-
.gitignore
4+
.idea
5+
.vscode
6+
.DS_Store
7+
.phpunit.result.cache
8+
.phpunit.cache

bootstrap.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
Description: Official <a href="https://www.intercom.io">Intercom</a> support for WordPress.
66
Author: Intercom
77
Author URI: https://www.intercom.io
8-
Version: 3.0.0
8+
Version: 3.0.1
99
*/
1010

11+
define('INTERCOM_PLUGIN_VERSION', '3.0.1');
12+
1113
require_once __DIR__ . '/vendor/autoload.php';
1214
use Firebase\JWT\JWT;
1315

@@ -404,6 +406,7 @@ private function getRawData()
404406
$settings = $messengerSecurityCalculator->messengerSecurityComponent();
405407
$result = $this->mergeConstants(apply_filters("intercom_settings", $settings));
406408
$result['installation_type'] = 'wordpress';
409+
$result['integration_version'] = INTERCOM_PLUGIN_VERSION;
407410
return $result;
408411
}
409412

@@ -586,9 +589,9 @@ function intercom_settings() {
586589
}
587590

588591
if (getenv('INTERCOM_PLUGIN_TEST') != '1') {
589-
//Add in priority to load the snippet last
590-
add_action('wp_footer', 'add_intercom_snippet', 999);
591592
add_action('admin_menu', 'add_intercom_settings_page');
592593
add_action('network_admin_menu', 'add_intercom_settings_page');
593594
add_action('admin_init', 'intercom_settings');
595+
// Add in priority to load the snippet last
596+
add_action('wp_footer', 'add_intercom_snippet', 999);
594597
}

readme.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Requires at least: 4.7.0
55
Tested up to: 6.7.2
66
Requires PHP: 7.2
77
License: Apache 2.0
8-
Stable tag: 3.0.0
8+
Stable tag: 3.0.1
99

1010
Official Intercom WordPress plugin: Engage visitors in real time, power growth with AI, and convert leads into loyal customers.
1111

@@ -32,13 +32,25 @@ Note: This plugin injects a Javascript snippet on your website frontend containi
3232
2. Plugin settings successfully authenticated with Intercom settings_auth.png
3333
3. Intercom widget used by customers to communicate with the business widget.png
3434
== Changelog ==
35+
= 3.0.1 =
36+
37+
https://github.com/intercom/intercom-wordpress/pull/130
38+
* Added version tracking to help Intercom provide better support by identifying which plugin version is in use.
39+
40+
https://github.com/intercom/intercom-wordpress/pull/88
41+
* Loads Intercom messenger last to ensure JQuery is present.
3542

3643
= 3.0.0 =
44+
45+
https://github.com/intercom/intercom-wordpress/pull/127
3746
* Replaced user_hash with intercom_user_jwt https://www.intercom.com/help/en/articles/10589769-authenticating-users-in-the-messenger-with-json-web-tokens-jwts.
3847
* Updated readme to follow guidelines.
3948
* Added missing tests.
4049

4150
== Upgrade Notice ==
4251

52+
= 3.0.1 =
53+
Help Intercom provide better support by sharing the plugin version is in use.
54+
4355
= 3.0.0 =
4456
Upgrade the security of your messenger with the introduction of JWT - https://www.intercom.com/help/en/articles/10589769-authenticating-users-in-the-messenger-with-json-web-tokens-jwts

test/SnippetSettingsTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected function tearDown(): void
2626
public function testJSONRendering()
2727
{
2828
$snippet_settings = new IntercomSnippetSettings(array("app_id" => "bar"));
29-
$this->assertEquals("{\"app_id\":\"bar\",\"installation_type\":\"wordpress\"}", $snippet_settings->json());
29+
$this->assertEquals("{\"app_id\":\"bar\",\"installation_type\":\"wordpress\",\"integration_version\":\"" . INTERCOM_PLUGIN_VERSION . "\"}", $snippet_settings->json());
3030
}
3131
public function testJSONRenderingWithIdentityVerification()
3232
{
@@ -37,23 +37,23 @@ public function testJSONRenderingWithIdentityVerification()
3737
"exp" => TimeProvider::getCurrentTime() + 3600
3838
);
3939
$jwt = JWT::encode($jwt_data, "s3cre7", 'HS256');
40-
$this->assertEquals('{"app_id":"bar","intercom_user_jwt":"'.$jwt.'","installation_type":"wordpress"}', $snippet_settings->json());
40+
$this->assertEquals('{"app_id":"bar","intercom_user_jwt":"'.$jwt.'","installation_type":"wordpress","integration_version":"' . INTERCOM_PLUGIN_VERSION . '"}', $snippet_settings->json());
4141
}
4242
public function testJSONRenderingWithIdentityVerificationAndNoSecret()
4343
{
4444
$snippet_settings = new IntercomSnippetSettings(array("app_id" => "bar"), NULL, new FakeWordPressUserForSnippetTest());
45-
$this->assertEquals("{\"app_id\":\"bar\",\"email\":\"foo@bar.com\",\"installation_type\":\"wordpress\"}", $snippet_settings->json());
45+
$this->assertEquals("{\"app_id\":\"bar\",\"email\":\"foo@bar.com\",\"installation_type\":\"wordpress\",\"integration_version\":\"" . INTERCOM_PLUGIN_VERSION . "\"}", $snippet_settings->json());
4646
}
4747
public function testInstallationType()
4848
{
4949
$snippet_settings = new IntercomSnippetSettings(array("app_id" => "bar"));
50-
$this->assertEquals("{\"app_id\":\"bar\",\"installation_type\":\"wordpress\"}", $snippet_settings->json());
50+
$this->assertEquals("{\"app_id\":\"bar\",\"installation_type\":\"wordpress\",\"integration_version\":\"" . INTERCOM_PLUGIN_VERSION . "\"}", $snippet_settings->json());
5151
}
5252
public function testIclLanguageConstant()
5353
{
5454
define('ICL_LANGUAGE_CODE', 'fr');
5555
$snippet_settings = new IntercomSnippetSettings(array("app_id" => "bar"));
56-
$this->assertEquals("{\"app_id\":\"bar\",\"language_override\":\"fr\",\"installation_type\":\"wordpress\"}", $snippet_settings->json());
56+
$this->assertEquals("{\"app_id\":\"bar\",\"language_override\":\"fr\",\"installation_type\":\"wordpress\",\"integration_version\":\"" . INTERCOM_PLUGIN_VERSION . "\"}", $snippet_settings->json());
5757
}
5858

5959
public function testAppId()

test/SnippetTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testGeneratedHtml()
2424
};
2525
</script>
2626
<script data-cfasync="false">
27-
window.intercomSettings = {"app_id":"foo","name":"Nikola Tesla","installation_type":"wordpress"};
27+
window.intercomSettings = {"app_id":"foo","name":"Nikola Tesla","installation_type":"wordpress","integration_version":"3.0.1"};
2828
</script>
2929
<script data-cfasync="false">(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',w.intercomSettings);}else{var d=document;var i=function(){i.c(arguments);};i.q=[];i.c=function(args){i.q.push(args);};w.Intercom=i;var l=function(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/foo';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s, x);};if(document.readyState==='complete'){l();}else if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>
3030
HTML;

0 commit comments

Comments
 (0)