UNPKG

@react-native-karte/core

Version:

KARTE SDK Core for React Native.

210 lines (172 loc) 6.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UserSync = exports.Tracker = exports.KarteApp = void 0; Object.defineProperty(exports, "normalize", { enumerable: true, get: function () { return _utilities.normalize; } }); var _reactNative = require("react-native"); var _utilities = require("@react-native-karte/utilities"); // // Copyright 2020 PLAID, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // const nativeModule = _reactNative.NativeModules.RNKRTCoreModule; /** KARTE SDKのエントリポイントクラスです。 */ class KarteApp { constructor() {} /** * ビジターIDを返します。 * * @remarks * ユーザーを一意に識別するためのID(ビジターID)を返します。 * * なお初期化が行われていない場合は空文字列を返します。 */ static get visitorId() { return nativeModule.getVisitorId(); } /** * オプトアウトの設定有無を返します。 * * @remarks * オプトアウトされている場合は、`true` を返し、されていない場合は `false` を返します。 * * また初期化が行われていない場合は `false` を返します。 */ static get isOptOut() { return nativeModule.isOptOut(); } /** * オプトインします。 * * @remarks * 初期化が行われていない状態で呼び出した場合はオプトインは行われません。 */ static optIn() { nativeModule.optIn(); } /** * オプトアウトします。 * * @remarks * 初期化が行われていない状態で呼び出した場合はオプトアウトは行われません。 */ static optOut() { nativeModule.optOut(); } /** * ビジターIDを再生成します。 * * @remarks * ビジターIDの再生成は、現在のユーザーとは異なるユーザーとして計測したい場合などに行います。 * 例えば、アプリケーションでログアウトを行った場合などがこれに該当します。 * * なお初期化が行われていない状態で呼び出した場合は再生成は行われません。 */ static renewVisitorId() { nativeModule.renewVisitorId(); } } /** イベントトラッキングを行うためのクラスです。 */ exports.KarteApp = KarteApp; class Tracker { constructor() {} /** * イベントの送信を行います。 * @param name イベント名 * @param values イベントに紐付けるカスタムオブジェクト */ static track(name) { let values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; nativeModule.track(name, (0, _utilities.normalize)(values)); } /** * Identifyイベントの送信を行います。 * * @param values Identifyイベントに紐付けるカスタムオブジェクト */ /** * Identifyイベントの送信を行います。 * * @param userId ユーザーを識別する一意なID * @param values Identifyイベントに紐付けるカスタムオブジェクト */ static identify(value, values) { if (typeof value === 'string') { nativeModule.identifyWithUserId(value, (0, _utilities.normalize)(values ?? {})); } else { nativeModule.identify((0, _utilities.normalize)(value)); } } /** * Attributeイベントの送信を行います。 * * @param values Attributeイベントに紐付けるカスタムオブジェクト */ static attribute(values) { nativeModule.attribute((0, _utilities.normalize)(values)); } /** * Viewイベントの送信を行います。 * @param viewName 画面名 * @param title タイトル * @param values Viewイベントに紐付けるカスタムオブジェクト */ static view(viewName, title) { let values = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; nativeModule.view(viewName, title, (0, _utilities.normalize)(values)); } } /** * WebView 連携するためのクラスです。 * * @remarks * WebページURLに連携用のクエリパラメータを付与した状態で、URLをWebViewで開くことでWebとAppのユーザーの紐付けが行われます。 * なお連携を行うためにはWebページに、KARTEのタグが埋め込まれている必要があります。 */ exports.Tracker = Tracker; class UserSync { constructor() {} /** * @deprecated User sync function using query parameters is deprecated. It will be removed in the future. Use {@link getUserSyncScript} instead. * * 指定されたURL文字列にWebView連携用のクエリパラメータを付与します。 * * @remarks * 連携用のクエリパラメータを付与したURL文字列を返します。 * 指定されたURL文字列の形式が正しくない場合、またはSDKの初期化が行われていない場合は、引数に指定したURL文字列を返します。 * * @param url 連携するページのURL文字列 */ static appendingQueryParameter(url) { return nativeModule.appendingUserSyncQueryParameter(url); } /** * WebView 連携用のスクリプト(javascript)を返却します。 * * @remarks * ユーザースクリプトとしてWebViewに設定することで、WebView内のタグと連携されます。 * なおSDKの初期化が行われていない場合はnullを返却します。 */ static getUserSyncScript() { return nativeModule.getUserSyncScript(); } } exports.UserSync = UserSync; //# sourceMappingURL=index.js.map