Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
Send the CodePush plugin version with server requests (microsoft#560)
Browse files Browse the repository at this point in the history
This allows the server to maintain backward compatibility by distinguishing between different plugins (e.g. React Native/Cordova/Windows), as well as individual versions of these plugins, without needing to use the old SDK version (which refers to the acquisition SDK, which is shared between all plugins).

This will also enable us to resolve microsoft#514, by rolling out a CDN only for newer plugin versions. (On the Cordova end at the very least, some users have plugins installed that have a whitelist of acceptable endpoints).
  • Loading branch information
Richard Hua authored Oct 10, 2016
1 parent 22d2a14 commit d2e150a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions request-fetch-adapter.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const packageJson = require("./package.json");

module.exports = {
async request(verb, url, requestBody, callback) {
if (typeof requestBody === "function") {
Expand All @@ -8,7 +10,9 @@ module.exports = {
const headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"X-CodePush-SDK-Version": getSDKVersion()
"X-CodePush-Plugin-Name": packageJson.name,
"X-CodePush-Plugin-Version": packageJson.version,
"X-CodePush-SDK-Version": packageJson.dependencies["code-push"]
};

if (requestBody && typeof requestBody === "object") {
Expand All @@ -31,10 +35,6 @@ module.exports = {
}
};

function getSDKVersion() {
return require("./package.json").dependencies["code-push"];
}

function getHttpMethodName(verb) {
// Note: This should stay in sync with the enum definition in
// https://github.com/Microsoft/code-push/blob/master/sdk/script/acquisition-sdk.ts#L6
Expand Down

0 comments on commit d2e150a

Please sign in to comment.