Skip to content

Commit

Permalink
fix(countly): remove app_key from template and put it into the applic…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
aweiss-dev committed Oct 17, 2024
1 parent e8f2214 commit 1266aa4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
1 change: 0 additions & 1 deletion server/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ class Server {
APP_BASE: this.config.APP_BASE,
OPEN_GRAPH: this.config.OPEN_GRAPH,
VERSION: this.config.VERSION,
COUNTLY_API_KEY: this.config.COUNTLY_API_KEY,
COUNTLY_NONCE: this.config.COUNTLY_NONCE,
};
}
Expand Down
1 change: 0 additions & 1 deletion server/config/server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ export function generateConfig(params: ConfigGeneratorParams, env: Env) {
ALLOWED_HOSTS: ['app.wire.com'],
DISALLOW: readFile(ROBOTS_DISALLOW_FILE, 'User-agent: *\r\nDisallow: /'),
},
COUNTLY_API_KEY: env.COUNTLY_API_KEY || '',
COUNTLY_NONCE: COUNTLY_NONCE.value,
SSL_CERTIFICATE_KEY_PATH:
env.SSL_CERTIFICATE_KEY_PATH || path.join(__dirname, '../certificate/development-key.pem'),
Expand Down
2 changes: 0 additions & 2 deletions src/page/auth.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
var Countly = Countly || {};
Countly.q = Countly.q || [];
Countly.app_key = "<%= COUNTLY_API_KEY %>";
Countly.url = "https://countly.wire.com/";
Countly.offline_mode = true;
Countly.use_session_cookie = false;
Countly.storage = 'localstorage';
Expand Down
2 changes: 0 additions & 2 deletions src/page/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
var Countly = Countly || {};
Countly.q = Countly.q || [];
Countly.app_key = "<%= COUNTLY_API_KEY %>";
Countly.url = "https://countly.wire.com/";
Countly.offline_mode = true;
Countly.use_session_cookie = false;
Countly.storage = 'localstorage';
Expand Down
14 changes: 9 additions & 5 deletions src/script/tracking/EventTrackingRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export class EventTrackingRepository {
this.unsubscribeFromProductTrackingEvents();
}

private async startProductReporting(trackingId?: string): Promise<void> {
private async startProductReporting(trackingId: string = ''): Promise<void> {
// This is a global object provided by the countly.min.js script
if (!isCountlyLoaded()) {
this.countlyLogger.warn('Countly is not available');
Expand All @@ -253,23 +253,27 @@ export class EventTrackingRepository {

// Add Parameters to previous Countly object

const {COUNTLY_ENABLE_LOGGING, VERSION} = Config.getConfig();
const {COUNTLY_ENABLE_LOGGING, VERSION, COUNTLY_API_KEY} = Config.getConfig();

// Initialize Countly if it is not initialized yet
if (!this.countlyInitialized) {
window.Countly.app_version = VERSION;
window.Countly.app_key = COUNTLY_API_KEY;
window.Countly.debug = COUNTLY_ENABLE_LOGGING;
window.Countly.url = 'https://countly.wire.com/';
window.Countly.init();
this.countlyInitialized = true;
this.countlyLogger.info(
'Countly has been initialized with version',
VERSION,
'and logging',
', logging',
COUNTLY_ENABLE_LOGGING,
'and app_key',
COUNTLY_API_KEY,
);
this.countlyInitialized = true;
}

const device_id = trackingId || this.countlyDeviceId;
const device_id = Boolean(trackingId.length) ? trackingId : this.countlyDeviceId;
window.Countly.q.push(['change_id', device_id]);
window.Countly.q.push(['disable_offline_mode', device_id]);
this.countlyLogger.info(`Countly tracking id is now ${device_id}`);
Expand Down
2 changes: 0 additions & 2 deletions webpack.config.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ const templateParameters = {
OPEN_GRAPH_TITLE: serverConfig.OPEN_GRAPH.TITLE,
OPEN_GRAPH_DESCRIPTION: serverConfig.OPEN_GRAPH.DESCRIPTION,
OPEN_GRAPH_IMAGE_URL: serverConfig.OPEN_GRAPH.IMAGE_URL,
COUNTLY_API_KEY: serverConfig.COUNTLY_API_KEY,
COUNTLY_ENABLE_LOGGING: serverConfig.COUNTLY_ENABLE_LOGGING,
COUNTLY_NONCE: serverConfig.COUNTLY_NONCE,
};

Expand Down

0 comments on commit 1266aa4

Please sign in to comment.